documentation.d.ts 2.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162
  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. * Gets the list of observers
  4357. */
  4358. readonly observers: Array<Observer<T>>;
  4359. /**
  4360. * Creates a new observable
  4361. * @param onObserverAdded defines a callback to call when a new observer is added
  4362. */
  4363. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4364. /**
  4365. * Create a new Observer with the specified callback
  4366. * @param callback the callback that will be executed for that Observer
  4367. * @param mask the mask used to filter observers
  4368. * @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.
  4369. * @param scope optional scope for the callback to be called from
  4370. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4371. * @returns the new observer created for the callback
  4372. */
  4373. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4374. /**
  4375. * Create a new Observer with the specified callback and unregisters after the next notification
  4376. * @param callback the callback that will be executed for that Observer
  4377. * @returns the new observer created for the callback
  4378. */
  4379. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4380. /**
  4381. * Remove an Observer from the Observable object
  4382. * @param observer the instance of the Observer to remove
  4383. * @returns false if it doesn't belong to this Observable
  4384. */
  4385. remove(observer: Nullable<Observer<T>>): boolean;
  4386. /**
  4387. * Remove a callback from the Observable object
  4388. * @param callback the callback to remove
  4389. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4390. * @returns false if it doesn't belong to this Observable
  4391. */
  4392. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4393. private _deferUnregister;
  4394. private _remove;
  4395. /**
  4396. * Moves the observable to the top of the observer list making it get called first when notified
  4397. * @param observer the observer to move
  4398. */
  4399. makeObserverTopPriority(observer: Observer<T>): void;
  4400. /**
  4401. * Moves the observable to the bottom of the observer list making it get called last when notified
  4402. * @param observer the observer to move
  4403. */
  4404. makeObserverBottomPriority(observer: Observer<T>): void;
  4405. /**
  4406. * Notify all Observers by calling their respective callback with the given data
  4407. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4408. * @param eventData defines the data to send to all observers
  4409. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4410. * @param target defines the original target of the state
  4411. * @param currentTarget defines the current target of the state
  4412. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4413. */
  4414. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4415. /**
  4416. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4417. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4418. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4419. * and it is crucial that all callbacks will be executed.
  4420. * The order of the callbacks is kept, callbacks are not executed parallel.
  4421. *
  4422. * @param eventData The data to be sent to each callback
  4423. * @param mask is used to filter observers defaults to -1
  4424. * @param target defines the callback target (see EventState)
  4425. * @param currentTarget defines he current object in the bubbling phase
  4426. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4427. */
  4428. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4429. /**
  4430. * Notify a specific observer
  4431. * @param observer defines the observer to notify
  4432. * @param eventData defines the data to be sent to each callback
  4433. * @param mask is used to filter observers defaults to -1
  4434. */
  4435. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4436. /**
  4437. * Gets a boolean indicating if the observable has at least one observer
  4438. * @returns true is the Observable has at least one Observer registered
  4439. */
  4440. hasObservers(): boolean;
  4441. /**
  4442. * Clear the list of observers
  4443. */
  4444. clear(): void;
  4445. /**
  4446. * Clone the current observable
  4447. * @returns a new observable
  4448. */
  4449. clone(): Observable<T>;
  4450. /**
  4451. * Does this observable handles observer registered with a given mask
  4452. * @param mask defines the mask to be tested
  4453. * @return whether or not one observer registered with the given mask is handeled
  4454. **/
  4455. hasSpecificMask(mask?: number): boolean;
  4456. }
  4457. }
  4458. declare module BABYLON {
  4459. /**
  4460. * Class used to help managing file picking and drag'n'drop
  4461. * File Storage
  4462. */
  4463. export class FilesInputStore {
  4464. /**
  4465. * List of files ready to be loaded
  4466. */
  4467. static FilesToLoad: {
  4468. [key: string]: File;
  4469. };
  4470. }
  4471. }
  4472. declare module BABYLON {
  4473. /** Defines the cross module used constants to avoid circular dependncies */
  4474. export class Constants {
  4475. /** Defines that alpha blending is disabled */
  4476. static readonly ALPHA_DISABLE: number;
  4477. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4478. static readonly ALPHA_ADD: number;
  4479. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4480. static readonly ALPHA_COMBINE: number;
  4481. /** Defines that alpha blending to DEST - SRC * DEST */
  4482. static readonly ALPHA_SUBTRACT: number;
  4483. /** Defines that alpha blending to SRC * DEST */
  4484. static readonly ALPHA_MULTIPLY: number;
  4485. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4486. static readonly ALPHA_MAXIMIZED: number;
  4487. /** Defines that alpha blending to SRC + DEST */
  4488. static readonly ALPHA_ONEONE: number;
  4489. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4490. static readonly ALPHA_PREMULTIPLIED: number;
  4491. /**
  4492. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4493. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4494. */
  4495. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4496. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4497. static readonly ALPHA_INTERPOLATE: number;
  4498. /**
  4499. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4500. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4501. */
  4502. static readonly ALPHA_SCREENMODE: number;
  4503. /** Defines that the ressource is not delayed*/
  4504. static readonly DELAYLOADSTATE_NONE: number;
  4505. /** Defines that the ressource was successfully delay loaded */
  4506. static readonly DELAYLOADSTATE_LOADED: number;
  4507. /** Defines that the ressource is currently delay loading */
  4508. static readonly DELAYLOADSTATE_LOADING: number;
  4509. /** Defines that the ressource is delayed and has not started loading */
  4510. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4511. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4512. static readonly NEVER: number;
  4513. /** 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 */
  4514. static readonly ALWAYS: number;
  4515. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4516. static readonly LESS: number;
  4517. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4518. static readonly EQUAL: number;
  4519. /** 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 */
  4520. static readonly LEQUAL: number;
  4521. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4522. static readonly GREATER: number;
  4523. /** 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 */
  4524. static readonly GEQUAL: number;
  4525. /** 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 */
  4526. static readonly NOTEQUAL: number;
  4527. /** Passed to stencilOperation to specify that stencil value must be kept */
  4528. static readonly KEEP: number;
  4529. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4530. static readonly REPLACE: number;
  4531. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4532. static readonly INCR: number;
  4533. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4534. static readonly DECR: number;
  4535. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4536. static readonly INVERT: number;
  4537. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4538. static readonly INCR_WRAP: number;
  4539. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4540. static readonly DECR_WRAP: number;
  4541. /** Texture is not repeating outside of 0..1 UVs */
  4542. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4543. /** Texture is repeating outside of 0..1 UVs */
  4544. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4545. /** Texture is repeating and mirrored */
  4546. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4547. /** ALPHA */
  4548. static readonly TEXTUREFORMAT_ALPHA: number;
  4549. /** LUMINANCE */
  4550. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4551. /** LUMINANCE_ALPHA */
  4552. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4553. /** RGB */
  4554. static readonly TEXTUREFORMAT_RGB: number;
  4555. /** RGBA */
  4556. static readonly TEXTUREFORMAT_RGBA: number;
  4557. /** RED */
  4558. static readonly TEXTUREFORMAT_RED: number;
  4559. /** RED (2nd reference) */
  4560. static readonly TEXTUREFORMAT_R: number;
  4561. /** RG */
  4562. static readonly TEXTUREFORMAT_RG: number;
  4563. /** RED_INTEGER */
  4564. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4565. /** RED_INTEGER (2nd reference) */
  4566. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4567. /** RG_INTEGER */
  4568. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4569. /** RGB_INTEGER */
  4570. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4571. /** RGBA_INTEGER */
  4572. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4573. /** UNSIGNED_BYTE */
  4574. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4575. /** UNSIGNED_BYTE (2nd reference) */
  4576. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4577. /** FLOAT */
  4578. static readonly TEXTURETYPE_FLOAT: number;
  4579. /** HALF_FLOAT */
  4580. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4581. /** BYTE */
  4582. static readonly TEXTURETYPE_BYTE: number;
  4583. /** SHORT */
  4584. static readonly TEXTURETYPE_SHORT: number;
  4585. /** UNSIGNED_SHORT */
  4586. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4587. /** INT */
  4588. static readonly TEXTURETYPE_INT: number;
  4589. /** UNSIGNED_INT */
  4590. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4591. /** UNSIGNED_SHORT_4_4_4_4 */
  4592. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4593. /** UNSIGNED_SHORT_5_5_5_1 */
  4594. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4595. /** UNSIGNED_SHORT_5_6_5 */
  4596. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4597. /** UNSIGNED_INT_2_10_10_10_REV */
  4598. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4599. /** UNSIGNED_INT_24_8 */
  4600. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4601. /** UNSIGNED_INT_10F_11F_11F_REV */
  4602. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4603. /** UNSIGNED_INT_5_9_9_9_REV */
  4604. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4605. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4606. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4607. /** nearest is mag = nearest and min = nearest and mip = linear */
  4608. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4609. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4610. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4611. /** Trilinear is mag = linear and min = linear and mip = linear */
  4612. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4613. /** nearest is mag = nearest and min = nearest and mip = linear */
  4614. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4615. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4616. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4617. /** Trilinear is mag = linear and min = linear and mip = linear */
  4618. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4619. /** mag = nearest and min = nearest and mip = nearest */
  4620. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4621. /** mag = nearest and min = linear and mip = nearest */
  4622. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4623. /** mag = nearest and min = linear and mip = linear */
  4624. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4625. /** mag = nearest and min = linear and mip = none */
  4626. static readonly TEXTURE_NEAREST_LINEAR: number;
  4627. /** mag = nearest and min = nearest and mip = none */
  4628. static readonly TEXTURE_NEAREST_NEAREST: number;
  4629. /** mag = linear and min = nearest and mip = nearest */
  4630. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4631. /** mag = linear and min = nearest and mip = linear */
  4632. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4633. /** mag = linear and min = linear and mip = none */
  4634. static readonly TEXTURE_LINEAR_LINEAR: number;
  4635. /** mag = linear and min = nearest and mip = none */
  4636. static readonly TEXTURE_LINEAR_NEAREST: number;
  4637. /** Explicit coordinates mode */
  4638. static readonly TEXTURE_EXPLICIT_MODE: number;
  4639. /** Spherical coordinates mode */
  4640. static readonly TEXTURE_SPHERICAL_MODE: number;
  4641. /** Planar coordinates mode */
  4642. static readonly TEXTURE_PLANAR_MODE: number;
  4643. /** Cubic coordinates mode */
  4644. static readonly TEXTURE_CUBIC_MODE: number;
  4645. /** Projection coordinates mode */
  4646. static readonly TEXTURE_PROJECTION_MODE: number;
  4647. /** Skybox coordinates mode */
  4648. static readonly TEXTURE_SKYBOX_MODE: number;
  4649. /** Inverse Cubic coordinates mode */
  4650. static readonly TEXTURE_INVCUBIC_MODE: number;
  4651. /** Equirectangular coordinates mode */
  4652. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4653. /** Equirectangular Fixed coordinates mode */
  4654. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4655. /** Equirectangular Fixed Mirrored coordinates mode */
  4656. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4657. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4658. static readonly SCALEMODE_FLOOR: number;
  4659. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4660. static readonly SCALEMODE_NEAREST: number;
  4661. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4662. static readonly SCALEMODE_CEILING: number;
  4663. /**
  4664. * The dirty texture flag value
  4665. */
  4666. static readonly MATERIAL_TextureDirtyFlag: number;
  4667. /**
  4668. * The dirty light flag value
  4669. */
  4670. static readonly MATERIAL_LightDirtyFlag: number;
  4671. /**
  4672. * The dirty fresnel flag value
  4673. */
  4674. static readonly MATERIAL_FresnelDirtyFlag: number;
  4675. /**
  4676. * The dirty attribute flag value
  4677. */
  4678. static readonly MATERIAL_AttributesDirtyFlag: number;
  4679. /**
  4680. * The dirty misc flag value
  4681. */
  4682. static readonly MATERIAL_MiscDirtyFlag: number;
  4683. /**
  4684. * The all dirty flag value
  4685. */
  4686. static readonly MATERIAL_AllDirtyFlag: number;
  4687. /**
  4688. * Returns the triangle fill mode
  4689. */
  4690. static readonly MATERIAL_TriangleFillMode: number;
  4691. /**
  4692. * Returns the wireframe mode
  4693. */
  4694. static readonly MATERIAL_WireFrameFillMode: number;
  4695. /**
  4696. * Returns the point fill mode
  4697. */
  4698. static readonly MATERIAL_PointFillMode: number;
  4699. /**
  4700. * Returns the point list draw mode
  4701. */
  4702. static readonly MATERIAL_PointListDrawMode: number;
  4703. /**
  4704. * Returns the line list draw mode
  4705. */
  4706. static readonly MATERIAL_LineListDrawMode: number;
  4707. /**
  4708. * Returns the line loop draw mode
  4709. */
  4710. static readonly MATERIAL_LineLoopDrawMode: number;
  4711. /**
  4712. * Returns the line strip draw mode
  4713. */
  4714. static readonly MATERIAL_LineStripDrawMode: number;
  4715. /**
  4716. * Returns the triangle strip draw mode
  4717. */
  4718. static readonly MATERIAL_TriangleStripDrawMode: number;
  4719. /**
  4720. * Returns the triangle fan draw mode
  4721. */
  4722. static readonly MATERIAL_TriangleFanDrawMode: number;
  4723. /**
  4724. * Stores the clock-wise side orientation
  4725. */
  4726. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4727. /**
  4728. * Stores the counter clock-wise side orientation
  4729. */
  4730. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4731. /**
  4732. * Nothing
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_NothingTrigger: number;
  4736. /**
  4737. * On pick
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnPickTrigger: number;
  4741. /**
  4742. * On left pick
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnLeftPickTrigger: number;
  4746. /**
  4747. * On right pick
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnRightPickTrigger: number;
  4751. /**
  4752. * On center pick
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnCenterPickTrigger: number;
  4756. /**
  4757. * On pick down
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnPickDownTrigger: number;
  4761. /**
  4762. * On double pick
  4763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4764. */
  4765. static readonly ACTION_OnDoublePickTrigger: number;
  4766. /**
  4767. * On pick up
  4768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4769. */
  4770. static readonly ACTION_OnPickUpTrigger: number;
  4771. /**
  4772. * On pick out.
  4773. * This trigger will only be raised if you also declared a OnPickDown
  4774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4775. */
  4776. static readonly ACTION_OnPickOutTrigger: number;
  4777. /**
  4778. * On long press
  4779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4780. */
  4781. static readonly ACTION_OnLongPressTrigger: number;
  4782. /**
  4783. * On pointer over
  4784. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4785. */
  4786. static readonly ACTION_OnPointerOverTrigger: number;
  4787. /**
  4788. * On pointer out
  4789. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4790. */
  4791. static readonly ACTION_OnPointerOutTrigger: number;
  4792. /**
  4793. * On every frame
  4794. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4795. */
  4796. static readonly ACTION_OnEveryFrameTrigger: number;
  4797. /**
  4798. * On intersection enter
  4799. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4800. */
  4801. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4802. /**
  4803. * On intersection exit
  4804. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4805. */
  4806. static readonly ACTION_OnIntersectionExitTrigger: number;
  4807. /**
  4808. * On key down
  4809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4810. */
  4811. static readonly ACTION_OnKeyDownTrigger: number;
  4812. /**
  4813. * On key up
  4814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4815. */
  4816. static readonly ACTION_OnKeyUpTrigger: number;
  4817. /**
  4818. * Billboard mode will only apply to Y axis
  4819. */
  4820. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4821. /**
  4822. * Billboard mode will apply to all axes
  4823. */
  4824. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4825. /**
  4826. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4827. */
  4828. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4829. /**
  4830. * Gets or sets base Assets URL
  4831. */
  4832. static PARTICLES_BaseAssetsUrl: string;
  4833. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4834. * Test order :
  4835. * Is the bounding sphere outside the frustum ?
  4836. * If not, are the bounding box vertices outside the frustum ?
  4837. * It not, then the cullable object is in the frustum.
  4838. */
  4839. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4840. /** Culling strategy : Bounding Sphere Only.
  4841. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4842. * It's also less accurate than the standard because some not visible objects can still be selected.
  4843. * Test : is the bounding sphere outside the frustum ?
  4844. * If not, then the cullable object is in the frustum.
  4845. */
  4846. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4847. /** Culling strategy : Optimistic Inclusion.
  4848. * This in an inclusion test first, then the standard exclusion test.
  4849. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4850. * 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.
  4851. * Anyway, it's as accurate as the standard strategy.
  4852. * Test :
  4853. * Is the cullable object bounding sphere center in the frustum ?
  4854. * If not, apply the default culling strategy.
  4855. */
  4856. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4857. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4858. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4859. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4860. * 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.
  4861. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4862. * Test :
  4863. * Is the cullable object bounding sphere center in the frustum ?
  4864. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4865. */
  4866. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4867. /**
  4868. * No logging while loading
  4869. */
  4870. static readonly SCENELOADER_NO_LOGGING: number;
  4871. /**
  4872. * Minimal logging while loading
  4873. */
  4874. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4875. /**
  4876. * Summary logging while loading
  4877. */
  4878. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4879. /**
  4880. * Detailled logging while loading
  4881. */
  4882. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4883. }
  4884. }
  4885. declare module BABYLON {
  4886. /**
  4887. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4888. * Babylon.js
  4889. */
  4890. export class DomManagement {
  4891. /**
  4892. * Checks if the window object exists
  4893. * @returns true if the window object exists
  4894. */
  4895. static IsWindowObjectExist(): boolean;
  4896. /**
  4897. * Extracts text content from a DOM element hierarchy
  4898. * @param element defines the root element
  4899. * @returns a string
  4900. */
  4901. static GetDOMTextContent(element: HTMLElement): string;
  4902. }
  4903. }
  4904. declare module BABYLON {
  4905. /**
  4906. * Logger used througouht the application to allow configuration of
  4907. * the log level required for the messages.
  4908. */
  4909. export class Logger {
  4910. /**
  4911. * No log
  4912. */
  4913. static readonly NoneLogLevel: number;
  4914. /**
  4915. * Only message logs
  4916. */
  4917. static readonly MessageLogLevel: number;
  4918. /**
  4919. * Only warning logs
  4920. */
  4921. static readonly WarningLogLevel: number;
  4922. /**
  4923. * Only error logs
  4924. */
  4925. static readonly ErrorLogLevel: number;
  4926. /**
  4927. * All logs
  4928. */
  4929. static readonly AllLogLevel: number;
  4930. private static _LogCache;
  4931. /**
  4932. * Gets a value indicating the number of loading errors
  4933. * @ignorenaming
  4934. */
  4935. static errorsCount: number;
  4936. /**
  4937. * Callback called when a new log is added
  4938. */
  4939. static OnNewCacheEntry: (entry: string) => void;
  4940. private static _AddLogEntry;
  4941. private static _FormatMessage;
  4942. private static _LogDisabled;
  4943. private static _LogEnabled;
  4944. private static _WarnDisabled;
  4945. private static _WarnEnabled;
  4946. private static _ErrorDisabled;
  4947. private static _ErrorEnabled;
  4948. /**
  4949. * Log a message to the console
  4950. */
  4951. static Log: (message: string) => void;
  4952. /**
  4953. * Write a warning message to the console
  4954. */
  4955. static Warn: (message: string) => void;
  4956. /**
  4957. * Write an error message to the console
  4958. */
  4959. static Error: (message: string) => void;
  4960. /**
  4961. * Gets current log cache (list of logs)
  4962. */
  4963. static readonly LogCache: string;
  4964. /**
  4965. * Clears the log cache
  4966. */
  4967. static ClearLogCache(): void;
  4968. /**
  4969. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4970. */
  4971. static LogLevels: number;
  4972. }
  4973. }
  4974. declare module BABYLON {
  4975. /** @hidden */
  4976. export class _TypeStore {
  4977. /** @hidden */
  4978. static RegisteredTypes: {
  4979. [key: string]: Object;
  4980. };
  4981. /** @hidden */
  4982. static GetClass(fqdn: string): any;
  4983. }
  4984. }
  4985. declare module BABYLON {
  4986. /**
  4987. * Class containing a set of static utilities functions for deep copy.
  4988. */
  4989. export class DeepCopier {
  4990. /**
  4991. * Tries to copy an object by duplicating every property
  4992. * @param source defines the source object
  4993. * @param destination defines the target object
  4994. * @param doNotCopyList defines a list of properties to avoid
  4995. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4996. */
  4997. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4998. }
  4999. }
  5000. declare module BABYLON {
  5001. /**
  5002. * Class containing a set of static utilities functions for precision date
  5003. */
  5004. export class PrecisionDate {
  5005. /**
  5006. * Gets either window.performance.now() if supported or Date.now() else
  5007. */
  5008. static readonly Now: number;
  5009. }
  5010. }
  5011. declare module BABYLON {
  5012. /** @hidden */
  5013. export class _DevTools {
  5014. static WarnImport(name: string): string;
  5015. }
  5016. }
  5017. declare module BABYLON {
  5018. /**
  5019. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5020. */
  5021. export class WebRequest {
  5022. private _xhr;
  5023. /**
  5024. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5025. * i.e. when loading files, where the server/service expects an Authorization header
  5026. */
  5027. static CustomRequestHeaders: {
  5028. [key: string]: string;
  5029. };
  5030. /**
  5031. * Add callback functions in this array to update all the requests before they get sent to the network
  5032. */
  5033. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  5034. private _injectCustomRequestHeaders;
  5035. /**
  5036. * Gets or sets a function to be called when loading progress changes
  5037. */
  5038. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5039. /**
  5040. * Returns client's state
  5041. */
  5042. readonly readyState: number;
  5043. /**
  5044. * Returns client's status
  5045. */
  5046. readonly status: number;
  5047. /**
  5048. * Returns client's status as a text
  5049. */
  5050. readonly statusText: string;
  5051. /**
  5052. * Returns client's response
  5053. */
  5054. readonly response: any;
  5055. /**
  5056. * Returns client's response url
  5057. */
  5058. readonly responseURL: string;
  5059. /**
  5060. * Returns client's response as text
  5061. */
  5062. readonly responseText: string;
  5063. /**
  5064. * Gets or sets the expected response type
  5065. */
  5066. responseType: XMLHttpRequestResponseType;
  5067. /** @hidden */
  5068. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5069. /** @hidden */
  5070. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5071. /**
  5072. * Cancels any network activity
  5073. */
  5074. abort(): void;
  5075. /**
  5076. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5077. * @param body defines an optional request body
  5078. */
  5079. send(body?: Document | BodyInit | null): void;
  5080. /**
  5081. * Sets the request method, request URL
  5082. * @param method defines the method to use (GET, POST, etc..)
  5083. * @param url defines the url to connect with
  5084. */
  5085. open(method: string, url: string): void;
  5086. }
  5087. }
  5088. declare module BABYLON {
  5089. /**
  5090. * Class used to evalaute queries containing `and` and `or` operators
  5091. */
  5092. export class AndOrNotEvaluator {
  5093. /**
  5094. * Evaluate a query
  5095. * @param query defines the query to evaluate
  5096. * @param evaluateCallback defines the callback used to filter result
  5097. * @returns true if the query matches
  5098. */
  5099. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5100. private static _HandleParenthesisContent;
  5101. private static _SimplifyNegation;
  5102. }
  5103. }
  5104. declare module BABYLON {
  5105. /**
  5106. * Class used to store custom tags
  5107. */
  5108. export class Tags {
  5109. /**
  5110. * Adds support for tags on the given object
  5111. * @param obj defines the object to use
  5112. */
  5113. static EnableFor(obj: any): void;
  5114. /**
  5115. * Removes tags support
  5116. * @param obj defines the object to use
  5117. */
  5118. static DisableFor(obj: any): void;
  5119. /**
  5120. * Gets a boolean indicating if the given object has tags
  5121. * @param obj defines the object to use
  5122. * @returns a boolean
  5123. */
  5124. static HasTags(obj: any): boolean;
  5125. /**
  5126. * Gets the tags available on a given object
  5127. * @param obj defines the object to use
  5128. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5129. * @returns the tags
  5130. */
  5131. static GetTags(obj: any, asString?: boolean): any;
  5132. /**
  5133. * Adds tags to an object
  5134. * @param obj defines the object to use
  5135. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5136. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5137. */
  5138. static AddTagsTo(obj: any, tagsString: string): void;
  5139. /**
  5140. * @hidden
  5141. */
  5142. static _AddTagTo(obj: any, tag: string): void;
  5143. /**
  5144. * Removes specific tags from a specific object
  5145. * @param obj defines the object to use
  5146. * @param tagsString defines the tags to remove
  5147. */
  5148. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5149. /**
  5150. * @hidden
  5151. */
  5152. static _RemoveTagFrom(obj: any, tag: string): void;
  5153. /**
  5154. * Defines if tags hosted on an object match a given query
  5155. * @param obj defines the object to use
  5156. * @param tagsQuery defines the tag query
  5157. * @returns a boolean
  5158. */
  5159. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5160. }
  5161. }
  5162. declare module BABYLON {
  5163. /**
  5164. * Manages the defines for the Material
  5165. */
  5166. export class MaterialDefines {
  5167. /** @hidden */
  5168. protected _keys: string[];
  5169. private _isDirty;
  5170. /** @hidden */
  5171. _renderId: number;
  5172. /** @hidden */
  5173. _areLightsDirty: boolean;
  5174. /** @hidden */
  5175. _areAttributesDirty: boolean;
  5176. /** @hidden */
  5177. _areTexturesDirty: boolean;
  5178. /** @hidden */
  5179. _areFresnelDirty: boolean;
  5180. /** @hidden */
  5181. _areMiscDirty: boolean;
  5182. /** @hidden */
  5183. _areImageProcessingDirty: boolean;
  5184. /** @hidden */
  5185. _normals: boolean;
  5186. /** @hidden */
  5187. _uvs: boolean;
  5188. /** @hidden */
  5189. _needNormals: boolean;
  5190. /** @hidden */
  5191. _needUVs: boolean;
  5192. [id: string]: any;
  5193. /**
  5194. * Specifies if the material needs to be re-calculated
  5195. */
  5196. readonly isDirty: boolean;
  5197. /**
  5198. * Marks the material to indicate that it has been re-calculated
  5199. */
  5200. markAsProcessed(): void;
  5201. /**
  5202. * Marks the material to indicate that it needs to be re-calculated
  5203. */
  5204. markAsUnprocessed(): void;
  5205. /**
  5206. * Marks the material to indicate all of its defines need to be re-calculated
  5207. */
  5208. markAllAsDirty(): void;
  5209. /**
  5210. * Marks the material to indicate that image processing needs to be re-calculated
  5211. */
  5212. markAsImageProcessingDirty(): void;
  5213. /**
  5214. * Marks the material to indicate the lights need to be re-calculated
  5215. */
  5216. markAsLightDirty(): void;
  5217. /**
  5218. * Marks the attribute state as changed
  5219. */
  5220. markAsAttributesDirty(): void;
  5221. /**
  5222. * Marks the texture state as changed
  5223. */
  5224. markAsTexturesDirty(): void;
  5225. /**
  5226. * Marks the fresnel state as changed
  5227. */
  5228. markAsFresnelDirty(): void;
  5229. /**
  5230. * Marks the misc state as changed
  5231. */
  5232. markAsMiscDirty(): void;
  5233. /**
  5234. * Rebuilds the material defines
  5235. */
  5236. rebuild(): void;
  5237. /**
  5238. * Specifies if two material defines are equal
  5239. * @param other - A material define instance to compare to
  5240. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5241. */
  5242. isEqual(other: MaterialDefines): boolean;
  5243. /**
  5244. * Clones this instance's defines to another instance
  5245. * @param other - material defines to clone values to
  5246. */
  5247. cloneTo(other: MaterialDefines): void;
  5248. /**
  5249. * Resets the material define values
  5250. */
  5251. reset(): void;
  5252. /**
  5253. * Converts the material define values to a string
  5254. * @returns - String of material define information
  5255. */
  5256. toString(): string;
  5257. }
  5258. }
  5259. declare module BABYLON {
  5260. /**
  5261. * Class used to store and describe the pipeline context associated with an effect
  5262. */
  5263. export interface IPipelineContext {
  5264. /**
  5265. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5266. */
  5267. isAsync: boolean;
  5268. /**
  5269. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5270. */
  5271. isReady: boolean;
  5272. /** @hidden */
  5273. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5274. }
  5275. }
  5276. declare module BABYLON {
  5277. /**
  5278. * Class used to store gfx data (like WebGLBuffer)
  5279. */
  5280. export class DataBuffer {
  5281. /**
  5282. * Gets or sets the number of objects referencing this buffer
  5283. */
  5284. references: number;
  5285. /** Gets or sets the size of the underlying buffer */
  5286. capacity: number;
  5287. /**
  5288. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5289. */
  5290. is32Bits: boolean;
  5291. /**
  5292. * Gets the underlying buffer
  5293. */
  5294. readonly underlyingResource: any;
  5295. }
  5296. }
  5297. declare module BABYLON {
  5298. /** @hidden */
  5299. export interface IShaderProcessor {
  5300. attributeProcessor?: (attribute: string) => string;
  5301. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  5302. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  5303. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  5304. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  5305. lineProcessor?: (line: string, isFragment: boolean) => string;
  5306. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5307. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5308. }
  5309. }
  5310. declare module BABYLON {
  5311. /** @hidden */
  5312. export interface ProcessingOptions {
  5313. defines: string[];
  5314. indexParameters: any;
  5315. isFragment: boolean;
  5316. shouldUseHighPrecisionShader: boolean;
  5317. supportsUniformBuffers: boolean;
  5318. shadersRepository: string;
  5319. includesShadersStore: {
  5320. [key: string]: string;
  5321. };
  5322. processor?: IShaderProcessor;
  5323. version: string;
  5324. platformName: string;
  5325. lookForClosingBracketForUniformBuffer?: boolean;
  5326. }
  5327. }
  5328. declare module BABYLON {
  5329. /** @hidden */
  5330. export class ShaderCodeNode {
  5331. line: string;
  5332. children: ShaderCodeNode[];
  5333. additionalDefineKey?: string;
  5334. additionalDefineValue?: string;
  5335. isValid(preprocessors: {
  5336. [key: string]: string;
  5337. }): boolean;
  5338. process(preprocessors: {
  5339. [key: string]: string;
  5340. }, options: ProcessingOptions): string;
  5341. }
  5342. }
  5343. declare module BABYLON {
  5344. /** @hidden */
  5345. export class ShaderCodeCursor {
  5346. private _lines;
  5347. lineIndex: number;
  5348. readonly currentLine: string;
  5349. readonly canRead: boolean;
  5350. lines: string[];
  5351. }
  5352. }
  5353. declare module BABYLON {
  5354. /** @hidden */
  5355. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5356. process(preprocessors: {
  5357. [key: string]: string;
  5358. }, options: ProcessingOptions): string;
  5359. }
  5360. }
  5361. declare module BABYLON {
  5362. /** @hidden */
  5363. export class ShaderDefineExpression {
  5364. isTrue(preprocessors: {
  5365. [key: string]: string;
  5366. }): boolean;
  5367. }
  5368. }
  5369. declare module BABYLON {
  5370. /** @hidden */
  5371. export class ShaderCodeTestNode extends ShaderCodeNode {
  5372. testExpression: ShaderDefineExpression;
  5373. isValid(preprocessors: {
  5374. [key: string]: string;
  5375. }): boolean;
  5376. }
  5377. }
  5378. declare module BABYLON {
  5379. /** @hidden */
  5380. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5381. define: string;
  5382. not: boolean;
  5383. constructor(define: string, not?: boolean);
  5384. isTrue(preprocessors: {
  5385. [key: string]: string;
  5386. }): boolean;
  5387. }
  5388. }
  5389. declare module BABYLON {
  5390. /** @hidden */
  5391. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5392. leftOperand: ShaderDefineExpression;
  5393. rightOperand: ShaderDefineExpression;
  5394. isTrue(preprocessors: {
  5395. [key: string]: string;
  5396. }): boolean;
  5397. }
  5398. }
  5399. declare module BABYLON {
  5400. /** @hidden */
  5401. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5402. leftOperand: ShaderDefineExpression;
  5403. rightOperand: ShaderDefineExpression;
  5404. isTrue(preprocessors: {
  5405. [key: string]: string;
  5406. }): boolean;
  5407. }
  5408. }
  5409. declare module BABYLON {
  5410. /** @hidden */
  5411. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5412. define: string;
  5413. operand: string;
  5414. testValue: string;
  5415. constructor(define: string, operand: string, testValue: string);
  5416. isTrue(preprocessors: {
  5417. [key: string]: string;
  5418. }): boolean;
  5419. }
  5420. }
  5421. declare module BABYLON {
  5422. /** @hidden */
  5423. export class ShaderProcessor {
  5424. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5425. private static _ProcessPrecision;
  5426. private static _ExtractOperation;
  5427. private static _BuildSubExpression;
  5428. private static _BuildExpression;
  5429. private static _MoveCursorWithinIf;
  5430. private static _MoveCursor;
  5431. private static _EvaluatePreProcessors;
  5432. private static _PreparePreProcessors;
  5433. private static _ProcessShaderConversion;
  5434. private static _ProcessIncludes;
  5435. }
  5436. }
  5437. declare module BABYLON {
  5438. /**
  5439. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5440. */
  5441. export class PerformanceMonitor {
  5442. private _enabled;
  5443. private _rollingFrameTime;
  5444. private _lastFrameTimeMs;
  5445. /**
  5446. * constructor
  5447. * @param frameSampleSize The number of samples required to saturate the sliding window
  5448. */
  5449. constructor(frameSampleSize?: number);
  5450. /**
  5451. * Samples current frame
  5452. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5453. */
  5454. sampleFrame(timeMs?: number): void;
  5455. /**
  5456. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5457. */
  5458. readonly averageFrameTime: number;
  5459. /**
  5460. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5461. */
  5462. readonly averageFrameTimeVariance: number;
  5463. /**
  5464. * Returns the frame time of the most recent frame
  5465. */
  5466. readonly instantaneousFrameTime: number;
  5467. /**
  5468. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5469. */
  5470. readonly averageFPS: number;
  5471. /**
  5472. * Returns the average framerate in frames per second using the most recent frame time
  5473. */
  5474. readonly instantaneousFPS: number;
  5475. /**
  5476. * Returns true if enough samples have been taken to completely fill the sliding window
  5477. */
  5478. readonly isSaturated: boolean;
  5479. /**
  5480. * Enables contributions to the sliding window sample set
  5481. */
  5482. enable(): void;
  5483. /**
  5484. * Disables contributions to the sliding window sample set
  5485. * Samples will not be interpolated over the disabled period
  5486. */
  5487. disable(): void;
  5488. /**
  5489. * Returns true if sampling is enabled
  5490. */
  5491. readonly isEnabled: boolean;
  5492. /**
  5493. * Resets performance monitor
  5494. */
  5495. reset(): void;
  5496. }
  5497. /**
  5498. * RollingAverage
  5499. *
  5500. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5501. */
  5502. export class RollingAverage {
  5503. /**
  5504. * Current average
  5505. */
  5506. average: number;
  5507. /**
  5508. * Current variance
  5509. */
  5510. variance: number;
  5511. protected _samples: Array<number>;
  5512. protected _sampleCount: number;
  5513. protected _pos: number;
  5514. protected _m2: number;
  5515. /**
  5516. * constructor
  5517. * @param length The number of samples required to saturate the sliding window
  5518. */
  5519. constructor(length: number);
  5520. /**
  5521. * Adds a sample to the sample set
  5522. * @param v The sample value
  5523. */
  5524. add(v: number): void;
  5525. /**
  5526. * Returns previously added values or null if outside of history or outside the sliding window domain
  5527. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5528. * @return Value previously recorded with add() or null if outside of range
  5529. */
  5530. history(i: number): number;
  5531. /**
  5532. * Returns true if enough samples have been taken to completely fill the sliding window
  5533. * @return true if sample-set saturated
  5534. */
  5535. isSaturated(): boolean;
  5536. /**
  5537. * Resets the rolling average (equivalent to 0 samples taken so far)
  5538. */
  5539. reset(): void;
  5540. /**
  5541. * Wraps a value around the sample range boundaries
  5542. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5543. * @return Wrapped position in sample range
  5544. */
  5545. protected _wrapPosition(i: number): number;
  5546. }
  5547. }
  5548. declare module BABYLON {
  5549. /**
  5550. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5551. * The underlying implementation relies on an associative array to ensure the best performances.
  5552. * The value can be anything including 'null' but except 'undefined'
  5553. */
  5554. export class StringDictionary<T> {
  5555. /**
  5556. * This will clear this dictionary and copy the content from the 'source' one.
  5557. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5558. * @param source the dictionary to take the content from and copy to this dictionary
  5559. */
  5560. copyFrom(source: StringDictionary<T>): void;
  5561. /**
  5562. * Get a value based from its key
  5563. * @param key the given key to get the matching value from
  5564. * @return the value if found, otherwise undefined is returned
  5565. */
  5566. get(key: string): T | undefined;
  5567. /**
  5568. * Get a value from its key or add it if it doesn't exist.
  5569. * This method will ensure you that a given key/data will be present in the dictionary.
  5570. * @param key the given key to get the matching value from
  5571. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5572. * The factory will only be invoked if there's no data for the given key.
  5573. * @return the value corresponding to the key.
  5574. */
  5575. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5576. /**
  5577. * Get a value from its key if present in the dictionary otherwise add it
  5578. * @param key the key to get the value from
  5579. * @param val if there's no such key/value pair in the dictionary add it with this value
  5580. * @return the value corresponding to the key
  5581. */
  5582. getOrAdd(key: string, val: T): T;
  5583. /**
  5584. * Check if there's a given key in the dictionary
  5585. * @param key the key to check for
  5586. * @return true if the key is present, false otherwise
  5587. */
  5588. contains(key: string): boolean;
  5589. /**
  5590. * Add a new key and its corresponding value
  5591. * @param key the key to add
  5592. * @param value the value corresponding to the key
  5593. * @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
  5594. */
  5595. add(key: string, value: T): boolean;
  5596. /**
  5597. * Update a specific value associated to a key
  5598. * @param key defines the key to use
  5599. * @param value defines the value to store
  5600. * @returns true if the value was updated (or false if the key was not found)
  5601. */
  5602. set(key: string, value: T): boolean;
  5603. /**
  5604. * Get the element of the given key and remove it from the dictionary
  5605. * @param key defines the key to search
  5606. * @returns the value associated with the key or null if not found
  5607. */
  5608. getAndRemove(key: string): Nullable<T>;
  5609. /**
  5610. * Remove a key/value from the dictionary.
  5611. * @param key the key to remove
  5612. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5613. */
  5614. remove(key: string): boolean;
  5615. /**
  5616. * Clear the whole content of the dictionary
  5617. */
  5618. clear(): void;
  5619. /**
  5620. * Gets the current count
  5621. */
  5622. readonly count: number;
  5623. /**
  5624. * Execute a callback on each key/val of the dictionary.
  5625. * Note that you can remove any element in this dictionary in the callback implementation
  5626. * @param callback the callback to execute on a given key/value pair
  5627. */
  5628. forEach(callback: (key: string, val: T) => void): void;
  5629. /**
  5630. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5631. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5632. * Note that you can remove any element in this dictionary in the callback implementation
  5633. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5634. * @returns the first item
  5635. */
  5636. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5637. private _count;
  5638. private _data;
  5639. }
  5640. }
  5641. declare module BABYLON {
  5642. /**
  5643. * Helper class that provides a small promise polyfill
  5644. */
  5645. export class PromisePolyfill {
  5646. /**
  5647. * Static function used to check if the polyfill is required
  5648. * If this is the case then the function will inject the polyfill to window.Promise
  5649. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5650. */
  5651. static Apply(force?: boolean): void;
  5652. }
  5653. }
  5654. declare module BABYLON {
  5655. /**
  5656. * Class used to store data that will be store in GPU memory
  5657. */
  5658. export class Buffer {
  5659. private _engine;
  5660. private _buffer;
  5661. /** @hidden */
  5662. _data: Nullable<DataArray>;
  5663. private _updatable;
  5664. private _instanced;
  5665. /**
  5666. * Gets the byte stride.
  5667. */
  5668. readonly byteStride: number;
  5669. /**
  5670. * Constructor
  5671. * @param engine the engine
  5672. * @param data the data to use for this buffer
  5673. * @param updatable whether the data is updatable
  5674. * @param stride the stride (optional)
  5675. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5676. * @param instanced whether the buffer is instanced (optional)
  5677. * @param useBytes set to true if the stride in in bytes (optional)
  5678. */
  5679. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5680. /**
  5681. * Create a new VertexBuffer based on the current buffer
  5682. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5683. * @param offset defines offset in the buffer (0 by default)
  5684. * @param size defines the size in floats of attributes (position is 3 for instance)
  5685. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5686. * @param instanced defines if the vertex buffer contains indexed data
  5687. * @param useBytes defines if the offset and stride are in bytes
  5688. * @returns the new vertex buffer
  5689. */
  5690. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5691. /**
  5692. * Gets a boolean indicating if the Buffer is updatable?
  5693. * @returns true if the buffer is updatable
  5694. */
  5695. isUpdatable(): boolean;
  5696. /**
  5697. * Gets current buffer's data
  5698. * @returns a DataArray or null
  5699. */
  5700. getData(): Nullable<DataArray>;
  5701. /**
  5702. * Gets underlying native buffer
  5703. * @returns underlying native buffer
  5704. */
  5705. getBuffer(): Nullable<DataBuffer>;
  5706. /**
  5707. * Gets the stride in float32 units (i.e. byte stride / 4).
  5708. * May not be an integer if the byte stride is not divisible by 4.
  5709. * DEPRECATED. Use byteStride instead.
  5710. * @returns the stride in float32 units
  5711. */
  5712. getStrideSize(): number;
  5713. /**
  5714. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5715. * @param data defines the data to store
  5716. */
  5717. create(data?: Nullable<DataArray>): void;
  5718. /** @hidden */
  5719. _rebuild(): void;
  5720. /**
  5721. * Update current buffer data
  5722. * @param data defines the data to store
  5723. */
  5724. update(data: DataArray): void;
  5725. /**
  5726. * Updates the data directly.
  5727. * @param data the new data
  5728. * @param offset the new offset
  5729. * @param vertexCount the vertex count (optional)
  5730. * @param useBytes set to true if the offset is in bytes
  5731. */
  5732. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5733. /**
  5734. * Release all resources
  5735. */
  5736. dispose(): void;
  5737. }
  5738. /**
  5739. * Specialized buffer used to store vertex data
  5740. */
  5741. export class VertexBuffer {
  5742. /** @hidden */
  5743. _buffer: Buffer;
  5744. private _kind;
  5745. private _size;
  5746. private _ownsBuffer;
  5747. private _instanced;
  5748. private _instanceDivisor;
  5749. /**
  5750. * The byte type.
  5751. */
  5752. static readonly BYTE: number;
  5753. /**
  5754. * The unsigned byte type.
  5755. */
  5756. static readonly UNSIGNED_BYTE: number;
  5757. /**
  5758. * The short type.
  5759. */
  5760. static readonly SHORT: number;
  5761. /**
  5762. * The unsigned short type.
  5763. */
  5764. static readonly UNSIGNED_SHORT: number;
  5765. /**
  5766. * The integer type.
  5767. */
  5768. static readonly INT: number;
  5769. /**
  5770. * The unsigned integer type.
  5771. */
  5772. static readonly UNSIGNED_INT: number;
  5773. /**
  5774. * The float type.
  5775. */
  5776. static readonly FLOAT: number;
  5777. /**
  5778. * Gets or sets the instance divisor when in instanced mode
  5779. */
  5780. instanceDivisor: number;
  5781. /**
  5782. * Gets the byte stride.
  5783. */
  5784. readonly byteStride: number;
  5785. /**
  5786. * Gets the byte offset.
  5787. */
  5788. readonly byteOffset: number;
  5789. /**
  5790. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5791. */
  5792. readonly normalized: boolean;
  5793. /**
  5794. * Gets the data type of each component in the array.
  5795. */
  5796. readonly type: number;
  5797. /**
  5798. * Constructor
  5799. * @param engine the engine
  5800. * @param data the data to use for this vertex buffer
  5801. * @param kind the vertex buffer kind
  5802. * @param updatable whether the data is updatable
  5803. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5804. * @param stride the stride (optional)
  5805. * @param instanced whether the buffer is instanced (optional)
  5806. * @param offset the offset of the data (optional)
  5807. * @param size the number of components (optional)
  5808. * @param type the type of the component (optional)
  5809. * @param normalized whether the data contains normalized data (optional)
  5810. * @param useBytes set to true if stride and offset are in bytes (optional)
  5811. */
  5812. 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);
  5813. /** @hidden */
  5814. _rebuild(): void;
  5815. /**
  5816. * Returns the kind of the VertexBuffer (string)
  5817. * @returns a string
  5818. */
  5819. getKind(): string;
  5820. /**
  5821. * Gets a boolean indicating if the VertexBuffer is updatable?
  5822. * @returns true if the buffer is updatable
  5823. */
  5824. isUpdatable(): boolean;
  5825. /**
  5826. * Gets current buffer's data
  5827. * @returns a DataArray or null
  5828. */
  5829. getData(): Nullable<DataArray>;
  5830. /**
  5831. * Gets underlying native buffer
  5832. * @returns underlying native buffer
  5833. */
  5834. getBuffer(): Nullable<DataBuffer>;
  5835. /**
  5836. * Gets the stride in float32 units (i.e. byte stride / 4).
  5837. * May not be an integer if the byte stride is not divisible by 4.
  5838. * DEPRECATED. Use byteStride instead.
  5839. * @returns the stride in float32 units
  5840. */
  5841. getStrideSize(): number;
  5842. /**
  5843. * Returns the offset as a multiple of the type byte length.
  5844. * DEPRECATED. Use byteOffset instead.
  5845. * @returns the offset in bytes
  5846. */
  5847. getOffset(): number;
  5848. /**
  5849. * Returns the number of components per vertex attribute (integer)
  5850. * @returns the size in float
  5851. */
  5852. getSize(): number;
  5853. /**
  5854. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5855. * @returns true if this buffer is instanced
  5856. */
  5857. getIsInstanced(): boolean;
  5858. /**
  5859. * Returns the instancing divisor, zero for non-instanced (integer).
  5860. * @returns a number
  5861. */
  5862. getInstanceDivisor(): number;
  5863. /**
  5864. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5865. * @param data defines the data to store
  5866. */
  5867. create(data?: DataArray): void;
  5868. /**
  5869. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5870. * This function will create a new buffer if the current one is not updatable
  5871. * @param data defines the data to store
  5872. */
  5873. update(data: DataArray): void;
  5874. /**
  5875. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5876. * Returns the directly updated WebGLBuffer.
  5877. * @param data the new data
  5878. * @param offset the new offset
  5879. * @param useBytes set to true if the offset is in bytes
  5880. */
  5881. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5882. /**
  5883. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5884. */
  5885. dispose(): void;
  5886. /**
  5887. * Enumerates each value of this vertex buffer as numbers.
  5888. * @param count the number of values to enumerate
  5889. * @param callback the callback function called for each value
  5890. */
  5891. forEach(count: number, callback: (value: number, index: number) => void): void;
  5892. /**
  5893. * Positions
  5894. */
  5895. static readonly PositionKind: string;
  5896. /**
  5897. * Normals
  5898. */
  5899. static readonly NormalKind: string;
  5900. /**
  5901. * Tangents
  5902. */
  5903. static readonly TangentKind: string;
  5904. /**
  5905. * Texture coordinates
  5906. */
  5907. static readonly UVKind: string;
  5908. /**
  5909. * Texture coordinates 2
  5910. */
  5911. static readonly UV2Kind: string;
  5912. /**
  5913. * Texture coordinates 3
  5914. */
  5915. static readonly UV3Kind: string;
  5916. /**
  5917. * Texture coordinates 4
  5918. */
  5919. static readonly UV4Kind: string;
  5920. /**
  5921. * Texture coordinates 5
  5922. */
  5923. static readonly UV5Kind: string;
  5924. /**
  5925. * Texture coordinates 6
  5926. */
  5927. static readonly UV6Kind: string;
  5928. /**
  5929. * Colors
  5930. */
  5931. static readonly ColorKind: string;
  5932. /**
  5933. * Matrix indices (for bones)
  5934. */
  5935. static readonly MatricesIndicesKind: string;
  5936. /**
  5937. * Matrix weights (for bones)
  5938. */
  5939. static readonly MatricesWeightsKind: string;
  5940. /**
  5941. * Additional matrix indices (for bones)
  5942. */
  5943. static readonly MatricesIndicesExtraKind: string;
  5944. /**
  5945. * Additional matrix weights (for bones)
  5946. */
  5947. static readonly MatricesWeightsExtraKind: string;
  5948. /**
  5949. * Deduces the stride given a kind.
  5950. * @param kind The kind string to deduce
  5951. * @returns The deduced stride
  5952. */
  5953. static DeduceStride(kind: string): number;
  5954. /**
  5955. * Gets the byte length of the given type.
  5956. * @param type the type
  5957. * @returns the number of bytes
  5958. */
  5959. static GetTypeByteLength(type: number): number;
  5960. /**
  5961. * Enumerates each value of the given parameters as numbers.
  5962. * @param data the data to enumerate
  5963. * @param byteOffset the byte offset of the data
  5964. * @param byteStride the byte stride of the data
  5965. * @param componentCount the number of components per element
  5966. * @param componentType the type of the component
  5967. * @param count the number of values to enumerate
  5968. * @param normalized whether the data is normalized
  5969. * @param callback the callback function called for each value
  5970. */
  5971. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5972. private static _GetFloatValue;
  5973. }
  5974. }
  5975. declare module BABYLON {
  5976. /**
  5977. * Class representing spherical harmonics coefficients to the 3rd degree
  5978. */
  5979. export class SphericalHarmonics {
  5980. /**
  5981. * Defines whether or not the harmonics have been prescaled for rendering.
  5982. */
  5983. preScaled: boolean;
  5984. /**
  5985. * The l0,0 coefficients of the spherical harmonics
  5986. */
  5987. l00: Vector3;
  5988. /**
  5989. * The l1,-1 coefficients of the spherical harmonics
  5990. */
  5991. l1_1: Vector3;
  5992. /**
  5993. * The l1,0 coefficients of the spherical harmonics
  5994. */
  5995. l10: Vector3;
  5996. /**
  5997. * The l1,1 coefficients of the spherical harmonics
  5998. */
  5999. l11: Vector3;
  6000. /**
  6001. * The l2,-2 coefficients of the spherical harmonics
  6002. */
  6003. l2_2: Vector3;
  6004. /**
  6005. * The l2,-1 coefficients of the spherical harmonics
  6006. */
  6007. l2_1: Vector3;
  6008. /**
  6009. * The l2,0 coefficients of the spherical harmonics
  6010. */
  6011. l20: Vector3;
  6012. /**
  6013. * The l2,1 coefficients of the spherical harmonics
  6014. */
  6015. l21: Vector3;
  6016. /**
  6017. * The l2,2 coefficients of the spherical harmonics
  6018. */
  6019. l22: Vector3;
  6020. /**
  6021. * Adds a light to the spherical harmonics
  6022. * @param direction the direction of the light
  6023. * @param color the color of the light
  6024. * @param deltaSolidAngle the delta solid angle of the light
  6025. */
  6026. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6027. /**
  6028. * Scales the spherical harmonics by the given amount
  6029. * @param scale the amount to scale
  6030. */
  6031. scaleInPlace(scale: number): void;
  6032. /**
  6033. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6034. *
  6035. * ```
  6036. * E_lm = A_l * L_lm
  6037. * ```
  6038. *
  6039. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6040. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6041. * the scaling factors are given in equation 9.
  6042. */
  6043. convertIncidentRadianceToIrradiance(): void;
  6044. /**
  6045. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6046. *
  6047. * ```
  6048. * L = (1/pi) * E * rho
  6049. * ```
  6050. *
  6051. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6052. */
  6053. convertIrradianceToLambertianRadiance(): void;
  6054. /**
  6055. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6056. * required operations at run time.
  6057. *
  6058. * This is simply done by scaling back the SH with Ylm constants parameter.
  6059. * The trigonometric part being applied by the shader at run time.
  6060. */
  6061. preScaleForRendering(): void;
  6062. /**
  6063. * Constructs a spherical harmonics from an array.
  6064. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6065. * @returns the spherical harmonics
  6066. */
  6067. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6068. /**
  6069. * Gets the spherical harmonics from polynomial
  6070. * @param polynomial the spherical polynomial
  6071. * @returns the spherical harmonics
  6072. */
  6073. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6074. }
  6075. /**
  6076. * Class representing spherical polynomial coefficients to the 3rd degree
  6077. */
  6078. export class SphericalPolynomial {
  6079. private _harmonics;
  6080. /**
  6081. * The spherical harmonics used to create the polynomials.
  6082. */
  6083. readonly preScaledHarmonics: SphericalHarmonics;
  6084. /**
  6085. * The x coefficients of the spherical polynomial
  6086. */
  6087. x: Vector3;
  6088. /**
  6089. * The y coefficients of the spherical polynomial
  6090. */
  6091. y: Vector3;
  6092. /**
  6093. * The z coefficients of the spherical polynomial
  6094. */
  6095. z: Vector3;
  6096. /**
  6097. * The xx coefficients of the spherical polynomial
  6098. */
  6099. xx: Vector3;
  6100. /**
  6101. * The yy coefficients of the spherical polynomial
  6102. */
  6103. yy: Vector3;
  6104. /**
  6105. * The zz coefficients of the spherical polynomial
  6106. */
  6107. zz: Vector3;
  6108. /**
  6109. * The xy coefficients of the spherical polynomial
  6110. */
  6111. xy: Vector3;
  6112. /**
  6113. * The yz coefficients of the spherical polynomial
  6114. */
  6115. yz: Vector3;
  6116. /**
  6117. * The zx coefficients of the spherical polynomial
  6118. */
  6119. zx: Vector3;
  6120. /**
  6121. * Adds an ambient color to the spherical polynomial
  6122. * @param color the color to add
  6123. */
  6124. addAmbient(color: Color3): void;
  6125. /**
  6126. * Scales the spherical polynomial by the given amount
  6127. * @param scale the amount to scale
  6128. */
  6129. scaleInPlace(scale: number): void;
  6130. /**
  6131. * Gets the spherical polynomial from harmonics
  6132. * @param harmonics the spherical harmonics
  6133. * @returns the spherical polynomial
  6134. */
  6135. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6136. /**
  6137. * Constructs a spherical polynomial from an array.
  6138. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6139. * @returns the spherical polynomial
  6140. */
  6141. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6142. }
  6143. }
  6144. declare module BABYLON {
  6145. /**
  6146. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6147. */
  6148. export interface CubeMapInfo {
  6149. /**
  6150. * The pixel array for the front face.
  6151. * This is stored in format, left to right, up to down format.
  6152. */
  6153. front: Nullable<ArrayBufferView>;
  6154. /**
  6155. * The pixel array for the back face.
  6156. * This is stored in format, left to right, up to down format.
  6157. */
  6158. back: Nullable<ArrayBufferView>;
  6159. /**
  6160. * The pixel array for the left face.
  6161. * This is stored in format, left to right, up to down format.
  6162. */
  6163. left: Nullable<ArrayBufferView>;
  6164. /**
  6165. * The pixel array for the right face.
  6166. * This is stored in format, left to right, up to down format.
  6167. */
  6168. right: Nullable<ArrayBufferView>;
  6169. /**
  6170. * The pixel array for the up face.
  6171. * This is stored in format, left to right, up to down format.
  6172. */
  6173. up: Nullable<ArrayBufferView>;
  6174. /**
  6175. * The pixel array for the down face.
  6176. * This is stored in format, left to right, up to down format.
  6177. */
  6178. down: Nullable<ArrayBufferView>;
  6179. /**
  6180. * The size of the cubemap stored.
  6181. *
  6182. * Each faces will be size * size pixels.
  6183. */
  6184. size: number;
  6185. /**
  6186. * The format of the texture.
  6187. *
  6188. * RGBA, RGB.
  6189. */
  6190. format: number;
  6191. /**
  6192. * The type of the texture data.
  6193. *
  6194. * UNSIGNED_INT, FLOAT.
  6195. */
  6196. type: number;
  6197. /**
  6198. * Specifies whether the texture is in gamma space.
  6199. */
  6200. gammaSpace: boolean;
  6201. }
  6202. /**
  6203. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6204. */
  6205. export class PanoramaToCubeMapTools {
  6206. private static FACE_FRONT;
  6207. private static FACE_BACK;
  6208. private static FACE_RIGHT;
  6209. private static FACE_LEFT;
  6210. private static FACE_DOWN;
  6211. private static FACE_UP;
  6212. /**
  6213. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6214. *
  6215. * @param float32Array The source data.
  6216. * @param inputWidth The width of the input panorama.
  6217. * @param inputHeight The height of the input panorama.
  6218. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6219. * @return The cubemap data
  6220. */
  6221. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6222. private static CreateCubemapTexture;
  6223. private static CalcProjectionSpherical;
  6224. }
  6225. }
  6226. declare module BABYLON {
  6227. /**
  6228. * Helper class dealing with the extraction of spherical polynomial dataArray
  6229. * from a cube map.
  6230. */
  6231. export class CubeMapToSphericalPolynomialTools {
  6232. private static FileFaces;
  6233. /**
  6234. * Converts a texture to the according Spherical Polynomial data.
  6235. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6236. *
  6237. * @param texture The texture to extract the information from.
  6238. * @return The Spherical Polynomial data.
  6239. */
  6240. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6241. /**
  6242. * Converts a cubemap to the according Spherical Polynomial data.
  6243. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6244. *
  6245. * @param cubeInfo The Cube map to extract the information from.
  6246. * @return The Spherical Polynomial data.
  6247. */
  6248. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6249. }
  6250. }
  6251. declare module BABYLON {
  6252. /**
  6253. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6254. * during the life time of the application.
  6255. */
  6256. export class EngineStore {
  6257. /** Gets the list of created engines */
  6258. static Instances: Engine[];
  6259. /** @hidden */
  6260. static _LastCreatedScene: Nullable<Scene>;
  6261. /**
  6262. * Gets the latest created engine
  6263. */
  6264. static readonly LastCreatedEngine: Nullable<Engine>;
  6265. /**
  6266. * Gets the latest created scene
  6267. */
  6268. static readonly LastCreatedScene: Nullable<Scene>;
  6269. }
  6270. }
  6271. declare module BABYLON {
  6272. /**
  6273. * Define options used to create a render target texture
  6274. */
  6275. export class RenderTargetCreationOptions {
  6276. /**
  6277. * Specifies is mipmaps must be generated
  6278. */
  6279. generateMipMaps?: boolean;
  6280. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6281. generateDepthBuffer?: boolean;
  6282. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6283. generateStencilBuffer?: boolean;
  6284. /** Defines texture type (int by default) */
  6285. type?: number;
  6286. /** Defines sampling mode (trilinear by default) */
  6287. samplingMode?: number;
  6288. /** Defines format (RGBA by default) */
  6289. format?: number;
  6290. }
  6291. }
  6292. declare module BABYLON {
  6293. /**
  6294. * @hidden
  6295. **/
  6296. export class _AlphaState {
  6297. private _isAlphaBlendDirty;
  6298. private _isBlendFunctionParametersDirty;
  6299. private _isBlendEquationParametersDirty;
  6300. private _isBlendConstantsDirty;
  6301. private _alphaBlend;
  6302. private _blendFunctionParameters;
  6303. private _blendEquationParameters;
  6304. private _blendConstants;
  6305. /**
  6306. * Initializes the state.
  6307. */
  6308. constructor();
  6309. readonly isDirty: boolean;
  6310. alphaBlend: boolean;
  6311. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6312. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6313. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6314. reset(): void;
  6315. apply(gl: WebGLRenderingContext): void;
  6316. }
  6317. }
  6318. declare module BABYLON {
  6319. /**
  6320. * @hidden
  6321. **/
  6322. export class _DepthCullingState {
  6323. private _isDepthTestDirty;
  6324. private _isDepthMaskDirty;
  6325. private _isDepthFuncDirty;
  6326. private _isCullFaceDirty;
  6327. private _isCullDirty;
  6328. private _isZOffsetDirty;
  6329. private _isFrontFaceDirty;
  6330. private _depthTest;
  6331. private _depthMask;
  6332. private _depthFunc;
  6333. private _cull;
  6334. private _cullFace;
  6335. private _zOffset;
  6336. private _frontFace;
  6337. /**
  6338. * Initializes the state.
  6339. */
  6340. constructor();
  6341. readonly isDirty: boolean;
  6342. zOffset: number;
  6343. cullFace: Nullable<number>;
  6344. cull: Nullable<boolean>;
  6345. depthFunc: Nullable<number>;
  6346. depthMask: boolean;
  6347. depthTest: boolean;
  6348. frontFace: Nullable<number>;
  6349. reset(): void;
  6350. apply(gl: WebGLRenderingContext): void;
  6351. }
  6352. }
  6353. declare module BABYLON {
  6354. /**
  6355. * @hidden
  6356. **/
  6357. export class _StencilState {
  6358. /** 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 */
  6359. static readonly ALWAYS: number;
  6360. /** Passed to stencilOperation to specify that stencil value must be kept */
  6361. static readonly KEEP: number;
  6362. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6363. static readonly REPLACE: number;
  6364. private _isStencilTestDirty;
  6365. private _isStencilMaskDirty;
  6366. private _isStencilFuncDirty;
  6367. private _isStencilOpDirty;
  6368. private _stencilTest;
  6369. private _stencilMask;
  6370. private _stencilFunc;
  6371. private _stencilFuncRef;
  6372. private _stencilFuncMask;
  6373. private _stencilOpStencilFail;
  6374. private _stencilOpDepthFail;
  6375. private _stencilOpStencilDepthPass;
  6376. readonly isDirty: boolean;
  6377. stencilFunc: number;
  6378. stencilFuncRef: number;
  6379. stencilFuncMask: number;
  6380. stencilOpStencilFail: number;
  6381. stencilOpDepthFail: number;
  6382. stencilOpStencilDepthPass: number;
  6383. stencilMask: number;
  6384. stencilTest: boolean;
  6385. constructor();
  6386. reset(): void;
  6387. apply(gl: WebGLRenderingContext): void;
  6388. }
  6389. }
  6390. declare module BABYLON {
  6391. /**
  6392. * @hidden
  6393. **/
  6394. export class _TimeToken {
  6395. _startTimeQuery: Nullable<WebGLQuery>;
  6396. _endTimeQuery: Nullable<WebGLQuery>;
  6397. _timeElapsedQuery: Nullable<WebGLQuery>;
  6398. _timeElapsedQueryEnded: boolean;
  6399. }
  6400. }
  6401. declare module BABYLON {
  6402. /**
  6403. * Class used to store data associated with WebGL texture data for the engine
  6404. * This class should not be used directly
  6405. */
  6406. export class InternalTexture {
  6407. /** @hidden */
  6408. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6409. /**
  6410. * The source of the texture data is unknown
  6411. */
  6412. static DATASOURCE_UNKNOWN: number;
  6413. /**
  6414. * Texture data comes from an URL
  6415. */
  6416. static DATASOURCE_URL: number;
  6417. /**
  6418. * Texture data is only used for temporary storage
  6419. */
  6420. static DATASOURCE_TEMP: number;
  6421. /**
  6422. * Texture data comes from raw data (ArrayBuffer)
  6423. */
  6424. static DATASOURCE_RAW: number;
  6425. /**
  6426. * Texture content is dynamic (video or dynamic texture)
  6427. */
  6428. static DATASOURCE_DYNAMIC: number;
  6429. /**
  6430. * Texture content is generated by rendering to it
  6431. */
  6432. static DATASOURCE_RENDERTARGET: number;
  6433. /**
  6434. * Texture content is part of a multi render target process
  6435. */
  6436. static DATASOURCE_MULTIRENDERTARGET: number;
  6437. /**
  6438. * Texture data comes from a cube data file
  6439. */
  6440. static DATASOURCE_CUBE: number;
  6441. /**
  6442. * Texture data comes from a raw cube data
  6443. */
  6444. static DATASOURCE_CUBERAW: number;
  6445. /**
  6446. * Texture data come from a prefiltered cube data file
  6447. */
  6448. static DATASOURCE_CUBEPREFILTERED: number;
  6449. /**
  6450. * Texture content is raw 3D data
  6451. */
  6452. static DATASOURCE_RAW3D: number;
  6453. /**
  6454. * Texture content is a depth texture
  6455. */
  6456. static DATASOURCE_DEPTHTEXTURE: number;
  6457. /**
  6458. * Texture data comes from a raw cube data encoded with RGBD
  6459. */
  6460. static DATASOURCE_CUBERAW_RGBD: number;
  6461. /**
  6462. * Defines if the texture is ready
  6463. */
  6464. isReady: boolean;
  6465. /**
  6466. * Defines if the texture is a cube texture
  6467. */
  6468. isCube: boolean;
  6469. /**
  6470. * Defines if the texture contains 3D data
  6471. */
  6472. is3D: boolean;
  6473. /**
  6474. * Defines if the texture contains multiview data
  6475. */
  6476. isMultiview: boolean;
  6477. /**
  6478. * Gets the URL used to load this texture
  6479. */
  6480. url: string;
  6481. /**
  6482. * Gets the sampling mode of the texture
  6483. */
  6484. samplingMode: number;
  6485. /**
  6486. * Gets a boolean indicating if the texture needs mipmaps generation
  6487. */
  6488. generateMipMaps: boolean;
  6489. /**
  6490. * Gets the number of samples used by the texture (WebGL2+ only)
  6491. */
  6492. samples: number;
  6493. /**
  6494. * Gets the type of the texture (int, float...)
  6495. */
  6496. type: number;
  6497. /**
  6498. * Gets the format of the texture (RGB, RGBA...)
  6499. */
  6500. format: number;
  6501. /**
  6502. * Observable called when the texture is loaded
  6503. */
  6504. onLoadedObservable: Observable<InternalTexture>;
  6505. /**
  6506. * Gets the width of the texture
  6507. */
  6508. width: number;
  6509. /**
  6510. * Gets the height of the texture
  6511. */
  6512. height: number;
  6513. /**
  6514. * Gets the depth of the texture
  6515. */
  6516. depth: number;
  6517. /**
  6518. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6519. */
  6520. baseWidth: number;
  6521. /**
  6522. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6523. */
  6524. baseHeight: number;
  6525. /**
  6526. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6527. */
  6528. baseDepth: number;
  6529. /**
  6530. * Gets a boolean indicating if the texture is inverted on Y axis
  6531. */
  6532. invertY: boolean;
  6533. /** @hidden */
  6534. _invertVScale: boolean;
  6535. /** @hidden */
  6536. _associatedChannel: number;
  6537. /** @hidden */
  6538. _dataSource: number;
  6539. /** @hidden */
  6540. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6541. /** @hidden */
  6542. _bufferView: Nullable<ArrayBufferView>;
  6543. /** @hidden */
  6544. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6545. /** @hidden */
  6546. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6547. /** @hidden */
  6548. _size: number;
  6549. /** @hidden */
  6550. _extension: string;
  6551. /** @hidden */
  6552. _files: Nullable<string[]>;
  6553. /** @hidden */
  6554. _workingCanvas: Nullable<HTMLCanvasElement>;
  6555. /** @hidden */
  6556. _workingContext: Nullable<CanvasRenderingContext2D>;
  6557. /** @hidden */
  6558. _framebuffer: Nullable<WebGLFramebuffer>;
  6559. /** @hidden */
  6560. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6561. /** @hidden */
  6562. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6563. /** @hidden */
  6564. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6565. /** @hidden */
  6566. _attachments: Nullable<number[]>;
  6567. /** @hidden */
  6568. _cachedCoordinatesMode: Nullable<number>;
  6569. /** @hidden */
  6570. _cachedWrapU: Nullable<number>;
  6571. /** @hidden */
  6572. _cachedWrapV: Nullable<number>;
  6573. /** @hidden */
  6574. _cachedWrapR: Nullable<number>;
  6575. /** @hidden */
  6576. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6577. /** @hidden */
  6578. _isDisabled: boolean;
  6579. /** @hidden */
  6580. _compression: Nullable<string>;
  6581. /** @hidden */
  6582. _generateStencilBuffer: boolean;
  6583. /** @hidden */
  6584. _generateDepthBuffer: boolean;
  6585. /** @hidden */
  6586. _comparisonFunction: number;
  6587. /** @hidden */
  6588. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6589. /** @hidden */
  6590. _lodGenerationScale: number;
  6591. /** @hidden */
  6592. _lodGenerationOffset: number;
  6593. /** @hidden */
  6594. _colorTextureArray: Nullable<WebGLTexture>;
  6595. /** @hidden */
  6596. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6597. /** @hidden */
  6598. _lodTextureHigh: Nullable<BaseTexture>;
  6599. /** @hidden */
  6600. _lodTextureMid: Nullable<BaseTexture>;
  6601. /** @hidden */
  6602. _lodTextureLow: Nullable<BaseTexture>;
  6603. /** @hidden */
  6604. _isRGBD: boolean;
  6605. /** @hidden */
  6606. _linearSpecularLOD: boolean;
  6607. /** @hidden */
  6608. _irradianceTexture: Nullable<BaseTexture>;
  6609. /** @hidden */
  6610. _webGLTexture: Nullable<WebGLTexture>;
  6611. /** @hidden */
  6612. _references: number;
  6613. private _engine;
  6614. /**
  6615. * Gets the Engine the texture belongs to.
  6616. * @returns The babylon engine
  6617. */
  6618. getEngine(): Engine;
  6619. /**
  6620. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6621. */
  6622. readonly dataSource: number;
  6623. /**
  6624. * Creates a new InternalTexture
  6625. * @param engine defines the engine to use
  6626. * @param dataSource defines the type of data that will be used
  6627. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6628. */
  6629. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6630. /**
  6631. * Increments the number of references (ie. the number of Texture that point to it)
  6632. */
  6633. incrementReferences(): void;
  6634. /**
  6635. * Change the size of the texture (not the size of the content)
  6636. * @param width defines the new width
  6637. * @param height defines the new height
  6638. * @param depth defines the new depth (1 by default)
  6639. */
  6640. updateSize(width: int, height: int, depth?: int): void;
  6641. /** @hidden */
  6642. _rebuild(): void;
  6643. /** @hidden */
  6644. _swapAndDie(target: InternalTexture): void;
  6645. /**
  6646. * Dispose the current allocated resources
  6647. */
  6648. dispose(): void;
  6649. }
  6650. }
  6651. declare module BABYLON {
  6652. /**
  6653. * This represents the main contract an easing function should follow.
  6654. * Easing functions are used throughout the animation system.
  6655. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6656. */
  6657. export interface IEasingFunction {
  6658. /**
  6659. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6660. * of the easing function.
  6661. * The link below provides some of the most common examples of easing functions.
  6662. * @see https://easings.net/
  6663. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6664. * @returns the corresponding value on the curve defined by the easing function
  6665. */
  6666. ease(gradient: number): number;
  6667. }
  6668. /**
  6669. * Base class used for every default easing function.
  6670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6671. */
  6672. export class EasingFunction implements IEasingFunction {
  6673. /**
  6674. * Interpolation follows the mathematical formula associated with the easing function.
  6675. */
  6676. static readonly EASINGMODE_EASEIN: number;
  6677. /**
  6678. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6679. */
  6680. static readonly EASINGMODE_EASEOUT: number;
  6681. /**
  6682. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6683. */
  6684. static readonly EASINGMODE_EASEINOUT: number;
  6685. private _easingMode;
  6686. /**
  6687. * Sets the easing mode of the current function.
  6688. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6689. */
  6690. setEasingMode(easingMode: number): void;
  6691. /**
  6692. * Gets the current easing mode.
  6693. * @returns the easing mode
  6694. */
  6695. getEasingMode(): number;
  6696. /**
  6697. * @hidden
  6698. */
  6699. easeInCore(gradient: number): number;
  6700. /**
  6701. * Given an input gradient between 0 and 1, this returns the corresponding value
  6702. * of the easing function.
  6703. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6704. * @returns the corresponding value on the curve defined by the easing function
  6705. */
  6706. ease(gradient: number): number;
  6707. }
  6708. /**
  6709. * Easing function with a circle shape (see link below).
  6710. * @see https://easings.net/#easeInCirc
  6711. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6712. */
  6713. export class CircleEase extends EasingFunction implements IEasingFunction {
  6714. /** @hidden */
  6715. easeInCore(gradient: number): number;
  6716. }
  6717. /**
  6718. * Easing function with a ease back shape (see link below).
  6719. * @see https://easings.net/#easeInBack
  6720. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6721. */
  6722. export class BackEase extends EasingFunction implements IEasingFunction {
  6723. /** Defines the amplitude of the function */
  6724. amplitude: number;
  6725. /**
  6726. * Instantiates a back ease easing
  6727. * @see https://easings.net/#easeInBack
  6728. * @param amplitude Defines the amplitude of the function
  6729. */
  6730. constructor(
  6731. /** Defines the amplitude of the function */
  6732. amplitude?: number);
  6733. /** @hidden */
  6734. easeInCore(gradient: number): number;
  6735. }
  6736. /**
  6737. * Easing function with a bouncing shape (see link below).
  6738. * @see https://easings.net/#easeInBounce
  6739. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6740. */
  6741. export class BounceEase extends EasingFunction implements IEasingFunction {
  6742. /** Defines the number of bounces */
  6743. bounces: number;
  6744. /** Defines the amplitude of the bounce */
  6745. bounciness: number;
  6746. /**
  6747. * Instantiates a bounce easing
  6748. * @see https://easings.net/#easeInBounce
  6749. * @param bounces Defines the number of bounces
  6750. * @param bounciness Defines the amplitude of the bounce
  6751. */
  6752. constructor(
  6753. /** Defines the number of bounces */
  6754. bounces?: number,
  6755. /** Defines the amplitude of the bounce */
  6756. bounciness?: number);
  6757. /** @hidden */
  6758. easeInCore(gradient: number): number;
  6759. }
  6760. /**
  6761. * Easing function with a power of 3 shape (see link below).
  6762. * @see https://easings.net/#easeInCubic
  6763. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6764. */
  6765. export class CubicEase extends EasingFunction implements IEasingFunction {
  6766. /** @hidden */
  6767. easeInCore(gradient: number): number;
  6768. }
  6769. /**
  6770. * Easing function with an elastic shape (see link below).
  6771. * @see https://easings.net/#easeInElastic
  6772. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6773. */
  6774. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6775. /** Defines the number of oscillations*/
  6776. oscillations: number;
  6777. /** Defines the amplitude of the oscillations*/
  6778. springiness: number;
  6779. /**
  6780. * Instantiates an elastic easing function
  6781. * @see https://easings.net/#easeInElastic
  6782. * @param oscillations Defines the number of oscillations
  6783. * @param springiness Defines the amplitude of the oscillations
  6784. */
  6785. constructor(
  6786. /** Defines the number of oscillations*/
  6787. oscillations?: number,
  6788. /** Defines the amplitude of the oscillations*/
  6789. springiness?: number);
  6790. /** @hidden */
  6791. easeInCore(gradient: number): number;
  6792. }
  6793. /**
  6794. * Easing function with an exponential shape (see link below).
  6795. * @see https://easings.net/#easeInExpo
  6796. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6797. */
  6798. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6799. /** Defines the exponent of the function */
  6800. exponent: number;
  6801. /**
  6802. * Instantiates an exponential easing function
  6803. * @see https://easings.net/#easeInExpo
  6804. * @param exponent Defines the exponent of the function
  6805. */
  6806. constructor(
  6807. /** Defines the exponent of the function */
  6808. exponent?: number);
  6809. /** @hidden */
  6810. easeInCore(gradient: number): number;
  6811. }
  6812. /**
  6813. * Easing function with a power shape (see link below).
  6814. * @see https://easings.net/#easeInQuad
  6815. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6816. */
  6817. export class PowerEase extends EasingFunction implements IEasingFunction {
  6818. /** Defines the power of the function */
  6819. power: number;
  6820. /**
  6821. * Instantiates an power base easing function
  6822. * @see https://easings.net/#easeInQuad
  6823. * @param power Defines the power of the function
  6824. */
  6825. constructor(
  6826. /** Defines the power of the function */
  6827. power?: number);
  6828. /** @hidden */
  6829. easeInCore(gradient: number): number;
  6830. }
  6831. /**
  6832. * Easing function with a power of 2 shape (see link below).
  6833. * @see https://easings.net/#easeInQuad
  6834. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6835. */
  6836. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6837. /** @hidden */
  6838. easeInCore(gradient: number): number;
  6839. }
  6840. /**
  6841. * Easing function with a power of 4 shape (see link below).
  6842. * @see https://easings.net/#easeInQuart
  6843. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6844. */
  6845. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6846. /** @hidden */
  6847. easeInCore(gradient: number): number;
  6848. }
  6849. /**
  6850. * Easing function with a power of 5 shape (see link below).
  6851. * @see https://easings.net/#easeInQuint
  6852. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6853. */
  6854. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6855. /** @hidden */
  6856. easeInCore(gradient: number): number;
  6857. }
  6858. /**
  6859. * Easing function with a sin shape (see link below).
  6860. * @see https://easings.net/#easeInSine
  6861. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6862. */
  6863. export class SineEase extends EasingFunction implements IEasingFunction {
  6864. /** @hidden */
  6865. easeInCore(gradient: number): number;
  6866. }
  6867. /**
  6868. * Easing function with a bezier shape (see link below).
  6869. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6870. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6871. */
  6872. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6873. /** Defines the x component of the start tangent in the bezier curve */
  6874. x1: number;
  6875. /** Defines the y component of the start tangent in the bezier curve */
  6876. y1: number;
  6877. /** Defines the x component of the end tangent in the bezier curve */
  6878. x2: number;
  6879. /** Defines the y component of the end tangent in the bezier curve */
  6880. y2: number;
  6881. /**
  6882. * Instantiates a bezier function
  6883. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6884. * @param x1 Defines the x component of the start tangent in the bezier curve
  6885. * @param y1 Defines the y component of the start tangent in the bezier curve
  6886. * @param x2 Defines the x component of the end tangent in the bezier curve
  6887. * @param y2 Defines the y component of the end tangent in the bezier curve
  6888. */
  6889. constructor(
  6890. /** Defines the x component of the start tangent in the bezier curve */
  6891. x1?: number,
  6892. /** Defines the y component of the start tangent in the bezier curve */
  6893. y1?: number,
  6894. /** Defines the x component of the end tangent in the bezier curve */
  6895. x2?: number,
  6896. /** Defines the y component of the end tangent in the bezier curve */
  6897. y2?: number);
  6898. /** @hidden */
  6899. easeInCore(gradient: number): number;
  6900. }
  6901. }
  6902. declare module BABYLON {
  6903. /**
  6904. * Defines an interface which represents an animation key frame
  6905. */
  6906. export interface IAnimationKey {
  6907. /**
  6908. * Frame of the key frame
  6909. */
  6910. frame: number;
  6911. /**
  6912. * Value at the specifies key frame
  6913. */
  6914. value: any;
  6915. /**
  6916. * The input tangent for the cubic hermite spline
  6917. */
  6918. inTangent?: any;
  6919. /**
  6920. * The output tangent for the cubic hermite spline
  6921. */
  6922. outTangent?: any;
  6923. /**
  6924. * The animation interpolation type
  6925. */
  6926. interpolation?: AnimationKeyInterpolation;
  6927. }
  6928. /**
  6929. * Enum for the animation key frame interpolation type
  6930. */
  6931. export enum AnimationKeyInterpolation {
  6932. /**
  6933. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6934. */
  6935. STEP = 1
  6936. }
  6937. }
  6938. declare module BABYLON {
  6939. /**
  6940. * Represents the range of an animation
  6941. */
  6942. export class AnimationRange {
  6943. /**The name of the animation range**/
  6944. name: string;
  6945. /**The starting frame of the animation */
  6946. from: number;
  6947. /**The ending frame of the animation*/
  6948. to: number;
  6949. /**
  6950. * Initializes the range of an animation
  6951. * @param name The name of the animation range
  6952. * @param from The starting frame of the animation
  6953. * @param to The ending frame of the animation
  6954. */
  6955. constructor(
  6956. /**The name of the animation range**/
  6957. name: string,
  6958. /**The starting frame of the animation */
  6959. from: number,
  6960. /**The ending frame of the animation*/
  6961. to: number);
  6962. /**
  6963. * Makes a copy of the animation range
  6964. * @returns A copy of the animation range
  6965. */
  6966. clone(): AnimationRange;
  6967. }
  6968. }
  6969. declare module BABYLON {
  6970. /**
  6971. * Composed of a frame, and an action function
  6972. */
  6973. export class AnimationEvent {
  6974. /** The frame for which the event is triggered **/
  6975. frame: number;
  6976. /** The event to perform when triggered **/
  6977. action: (currentFrame: number) => void;
  6978. /** Specifies if the event should be triggered only once**/
  6979. onlyOnce?: boolean | undefined;
  6980. /**
  6981. * Specifies if the animation event is done
  6982. */
  6983. isDone: boolean;
  6984. /**
  6985. * Initializes the animation event
  6986. * @param frame The frame for which the event is triggered
  6987. * @param action The event to perform when triggered
  6988. * @param onlyOnce Specifies if the event should be triggered only once
  6989. */
  6990. constructor(
  6991. /** The frame for which the event is triggered **/
  6992. frame: number,
  6993. /** The event to perform when triggered **/
  6994. action: (currentFrame: number) => void,
  6995. /** Specifies if the event should be triggered only once**/
  6996. onlyOnce?: boolean | undefined);
  6997. /** @hidden */
  6998. _clone(): AnimationEvent;
  6999. }
  7000. }
  7001. declare module BABYLON {
  7002. /**
  7003. * Interface used to define a behavior
  7004. */
  7005. export interface Behavior<T> {
  7006. /** gets or sets behavior's name */
  7007. name: string;
  7008. /**
  7009. * Function called when the behavior needs to be initialized (after attaching it to a target)
  7010. */
  7011. init(): void;
  7012. /**
  7013. * Called when the behavior is attached to a target
  7014. * @param target defines the target where the behavior is attached to
  7015. */
  7016. attach(target: T): void;
  7017. /**
  7018. * Called when the behavior is detached from its target
  7019. */
  7020. detach(): void;
  7021. }
  7022. /**
  7023. * Interface implemented by classes supporting behaviors
  7024. */
  7025. export interface IBehaviorAware<T> {
  7026. /**
  7027. * Attach a behavior
  7028. * @param behavior defines the behavior to attach
  7029. * @returns the current host
  7030. */
  7031. addBehavior(behavior: Behavior<T>): T;
  7032. /**
  7033. * Remove a behavior from the current object
  7034. * @param behavior defines the behavior to detach
  7035. * @returns the current host
  7036. */
  7037. removeBehavior(behavior: Behavior<T>): T;
  7038. /**
  7039. * Gets a behavior using its name to search
  7040. * @param name defines the name to search
  7041. * @returns the behavior or null if not found
  7042. */
  7043. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  7044. }
  7045. }
  7046. declare module BABYLON {
  7047. /**
  7048. * @hidden
  7049. */
  7050. export class IntersectionInfo {
  7051. bu: Nullable<number>;
  7052. bv: Nullable<number>;
  7053. distance: number;
  7054. faceId: number;
  7055. subMeshId: number;
  7056. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7057. }
  7058. }
  7059. declare module BABYLON {
  7060. /**
  7061. * Class used to store bounding sphere information
  7062. */
  7063. export class BoundingSphere {
  7064. /**
  7065. * Gets the center of the bounding sphere in local space
  7066. */
  7067. readonly center: Vector3;
  7068. /**
  7069. * Radius of the bounding sphere in local space
  7070. */
  7071. radius: number;
  7072. /**
  7073. * Gets the center of the bounding sphere in world space
  7074. */
  7075. readonly centerWorld: Vector3;
  7076. /**
  7077. * Radius of the bounding sphere in world space
  7078. */
  7079. radiusWorld: number;
  7080. /**
  7081. * Gets the minimum vector in local space
  7082. */
  7083. readonly minimum: Vector3;
  7084. /**
  7085. * Gets the maximum vector in local space
  7086. */
  7087. readonly maximum: Vector3;
  7088. private _worldMatrix;
  7089. private static readonly TmpVector3;
  7090. /**
  7091. * Creates a new bounding sphere
  7092. * @param min defines the minimum vector (in local space)
  7093. * @param max defines the maximum vector (in local space)
  7094. * @param worldMatrix defines the new world matrix
  7095. */
  7096. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7097. /**
  7098. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7099. * @param min defines the new minimum vector (in local space)
  7100. * @param max defines the new maximum vector (in local space)
  7101. * @param worldMatrix defines the new world matrix
  7102. */
  7103. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7104. /**
  7105. * Scale the current bounding sphere by applying a scale factor
  7106. * @param factor defines the scale factor to apply
  7107. * @returns the current bounding box
  7108. */
  7109. scale(factor: number): BoundingSphere;
  7110. /**
  7111. * Gets the world matrix of the bounding box
  7112. * @returns a matrix
  7113. */
  7114. getWorldMatrix(): DeepImmutable<Matrix>;
  7115. /** @hidden */
  7116. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7117. /**
  7118. * Tests if the bounding sphere is intersecting the frustum planes
  7119. * @param frustumPlanes defines the frustum planes to test
  7120. * @returns true if there is an intersection
  7121. */
  7122. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7123. /**
  7124. * Tests if the bounding sphere center is in between the frustum planes.
  7125. * Used for optimistic fast inclusion.
  7126. * @param frustumPlanes defines the frustum planes to test
  7127. * @returns true if the sphere center is in between the frustum planes
  7128. */
  7129. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7130. /**
  7131. * Tests if a point is inside the bounding sphere
  7132. * @param point defines the point to test
  7133. * @returns true if the point is inside the bounding sphere
  7134. */
  7135. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7136. /**
  7137. * Checks if two sphere intersct
  7138. * @param sphere0 sphere 0
  7139. * @param sphere1 sphere 1
  7140. * @returns true if the speres intersect
  7141. */
  7142. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7143. }
  7144. }
  7145. declare module BABYLON {
  7146. /**
  7147. * Class used to store bounding box information
  7148. */
  7149. export class BoundingBox implements ICullable {
  7150. /**
  7151. * Gets the 8 vectors representing the bounding box in local space
  7152. */
  7153. readonly vectors: Vector3[];
  7154. /**
  7155. * Gets the center of the bounding box in local space
  7156. */
  7157. readonly center: Vector3;
  7158. /**
  7159. * Gets the center of the bounding box in world space
  7160. */
  7161. readonly centerWorld: Vector3;
  7162. /**
  7163. * Gets the extend size in local space
  7164. */
  7165. readonly extendSize: Vector3;
  7166. /**
  7167. * Gets the extend size in world space
  7168. */
  7169. readonly extendSizeWorld: Vector3;
  7170. /**
  7171. * Gets the OBB (object bounding box) directions
  7172. */
  7173. readonly directions: Vector3[];
  7174. /**
  7175. * Gets the 8 vectors representing the bounding box in world space
  7176. */
  7177. readonly vectorsWorld: Vector3[];
  7178. /**
  7179. * Gets the minimum vector in world space
  7180. */
  7181. readonly minimumWorld: Vector3;
  7182. /**
  7183. * Gets the maximum vector in world space
  7184. */
  7185. readonly maximumWorld: Vector3;
  7186. /**
  7187. * Gets the minimum vector in local space
  7188. */
  7189. readonly minimum: Vector3;
  7190. /**
  7191. * Gets the maximum vector in local space
  7192. */
  7193. readonly maximum: Vector3;
  7194. private _worldMatrix;
  7195. private static readonly TmpVector3;
  7196. /**
  7197. * @hidden
  7198. */
  7199. _tag: number;
  7200. /**
  7201. * Creates a new bounding box
  7202. * @param min defines the minimum vector (in local space)
  7203. * @param max defines the maximum vector (in local space)
  7204. * @param worldMatrix defines the new world matrix
  7205. */
  7206. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7207. /**
  7208. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7209. * @param min defines the new minimum vector (in local space)
  7210. * @param max defines the new maximum vector (in local space)
  7211. * @param worldMatrix defines the new world matrix
  7212. */
  7213. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7214. /**
  7215. * Scale the current bounding box by applying a scale factor
  7216. * @param factor defines the scale factor to apply
  7217. * @returns the current bounding box
  7218. */
  7219. scale(factor: number): BoundingBox;
  7220. /**
  7221. * Gets the world matrix of the bounding box
  7222. * @returns a matrix
  7223. */
  7224. getWorldMatrix(): DeepImmutable<Matrix>;
  7225. /** @hidden */
  7226. _update(world: DeepImmutable<Matrix>): void;
  7227. /**
  7228. * Tests if the bounding box is intersecting the frustum planes
  7229. * @param frustumPlanes defines the frustum planes to test
  7230. * @returns true if there is an intersection
  7231. */
  7232. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7233. /**
  7234. * Tests if the bounding box is entirely inside the frustum planes
  7235. * @param frustumPlanes defines the frustum planes to test
  7236. * @returns true if there is an inclusion
  7237. */
  7238. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7239. /**
  7240. * Tests if a point is inside the bounding box
  7241. * @param point defines the point to test
  7242. * @returns true if the point is inside the bounding box
  7243. */
  7244. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7245. /**
  7246. * Tests if the bounding box intersects with a bounding sphere
  7247. * @param sphere defines the sphere to test
  7248. * @returns true if there is an intersection
  7249. */
  7250. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7251. /**
  7252. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7253. * @param min defines the min vector to use
  7254. * @param max defines the max vector to use
  7255. * @returns true if there is an intersection
  7256. */
  7257. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7258. /**
  7259. * Tests if two bounding boxes are intersections
  7260. * @param box0 defines the first box to test
  7261. * @param box1 defines the second box to test
  7262. * @returns true if there is an intersection
  7263. */
  7264. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7265. /**
  7266. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7267. * @param minPoint defines the minimum vector of the bounding box
  7268. * @param maxPoint defines the maximum vector of the bounding box
  7269. * @param sphereCenter defines the sphere center
  7270. * @param sphereRadius defines the sphere radius
  7271. * @returns true if there is an intersection
  7272. */
  7273. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7274. /**
  7275. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7276. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7277. * @param frustumPlanes defines the frustum planes to test
  7278. * @return true if there is an inclusion
  7279. */
  7280. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7281. /**
  7282. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7283. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7284. * @param frustumPlanes defines the frustum planes to test
  7285. * @return true if there is an intersection
  7286. */
  7287. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7288. }
  7289. }
  7290. declare module BABYLON {
  7291. /** @hidden */
  7292. export class Collider {
  7293. /** Define if a collision was found */
  7294. collisionFound: boolean;
  7295. /**
  7296. * Define last intersection point in local space
  7297. */
  7298. intersectionPoint: Vector3;
  7299. /**
  7300. * Define last collided mesh
  7301. */
  7302. collidedMesh: Nullable<AbstractMesh>;
  7303. private _collisionPoint;
  7304. private _planeIntersectionPoint;
  7305. private _tempVector;
  7306. private _tempVector2;
  7307. private _tempVector3;
  7308. private _tempVector4;
  7309. private _edge;
  7310. private _baseToVertex;
  7311. private _destinationPoint;
  7312. private _slidePlaneNormal;
  7313. private _displacementVector;
  7314. /** @hidden */
  7315. _radius: Vector3;
  7316. /** @hidden */
  7317. _retry: number;
  7318. private _velocity;
  7319. private _basePoint;
  7320. private _epsilon;
  7321. /** @hidden */
  7322. _velocityWorldLength: number;
  7323. /** @hidden */
  7324. _basePointWorld: Vector3;
  7325. private _velocityWorld;
  7326. private _normalizedVelocity;
  7327. /** @hidden */
  7328. _initialVelocity: Vector3;
  7329. /** @hidden */
  7330. _initialPosition: Vector3;
  7331. private _nearestDistance;
  7332. private _collisionMask;
  7333. collisionMask: number;
  7334. /**
  7335. * Gets the plane normal used to compute the sliding response (in local space)
  7336. */
  7337. readonly slidePlaneNormal: Vector3;
  7338. /** @hidden */
  7339. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7340. /** @hidden */
  7341. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7342. /** @hidden */
  7343. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7344. /** @hidden */
  7345. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7346. /** @hidden */
  7347. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7348. /** @hidden */
  7349. _getResponse(pos: Vector3, vel: Vector3): void;
  7350. }
  7351. }
  7352. declare module BABYLON {
  7353. /**
  7354. * Interface for cullable objects
  7355. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7356. */
  7357. export interface ICullable {
  7358. /**
  7359. * Checks if the object or part of the object is in the frustum
  7360. * @param frustumPlanes Camera near/planes
  7361. * @returns true if the object is in frustum otherwise false
  7362. */
  7363. isInFrustum(frustumPlanes: Plane[]): boolean;
  7364. /**
  7365. * Checks if a cullable object (mesh...) is in the camera frustum
  7366. * Unlike isInFrustum this cheks the full bounding box
  7367. * @param frustumPlanes Camera near/planes
  7368. * @returns true if the object is in frustum otherwise false
  7369. */
  7370. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7371. }
  7372. /**
  7373. * Info for a bounding data of a mesh
  7374. */
  7375. export class BoundingInfo implements ICullable {
  7376. /**
  7377. * Bounding box for the mesh
  7378. */
  7379. readonly boundingBox: BoundingBox;
  7380. /**
  7381. * Bounding sphere for the mesh
  7382. */
  7383. readonly boundingSphere: BoundingSphere;
  7384. private _isLocked;
  7385. private static readonly TmpVector3;
  7386. /**
  7387. * Constructs bounding info
  7388. * @param minimum min vector of the bounding box/sphere
  7389. * @param maximum max vector of the bounding box/sphere
  7390. * @param worldMatrix defines the new world matrix
  7391. */
  7392. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7393. /**
  7394. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7395. * @param min defines the new minimum vector (in local space)
  7396. * @param max defines the new maximum vector (in local space)
  7397. * @param worldMatrix defines the new world matrix
  7398. */
  7399. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7400. /**
  7401. * min vector of the bounding box/sphere
  7402. */
  7403. readonly minimum: Vector3;
  7404. /**
  7405. * max vector of the bounding box/sphere
  7406. */
  7407. readonly maximum: Vector3;
  7408. /**
  7409. * If the info is locked and won't be updated to avoid perf overhead
  7410. */
  7411. isLocked: boolean;
  7412. /**
  7413. * Updates the bounding sphere and box
  7414. * @param world world matrix to be used to update
  7415. */
  7416. update(world: DeepImmutable<Matrix>): void;
  7417. /**
  7418. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7419. * @param center New center of the bounding info
  7420. * @param extend New extend of the bounding info
  7421. * @returns the current bounding info
  7422. */
  7423. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7424. /**
  7425. * Scale the current bounding info by applying a scale factor
  7426. * @param factor defines the scale factor to apply
  7427. * @returns the current bounding info
  7428. */
  7429. scale(factor: number): BoundingInfo;
  7430. /**
  7431. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7432. * @param frustumPlanes defines the frustum to test
  7433. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7434. * @returns true if the bounding info is in the frustum planes
  7435. */
  7436. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7437. /**
  7438. * Gets the world distance between the min and max points of the bounding box
  7439. */
  7440. readonly diagonalLength: number;
  7441. /**
  7442. * Checks if a cullable object (mesh...) is in the camera frustum
  7443. * Unlike isInFrustum this cheks the full bounding box
  7444. * @param frustumPlanes Camera near/planes
  7445. * @returns true if the object is in frustum otherwise false
  7446. */
  7447. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7448. /** @hidden */
  7449. _checkCollision(collider: Collider): boolean;
  7450. /**
  7451. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7452. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7453. * @param point the point to check intersection with
  7454. * @returns if the point intersects
  7455. */
  7456. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7457. /**
  7458. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7459. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7460. * @param boundingInfo the bounding info to check intersection with
  7461. * @param precise if the intersection should be done using OBB
  7462. * @returns if the bounding info intersects
  7463. */
  7464. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7465. }
  7466. }
  7467. declare module BABYLON {
  7468. /**
  7469. * Defines an array and its length.
  7470. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7471. */
  7472. export interface ISmartArrayLike<T> {
  7473. /**
  7474. * The data of the array.
  7475. */
  7476. data: Array<T>;
  7477. /**
  7478. * The active length of the array.
  7479. */
  7480. length: number;
  7481. }
  7482. /**
  7483. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7484. */
  7485. export class SmartArray<T> implements ISmartArrayLike<T> {
  7486. /**
  7487. * The full set of data from the array.
  7488. */
  7489. data: Array<T>;
  7490. /**
  7491. * The active length of the array.
  7492. */
  7493. length: number;
  7494. protected _id: number;
  7495. /**
  7496. * Instantiates a Smart Array.
  7497. * @param capacity defines the default capacity of the array.
  7498. */
  7499. constructor(capacity: number);
  7500. /**
  7501. * Pushes a value at the end of the active data.
  7502. * @param value defines the object to push in the array.
  7503. */
  7504. push(value: T): void;
  7505. /**
  7506. * Iterates over the active data and apply the lambda to them.
  7507. * @param func defines the action to apply on each value.
  7508. */
  7509. forEach(func: (content: T) => void): void;
  7510. /**
  7511. * Sorts the full sets of data.
  7512. * @param compareFn defines the comparison function to apply.
  7513. */
  7514. sort(compareFn: (a: T, b: T) => number): void;
  7515. /**
  7516. * Resets the active data to an empty array.
  7517. */
  7518. reset(): void;
  7519. /**
  7520. * Releases all the data from the array as well as the array.
  7521. */
  7522. dispose(): void;
  7523. /**
  7524. * Concats the active data with a given array.
  7525. * @param array defines the data to concatenate with.
  7526. */
  7527. concat(array: any): void;
  7528. /**
  7529. * Returns the position of a value in the active data.
  7530. * @param value defines the value to find the index for
  7531. * @returns the index if found in the active data otherwise -1
  7532. */
  7533. indexOf(value: T): number;
  7534. /**
  7535. * Returns whether an element is part of the active data.
  7536. * @param value defines the value to look for
  7537. * @returns true if found in the active data otherwise false
  7538. */
  7539. contains(value: T): boolean;
  7540. private static _GlobalId;
  7541. }
  7542. /**
  7543. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7544. * The data in this array can only be present once
  7545. */
  7546. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7547. private _duplicateId;
  7548. /**
  7549. * Pushes a value at the end of the active data.
  7550. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7551. * @param value defines the object to push in the array.
  7552. */
  7553. push(value: T): void;
  7554. /**
  7555. * Pushes a value at the end of the active data.
  7556. * If the data is already present, it won t be added again
  7557. * @param value defines the object to push in the array.
  7558. * @returns true if added false if it was already present
  7559. */
  7560. pushNoDuplicate(value: T): boolean;
  7561. /**
  7562. * Resets the active data to an empty array.
  7563. */
  7564. reset(): void;
  7565. /**
  7566. * Concats the active data with a given array.
  7567. * This ensures no dupplicate will be present in the result.
  7568. * @param array defines the data to concatenate with.
  7569. */
  7570. concatWithNoDuplicate(array: any): void;
  7571. }
  7572. }
  7573. declare module BABYLON {
  7574. /**
  7575. * Enum that determines the text-wrapping mode to use.
  7576. */
  7577. export enum InspectableType {
  7578. /**
  7579. * Checkbox for booleans
  7580. */
  7581. Checkbox = 0,
  7582. /**
  7583. * Sliders for numbers
  7584. */
  7585. Slider = 1,
  7586. /**
  7587. * Vector3
  7588. */
  7589. Vector3 = 2,
  7590. /**
  7591. * Quaternions
  7592. */
  7593. Quaternion = 3,
  7594. /**
  7595. * Color3
  7596. */
  7597. Color3 = 4
  7598. }
  7599. /**
  7600. * Interface used to define custom inspectable properties.
  7601. * This interface is used by the inspector to display custom property grids
  7602. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7603. */
  7604. export interface IInspectable {
  7605. /**
  7606. * Gets the label to display
  7607. */
  7608. label: string;
  7609. /**
  7610. * Gets the name of the property to edit
  7611. */
  7612. propertyName: string;
  7613. /**
  7614. * Gets the type of the editor to use
  7615. */
  7616. type: InspectableType;
  7617. /**
  7618. * Gets the minimum value of the property when using in "slider" mode
  7619. */
  7620. min?: number;
  7621. /**
  7622. * Gets the maximum value of the property when using in "slider" mode
  7623. */
  7624. max?: number;
  7625. /**
  7626. * Gets the setp to use when using in "slider" mode
  7627. */
  7628. step?: number;
  7629. }
  7630. }
  7631. declare module BABYLON {
  7632. /**
  7633. * This represents the required contract to create a new type of texture loader.
  7634. */
  7635. export interface IInternalTextureLoader {
  7636. /**
  7637. * Defines wether the loader supports cascade loading the different faces.
  7638. */
  7639. supportCascades: boolean;
  7640. /**
  7641. * This returns if the loader support the current file information.
  7642. * @param extension defines the file extension of the file being loaded
  7643. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7644. * @param fallback defines the fallback internal texture if any
  7645. * @param isBase64 defines whether the texture is encoded as a base64
  7646. * @param isBuffer defines whether the texture data are stored as a buffer
  7647. * @returns true if the loader can load the specified file
  7648. */
  7649. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7650. /**
  7651. * Transform the url before loading if required.
  7652. * @param rootUrl the url of the texture
  7653. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7654. * @returns the transformed texture
  7655. */
  7656. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7657. /**
  7658. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7659. * @param rootUrl the url of the texture
  7660. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7661. * @returns the fallback texture
  7662. */
  7663. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7664. /**
  7665. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7666. * @param data contains the texture data
  7667. * @param texture defines the BabylonJS internal texture
  7668. * @param createPolynomials will be true if polynomials have been requested
  7669. * @param onLoad defines the callback to trigger once the texture is ready
  7670. * @param onError defines the callback to trigger in case of error
  7671. */
  7672. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7673. /**
  7674. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7675. * @param data contains the texture data
  7676. * @param texture defines the BabylonJS internal texture
  7677. * @param callback defines the method to call once ready to upload
  7678. */
  7679. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7680. }
  7681. }
  7682. declare module BABYLON {
  7683. interface Engine {
  7684. /**
  7685. * Creates a depth stencil cube texture.
  7686. * This is only available in WebGL 2.
  7687. * @param size The size of face edge in the cube texture.
  7688. * @param options The options defining the cube texture.
  7689. * @returns The cube texture
  7690. */
  7691. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7692. /**
  7693. * Creates a cube texture
  7694. * @param rootUrl defines the url where the files to load is located
  7695. * @param scene defines the current scene
  7696. * @param files defines the list of files to load (1 per face)
  7697. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7698. * @param onLoad defines an optional callback raised when the texture is loaded
  7699. * @param onError defines an optional callback raised if there is an issue to load the texture
  7700. * @param format defines the format of the data
  7701. * @param forcedExtension defines the extension to use to pick the right loader
  7702. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7703. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7704. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7705. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7706. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7707. * @returns the cube texture as an InternalTexture
  7708. */
  7709. 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;
  7710. /**
  7711. * Creates a cube texture
  7712. * @param rootUrl defines the url where the files to load is located
  7713. * @param scene defines the current scene
  7714. * @param files defines the list of files to load (1 per face)
  7715. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7716. * @param onLoad defines an optional callback raised when the texture is loaded
  7717. * @param onError defines an optional callback raised if there is an issue to load the texture
  7718. * @param format defines the format of the data
  7719. * @param forcedExtension defines the extension to use to pick the right loader
  7720. * @returns the cube texture as an InternalTexture
  7721. */
  7722. 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;
  7723. /**
  7724. * Creates a cube texture
  7725. * @param rootUrl defines the url where the files to load is located
  7726. * @param scene defines the current scene
  7727. * @param files defines the list of files to load (1 per face)
  7728. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7729. * @param onLoad defines an optional callback raised when the texture is loaded
  7730. * @param onError defines an optional callback raised if there is an issue to load the texture
  7731. * @param format defines the format of the data
  7732. * @param forcedExtension defines the extension to use to pick the right loader
  7733. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7734. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7735. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7736. * @returns the cube texture as an InternalTexture
  7737. */
  7738. 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;
  7739. /** @hidden */
  7740. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7741. /** @hidden */
  7742. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7743. /** @hidden */
  7744. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7745. /** @hidden */
  7746. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7747. }
  7748. }
  7749. declare module BABYLON {
  7750. /**
  7751. * Class for creating a cube texture
  7752. */
  7753. export class CubeTexture extends BaseTexture {
  7754. private _delayedOnLoad;
  7755. /**
  7756. * The url of the texture
  7757. */
  7758. url: string;
  7759. /**
  7760. * Gets or sets the center of the bounding box associated with the cube texture.
  7761. * It must define where the camera used to render the texture was set
  7762. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7763. */
  7764. boundingBoxPosition: Vector3;
  7765. private _boundingBoxSize;
  7766. /**
  7767. * Gets or sets the size of the bounding box associated with the cube texture
  7768. * When defined, the cubemap will switch to local mode
  7769. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7770. * @example https://www.babylonjs-playground.com/#RNASML
  7771. */
  7772. /**
  7773. * Returns the bounding box size
  7774. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7775. */
  7776. boundingBoxSize: Vector3;
  7777. protected _rotationY: number;
  7778. /**
  7779. * Sets texture matrix rotation angle around Y axis in radians.
  7780. */
  7781. /**
  7782. * Gets texture matrix rotation angle around Y axis radians.
  7783. */
  7784. rotationY: number;
  7785. /**
  7786. * Are mip maps generated for this texture or not.
  7787. */
  7788. readonly noMipmap: boolean;
  7789. private _noMipmap;
  7790. private _files;
  7791. private _extensions;
  7792. private _textureMatrix;
  7793. private _format;
  7794. private _createPolynomials;
  7795. /** @hidden */
  7796. _prefiltered: boolean;
  7797. /**
  7798. * Creates a cube texture from an array of image urls
  7799. * @param files defines an array of image urls
  7800. * @param scene defines the hosting scene
  7801. * @param noMipmap specifies if mip maps are not used
  7802. * @returns a cube texture
  7803. */
  7804. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7805. /**
  7806. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7807. * @param url defines the url of the prefiltered texture
  7808. * @param scene defines the scene the texture is attached to
  7809. * @param forcedExtension defines the extension of the file if different from the url
  7810. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7811. * @return the prefiltered texture
  7812. */
  7813. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7814. /**
  7815. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7816. * as prefiltered data.
  7817. * @param rootUrl defines the url of the texture or the root name of the six images
  7818. * @param scene defines the scene the texture is attached to
  7819. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7820. * @param noMipmap defines if mipmaps should be created or not
  7821. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7822. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7823. * @param onError defines a callback triggered in case of error during load
  7824. * @param format defines the internal format to use for the texture once loaded
  7825. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7826. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7827. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7828. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7829. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7830. * @return the cube texture
  7831. */
  7832. 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);
  7833. /**
  7834. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7835. */
  7836. readonly isPrefiltered: boolean;
  7837. /**
  7838. * Get the current class name of the texture useful for serialization or dynamic coding.
  7839. * @returns "CubeTexture"
  7840. */
  7841. getClassName(): string;
  7842. /**
  7843. * Update the url (and optional buffer) of this texture if url was null during construction.
  7844. * @param url the url of the texture
  7845. * @param forcedExtension defines the extension to use
  7846. * @param onLoad callback called when the texture is loaded (defaults to null)
  7847. */
  7848. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7849. /**
  7850. * Delays loading of the cube texture
  7851. * @param forcedExtension defines the extension to use
  7852. */
  7853. delayLoad(forcedExtension?: string): void;
  7854. /**
  7855. * Returns the reflection texture matrix
  7856. * @returns the reflection texture matrix
  7857. */
  7858. getReflectionTextureMatrix(): Matrix;
  7859. /**
  7860. * Sets the reflection texture matrix
  7861. * @param value Reflection texture matrix
  7862. */
  7863. setReflectionTextureMatrix(value: Matrix): void;
  7864. /**
  7865. * Parses text to create a cube texture
  7866. * @param parsedTexture define the serialized text to read from
  7867. * @param scene defines the hosting scene
  7868. * @param rootUrl defines the root url of the cube texture
  7869. * @returns a cube texture
  7870. */
  7871. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7872. /**
  7873. * Makes a clone, or deep copy, of the cube texture
  7874. * @returns a new cube texture
  7875. */
  7876. clone(): CubeTexture;
  7877. }
  7878. }
  7879. declare module BABYLON {
  7880. /** @hidden */
  7881. export var postprocessVertexShader: {
  7882. name: string;
  7883. shader: string;
  7884. };
  7885. }
  7886. declare module BABYLON {
  7887. /**
  7888. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7889. * This is the base of the follow, arc rotate cameras and Free camera
  7890. * @see http://doc.babylonjs.com/features/cameras
  7891. */
  7892. export class TargetCamera extends Camera {
  7893. private static _RigCamTransformMatrix;
  7894. private static _TargetTransformMatrix;
  7895. private static _TargetFocalPoint;
  7896. /**
  7897. * Define the current direction the camera is moving to
  7898. */
  7899. cameraDirection: Vector3;
  7900. /**
  7901. * Define the current rotation the camera is rotating to
  7902. */
  7903. cameraRotation: Vector2;
  7904. /**
  7905. * When set, the up vector of the camera will be updated by the rotation of the camera
  7906. */
  7907. updateUpVectorFromRotation: boolean;
  7908. private _tmpQuaternion;
  7909. /**
  7910. * Define the current rotation of the camera
  7911. */
  7912. rotation: Vector3;
  7913. /**
  7914. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7915. */
  7916. rotationQuaternion: Quaternion;
  7917. /**
  7918. * Define the current speed of the camera
  7919. */
  7920. speed: number;
  7921. /**
  7922. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7923. * around all axis.
  7924. */
  7925. noRotationConstraint: boolean;
  7926. /**
  7927. * Define the current target of the camera as an object or a position.
  7928. */
  7929. lockedTarget: any;
  7930. /** @hidden */
  7931. _currentTarget: Vector3;
  7932. /** @hidden */
  7933. _initialFocalDistance: number;
  7934. /** @hidden */
  7935. _viewMatrix: Matrix;
  7936. /** @hidden */
  7937. _camMatrix: Matrix;
  7938. /** @hidden */
  7939. _cameraTransformMatrix: Matrix;
  7940. /** @hidden */
  7941. _cameraRotationMatrix: Matrix;
  7942. /** @hidden */
  7943. _referencePoint: Vector3;
  7944. /** @hidden */
  7945. _transformedReferencePoint: Vector3;
  7946. protected _globalCurrentTarget: Vector3;
  7947. protected _globalCurrentUpVector: Vector3;
  7948. /** @hidden */
  7949. _reset: () => void;
  7950. private _defaultUp;
  7951. /**
  7952. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  7953. * This is the base of the follow, arc rotate cameras and Free camera
  7954. * @see http://doc.babylonjs.com/features/cameras
  7955. * @param name Defines the name of the camera in the scene
  7956. * @param position Defines the start position of the camera in the scene
  7957. * @param scene Defines the scene the camera belongs to
  7958. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7959. */
  7960. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7961. /**
  7962. * Gets the position in front of the camera at a given distance.
  7963. * @param distance The distance from the camera we want the position to be
  7964. * @returns the position
  7965. */
  7966. getFrontPosition(distance: number): Vector3;
  7967. /** @hidden */
  7968. _getLockedTargetPosition(): Nullable<Vector3>;
  7969. private _storedPosition;
  7970. private _storedRotation;
  7971. private _storedRotationQuaternion;
  7972. /**
  7973. * Store current camera state of the camera (fov, position, rotation, etc..)
  7974. * @returns the camera
  7975. */
  7976. storeState(): Camera;
  7977. /**
  7978. * Restored camera state. You must call storeState() first
  7979. * @returns whether it was successful or not
  7980. * @hidden
  7981. */
  7982. _restoreStateValues(): boolean;
  7983. /** @hidden */
  7984. _initCache(): void;
  7985. /** @hidden */
  7986. _updateCache(ignoreParentClass?: boolean): void;
  7987. /** @hidden */
  7988. _isSynchronizedViewMatrix(): boolean;
  7989. /** @hidden */
  7990. _computeLocalCameraSpeed(): number;
  7991. /**
  7992. * Defines the target the camera should look at.
  7993. * @param target Defines the new target as a Vector or a mesh
  7994. */
  7995. setTarget(target: Vector3): void;
  7996. /**
  7997. * Return the current target position of the camera. This value is expressed in local space.
  7998. * @returns the target position
  7999. */
  8000. getTarget(): Vector3;
  8001. /** @hidden */
  8002. _decideIfNeedsToMove(): boolean;
  8003. /** @hidden */
  8004. _updatePosition(): void;
  8005. /** @hidden */
  8006. _checkInputs(): void;
  8007. protected _updateCameraRotationMatrix(): void;
  8008. /**
  8009. * 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)
  8010. * @returns the current camera
  8011. */
  8012. private _rotateUpVectorWithCameraRotationMatrix;
  8013. private _cachedRotationZ;
  8014. private _cachedQuaternionRotationZ;
  8015. /** @hidden */
  8016. _getViewMatrix(): Matrix;
  8017. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8018. /**
  8019. * @hidden
  8020. */
  8021. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8022. /**
  8023. * @hidden
  8024. */
  8025. _updateRigCameras(): void;
  8026. private _getRigCamPositionAndTarget;
  8027. /**
  8028. * Gets the current object class name.
  8029. * @return the class name
  8030. */
  8031. getClassName(): string;
  8032. }
  8033. }
  8034. declare module BABYLON {
  8035. /**
  8036. * @ignore
  8037. * This is a list of all the different input types that are available in the application.
  8038. * Fo instance: ArcRotateCameraGamepadInput...
  8039. */
  8040. export var CameraInputTypes: {};
  8041. /**
  8042. * This is the contract to implement in order to create a new input class.
  8043. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8044. */
  8045. export interface ICameraInput<TCamera extends Camera> {
  8046. /**
  8047. * Defines the camera the input is attached to.
  8048. */
  8049. camera: Nullable<TCamera>;
  8050. /**
  8051. * Gets the class name of the current intput.
  8052. * @returns the class name
  8053. */
  8054. getClassName(): string;
  8055. /**
  8056. * Get the friendly name associated with the input class.
  8057. * @returns the input friendly name
  8058. */
  8059. getSimpleName(): string;
  8060. /**
  8061. * Attach the input controls to a specific dom element to get the input from.
  8062. * @param element Defines the element the controls should be listened from
  8063. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8064. */
  8065. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8066. /**
  8067. * Detach the current controls from the specified dom element.
  8068. * @param element Defines the element to stop listening the inputs from
  8069. */
  8070. detachControl(element: Nullable<HTMLElement>): void;
  8071. /**
  8072. * Update the current camera state depending on the inputs that have been used this frame.
  8073. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8074. */
  8075. checkInputs?: () => void;
  8076. }
  8077. /**
  8078. * Represents a map of input types to input instance or input index to input instance.
  8079. */
  8080. export interface CameraInputsMap<TCamera extends Camera> {
  8081. /**
  8082. * Accessor to the input by input type.
  8083. */
  8084. [name: string]: ICameraInput<TCamera>;
  8085. /**
  8086. * Accessor to the input by input index.
  8087. */
  8088. [idx: number]: ICameraInput<TCamera>;
  8089. }
  8090. /**
  8091. * This represents the input manager used within a camera.
  8092. * It helps dealing with all the different kind of input attached to a camera.
  8093. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8094. */
  8095. export class CameraInputsManager<TCamera extends Camera> {
  8096. /**
  8097. * Defines the list of inputs attahed to the camera.
  8098. */
  8099. attached: CameraInputsMap<TCamera>;
  8100. /**
  8101. * Defines the dom element the camera is collecting inputs from.
  8102. * This is null if the controls have not been attached.
  8103. */
  8104. attachedElement: Nullable<HTMLElement>;
  8105. /**
  8106. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8107. */
  8108. noPreventDefault: boolean;
  8109. /**
  8110. * Defined the camera the input manager belongs to.
  8111. */
  8112. camera: TCamera;
  8113. /**
  8114. * Update the current camera state depending on the inputs that have been used this frame.
  8115. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8116. */
  8117. checkInputs: () => void;
  8118. /**
  8119. * Instantiate a new Camera Input Manager.
  8120. * @param camera Defines the camera the input manager blongs to
  8121. */
  8122. constructor(camera: TCamera);
  8123. /**
  8124. * Add an input method to a camera
  8125. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8126. * @param input camera input method
  8127. */
  8128. add(input: ICameraInput<TCamera>): void;
  8129. /**
  8130. * Remove a specific input method from a camera
  8131. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8132. * @param inputToRemove camera input method
  8133. */
  8134. remove(inputToRemove: ICameraInput<TCamera>): void;
  8135. /**
  8136. * Remove a specific input type from a camera
  8137. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8138. * @param inputType the type of the input to remove
  8139. */
  8140. removeByType(inputType: string): void;
  8141. private _addCheckInputs;
  8142. /**
  8143. * Attach the input controls to the currently attached dom element to listen the events from.
  8144. * @param input Defines the input to attach
  8145. */
  8146. attachInput(input: ICameraInput<TCamera>): void;
  8147. /**
  8148. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8149. * @param element Defines the dom element to collect the events from
  8150. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8151. */
  8152. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8153. /**
  8154. * Detach the current manager inputs controls from a specific dom element.
  8155. * @param element Defines the dom element to collect the events from
  8156. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8157. */
  8158. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8159. /**
  8160. * Rebuild the dynamic inputCheck function from the current list of
  8161. * defined inputs in the manager.
  8162. */
  8163. rebuildInputCheck(): void;
  8164. /**
  8165. * Remove all attached input methods from a camera
  8166. */
  8167. clear(): void;
  8168. /**
  8169. * Serialize the current input manager attached to a camera.
  8170. * This ensures than once parsed,
  8171. * the input associated to the camera will be identical to the current ones
  8172. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8173. */
  8174. serialize(serializedCamera: any): void;
  8175. /**
  8176. * Parses an input manager serialized JSON to restore the previous list of inputs
  8177. * and states associated to a camera.
  8178. * @param parsedCamera Defines the JSON to parse
  8179. */
  8180. parse(parsedCamera: any): void;
  8181. }
  8182. }
  8183. declare module BABYLON {
  8184. /**
  8185. * Gather the list of keyboard event types as constants.
  8186. */
  8187. export class KeyboardEventTypes {
  8188. /**
  8189. * The keydown event is fired when a key becomes active (pressed).
  8190. */
  8191. static readonly KEYDOWN: number;
  8192. /**
  8193. * The keyup event is fired when a key has been released.
  8194. */
  8195. static readonly KEYUP: number;
  8196. }
  8197. /**
  8198. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8199. */
  8200. export class KeyboardInfo {
  8201. /**
  8202. * Defines the type of event (KeyboardEventTypes)
  8203. */
  8204. type: number;
  8205. /**
  8206. * Defines the related dom event
  8207. */
  8208. event: KeyboardEvent;
  8209. /**
  8210. * Instantiates a new keyboard info.
  8211. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8212. * @param type Defines the type of event (KeyboardEventTypes)
  8213. * @param event Defines the related dom event
  8214. */
  8215. constructor(
  8216. /**
  8217. * Defines the type of event (KeyboardEventTypes)
  8218. */
  8219. type: number,
  8220. /**
  8221. * Defines the related dom event
  8222. */
  8223. event: KeyboardEvent);
  8224. }
  8225. /**
  8226. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8227. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8228. */
  8229. export class KeyboardInfoPre extends KeyboardInfo {
  8230. /**
  8231. * Defines the type of event (KeyboardEventTypes)
  8232. */
  8233. type: number;
  8234. /**
  8235. * Defines the related dom event
  8236. */
  8237. event: KeyboardEvent;
  8238. /**
  8239. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8240. */
  8241. skipOnPointerObservable: boolean;
  8242. /**
  8243. * Instantiates a new keyboard pre info.
  8244. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8245. * @param type Defines the type of event (KeyboardEventTypes)
  8246. * @param event Defines the related dom event
  8247. */
  8248. constructor(
  8249. /**
  8250. * Defines the type of event (KeyboardEventTypes)
  8251. */
  8252. type: number,
  8253. /**
  8254. * Defines the related dom event
  8255. */
  8256. event: KeyboardEvent);
  8257. }
  8258. }
  8259. declare module BABYLON {
  8260. /**
  8261. * Manage the keyboard inputs to control the movement of a free camera.
  8262. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8263. */
  8264. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8265. /**
  8266. * Defines the camera the input is attached to.
  8267. */
  8268. camera: FreeCamera;
  8269. /**
  8270. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8271. */
  8272. keysUp: number[];
  8273. /**
  8274. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8275. */
  8276. keysDown: number[];
  8277. /**
  8278. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8279. */
  8280. keysLeft: number[];
  8281. /**
  8282. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8283. */
  8284. keysRight: number[];
  8285. private _keys;
  8286. private _onCanvasBlurObserver;
  8287. private _onKeyboardObserver;
  8288. private _engine;
  8289. private _scene;
  8290. /**
  8291. * Attach the input controls to a specific dom element to get the input from.
  8292. * @param element Defines the element the controls should be listened from
  8293. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8294. */
  8295. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8296. /**
  8297. * Detach the current controls from the specified dom element.
  8298. * @param element Defines the element to stop listening the inputs from
  8299. */
  8300. detachControl(element: Nullable<HTMLElement>): void;
  8301. /**
  8302. * Update the current camera state depending on the inputs that have been used this frame.
  8303. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8304. */
  8305. checkInputs(): void;
  8306. /**
  8307. * Gets the class name of the current intput.
  8308. * @returns the class name
  8309. */
  8310. getClassName(): string;
  8311. /** @hidden */
  8312. _onLostFocus(): void;
  8313. /**
  8314. * Get the friendly name associated with the input class.
  8315. * @returns the input friendly name
  8316. */
  8317. getSimpleName(): string;
  8318. }
  8319. }
  8320. declare module BABYLON {
  8321. /**
  8322. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8323. * separate meshes. This can be use to improve performances.
  8324. * @see http://doc.babylonjs.com/how_to/multi_materials
  8325. */
  8326. export class MultiMaterial extends Material {
  8327. private _subMaterials;
  8328. /**
  8329. * Gets or Sets the list of Materials used within the multi material.
  8330. * They need to be ordered according to the submeshes order in the associated mesh
  8331. */
  8332. subMaterials: Nullable<Material>[];
  8333. /**
  8334. * Function used to align with Node.getChildren()
  8335. * @returns the list of Materials used within the multi material
  8336. */
  8337. getChildren(): Nullable<Material>[];
  8338. /**
  8339. * Instantiates a new Multi Material
  8340. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8341. * separate meshes. This can be use to improve performances.
  8342. * @see http://doc.babylonjs.com/how_to/multi_materials
  8343. * @param name Define the name in the scene
  8344. * @param scene Define the scene the material belongs to
  8345. */
  8346. constructor(name: string, scene: Scene);
  8347. private _hookArray;
  8348. /**
  8349. * Get one of the submaterial by its index in the submaterials array
  8350. * @param index The index to look the sub material at
  8351. * @returns The Material if the index has been defined
  8352. */
  8353. getSubMaterial(index: number): Nullable<Material>;
  8354. /**
  8355. * Get the list of active textures for the whole sub materials list.
  8356. * @returns All the textures that will be used during the rendering
  8357. */
  8358. getActiveTextures(): BaseTexture[];
  8359. /**
  8360. * Gets the current class name of the material e.g. "MultiMaterial"
  8361. * Mainly use in serialization.
  8362. * @returns the class name
  8363. */
  8364. getClassName(): string;
  8365. /**
  8366. * Checks if the material is ready to render the requested sub mesh
  8367. * @param mesh Define the mesh the submesh belongs to
  8368. * @param subMesh Define the sub mesh to look readyness for
  8369. * @param useInstances Define whether or not the material is used with instances
  8370. * @returns true if ready, otherwise false
  8371. */
  8372. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  8373. /**
  8374. * Clones the current material and its related sub materials
  8375. * @param name Define the name of the newly cloned material
  8376. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  8377. * @returns the cloned material
  8378. */
  8379. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  8380. /**
  8381. * Serializes the materials into a JSON representation.
  8382. * @returns the JSON representation
  8383. */
  8384. serialize(): any;
  8385. /**
  8386. * Dispose the material and release its associated resources
  8387. * @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)
  8388. * @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)
  8389. * @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)
  8390. */
  8391. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  8392. /**
  8393. * Creates a MultiMaterial from parsed MultiMaterial data.
  8394. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  8395. * @param scene defines the hosting scene
  8396. * @returns a new MultiMaterial
  8397. */
  8398. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  8399. }
  8400. }
  8401. declare module BABYLON {
  8402. /**
  8403. * Class used to represent data loading progression
  8404. */
  8405. export class SceneLoaderFlags {
  8406. private static _ForceFullSceneLoadingForIncremental;
  8407. private static _ShowLoadingScreen;
  8408. private static _CleanBoneMatrixWeights;
  8409. private static _loggingLevel;
  8410. /**
  8411. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  8412. */
  8413. static ForceFullSceneLoadingForIncremental: boolean;
  8414. /**
  8415. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  8416. */
  8417. static ShowLoadingScreen: boolean;
  8418. /**
  8419. * Defines the current logging level (while loading the scene)
  8420. * @ignorenaming
  8421. */
  8422. static loggingLevel: number;
  8423. /**
  8424. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  8425. */
  8426. static CleanBoneMatrixWeights: boolean;
  8427. }
  8428. }
  8429. declare module BABYLON {
  8430. /**
  8431. * 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.
  8432. * @see https://doc.babylonjs.com/how_to/transformnode
  8433. */
  8434. export class TransformNode extends Node {
  8435. /**
  8436. * Object will not rotate to face the camera
  8437. */
  8438. static BILLBOARDMODE_NONE: number;
  8439. /**
  8440. * Object will rotate to face the camera but only on the x axis
  8441. */
  8442. static BILLBOARDMODE_X: number;
  8443. /**
  8444. * Object will rotate to face the camera but only on the y axis
  8445. */
  8446. static BILLBOARDMODE_Y: number;
  8447. /**
  8448. * Object will rotate to face the camera but only on the z axis
  8449. */
  8450. static BILLBOARDMODE_Z: number;
  8451. /**
  8452. * Object will rotate to face the camera
  8453. */
  8454. static BILLBOARDMODE_ALL: number;
  8455. private _forward;
  8456. private _forwardInverted;
  8457. private _up;
  8458. private _right;
  8459. private _rightInverted;
  8460. private _position;
  8461. private _rotation;
  8462. private _rotationQuaternion;
  8463. protected _scaling: Vector3;
  8464. protected _isDirty: boolean;
  8465. private _transformToBoneReferal;
  8466. private _billboardMode;
  8467. /**
  8468. * Gets or sets the billboard mode. Default is 0.
  8469. *
  8470. * | Value | Type | Description |
  8471. * | --- | --- | --- |
  8472. * | 0 | BILLBOARDMODE_NONE | |
  8473. * | 1 | BILLBOARDMODE_X | |
  8474. * | 2 | BILLBOARDMODE_Y | |
  8475. * | 4 | BILLBOARDMODE_Z | |
  8476. * | 7 | BILLBOARDMODE_ALL | |
  8477. *
  8478. */
  8479. billboardMode: number;
  8480. private _preserveParentRotationForBillboard;
  8481. /**
  8482. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  8483. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  8484. */
  8485. preserveParentRotationForBillboard: boolean;
  8486. /**
  8487. * 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
  8488. */
  8489. scalingDeterminant: number;
  8490. private _infiniteDistance;
  8491. /**
  8492. * Gets or sets the distance of the object to max, often used by skybox
  8493. */
  8494. infiniteDistance: boolean;
  8495. /**
  8496. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  8497. * By default the system will update normals to compensate
  8498. */
  8499. ignoreNonUniformScaling: boolean;
  8500. /**
  8501. * 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
  8502. */
  8503. reIntegrateRotationIntoRotationQuaternion: boolean;
  8504. /** @hidden */
  8505. _poseMatrix: Nullable<Matrix>;
  8506. /** @hidden */
  8507. _localMatrix: Matrix;
  8508. private _usePivotMatrix;
  8509. private _absolutePosition;
  8510. private _pivotMatrix;
  8511. private _pivotMatrixInverse;
  8512. protected _postMultiplyPivotMatrix: boolean;
  8513. protected _isWorldMatrixFrozen: boolean;
  8514. /** @hidden */
  8515. _indexInSceneTransformNodesArray: number;
  8516. /**
  8517. * An event triggered after the world matrix is updated
  8518. */
  8519. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  8520. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  8521. /**
  8522. * Gets a string identifying the name of the class
  8523. * @returns "TransformNode" string
  8524. */
  8525. getClassName(): string;
  8526. /**
  8527. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  8528. */
  8529. position: Vector3;
  8530. /**
  8531. * 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)).
  8532. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  8533. */
  8534. rotation: Vector3;
  8535. /**
  8536. * 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)).
  8537. */
  8538. scaling: Vector3;
  8539. /**
  8540. * 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).
  8541. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  8542. */
  8543. rotationQuaternion: Nullable<Quaternion>;
  8544. /**
  8545. * The forward direction of that transform in world space.
  8546. */
  8547. readonly forward: Vector3;
  8548. /**
  8549. * The up direction of that transform in world space.
  8550. */
  8551. readonly up: Vector3;
  8552. /**
  8553. * The right direction of that transform in world space.
  8554. */
  8555. readonly right: Vector3;
  8556. /**
  8557. * Copies the parameter passed Matrix into the mesh Pose matrix.
  8558. * @param matrix the matrix to copy the pose from
  8559. * @returns this TransformNode.
  8560. */
  8561. updatePoseMatrix(matrix: Matrix): TransformNode;
  8562. /**
  8563. * Returns the mesh Pose matrix.
  8564. * @returns the pose matrix
  8565. */
  8566. getPoseMatrix(): Matrix;
  8567. /** @hidden */
  8568. _isSynchronized(): boolean;
  8569. /** @hidden */
  8570. _initCache(): void;
  8571. /**
  8572. * Flag the transform node as dirty (Forcing it to update everything)
  8573. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  8574. * @returns this transform node
  8575. */
  8576. markAsDirty(property: string): TransformNode;
  8577. /**
  8578. * Returns the current mesh absolute position.
  8579. * Returns a Vector3.
  8580. */
  8581. readonly absolutePosition: Vector3;
  8582. /**
  8583. * Sets a new matrix to apply before all other transformation
  8584. * @param matrix defines the transform matrix
  8585. * @returns the current TransformNode
  8586. */
  8587. setPreTransformMatrix(matrix: Matrix): TransformNode;
  8588. /**
  8589. * Sets a new pivot matrix to the current node
  8590. * @param matrix defines the new pivot matrix to use
  8591. * @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
  8592. * @returns the current TransformNode
  8593. */
  8594. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  8595. /**
  8596. * Returns the mesh pivot matrix.
  8597. * Default : Identity.
  8598. * @returns the matrix
  8599. */
  8600. getPivotMatrix(): Matrix;
  8601. /**
  8602. * Prevents the World matrix to be computed any longer.
  8603. * @returns the TransformNode.
  8604. */
  8605. freezeWorldMatrix(): TransformNode;
  8606. /**
  8607. * Allows back the World matrix computation.
  8608. * @returns the TransformNode.
  8609. */
  8610. unfreezeWorldMatrix(): this;
  8611. /**
  8612. * True if the World matrix has been frozen.
  8613. */
  8614. readonly isWorldMatrixFrozen: boolean;
  8615. /**
  8616. * Retuns the mesh absolute position in the World.
  8617. * @returns a Vector3.
  8618. */
  8619. getAbsolutePosition(): Vector3;
  8620. /**
  8621. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  8622. * @param absolutePosition the absolute position to set
  8623. * @returns the TransformNode.
  8624. */
  8625. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  8626. /**
  8627. * Sets the mesh position in its local space.
  8628. * @param vector3 the position to set in localspace
  8629. * @returns the TransformNode.
  8630. */
  8631. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  8632. /**
  8633. * Returns the mesh position in the local space from the current World matrix values.
  8634. * @returns a new Vector3.
  8635. */
  8636. getPositionExpressedInLocalSpace(): Vector3;
  8637. /**
  8638. * Translates the mesh along the passed Vector3 in its local space.
  8639. * @param vector3 the distance to translate in localspace
  8640. * @returns the TransformNode.
  8641. */
  8642. locallyTranslate(vector3: Vector3): TransformNode;
  8643. private static _lookAtVectorCache;
  8644. /**
  8645. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  8646. * @param targetPoint the position (must be in same space as current mesh) to look at
  8647. * @param yawCor optional yaw (y-axis) correction in radians
  8648. * @param pitchCor optional pitch (x-axis) correction in radians
  8649. * @param rollCor optional roll (z-axis) correction in radians
  8650. * @param space the choosen space of the target
  8651. * @returns the TransformNode.
  8652. */
  8653. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  8654. /**
  8655. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8656. * This Vector3 is expressed in the World space.
  8657. * @param localAxis axis to rotate
  8658. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8659. */
  8660. getDirection(localAxis: Vector3): Vector3;
  8661. /**
  8662. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  8663. * localAxis is expressed in the mesh local space.
  8664. * result is computed in the Wordl space from the mesh World matrix.
  8665. * @param localAxis axis to rotate
  8666. * @param result the resulting transformnode
  8667. * @returns this TransformNode.
  8668. */
  8669. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  8670. /**
  8671. * Sets this transform node rotation to the given local axis.
  8672. * @param localAxis the axis in local space
  8673. * @param yawCor optional yaw (y-axis) correction in radians
  8674. * @param pitchCor optional pitch (x-axis) correction in radians
  8675. * @param rollCor optional roll (z-axis) correction in radians
  8676. * @returns this TransformNode
  8677. */
  8678. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  8679. /**
  8680. * Sets a new pivot point to the current node
  8681. * @param point defines the new pivot point to use
  8682. * @param space defines if the point is in world or local space (local by default)
  8683. * @returns the current TransformNode
  8684. */
  8685. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  8686. /**
  8687. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  8688. * @returns the pivot point
  8689. */
  8690. getPivotPoint(): Vector3;
  8691. /**
  8692. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8693. * @param result the vector3 to store the result
  8694. * @returns this TransformNode.
  8695. */
  8696. getPivotPointToRef(result: Vector3): TransformNode;
  8697. /**
  8698. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8699. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8700. */
  8701. getAbsolutePivotPoint(): Vector3;
  8702. /**
  8703. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8704. * @param result vector3 to store the result
  8705. * @returns this TransformNode.
  8706. */
  8707. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8708. /**
  8709. * Defines the passed node as the parent of the current node.
  8710. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8711. * @see https://doc.babylonjs.com/how_to/parenting
  8712. * @param node the node ot set as the parent
  8713. * @returns this TransformNode.
  8714. */
  8715. setParent(node: Nullable<Node>): TransformNode;
  8716. private _nonUniformScaling;
  8717. /**
  8718. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8719. */
  8720. readonly nonUniformScaling: boolean;
  8721. /** @hidden */
  8722. _updateNonUniformScalingState(value: boolean): boolean;
  8723. /**
  8724. * Attach the current TransformNode to another TransformNode associated with a bone
  8725. * @param bone Bone affecting the TransformNode
  8726. * @param affectedTransformNode TransformNode associated with the bone
  8727. * @returns this object
  8728. */
  8729. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8730. /**
  8731. * Detach the transform node if its associated with a bone
  8732. * @returns this object
  8733. */
  8734. detachFromBone(): TransformNode;
  8735. private static _rotationAxisCache;
  8736. /**
  8737. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8738. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8739. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8740. * The passed axis is also normalized.
  8741. * @param axis the axis to rotate around
  8742. * @param amount the amount to rotate in radians
  8743. * @param space Space to rotate in (Default: local)
  8744. * @returns the TransformNode.
  8745. */
  8746. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8747. /**
  8748. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8749. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8750. * The passed axis is also normalized. .
  8751. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8752. * @param point the point to rotate around
  8753. * @param axis the axis to rotate around
  8754. * @param amount the amount to rotate in radians
  8755. * @returns the TransformNode
  8756. */
  8757. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8758. /**
  8759. * Translates the mesh along the axis vector for the passed distance in the given space.
  8760. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8761. * @param axis the axis to translate in
  8762. * @param distance the distance to translate
  8763. * @param space Space to rotate in (Default: local)
  8764. * @returns the TransformNode.
  8765. */
  8766. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8767. /**
  8768. * Adds a rotation step to the mesh current rotation.
  8769. * x, y, z are Euler angles expressed in radians.
  8770. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8771. * This means this rotation is made in the mesh local space only.
  8772. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8773. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8774. * ```javascript
  8775. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8776. * ```
  8777. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8778. * 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.
  8779. * @param x Rotation to add
  8780. * @param y Rotation to add
  8781. * @param z Rotation to add
  8782. * @returns the TransformNode.
  8783. */
  8784. addRotation(x: number, y: number, z: number): TransformNode;
  8785. /**
  8786. * @hidden
  8787. */
  8788. protected _getEffectiveParent(): Nullable<Node>;
  8789. /**
  8790. * Computes the world matrix of the node
  8791. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8792. * @returns the world matrix
  8793. */
  8794. computeWorldMatrix(force?: boolean): Matrix;
  8795. protected _afterComputeWorldMatrix(): void;
  8796. /**
  8797. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8798. * @param func callback function to add
  8799. *
  8800. * @returns the TransformNode.
  8801. */
  8802. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8803. /**
  8804. * Removes a registered callback function.
  8805. * @param func callback function to remove
  8806. * @returns the TransformNode.
  8807. */
  8808. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8809. /**
  8810. * Gets the position of the current mesh in camera space
  8811. * @param camera defines the camera to use
  8812. * @returns a position
  8813. */
  8814. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8815. /**
  8816. * Returns the distance from the mesh to the active camera
  8817. * @param camera defines the camera to use
  8818. * @returns the distance
  8819. */
  8820. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8821. /**
  8822. * Clone the current transform node
  8823. * @param name Name of the new clone
  8824. * @param newParent New parent for the clone
  8825. * @param doNotCloneChildren Do not clone children hierarchy
  8826. * @returns the new transform node
  8827. */
  8828. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8829. /**
  8830. * Serializes the objects information.
  8831. * @param currentSerializationObject defines the object to serialize in
  8832. * @returns the serialized object
  8833. */
  8834. serialize(currentSerializationObject?: any): any;
  8835. /**
  8836. * Returns a new TransformNode object parsed from the source provided.
  8837. * @param parsedTransformNode is the source.
  8838. * @param scene the scne the object belongs to
  8839. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8840. * @returns a new TransformNode object parsed from the source provided.
  8841. */
  8842. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8843. /**
  8844. * Get all child-transformNodes of this node
  8845. * @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
  8846. * @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
  8847. * @returns an array of TransformNode
  8848. */
  8849. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8850. /**
  8851. * Releases resources associated with this transform node.
  8852. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8853. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8854. */
  8855. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8856. /**
  8857. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  8858. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  8859. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  8860. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  8861. * @returns the current mesh
  8862. */
  8863. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  8864. }
  8865. }
  8866. declare module BABYLON {
  8867. /**
  8868. * Class used to override all child animations of a given target
  8869. */
  8870. export class AnimationPropertiesOverride {
  8871. /**
  8872. * Gets or sets a value indicating if animation blending must be used
  8873. */
  8874. enableBlending: boolean;
  8875. /**
  8876. * Gets or sets the blending speed to use when enableBlending is true
  8877. */
  8878. blendingSpeed: number;
  8879. /**
  8880. * Gets or sets the default loop mode to use
  8881. */
  8882. loopMode: number;
  8883. }
  8884. }
  8885. declare module BABYLON {
  8886. /**
  8887. * Class used to store bone information
  8888. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8889. */
  8890. export class Bone extends Node {
  8891. /**
  8892. * defines the bone name
  8893. */
  8894. name: string;
  8895. private static _tmpVecs;
  8896. private static _tmpQuat;
  8897. private static _tmpMats;
  8898. /**
  8899. * Gets the list of child bones
  8900. */
  8901. children: Bone[];
  8902. /** Gets the animations associated with this bone */
  8903. animations: Animation[];
  8904. /**
  8905. * Gets or sets bone length
  8906. */
  8907. length: number;
  8908. /**
  8909. * @hidden Internal only
  8910. * Set this value to map this bone to a different index in the transform matrices
  8911. * Set this value to -1 to exclude the bone from the transform matrices
  8912. */
  8913. _index: Nullable<number>;
  8914. private _skeleton;
  8915. private _localMatrix;
  8916. private _restPose;
  8917. private _baseMatrix;
  8918. private _absoluteTransform;
  8919. private _invertedAbsoluteTransform;
  8920. private _parent;
  8921. private _scalingDeterminant;
  8922. private _worldTransform;
  8923. private _localScaling;
  8924. private _localRotation;
  8925. private _localPosition;
  8926. private _needToDecompose;
  8927. private _needToCompose;
  8928. /** @hidden */
  8929. _linkedTransformNode: Nullable<TransformNode>;
  8930. /** @hidden */
  8931. _waitingTransformNodeId: Nullable<string>;
  8932. /** @hidden */
  8933. /** @hidden */
  8934. _matrix: Matrix;
  8935. /**
  8936. * Create a new bone
  8937. * @param name defines the bone name
  8938. * @param skeleton defines the parent skeleton
  8939. * @param parentBone defines the parent (can be null if the bone is the root)
  8940. * @param localMatrix defines the local matrix
  8941. * @param restPose defines the rest pose matrix
  8942. * @param baseMatrix defines the base matrix
  8943. * @param index defines index of the bone in the hiearchy
  8944. */
  8945. constructor(
  8946. /**
  8947. * defines the bone name
  8948. */
  8949. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8950. /**
  8951. * Gets the current object class name.
  8952. * @return the class name
  8953. */
  8954. getClassName(): string;
  8955. /**
  8956. * Gets the parent skeleton
  8957. * @returns a skeleton
  8958. */
  8959. getSkeleton(): Skeleton;
  8960. /**
  8961. * Gets parent bone
  8962. * @returns a bone or null if the bone is the root of the bone hierarchy
  8963. */
  8964. getParent(): Nullable<Bone>;
  8965. /**
  8966. * Returns an array containing the root bones
  8967. * @returns an array containing the root bones
  8968. */
  8969. getChildren(): Array<Bone>;
  8970. /**
  8971. * Sets the parent bone
  8972. * @param parent defines the parent (can be null if the bone is the root)
  8973. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8974. */
  8975. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8976. /**
  8977. * Gets the local matrix
  8978. * @returns a matrix
  8979. */
  8980. getLocalMatrix(): Matrix;
  8981. /**
  8982. * Gets the base matrix (initial matrix which remains unchanged)
  8983. * @returns a matrix
  8984. */
  8985. getBaseMatrix(): Matrix;
  8986. /**
  8987. * Gets the rest pose matrix
  8988. * @returns a matrix
  8989. */
  8990. getRestPose(): Matrix;
  8991. /**
  8992. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8993. */
  8994. getWorldMatrix(): Matrix;
  8995. /**
  8996. * Sets the local matrix to rest pose matrix
  8997. */
  8998. returnToRest(): void;
  8999. /**
  9000. * Gets the inverse of the absolute transform matrix.
  9001. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9002. * @returns a matrix
  9003. */
  9004. getInvertedAbsoluteTransform(): Matrix;
  9005. /**
  9006. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9007. * @returns a matrix
  9008. */
  9009. getAbsoluteTransform(): Matrix;
  9010. /**
  9011. * Links with the given transform node.
  9012. * The local matrix of this bone is copied from the transform node every frame.
  9013. * @param transformNode defines the transform node to link to
  9014. */
  9015. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9016. /** Gets or sets current position (in local space) */
  9017. position: Vector3;
  9018. /** Gets or sets current rotation (in local space) */
  9019. rotation: Vector3;
  9020. /** Gets or sets current rotation quaternion (in local space) */
  9021. rotationQuaternion: Quaternion;
  9022. /** Gets or sets current scaling (in local space) */
  9023. scaling: Vector3;
  9024. /**
  9025. * Gets the animation properties override
  9026. */
  9027. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9028. private _decompose;
  9029. private _compose;
  9030. /**
  9031. * Update the base and local matrices
  9032. * @param matrix defines the new base or local matrix
  9033. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9034. * @param updateLocalMatrix defines if the local matrix should be updated
  9035. */
  9036. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9037. /** @hidden */
  9038. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9039. /**
  9040. * Flag the bone as dirty (Forcing it to update everything)
  9041. */
  9042. markAsDirty(): void;
  9043. /** @hidden */
  9044. _markAsDirtyAndCompose(): void;
  9045. private _markAsDirtyAndDecompose;
  9046. /**
  9047. * Translate the bone in local or world space
  9048. * @param vec The amount to translate the bone
  9049. * @param space The space that the translation is in
  9050. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9051. */
  9052. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9053. /**
  9054. * Set the postion of the bone in local or world space
  9055. * @param position The position to set the bone
  9056. * @param space The space that the position is in
  9057. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9058. */
  9059. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9060. /**
  9061. * Set the absolute position of the bone (world space)
  9062. * @param position The position to set the bone
  9063. * @param mesh The mesh that this bone is attached to
  9064. */
  9065. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9066. /**
  9067. * Scale the bone on the x, y and z axes (in local space)
  9068. * @param x The amount to scale the bone on the x axis
  9069. * @param y The amount to scale the bone on the y axis
  9070. * @param z The amount to scale the bone on the z axis
  9071. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9072. */
  9073. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9074. /**
  9075. * Set the bone scaling in local space
  9076. * @param scale defines the scaling vector
  9077. */
  9078. setScale(scale: Vector3): void;
  9079. /**
  9080. * Gets the current scaling in local space
  9081. * @returns the current scaling vector
  9082. */
  9083. getScale(): Vector3;
  9084. /**
  9085. * Gets the current scaling in local space and stores it in a target vector
  9086. * @param result defines the target vector
  9087. */
  9088. getScaleToRef(result: Vector3): void;
  9089. /**
  9090. * Set the yaw, pitch, and roll of the bone in local or world space
  9091. * @param yaw The rotation of the bone on the y axis
  9092. * @param pitch The rotation of the bone on the x axis
  9093. * @param roll The rotation of the bone on the z axis
  9094. * @param space The space that the axes of rotation are in
  9095. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9096. */
  9097. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9098. /**
  9099. * Add a rotation to the bone on an axis in local or world space
  9100. * @param axis The axis to rotate the bone on
  9101. * @param amount The amount to rotate the bone
  9102. * @param space The space that the axis is in
  9103. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9104. */
  9105. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9106. /**
  9107. * Set the rotation of the bone to a particular axis angle in local or world space
  9108. * @param axis The axis to rotate the bone on
  9109. * @param angle The angle that the bone should be rotated to
  9110. * @param space The space that the axis is in
  9111. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9112. */
  9113. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9114. /**
  9115. * Set the euler rotation of the bone in local of world space
  9116. * @param rotation The euler rotation that the bone should be set to
  9117. * @param space The space that the rotation is in
  9118. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9119. */
  9120. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9121. /**
  9122. * Set the quaternion rotation of the bone in local of world space
  9123. * @param quat The quaternion rotation that the bone should be set to
  9124. * @param space The space that the rotation is in
  9125. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9126. */
  9127. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9128. /**
  9129. * Set the rotation matrix of the bone in local of world space
  9130. * @param rotMat The rotation matrix that the bone should be set to
  9131. * @param space The space that the rotation is in
  9132. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9133. */
  9134. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9135. private _rotateWithMatrix;
  9136. private _getNegativeRotationToRef;
  9137. /**
  9138. * Get the position of the bone in local or world space
  9139. * @param space The space that the returned position is in
  9140. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9141. * @returns The position of the bone
  9142. */
  9143. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9144. /**
  9145. * Copy the position of the bone to a vector3 in local or world space
  9146. * @param space The space that the returned position is in
  9147. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9148. * @param result The vector3 to copy the position to
  9149. */
  9150. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9151. /**
  9152. * Get the absolute position of the bone (world space)
  9153. * @param mesh The mesh that this bone is attached to
  9154. * @returns The absolute position of the bone
  9155. */
  9156. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9157. /**
  9158. * Copy the absolute position of the bone (world space) to the result param
  9159. * @param mesh The mesh that this bone is attached to
  9160. * @param result The vector3 to copy the absolute position to
  9161. */
  9162. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9163. /**
  9164. * Compute the absolute transforms of this bone and its children
  9165. */
  9166. computeAbsoluteTransforms(): void;
  9167. /**
  9168. * Get the world direction from an axis that is in the local space of the bone
  9169. * @param localAxis The local direction that is used to compute the world direction
  9170. * @param mesh The mesh that this bone is attached to
  9171. * @returns The world direction
  9172. */
  9173. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9174. /**
  9175. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9176. * @param localAxis The local direction that is used to compute the world direction
  9177. * @param mesh The mesh that this bone is attached to
  9178. * @param result The vector3 that the world direction will be copied to
  9179. */
  9180. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9181. /**
  9182. * Get the euler rotation of the bone in local or world space
  9183. * @param space The space that the rotation should be in
  9184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9185. * @returns The euler rotation
  9186. */
  9187. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9188. /**
  9189. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9190. * @param space The space that the rotation should be in
  9191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9192. * @param result The vector3 that the rotation should be copied to
  9193. */
  9194. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9195. /**
  9196. * Get the quaternion rotation of the bone in either local or world space
  9197. * @param space The space that the rotation should be in
  9198. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9199. * @returns The quaternion rotation
  9200. */
  9201. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9202. /**
  9203. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9204. * @param space The space that the rotation should be in
  9205. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9206. * @param result The quaternion that the rotation should be copied to
  9207. */
  9208. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9209. /**
  9210. * Get the rotation matrix of the bone in local or world space
  9211. * @param space The space that the rotation should be in
  9212. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9213. * @returns The rotation matrix
  9214. */
  9215. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9216. /**
  9217. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9218. * @param space The space that the rotation should be in
  9219. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9220. * @param result The quaternion that the rotation should be copied to
  9221. */
  9222. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9223. /**
  9224. * Get the world position of a point that is in the local space of the bone
  9225. * @param position The local position
  9226. * @param mesh The mesh that this bone is attached to
  9227. * @returns The world position
  9228. */
  9229. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9230. /**
  9231. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9232. * @param position The local position
  9233. * @param mesh The mesh that this bone is attached to
  9234. * @param result The vector3 that the world position should be copied to
  9235. */
  9236. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9237. /**
  9238. * Get the local position of a point that is in world space
  9239. * @param position The world position
  9240. * @param mesh The mesh that this bone is attached to
  9241. * @returns The local position
  9242. */
  9243. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9244. /**
  9245. * Get the local position of a point that is in world space and copy it to the result param
  9246. * @param position The world position
  9247. * @param mesh The mesh that this bone is attached to
  9248. * @param result The vector3 that the local position should be copied to
  9249. */
  9250. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9251. }
  9252. }
  9253. declare module BABYLON {
  9254. interface Engine {
  9255. /**
  9256. * Creates a raw texture
  9257. * @param data defines the data to store in the texture
  9258. * @param width defines the width of the texture
  9259. * @param height defines the height of the texture
  9260. * @param format defines the format of the data
  9261. * @param generateMipMaps defines if the engine should generate the mip levels
  9262. * @param invertY defines if data must be stored with Y axis inverted
  9263. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  9264. * @param compression defines the compression used (null by default)
  9265. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9266. * @returns the raw texture inside an InternalTexture
  9267. */
  9268. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  9269. /**
  9270. * Update a raw texture
  9271. * @param texture defines the texture to update
  9272. * @param data defines the data to store in the texture
  9273. * @param format defines the format of the data
  9274. * @param invertY defines if data must be stored with Y axis inverted
  9275. */
  9276. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9277. /**
  9278. * Update a raw texture
  9279. * @param texture defines the texture to update
  9280. * @param data defines the data to store in the texture
  9281. * @param format defines the format of the data
  9282. * @param invertY defines if data must be stored with Y axis inverted
  9283. * @param compression defines the compression used (null by default)
  9284. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9285. */
  9286. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  9287. /**
  9288. * Creates a new raw cube texture
  9289. * @param data defines the array of data to use to create each face
  9290. * @param size defines the size of the textures
  9291. * @param format defines the format of the data
  9292. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9293. * @param generateMipMaps defines if the engine should generate the mip levels
  9294. * @param invertY defines if data must be stored with Y axis inverted
  9295. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9296. * @param compression defines the compression used (null by default)
  9297. * @returns the cube texture as an InternalTexture
  9298. */
  9299. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  9300. /**
  9301. * Update a raw cube texture
  9302. * @param texture defines the texture to udpdate
  9303. * @param data defines the data to store
  9304. * @param format defines the data format
  9305. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9306. * @param invertY defines if data must be stored with Y axis inverted
  9307. */
  9308. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  9309. /**
  9310. * Update a raw cube texture
  9311. * @param texture defines the texture to udpdate
  9312. * @param data defines the data to store
  9313. * @param format defines the data format
  9314. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9315. * @param invertY defines if data must be stored with Y axis inverted
  9316. * @param compression defines the compression used (null by default)
  9317. */
  9318. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  9319. /**
  9320. * Update a raw cube texture
  9321. * @param texture defines the texture to udpdate
  9322. * @param data defines the data to store
  9323. * @param format defines the data format
  9324. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9325. * @param invertY defines if data must be stored with Y axis inverted
  9326. * @param compression defines the compression used (null by default)
  9327. * @param level defines which level of the texture to update
  9328. */
  9329. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  9330. /**
  9331. * Creates a new raw cube texture from a specified url
  9332. * @param url defines the url where the data is located
  9333. * @param scene defines the current scene
  9334. * @param size defines the size of the textures
  9335. * @param format defines the format of the data
  9336. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9337. * @param noMipmap defines if the engine should avoid generating the mip levels
  9338. * @param callback defines a callback used to extract texture data from loaded data
  9339. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9340. * @param onLoad defines a callback called when texture is loaded
  9341. * @param onError defines a callback called if there is an error
  9342. * @returns the cube texture as an InternalTexture
  9343. */
  9344. 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;
  9345. /**
  9346. * Creates a new raw cube texture from a specified url
  9347. * @param url defines the url where the data is located
  9348. * @param scene defines the current scene
  9349. * @param size defines the size of the textures
  9350. * @param format defines the format of the data
  9351. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9352. * @param noMipmap defines if the engine should avoid generating the mip levels
  9353. * @param callback defines a callback used to extract texture data from loaded data
  9354. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9355. * @param onLoad defines a callback called when texture is loaded
  9356. * @param onError defines a callback called if there is an error
  9357. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9358. * @param invertY defines if data must be stored with Y axis inverted
  9359. * @returns the cube texture as an InternalTexture
  9360. */
  9361. 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;
  9362. /**
  9363. * Creates a new raw 3D texture
  9364. * @param data defines the data used to create the texture
  9365. * @param width defines the width of the texture
  9366. * @param height defines the height of the texture
  9367. * @param depth defines the depth of the texture
  9368. * @param format defines the format of the texture
  9369. * @param generateMipMaps defines if the engine must generate mip levels
  9370. * @param invertY defines if data must be stored with Y axis inverted
  9371. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9372. * @param compression defines the compressed used (can be null)
  9373. * @param textureType defines the compressed used (can be null)
  9374. * @returns a new raw 3D texture (stored in an InternalTexture)
  9375. */
  9376. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  9377. /**
  9378. * Update a raw 3D texture
  9379. * @param texture defines the texture to update
  9380. * @param data defines the data to store
  9381. * @param format defines the data format
  9382. * @param invertY defines if data must be stored with Y axis inverted
  9383. */
  9384. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9385. /**
  9386. * Update a raw 3D texture
  9387. * @param texture defines the texture to update
  9388. * @param data defines the data to store
  9389. * @param format defines the data format
  9390. * @param invertY defines if data must be stored with Y axis inverted
  9391. * @param compression defines the used compression (can be null)
  9392. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9393. */
  9394. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  9395. }
  9396. }
  9397. declare module BABYLON {
  9398. /**
  9399. * Raw texture can help creating a texture directly from an array of data.
  9400. * This can be super useful if you either get the data from an uncompressed source or
  9401. * if you wish to create your texture pixel by pixel.
  9402. */
  9403. export class RawTexture extends Texture {
  9404. /**
  9405. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9406. */
  9407. format: number;
  9408. private _engine;
  9409. /**
  9410. * Instantiates a new RawTexture.
  9411. * Raw texture can help creating a texture directly from an array of data.
  9412. * This can be super useful if you either get the data from an uncompressed source or
  9413. * if you wish to create your texture pixel by pixel.
  9414. * @param data define the array of data to use to create the texture
  9415. * @param width define the width of the texture
  9416. * @param height define the height of the texture
  9417. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9418. * @param scene define the scene the texture belongs to
  9419. * @param generateMipMaps define whether mip maps should be generated or not
  9420. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9421. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9422. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9423. */
  9424. constructor(data: ArrayBufferView, width: number, height: number,
  9425. /**
  9426. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9427. */
  9428. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  9429. /**
  9430. * Updates the texture underlying data.
  9431. * @param data Define the new data of the texture
  9432. */
  9433. update(data: ArrayBufferView): void;
  9434. /**
  9435. * Creates a luminance texture from some data.
  9436. * @param data Define the texture data
  9437. * @param width Define the width of the texture
  9438. * @param height Define the height of the texture
  9439. * @param scene Define the scene the texture belongs to
  9440. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9441. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9442. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9443. * @returns the luminance texture
  9444. */
  9445. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9446. /**
  9447. * Creates a luminance alpha texture from some data.
  9448. * @param data Define the texture data
  9449. * @param width Define the width of the texture
  9450. * @param height Define the height of the texture
  9451. * @param scene Define the scene the texture belongs to
  9452. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9453. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9454. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9455. * @returns the luminance alpha texture
  9456. */
  9457. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9458. /**
  9459. * Creates an alpha texture from some data.
  9460. * @param data Define the texture data
  9461. * @param width Define the width of the texture
  9462. * @param height Define the height of the texture
  9463. * @param scene Define the scene the texture belongs to
  9464. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9465. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9466. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9467. * @returns the alpha texture
  9468. */
  9469. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9470. /**
  9471. * Creates a RGB texture from some data.
  9472. * @param data Define the texture data
  9473. * @param width Define the width of the texture
  9474. * @param height Define the height of the texture
  9475. * @param scene Define the scene the texture belongs to
  9476. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9477. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9478. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9479. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9480. * @returns the RGB alpha texture
  9481. */
  9482. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9483. /**
  9484. * Creates a RGBA texture from some data.
  9485. * @param data Define the texture data
  9486. * @param width Define the width of the texture
  9487. * @param height Define the height of the texture
  9488. * @param scene Define the scene the texture belongs to
  9489. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9490. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9491. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9492. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9493. * @returns the RGBA texture
  9494. */
  9495. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9496. /**
  9497. * Creates a R texture from some data.
  9498. * @param data Define the texture data
  9499. * @param width Define the width of the texture
  9500. * @param height Define the height of the texture
  9501. * @param scene Define the scene the texture belongs to
  9502. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9503. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9504. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9505. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9506. * @returns the R texture
  9507. */
  9508. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9509. }
  9510. }
  9511. declare module BABYLON {
  9512. /**
  9513. * Defines a runtime animation
  9514. */
  9515. export class RuntimeAnimation {
  9516. private _events;
  9517. /**
  9518. * The current frame of the runtime animation
  9519. */
  9520. private _currentFrame;
  9521. /**
  9522. * The animation used by the runtime animation
  9523. */
  9524. private _animation;
  9525. /**
  9526. * The target of the runtime animation
  9527. */
  9528. private _target;
  9529. /**
  9530. * The initiating animatable
  9531. */
  9532. private _host;
  9533. /**
  9534. * The original value of the runtime animation
  9535. */
  9536. private _originalValue;
  9537. /**
  9538. * The original blend value of the runtime animation
  9539. */
  9540. private _originalBlendValue;
  9541. /**
  9542. * The offsets cache of the runtime animation
  9543. */
  9544. private _offsetsCache;
  9545. /**
  9546. * The high limits cache of the runtime animation
  9547. */
  9548. private _highLimitsCache;
  9549. /**
  9550. * Specifies if the runtime animation has been stopped
  9551. */
  9552. private _stopped;
  9553. /**
  9554. * The blending factor of the runtime animation
  9555. */
  9556. private _blendingFactor;
  9557. /**
  9558. * The BabylonJS scene
  9559. */
  9560. private _scene;
  9561. /**
  9562. * The current value of the runtime animation
  9563. */
  9564. private _currentValue;
  9565. /** @hidden */
  9566. _animationState: _IAnimationState;
  9567. /**
  9568. * The active target of the runtime animation
  9569. */
  9570. private _activeTargets;
  9571. private _currentActiveTarget;
  9572. private _directTarget;
  9573. /**
  9574. * The target path of the runtime animation
  9575. */
  9576. private _targetPath;
  9577. /**
  9578. * The weight of the runtime animation
  9579. */
  9580. private _weight;
  9581. /**
  9582. * The ratio offset of the runtime animation
  9583. */
  9584. private _ratioOffset;
  9585. /**
  9586. * The previous delay of the runtime animation
  9587. */
  9588. private _previousDelay;
  9589. /**
  9590. * The previous ratio of the runtime animation
  9591. */
  9592. private _previousRatio;
  9593. private _enableBlending;
  9594. private _keys;
  9595. private _minFrame;
  9596. private _maxFrame;
  9597. private _minValue;
  9598. private _maxValue;
  9599. private _targetIsArray;
  9600. /**
  9601. * Gets the current frame of the runtime animation
  9602. */
  9603. readonly currentFrame: number;
  9604. /**
  9605. * Gets the weight of the runtime animation
  9606. */
  9607. readonly weight: number;
  9608. /**
  9609. * Gets the current value of the runtime animation
  9610. */
  9611. readonly currentValue: any;
  9612. /**
  9613. * Gets the target path of the runtime animation
  9614. */
  9615. readonly targetPath: string;
  9616. /**
  9617. * Gets the actual target of the runtime animation
  9618. */
  9619. readonly target: any;
  9620. /** @hidden */
  9621. _onLoop: () => void;
  9622. /**
  9623. * Create a new RuntimeAnimation object
  9624. * @param target defines the target of the animation
  9625. * @param animation defines the source animation object
  9626. * @param scene defines the hosting scene
  9627. * @param host defines the initiating Animatable
  9628. */
  9629. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  9630. private _preparePath;
  9631. /**
  9632. * Gets the animation from the runtime animation
  9633. */
  9634. readonly animation: Animation;
  9635. /**
  9636. * Resets the runtime animation to the beginning
  9637. * @param restoreOriginal defines whether to restore the target property to the original value
  9638. */
  9639. reset(restoreOriginal?: boolean): void;
  9640. /**
  9641. * Specifies if the runtime animation is stopped
  9642. * @returns Boolean specifying if the runtime animation is stopped
  9643. */
  9644. isStopped(): boolean;
  9645. /**
  9646. * Disposes of the runtime animation
  9647. */
  9648. dispose(): void;
  9649. /**
  9650. * Apply the interpolated value to the target
  9651. * @param currentValue defines the value computed by the animation
  9652. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  9653. */
  9654. setValue(currentValue: any, weight: number): void;
  9655. private _getOriginalValues;
  9656. private _setValue;
  9657. /**
  9658. * Gets the loop pmode of the runtime animation
  9659. * @returns Loop Mode
  9660. */
  9661. private _getCorrectLoopMode;
  9662. /**
  9663. * Move the current animation to a given frame
  9664. * @param frame defines the frame to move to
  9665. */
  9666. goToFrame(frame: number): void;
  9667. /**
  9668. * @hidden Internal use only
  9669. */
  9670. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  9671. /**
  9672. * Execute the current animation
  9673. * @param delay defines the delay to add to the current frame
  9674. * @param from defines the lower bound of the animation range
  9675. * @param to defines the upper bound of the animation range
  9676. * @param loop defines if the current animation must loop
  9677. * @param speedRatio defines the current speed ratio
  9678. * @param weight defines the weight of the animation (default is -1 so no weight)
  9679. * @param onLoop optional callback called when animation loops
  9680. * @returns a boolean indicating if the animation is running
  9681. */
  9682. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  9683. }
  9684. }
  9685. declare module BABYLON {
  9686. /**
  9687. * Class used to store an actual running animation
  9688. */
  9689. export class Animatable {
  9690. /** defines the target object */
  9691. target: any;
  9692. /** defines the starting frame number (default is 0) */
  9693. fromFrame: number;
  9694. /** defines the ending frame number (default is 100) */
  9695. toFrame: number;
  9696. /** defines if the animation must loop (default is false) */
  9697. loopAnimation: boolean;
  9698. /** defines a callback to call when animation ends if it is not looping */
  9699. onAnimationEnd?: (() => void) | null | undefined;
  9700. /** defines a callback to call when animation loops */
  9701. onAnimationLoop?: (() => void) | null | undefined;
  9702. private _localDelayOffset;
  9703. private _pausedDelay;
  9704. private _runtimeAnimations;
  9705. private _paused;
  9706. private _scene;
  9707. private _speedRatio;
  9708. private _weight;
  9709. private _syncRoot;
  9710. /**
  9711. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  9712. * This will only apply for non looping animation (default is true)
  9713. */
  9714. disposeOnEnd: boolean;
  9715. /**
  9716. * Gets a boolean indicating if the animation has started
  9717. */
  9718. animationStarted: boolean;
  9719. /**
  9720. * Observer raised when the animation ends
  9721. */
  9722. onAnimationEndObservable: Observable<Animatable>;
  9723. /**
  9724. * Observer raised when the animation loops
  9725. */
  9726. onAnimationLoopObservable: Observable<Animatable>;
  9727. /**
  9728. * Gets the root Animatable used to synchronize and normalize animations
  9729. */
  9730. readonly syncRoot: Nullable<Animatable>;
  9731. /**
  9732. * Gets the current frame of the first RuntimeAnimation
  9733. * Used to synchronize Animatables
  9734. */
  9735. readonly masterFrame: number;
  9736. /**
  9737. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  9738. */
  9739. weight: number;
  9740. /**
  9741. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  9742. */
  9743. speedRatio: number;
  9744. /**
  9745. * Creates a new Animatable
  9746. * @param scene defines the hosting scene
  9747. * @param target defines the target object
  9748. * @param fromFrame defines the starting frame number (default is 0)
  9749. * @param toFrame defines the ending frame number (default is 100)
  9750. * @param loopAnimation defines if the animation must loop (default is false)
  9751. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  9752. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  9753. * @param animations defines a group of animation to add to the new Animatable
  9754. * @param onAnimationLoop defines a callback to call when animation loops
  9755. */
  9756. constructor(scene: Scene,
  9757. /** defines the target object */
  9758. target: any,
  9759. /** defines the starting frame number (default is 0) */
  9760. fromFrame?: number,
  9761. /** defines the ending frame number (default is 100) */
  9762. toFrame?: number,
  9763. /** defines if the animation must loop (default is false) */
  9764. loopAnimation?: boolean, speedRatio?: number,
  9765. /** defines a callback to call when animation ends if it is not looping */
  9766. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  9767. /** defines a callback to call when animation loops */
  9768. onAnimationLoop?: (() => void) | null | undefined);
  9769. /**
  9770. * Synchronize and normalize current Animatable with a source Animatable
  9771. * This is useful when using animation weights and when animations are not of the same length
  9772. * @param root defines the root Animatable to synchronize with
  9773. * @returns the current Animatable
  9774. */
  9775. syncWith(root: Animatable): Animatable;
  9776. /**
  9777. * Gets the list of runtime animations
  9778. * @returns an array of RuntimeAnimation
  9779. */
  9780. getAnimations(): RuntimeAnimation[];
  9781. /**
  9782. * Adds more animations to the current animatable
  9783. * @param target defines the target of the animations
  9784. * @param animations defines the new animations to add
  9785. */
  9786. appendAnimations(target: any, animations: Animation[]): void;
  9787. /**
  9788. * Gets the source animation for a specific property
  9789. * @param property defines the propertyu to look for
  9790. * @returns null or the source animation for the given property
  9791. */
  9792. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  9793. /**
  9794. * Gets the runtime animation for a specific property
  9795. * @param property defines the propertyu to look for
  9796. * @returns null or the runtime animation for the given property
  9797. */
  9798. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  9799. /**
  9800. * Resets the animatable to its original state
  9801. */
  9802. reset(): void;
  9803. /**
  9804. * Allows the animatable to blend with current running animations
  9805. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9806. * @param blendingSpeed defines the blending speed to use
  9807. */
  9808. enableBlending(blendingSpeed: number): void;
  9809. /**
  9810. * Disable animation blending
  9811. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9812. */
  9813. disableBlending(): void;
  9814. /**
  9815. * Jump directly to a given frame
  9816. * @param frame defines the frame to jump to
  9817. */
  9818. goToFrame(frame: number): void;
  9819. /**
  9820. * Pause the animation
  9821. */
  9822. pause(): void;
  9823. /**
  9824. * Restart the animation
  9825. */
  9826. restart(): void;
  9827. private _raiseOnAnimationEnd;
  9828. /**
  9829. * Stop and delete the current animation
  9830. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  9831. * @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)
  9832. */
  9833. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  9834. /**
  9835. * Wait asynchronously for the animation to end
  9836. * @returns a promise which will be fullfilled when the animation ends
  9837. */
  9838. waitAsync(): Promise<Animatable>;
  9839. /** @hidden */
  9840. _animate(delay: number): boolean;
  9841. }
  9842. interface Scene {
  9843. /** @hidden */
  9844. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  9845. /** @hidden */
  9846. _processLateAnimationBindingsForMatrices(holder: {
  9847. totalWeight: number;
  9848. animations: RuntimeAnimation[];
  9849. originalValue: Matrix;
  9850. }): any;
  9851. /** @hidden */
  9852. _processLateAnimationBindingsForQuaternions(holder: {
  9853. totalWeight: number;
  9854. animations: RuntimeAnimation[];
  9855. originalValue: Quaternion;
  9856. }, refQuaternion: Quaternion): Quaternion;
  9857. /** @hidden */
  9858. _processLateAnimationBindings(): void;
  9859. /**
  9860. * Will start the animation sequence of a given target
  9861. * @param target defines the target
  9862. * @param from defines from which frame should animation start
  9863. * @param to defines until which frame should animation run.
  9864. * @param weight defines the weight to apply to the animation (1.0 by default)
  9865. * @param loop defines if the animation loops
  9866. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9867. * @param onAnimationEnd defines the function to be executed when the animation ends
  9868. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9869. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9870. * @param onAnimationLoop defines the callback to call when an animation loops
  9871. * @returns the animatable object created for this animation
  9872. */
  9873. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9874. /**
  9875. * Will start the animation sequence of a given target
  9876. * @param target defines the target
  9877. * @param from defines from which frame should animation start
  9878. * @param to defines until which frame should animation run.
  9879. * @param loop defines if the animation loops
  9880. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9881. * @param onAnimationEnd defines the function to be executed when the animation ends
  9882. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9883. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9884. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  9885. * @param onAnimationLoop defines the callback to call when an animation loops
  9886. * @returns the animatable object created for this animation
  9887. */
  9888. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9889. /**
  9890. * Will start the animation sequence of a given target and its hierarchy
  9891. * @param target defines the target
  9892. * @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.
  9893. * @param from defines from which frame should animation start
  9894. * @param to defines until which frame should animation run.
  9895. * @param loop defines if the animation loops
  9896. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9897. * @param onAnimationEnd defines the function to be executed when the animation ends
  9898. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9899. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9900. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9901. * @param onAnimationLoop defines the callback to call when an animation loops
  9902. * @returns the list of created animatables
  9903. */
  9904. 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[];
  9905. /**
  9906. * Begin a new animation on a given node
  9907. * @param target defines the target where the animation will take place
  9908. * @param animations defines the list of animations to start
  9909. * @param from defines the initial value
  9910. * @param to defines the final value
  9911. * @param loop defines if you want animation to loop (off by default)
  9912. * @param speedRatio defines the speed ratio to apply to all animations
  9913. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  9914. * @param onAnimationLoop defines the callback to call when an animation loops
  9915. * @returns the list of created animatables
  9916. */
  9917. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  9918. /**
  9919. * Begin a new animation on a given node and its hierarchy
  9920. * @param target defines the root node where the animation will take place
  9921. * @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.
  9922. * @param animations defines the list of animations to start
  9923. * @param from defines the initial value
  9924. * @param to defines the final value
  9925. * @param loop defines if you want animation to loop (off by default)
  9926. * @param speedRatio defines the speed ratio to apply to all animations
  9927. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  9928. * @param onAnimationLoop defines the callback to call when an animation loops
  9929. * @returns the list of animatables created for all nodes
  9930. */
  9931. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  9932. /**
  9933. * Gets the animatable associated with a specific target
  9934. * @param target defines the target of the animatable
  9935. * @returns the required animatable if found
  9936. */
  9937. getAnimatableByTarget(target: any): Nullable<Animatable>;
  9938. /**
  9939. * Gets all animatables associated with a given target
  9940. * @param target defines the target to look animatables for
  9941. * @returns an array of Animatables
  9942. */
  9943. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  9944. /**
  9945. * Stops and removes all animations that have been applied to the scene
  9946. */
  9947. stopAllAnimations(): void;
  9948. }
  9949. interface Bone {
  9950. /**
  9951. * Copy an animation range from another bone
  9952. * @param source defines the source bone
  9953. * @param rangeName defines the range name to copy
  9954. * @param frameOffset defines the frame offset
  9955. * @param rescaleAsRequired defines if rescaling must be applied if required
  9956. * @param skelDimensionsRatio defines the scaling ratio
  9957. * @returns true if operation was successful
  9958. */
  9959. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  9960. }
  9961. }
  9962. declare module BABYLON {
  9963. /**
  9964. * Class used to handle skinning animations
  9965. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9966. */
  9967. export class Skeleton implements IAnimatable {
  9968. /** defines the skeleton name */
  9969. name: string;
  9970. /** defines the skeleton Id */
  9971. id: string;
  9972. /**
  9973. * Defines the list of child bones
  9974. */
  9975. bones: Bone[];
  9976. /**
  9977. * Defines an estimate of the dimension of the skeleton at rest
  9978. */
  9979. dimensionsAtRest: Vector3;
  9980. /**
  9981. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  9982. */
  9983. needInitialSkinMatrix: boolean;
  9984. /**
  9985. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  9986. */
  9987. overrideMesh: Nullable<AbstractMesh>;
  9988. /**
  9989. * Gets the list of animations attached to this skeleton
  9990. */
  9991. animations: Array<Animation>;
  9992. private _scene;
  9993. private _isDirty;
  9994. private _transformMatrices;
  9995. private _transformMatrixTexture;
  9996. private _meshesWithPoseMatrix;
  9997. private _animatables;
  9998. private _identity;
  9999. private _synchronizedWithMesh;
  10000. private _ranges;
  10001. private _lastAbsoluteTransformsUpdateId;
  10002. private _canUseTextureForBones;
  10003. private _uniqueId;
  10004. /** @hidden */
  10005. _numBonesWithLinkedTransformNode: number;
  10006. /** @hidden */
  10007. _hasWaitingData: Nullable<boolean>;
  10008. /**
  10009. * Specifies if the skeleton should be serialized
  10010. */
  10011. doNotSerialize: boolean;
  10012. private _useTextureToStoreBoneMatrices;
  10013. /**
  10014. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  10015. * Please note that this option is not available if the hardware does not support it
  10016. */
  10017. useTextureToStoreBoneMatrices: boolean;
  10018. private _animationPropertiesOverride;
  10019. /**
  10020. * Gets or sets the animation properties override
  10021. */
  10022. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10023. /**
  10024. * List of inspectable custom properties (used by the Inspector)
  10025. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  10026. */
  10027. inspectableCustomProperties: IInspectable[];
  10028. /**
  10029. * An observable triggered before computing the skeleton's matrices
  10030. */
  10031. onBeforeComputeObservable: Observable<Skeleton>;
  10032. /**
  10033. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  10034. */
  10035. readonly isUsingTextureForMatrices: boolean;
  10036. /**
  10037. * Gets the unique ID of this skeleton
  10038. */
  10039. readonly uniqueId: number;
  10040. /**
  10041. * Creates a new skeleton
  10042. * @param name defines the skeleton name
  10043. * @param id defines the skeleton Id
  10044. * @param scene defines the hosting scene
  10045. */
  10046. constructor(
  10047. /** defines the skeleton name */
  10048. name: string,
  10049. /** defines the skeleton Id */
  10050. id: string, scene: Scene);
  10051. /**
  10052. * Gets the current object class name.
  10053. * @return the class name
  10054. */
  10055. getClassName(): string;
  10056. /**
  10057. * Returns an array containing the root bones
  10058. * @returns an array containing the root bones
  10059. */
  10060. getChildren(): Array<Bone>;
  10061. /**
  10062. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  10063. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10064. * @returns a Float32Array containing matrices data
  10065. */
  10066. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  10067. /**
  10068. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  10069. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10070. * @returns a raw texture containing the data
  10071. */
  10072. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  10073. /**
  10074. * Gets the current hosting scene
  10075. * @returns a scene object
  10076. */
  10077. getScene(): Scene;
  10078. /**
  10079. * Gets a string representing the current skeleton data
  10080. * @param fullDetails defines a boolean indicating if we want a verbose version
  10081. * @returns a string representing the current skeleton data
  10082. */
  10083. toString(fullDetails?: boolean): string;
  10084. /**
  10085. * Get bone's index searching by name
  10086. * @param name defines bone's name to search for
  10087. * @return the indice of the bone. Returns -1 if not found
  10088. */
  10089. getBoneIndexByName(name: string): number;
  10090. /**
  10091. * Creater a new animation range
  10092. * @param name defines the name of the range
  10093. * @param from defines the start key
  10094. * @param to defines the end key
  10095. */
  10096. createAnimationRange(name: string, from: number, to: number): void;
  10097. /**
  10098. * Delete a specific animation range
  10099. * @param name defines the name of the range
  10100. * @param deleteFrames defines if frames must be removed as well
  10101. */
  10102. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  10103. /**
  10104. * Gets a specific animation range
  10105. * @param name defines the name of the range to look for
  10106. * @returns the requested animation range or null if not found
  10107. */
  10108. getAnimationRange(name: string): Nullable<AnimationRange>;
  10109. /**
  10110. * Gets the list of all animation ranges defined on this skeleton
  10111. * @returns an array
  10112. */
  10113. getAnimationRanges(): Nullable<AnimationRange>[];
  10114. /**
  10115. * Copy animation range from a source skeleton.
  10116. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  10117. * @param source defines the source skeleton
  10118. * @param name defines the name of the range to copy
  10119. * @param rescaleAsRequired defines if rescaling must be applied if required
  10120. * @returns true if operation was successful
  10121. */
  10122. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  10123. /**
  10124. * Forces the skeleton to go to rest pose
  10125. */
  10126. returnToRest(): void;
  10127. private _getHighestAnimationFrame;
  10128. /**
  10129. * Begin a specific animation range
  10130. * @param name defines the name of the range to start
  10131. * @param loop defines if looping must be turned on (false by default)
  10132. * @param speedRatio defines the speed ratio to apply (1 by default)
  10133. * @param onAnimationEnd defines a callback which will be called when animation will end
  10134. * @returns a new animatable
  10135. */
  10136. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  10137. /** @hidden */
  10138. _markAsDirty(): void;
  10139. /** @hidden */
  10140. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10141. /** @hidden */
  10142. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10143. private _computeTransformMatrices;
  10144. /**
  10145. * Build all resources required to render a skeleton
  10146. */
  10147. prepare(): void;
  10148. /**
  10149. * Gets the list of animatables currently running for this skeleton
  10150. * @returns an array of animatables
  10151. */
  10152. getAnimatables(): IAnimatable[];
  10153. /**
  10154. * Clone the current skeleton
  10155. * @param name defines the name of the new skeleton
  10156. * @param id defines the id of the new skeleton
  10157. * @returns the new skeleton
  10158. */
  10159. clone(name: string, id: string): Skeleton;
  10160. /**
  10161. * Enable animation blending for this skeleton
  10162. * @param blendingSpeed defines the blending speed to apply
  10163. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  10164. */
  10165. enableBlending(blendingSpeed?: number): void;
  10166. /**
  10167. * Releases all resources associated with the current skeleton
  10168. */
  10169. dispose(): void;
  10170. /**
  10171. * Serialize the skeleton in a JSON object
  10172. * @returns a JSON object
  10173. */
  10174. serialize(): any;
  10175. /**
  10176. * Creates a new skeleton from serialized data
  10177. * @param parsedSkeleton defines the serialized data
  10178. * @param scene defines the hosting scene
  10179. * @returns a new skeleton
  10180. */
  10181. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  10182. /**
  10183. * Compute all node absolute transforms
  10184. * @param forceUpdate defines if computation must be done even if cache is up to date
  10185. */
  10186. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  10187. /**
  10188. * Gets the root pose matrix
  10189. * @returns a matrix
  10190. */
  10191. getPoseMatrix(): Nullable<Matrix>;
  10192. /**
  10193. * Sorts bones per internal index
  10194. */
  10195. sortBones(): void;
  10196. private _sortBones;
  10197. }
  10198. }
  10199. declare module BABYLON {
  10200. /**
  10201. * Defines a target to use with MorphTargetManager
  10202. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10203. */
  10204. export class MorphTarget implements IAnimatable {
  10205. /** defines the name of the target */
  10206. name: string;
  10207. /**
  10208. * Gets or sets the list of animations
  10209. */
  10210. animations: Animation[];
  10211. private _scene;
  10212. private _positions;
  10213. private _normals;
  10214. private _tangents;
  10215. private _uvs;
  10216. private _influence;
  10217. /**
  10218. * Observable raised when the influence changes
  10219. */
  10220. onInfluenceChanged: Observable<boolean>;
  10221. /** @hidden */
  10222. _onDataLayoutChanged: Observable<void>;
  10223. /**
  10224. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  10225. */
  10226. influence: number;
  10227. /**
  10228. * Gets or sets the id of the morph Target
  10229. */
  10230. id: string;
  10231. private _animationPropertiesOverride;
  10232. /**
  10233. * Gets or sets the animation properties override
  10234. */
  10235. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10236. /**
  10237. * Creates a new MorphTarget
  10238. * @param name defines the name of the target
  10239. * @param influence defines the influence to use
  10240. * @param scene defines the scene the morphtarget belongs to
  10241. */
  10242. constructor(
  10243. /** defines the name of the target */
  10244. name: string, influence?: number, scene?: Nullable<Scene>);
  10245. /**
  10246. * Gets a boolean defining if the target contains position data
  10247. */
  10248. readonly hasPositions: boolean;
  10249. /**
  10250. * Gets a boolean defining if the target contains normal data
  10251. */
  10252. readonly hasNormals: boolean;
  10253. /**
  10254. * Gets a boolean defining if the target contains tangent data
  10255. */
  10256. readonly hasTangents: boolean;
  10257. /**
  10258. * Gets a boolean defining if the target contains texture coordinates data
  10259. */
  10260. readonly hasUVs: boolean;
  10261. /**
  10262. * Affects position data to this target
  10263. * @param data defines the position data to use
  10264. */
  10265. setPositions(data: Nullable<FloatArray>): void;
  10266. /**
  10267. * Gets the position data stored in this target
  10268. * @returns a FloatArray containing the position data (or null if not present)
  10269. */
  10270. getPositions(): Nullable<FloatArray>;
  10271. /**
  10272. * Affects normal data to this target
  10273. * @param data defines the normal data to use
  10274. */
  10275. setNormals(data: Nullable<FloatArray>): void;
  10276. /**
  10277. * Gets the normal data stored in this target
  10278. * @returns a FloatArray containing the normal data (or null if not present)
  10279. */
  10280. getNormals(): Nullable<FloatArray>;
  10281. /**
  10282. * Affects tangent data to this target
  10283. * @param data defines the tangent data to use
  10284. */
  10285. setTangents(data: Nullable<FloatArray>): void;
  10286. /**
  10287. * Gets the tangent data stored in this target
  10288. * @returns a FloatArray containing the tangent data (or null if not present)
  10289. */
  10290. getTangents(): Nullable<FloatArray>;
  10291. /**
  10292. * Affects texture coordinates data to this target
  10293. * @param data defines the texture coordinates data to use
  10294. */
  10295. setUVs(data: Nullable<FloatArray>): void;
  10296. /**
  10297. * Gets the texture coordinates data stored in this target
  10298. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  10299. */
  10300. getUVs(): Nullable<FloatArray>;
  10301. /**
  10302. * Serializes the current target into a Serialization object
  10303. * @returns the serialized object
  10304. */
  10305. serialize(): any;
  10306. /**
  10307. * Returns the string "MorphTarget"
  10308. * @returns "MorphTarget"
  10309. */
  10310. getClassName(): string;
  10311. /**
  10312. * Creates a new target from serialized data
  10313. * @param serializationObject defines the serialized data to use
  10314. * @returns a new MorphTarget
  10315. */
  10316. static Parse(serializationObject: any): MorphTarget;
  10317. /**
  10318. * Creates a MorphTarget from mesh data
  10319. * @param mesh defines the source mesh
  10320. * @param name defines the name to use for the new target
  10321. * @param influence defines the influence to attach to the target
  10322. * @returns a new MorphTarget
  10323. */
  10324. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  10325. }
  10326. }
  10327. declare module BABYLON {
  10328. /**
  10329. * This class is used to deform meshes using morphing between different targets
  10330. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10331. */
  10332. export class MorphTargetManager {
  10333. private _targets;
  10334. private _targetInfluenceChangedObservers;
  10335. private _targetDataLayoutChangedObservers;
  10336. private _activeTargets;
  10337. private _scene;
  10338. private _influences;
  10339. private _supportsNormals;
  10340. private _supportsTangents;
  10341. private _supportsUVs;
  10342. private _vertexCount;
  10343. private _uniqueId;
  10344. private _tempInfluences;
  10345. /**
  10346. * Gets or sets a boolean indicating if normals must be morphed
  10347. */
  10348. enableNormalMorphing: boolean;
  10349. /**
  10350. * Gets or sets a boolean indicating if tangents must be morphed
  10351. */
  10352. enableTangentMorphing: boolean;
  10353. /**
  10354. * Gets or sets a boolean indicating if UV must be morphed
  10355. */
  10356. enableUVMorphing: boolean;
  10357. /**
  10358. * Creates a new MorphTargetManager
  10359. * @param scene defines the current scene
  10360. */
  10361. constructor(scene?: Nullable<Scene>);
  10362. /**
  10363. * Gets the unique ID of this manager
  10364. */
  10365. readonly uniqueId: number;
  10366. /**
  10367. * Gets the number of vertices handled by this manager
  10368. */
  10369. readonly vertexCount: number;
  10370. /**
  10371. * Gets a boolean indicating if this manager supports morphing of normals
  10372. */
  10373. readonly supportsNormals: boolean;
  10374. /**
  10375. * Gets a boolean indicating if this manager supports morphing of tangents
  10376. */
  10377. readonly supportsTangents: boolean;
  10378. /**
  10379. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  10380. */
  10381. readonly supportsUVs: boolean;
  10382. /**
  10383. * Gets the number of targets stored in this manager
  10384. */
  10385. readonly numTargets: number;
  10386. /**
  10387. * Gets the number of influencers (ie. the number of targets with influences > 0)
  10388. */
  10389. readonly numInfluencers: number;
  10390. /**
  10391. * Gets the list of influences (one per target)
  10392. */
  10393. readonly influences: Float32Array;
  10394. /**
  10395. * Gets the active target at specified index. An active target is a target with an influence > 0
  10396. * @param index defines the index to check
  10397. * @returns the requested target
  10398. */
  10399. getActiveTarget(index: number): MorphTarget;
  10400. /**
  10401. * Gets the target at specified index
  10402. * @param index defines the index to check
  10403. * @returns the requested target
  10404. */
  10405. getTarget(index: number): MorphTarget;
  10406. /**
  10407. * Add a new target to this manager
  10408. * @param target defines the target to add
  10409. */
  10410. addTarget(target: MorphTarget): void;
  10411. /**
  10412. * Removes a target from the manager
  10413. * @param target defines the target to remove
  10414. */
  10415. removeTarget(target: MorphTarget): void;
  10416. /**
  10417. * Serializes the current manager into a Serialization object
  10418. * @returns the serialized object
  10419. */
  10420. serialize(): any;
  10421. private _syncActiveTargets;
  10422. /**
  10423. * Syncrhonize the targets with all the meshes using this morph target manager
  10424. */
  10425. synchronize(): void;
  10426. /**
  10427. * Creates a new MorphTargetManager from serialized data
  10428. * @param serializationObject defines the serialized data
  10429. * @param scene defines the hosting scene
  10430. * @returns the new MorphTargetManager
  10431. */
  10432. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  10433. }
  10434. }
  10435. declare module BABYLON {
  10436. /**
  10437. * Groups all the scene component constants in one place to ease maintenance.
  10438. * @hidden
  10439. */
  10440. export class SceneComponentConstants {
  10441. static readonly NAME_EFFECTLAYER: string;
  10442. static readonly NAME_LAYER: string;
  10443. static readonly NAME_LENSFLARESYSTEM: string;
  10444. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10445. static readonly NAME_PARTICLESYSTEM: string;
  10446. static readonly NAME_GAMEPAD: string;
  10447. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10448. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10449. static readonly NAME_DEPTHRENDERER: string;
  10450. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10451. static readonly NAME_SPRITE: string;
  10452. static readonly NAME_OUTLINERENDERER: string;
  10453. static readonly NAME_PROCEDURALTEXTURE: string;
  10454. static readonly NAME_SHADOWGENERATOR: string;
  10455. static readonly NAME_OCTREE: string;
  10456. static readonly NAME_PHYSICSENGINE: string;
  10457. static readonly NAME_AUDIO: string;
  10458. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10459. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10460. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10461. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10462. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10463. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10464. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10465. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10466. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10467. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10468. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10469. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10470. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10471. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10472. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10473. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10474. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10475. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10476. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10477. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10478. static readonly STEP_AFTERRENDER_AUDIO: number;
  10479. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10480. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10481. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10482. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10483. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10484. static readonly STEP_POINTERMOVE_SPRITE: number;
  10485. static readonly STEP_POINTERDOWN_SPRITE: number;
  10486. static readonly STEP_POINTERUP_SPRITE: number;
  10487. }
  10488. /**
  10489. * This represents a scene component.
  10490. *
  10491. * This is used to decouple the dependency the scene is having on the different workloads like
  10492. * layers, post processes...
  10493. */
  10494. export interface ISceneComponent {
  10495. /**
  10496. * The name of the component. Each component must have a unique name.
  10497. */
  10498. name: string;
  10499. /**
  10500. * The scene the component belongs to.
  10501. */
  10502. scene: Scene;
  10503. /**
  10504. * Register the component to one instance of a scene.
  10505. */
  10506. register(): void;
  10507. /**
  10508. * Rebuilds the elements related to this component in case of
  10509. * context lost for instance.
  10510. */
  10511. rebuild(): void;
  10512. /**
  10513. * Disposes the component and the associated ressources.
  10514. */
  10515. dispose(): void;
  10516. }
  10517. /**
  10518. * This represents a SERIALIZABLE scene component.
  10519. *
  10520. * This extends Scene Component to add Serialization methods on top.
  10521. */
  10522. export interface ISceneSerializableComponent extends ISceneComponent {
  10523. /**
  10524. * Adds all the elements from the container to the scene
  10525. * @param container the container holding the elements
  10526. */
  10527. addFromContainer(container: AbstractScene): void;
  10528. /**
  10529. * Removes all the elements in the container from the scene
  10530. * @param container contains the elements to remove
  10531. * @param dispose if the removed element should be disposed (default: false)
  10532. */
  10533. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10534. /**
  10535. * Serializes the component data to the specified json object
  10536. * @param serializationObject The object to serialize to
  10537. */
  10538. serialize(serializationObject: any): void;
  10539. }
  10540. /**
  10541. * Strong typing of a Mesh related stage step action
  10542. */
  10543. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10544. /**
  10545. * Strong typing of a Evaluate Sub Mesh related stage step action
  10546. */
  10547. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10548. /**
  10549. * Strong typing of a Active Mesh related stage step action
  10550. */
  10551. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10552. /**
  10553. * Strong typing of a Camera related stage step action
  10554. */
  10555. export type CameraStageAction = (camera: Camera) => void;
  10556. /**
  10557. * Strong typing of a Camera Frame buffer related stage step action
  10558. */
  10559. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10560. /**
  10561. * Strong typing of a Render Target related stage step action
  10562. */
  10563. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10564. /**
  10565. * Strong typing of a RenderingGroup related stage step action
  10566. */
  10567. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10568. /**
  10569. * Strong typing of a Mesh Render related stage step action
  10570. */
  10571. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10572. /**
  10573. * Strong typing of a simple stage step action
  10574. */
  10575. export type SimpleStageAction = () => void;
  10576. /**
  10577. * Strong typing of a render target action.
  10578. */
  10579. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10580. /**
  10581. * Strong typing of a pointer move action.
  10582. */
  10583. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  10584. /**
  10585. * Strong typing of a pointer up/down action.
  10586. */
  10587. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10588. /**
  10589. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  10590. * @hidden
  10591. */
  10592. export class Stage<T extends Function> extends Array<{
  10593. index: number;
  10594. component: ISceneComponent;
  10595. action: T;
  10596. }> {
  10597. /**
  10598. * Hide ctor from the rest of the world.
  10599. * @param items The items to add.
  10600. */
  10601. private constructor();
  10602. /**
  10603. * Creates a new Stage.
  10604. * @returns A new instance of a Stage
  10605. */
  10606. static Create<T extends Function>(): Stage<T>;
  10607. /**
  10608. * Registers a step in an ordered way in the targeted stage.
  10609. * @param index Defines the position to register the step in
  10610. * @param component Defines the component attached to the step
  10611. * @param action Defines the action to launch during the step
  10612. */
  10613. registerStep(index: number, component: ISceneComponent, action: T): void;
  10614. /**
  10615. * Clears all the steps from the stage.
  10616. */
  10617. clear(): void;
  10618. }
  10619. }
  10620. declare module BABYLON {
  10621. /**
  10622. * Class used to represent a specific level of detail of a mesh
  10623. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  10624. */
  10625. export class MeshLODLevel {
  10626. /** Defines the distance where this level should star being displayed */
  10627. distance: number;
  10628. /** Defines the mesh to use to render this level */
  10629. mesh: Nullable<Mesh>;
  10630. /**
  10631. * Creates a new LOD level
  10632. * @param distance defines the distance where this level should star being displayed
  10633. * @param mesh defines the mesh to use to render this level
  10634. */
  10635. constructor(
  10636. /** Defines the distance where this level should star being displayed */
  10637. distance: number,
  10638. /** Defines the mesh to use to render this level */
  10639. mesh: Nullable<Mesh>);
  10640. }
  10641. }
  10642. declare module BABYLON {
  10643. /**
  10644. * Interface describing all the common properties and methods a shadow light needs to implement.
  10645. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10646. * as well as binding the different shadow properties to the effects.
  10647. */
  10648. export interface IShadowLight extends Light {
  10649. /**
  10650. * The light id in the scene (used in scene.findLighById for instance)
  10651. */
  10652. id: string;
  10653. /**
  10654. * The position the shdow will be casted from.
  10655. */
  10656. position: Vector3;
  10657. /**
  10658. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10659. */
  10660. direction: Vector3;
  10661. /**
  10662. * The transformed position. Position of the light in world space taking parenting in account.
  10663. */
  10664. transformedPosition: Vector3;
  10665. /**
  10666. * The transformed direction. Direction of the light in world space taking parenting in account.
  10667. */
  10668. transformedDirection: Vector3;
  10669. /**
  10670. * The friendly name of the light in the scene.
  10671. */
  10672. name: string;
  10673. /**
  10674. * Defines the shadow projection clipping minimum z value.
  10675. */
  10676. shadowMinZ: number;
  10677. /**
  10678. * Defines the shadow projection clipping maximum z value.
  10679. */
  10680. shadowMaxZ: number;
  10681. /**
  10682. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10683. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10684. */
  10685. computeTransformedInformation(): boolean;
  10686. /**
  10687. * Gets the scene the light belongs to.
  10688. * @returns The scene
  10689. */
  10690. getScene(): Scene;
  10691. /**
  10692. * Callback defining a custom Projection Matrix Builder.
  10693. * This can be used to override the default projection matrix computation.
  10694. */
  10695. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10696. /**
  10697. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10698. * @param matrix The materix to updated with the projection information
  10699. * @param viewMatrix The transform matrix of the light
  10700. * @param renderList The list of mesh to render in the map
  10701. * @returns The current light
  10702. */
  10703. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10704. /**
  10705. * Gets the current depth scale used in ESM.
  10706. * @returns The scale
  10707. */
  10708. getDepthScale(): number;
  10709. /**
  10710. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10711. * @returns true if a cube texture needs to be use
  10712. */
  10713. needCube(): boolean;
  10714. /**
  10715. * Detects if the projection matrix requires to be recomputed this frame.
  10716. * @returns true if it requires to be recomputed otherwise, false.
  10717. */
  10718. needProjectionMatrixCompute(): boolean;
  10719. /**
  10720. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10721. */
  10722. forceProjectionMatrixCompute(): void;
  10723. /**
  10724. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10725. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10726. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10727. */
  10728. getShadowDirection(faceIndex?: number): Vector3;
  10729. /**
  10730. * Gets the minZ used for shadow according to both the scene and the light.
  10731. * @param activeCamera The camera we are returning the min for
  10732. * @returns the depth min z
  10733. */
  10734. getDepthMinZ(activeCamera: Camera): number;
  10735. /**
  10736. * Gets the maxZ used for shadow according to both the scene and the light.
  10737. * @param activeCamera The camera we are returning the max for
  10738. * @returns the depth max z
  10739. */
  10740. getDepthMaxZ(activeCamera: Camera): number;
  10741. }
  10742. /**
  10743. * Base implementation IShadowLight
  10744. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10745. */
  10746. export abstract class ShadowLight extends Light implements IShadowLight {
  10747. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10748. protected _position: Vector3;
  10749. protected _setPosition(value: Vector3): void;
  10750. /**
  10751. * Sets the position the shadow will be casted from. Also use as the light position for both
  10752. * point and spot lights.
  10753. */
  10754. /**
  10755. * Sets the position the shadow will be casted from. Also use as the light position for both
  10756. * point and spot lights.
  10757. */
  10758. position: Vector3;
  10759. protected _direction: Vector3;
  10760. protected _setDirection(value: Vector3): void;
  10761. /**
  10762. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10763. * Also use as the light direction on spot and directional lights.
  10764. */
  10765. /**
  10766. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10767. * Also use as the light direction on spot and directional lights.
  10768. */
  10769. direction: Vector3;
  10770. private _shadowMinZ;
  10771. /**
  10772. * Gets the shadow projection clipping minimum z value.
  10773. */
  10774. /**
  10775. * Sets the shadow projection clipping minimum z value.
  10776. */
  10777. shadowMinZ: number;
  10778. private _shadowMaxZ;
  10779. /**
  10780. * Sets the shadow projection clipping maximum z value.
  10781. */
  10782. /**
  10783. * Gets the shadow projection clipping maximum z value.
  10784. */
  10785. shadowMaxZ: number;
  10786. /**
  10787. * Callback defining a custom Projection Matrix Builder.
  10788. * This can be used to override the default projection matrix computation.
  10789. */
  10790. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10791. /**
  10792. * The transformed position. Position of the light in world space taking parenting in account.
  10793. */
  10794. transformedPosition: Vector3;
  10795. /**
  10796. * The transformed direction. Direction of the light in world space taking parenting in account.
  10797. */
  10798. transformedDirection: Vector3;
  10799. private _needProjectionMatrixCompute;
  10800. /**
  10801. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10802. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10803. */
  10804. computeTransformedInformation(): boolean;
  10805. /**
  10806. * Return the depth scale used for the shadow map.
  10807. * @returns the depth scale.
  10808. */
  10809. getDepthScale(): number;
  10810. /**
  10811. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10812. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10813. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10814. */
  10815. getShadowDirection(faceIndex?: number): Vector3;
  10816. /**
  10817. * Returns the ShadowLight absolute position in the World.
  10818. * @returns the position vector in world space
  10819. */
  10820. getAbsolutePosition(): Vector3;
  10821. /**
  10822. * Sets the ShadowLight direction toward the passed target.
  10823. * @param target The point to target in local space
  10824. * @returns the updated ShadowLight direction
  10825. */
  10826. setDirectionToTarget(target: Vector3): Vector3;
  10827. /**
  10828. * Returns the light rotation in euler definition.
  10829. * @returns the x y z rotation in local space.
  10830. */
  10831. getRotation(): Vector3;
  10832. /**
  10833. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10834. * @returns true if a cube texture needs to be use
  10835. */
  10836. needCube(): boolean;
  10837. /**
  10838. * Detects if the projection matrix requires to be recomputed this frame.
  10839. * @returns true if it requires to be recomputed otherwise, false.
  10840. */
  10841. needProjectionMatrixCompute(): boolean;
  10842. /**
  10843. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10844. */
  10845. forceProjectionMatrixCompute(): void;
  10846. /** @hidden */
  10847. _initCache(): void;
  10848. /** @hidden */
  10849. _isSynchronized(): boolean;
  10850. /**
  10851. * Computes the world matrix of the node
  10852. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10853. * @returns the world matrix
  10854. */
  10855. computeWorldMatrix(force?: boolean): Matrix;
  10856. /**
  10857. * Gets the minZ used for shadow according to both the scene and the light.
  10858. * @param activeCamera The camera we are returning the min for
  10859. * @returns the depth min z
  10860. */
  10861. getDepthMinZ(activeCamera: Camera): number;
  10862. /**
  10863. * Gets the maxZ used for shadow according to both the scene and the light.
  10864. * @param activeCamera The camera we are returning the max for
  10865. * @returns the depth max z
  10866. */
  10867. getDepthMaxZ(activeCamera: Camera): number;
  10868. /**
  10869. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10870. * @param matrix The materix to updated with the projection information
  10871. * @param viewMatrix The transform matrix of the light
  10872. * @param renderList The list of mesh to render in the map
  10873. * @returns The current light
  10874. */
  10875. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10876. }
  10877. }
  10878. declare module BABYLON {
  10879. /**
  10880. * "Static Class" containing the most commonly used helper while dealing with material for
  10881. * rendering purpose.
  10882. *
  10883. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  10884. *
  10885. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  10886. */
  10887. export class MaterialHelper {
  10888. /**
  10889. * Bind the current view position to an effect.
  10890. * @param effect The effect to be bound
  10891. * @param scene The scene the eyes position is used from
  10892. */
  10893. static BindEyePosition(effect: Effect, scene: Scene): void;
  10894. /**
  10895. * Helps preparing the defines values about the UVs in used in the effect.
  10896. * UVs are shared as much as we can accross channels in the shaders.
  10897. * @param texture The texture we are preparing the UVs for
  10898. * @param defines The defines to update
  10899. * @param key The channel key "diffuse", "specular"... used in the shader
  10900. */
  10901. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  10902. /**
  10903. * Binds a texture matrix value to its corrsponding uniform
  10904. * @param texture The texture to bind the matrix for
  10905. * @param uniformBuffer The uniform buffer receivin the data
  10906. * @param key The channel key "diffuse", "specular"... used in the shader
  10907. */
  10908. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  10909. /**
  10910. * Gets the current status of the fog (should it be enabled?)
  10911. * @param mesh defines the mesh to evaluate for fog support
  10912. * @param scene defines the hosting scene
  10913. * @returns true if fog must be enabled
  10914. */
  10915. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  10916. /**
  10917. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  10918. * @param mesh defines the current mesh
  10919. * @param scene defines the current scene
  10920. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  10921. * @param pointsCloud defines if point cloud rendering has to be turned on
  10922. * @param fogEnabled defines if fog has to be turned on
  10923. * @param alphaTest defines if alpha testing has to be turned on
  10924. * @param defines defines the current list of defines
  10925. */
  10926. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  10927. /**
  10928. * Helper used to prepare the list of defines associated with frame values for shader compilation
  10929. * @param scene defines the current scene
  10930. * @param engine defines the current engine
  10931. * @param defines specifies the list of active defines
  10932. * @param useInstances defines if instances have to be turned on
  10933. * @param useClipPlane defines if clip plane have to be turned on
  10934. */
  10935. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  10936. /**
  10937. * Prepares the defines for bones
  10938. * @param mesh The mesh containing the geometry data we will draw
  10939. * @param defines The defines to update
  10940. */
  10941. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  10942. /**
  10943. * Prepares the defines for morph targets
  10944. * @param mesh The mesh containing the geometry data we will draw
  10945. * @param defines The defines to update
  10946. */
  10947. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  10948. /**
  10949. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  10950. * @param mesh The mesh containing the geometry data we will draw
  10951. * @param defines The defines to update
  10952. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  10953. * @param useBones Precise whether bones should be used or not (override mesh info)
  10954. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  10955. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  10956. * @returns false if defines are considered not dirty and have not been checked
  10957. */
  10958. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  10959. /**
  10960. * Prepares the defines related to multiview
  10961. * @param scene The scene we are intending to draw
  10962. * @param defines The defines to update
  10963. */
  10964. static PrepareDefinesForMultiview(scene: Scene, defines: any): 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 light The light the effect is compiling for
  10970. * @param lightIndex The index of the light
  10971. * @param defines The defines to update
  10972. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10973. * @param state Defines the current state regarding what is needed (normals, etc...)
  10974. */
  10975. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  10976. needNormals: boolean;
  10977. needRebuild: boolean;
  10978. shadowEnabled: boolean;
  10979. specularEnabled: boolean;
  10980. lightmapMode: boolean;
  10981. }): void;
  10982. /**
  10983. * Prepares the defines related to the light information passed in parameter
  10984. * @param scene The scene we are intending to draw
  10985. * @param mesh The mesh the effect is compiling for
  10986. * @param defines The defines to update
  10987. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10988. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  10989. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  10990. * @returns true if normals will be required for the rest of the effect
  10991. */
  10992. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  10993. /**
  10994. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  10995. * @param lightIndex defines the light index
  10996. * @param uniformsList The uniform list
  10997. * @param samplersList The sampler list
  10998. * @param projectedLightTexture defines if projected texture must be used
  10999. * @param uniformBuffersList defines an optional list of uniform buffers
  11000. */
  11001. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  11002. /**
  11003. * Prepares the uniforms and samplers list to be used in the effect
  11004. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  11005. * @param samplersList The sampler list
  11006. * @param defines The defines helping in the list generation
  11007. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  11008. */
  11009. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  11010. /**
  11011. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  11012. * @param defines The defines to update while falling back
  11013. * @param fallbacks The authorized effect fallbacks
  11014. * @param maxSimultaneousLights The maximum number of lights allowed
  11015. * @param rank the current rank of the Effect
  11016. * @returns The newly affected rank
  11017. */
  11018. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  11019. private static _TmpMorphInfluencers;
  11020. /**
  11021. * Prepares the list of attributes required for morph targets according to the effect defines.
  11022. * @param attribs The current list of supported attribs
  11023. * @param mesh The mesh to prepare the morph targets attributes for
  11024. * @param influencers The number of influencers
  11025. */
  11026. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  11027. /**
  11028. * Prepares the list of attributes required for morph targets according to the effect defines.
  11029. * @param attribs The current list of supported attribs
  11030. * @param mesh The mesh to prepare the morph targets attributes for
  11031. * @param defines The current Defines of the effect
  11032. */
  11033. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  11034. /**
  11035. * Prepares the list of attributes required for bones according to the effect defines.
  11036. * @param attribs The current list of supported attribs
  11037. * @param mesh The mesh to prepare the bones attributes for
  11038. * @param defines The current Defines of the effect
  11039. * @param fallbacks The current efffect fallback strategy
  11040. */
  11041. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  11042. /**
  11043. * Check and prepare the list of attributes required for instances according to the effect defines.
  11044. * @param attribs The current list of supported attribs
  11045. * @param defines The current MaterialDefines of the effect
  11046. */
  11047. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  11048. /**
  11049. * Add the list of attributes required for instances to the attribs array.
  11050. * @param attribs The current list of supported attribs
  11051. */
  11052. static PushAttributesForInstances(attribs: string[]): void;
  11053. /**
  11054. * Binds the light shadow information to the effect for the given mesh.
  11055. * @param light The light containing the generator
  11056. * @param scene The scene the lights belongs to
  11057. * @param mesh The mesh we are binding the information to render
  11058. * @param lightIndex The light index in the effect used to render the mesh
  11059. * @param effect The effect we are binding the data to
  11060. */
  11061. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  11062. /**
  11063. * Binds the light information to the effect.
  11064. * @param light The light containing the generator
  11065. * @param effect The effect we are binding the data to
  11066. * @param lightIndex The light index in the effect used to render
  11067. */
  11068. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  11069. /**
  11070. * Binds the lights information from the scene to the effect for the given mesh.
  11071. * @param light Light to bind
  11072. * @param lightIndex Light index
  11073. * @param scene The scene where the light belongs to
  11074. * @param mesh The mesh we are binding the information to render
  11075. * @param effect The effect we are binding the data to
  11076. * @param useSpecular Defines if specular is supported
  11077. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11078. */
  11079. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  11080. /**
  11081. * Binds the lights information from the scene to the effect for the given mesh.
  11082. * @param scene The scene the lights belongs to
  11083. * @param mesh The mesh we are binding the information to render
  11084. * @param effect The effect we are binding the data to
  11085. * @param defines The generated defines for the effect
  11086. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  11087. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11088. */
  11089. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  11090. private static _tempFogColor;
  11091. /**
  11092. * Binds the fog information from the scene to the effect for the given mesh.
  11093. * @param scene The scene the lights belongs to
  11094. * @param mesh The mesh we are binding the information to render
  11095. * @param effect The effect we are binding the data to
  11096. * @param linearSpace Defines if the fog effect is applied in linear space
  11097. */
  11098. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  11099. /**
  11100. * Binds the bones information from the mesh to the effect.
  11101. * @param mesh The mesh we are binding the information to render
  11102. * @param effect The effect we are binding the data to
  11103. */
  11104. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  11105. /**
  11106. * Binds the morph targets information from the mesh to the effect.
  11107. * @param abstractMesh The mesh we are binding the information to render
  11108. * @param effect The effect we are binding the data to
  11109. */
  11110. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  11111. /**
  11112. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  11113. * @param defines The generated defines used in the effect
  11114. * @param effect The effect we are binding the data to
  11115. * @param scene The scene we are willing to render with logarithmic scale for
  11116. */
  11117. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  11118. /**
  11119. * Binds the clip plane information from the scene to the effect.
  11120. * @param scene The scene the clip plane information are extracted from
  11121. * @param effect The effect we are binding the data to
  11122. */
  11123. static BindClipPlane(effect: Effect, scene: Scene): void;
  11124. }
  11125. }
  11126. declare module BABYLON {
  11127. /** @hidden */
  11128. export var shadowMapPixelShader: {
  11129. name: string;
  11130. shader: string;
  11131. };
  11132. }
  11133. declare module BABYLON {
  11134. /** @hidden */
  11135. export var bonesDeclaration: {
  11136. name: string;
  11137. shader: string;
  11138. };
  11139. }
  11140. declare module BABYLON {
  11141. /** @hidden */
  11142. export var morphTargetsVertexGlobalDeclaration: {
  11143. name: string;
  11144. shader: string;
  11145. };
  11146. }
  11147. declare module BABYLON {
  11148. /** @hidden */
  11149. export var morphTargetsVertexDeclaration: {
  11150. name: string;
  11151. shader: string;
  11152. };
  11153. }
  11154. declare module BABYLON {
  11155. /** @hidden */
  11156. export var instancesDeclaration: {
  11157. name: string;
  11158. shader: string;
  11159. };
  11160. }
  11161. declare module BABYLON {
  11162. /** @hidden */
  11163. export var helperFunctions: {
  11164. name: string;
  11165. shader: string;
  11166. };
  11167. }
  11168. declare module BABYLON {
  11169. /** @hidden */
  11170. export var morphTargetsVertex: {
  11171. name: string;
  11172. shader: string;
  11173. };
  11174. }
  11175. declare module BABYLON {
  11176. /** @hidden */
  11177. export var instancesVertex: {
  11178. name: string;
  11179. shader: string;
  11180. };
  11181. }
  11182. declare module BABYLON {
  11183. /** @hidden */
  11184. export var bonesVertex: {
  11185. name: string;
  11186. shader: string;
  11187. };
  11188. }
  11189. declare module BABYLON {
  11190. /** @hidden */
  11191. export var shadowMapVertexShader: {
  11192. name: string;
  11193. shader: string;
  11194. };
  11195. }
  11196. declare module BABYLON {
  11197. /** @hidden */
  11198. export var depthBoxBlurPixelShader: {
  11199. name: string;
  11200. shader: string;
  11201. };
  11202. }
  11203. declare module BABYLON {
  11204. /**
  11205. * Defines the options associated with the creation of a custom shader for a shadow generator.
  11206. */
  11207. export interface ICustomShaderOptions {
  11208. /**
  11209. * Gets or sets the custom shader name to use
  11210. */
  11211. shaderName: string;
  11212. /**
  11213. * The list of attribute names used in the shader
  11214. */
  11215. attributes?: string[];
  11216. /**
  11217. * The list of unifrom names used in the shader
  11218. */
  11219. uniforms?: string[];
  11220. /**
  11221. * The list of sampler names used in the shader
  11222. */
  11223. samplers?: string[];
  11224. /**
  11225. * The list of defines used in the shader
  11226. */
  11227. defines?: string[];
  11228. }
  11229. /**
  11230. * Interface to implement to create a shadow generator compatible with BJS.
  11231. */
  11232. export interface IShadowGenerator {
  11233. /**
  11234. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11235. * @returns The render target texture if present otherwise, null
  11236. */
  11237. getShadowMap(): Nullable<RenderTargetTexture>;
  11238. /**
  11239. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11240. * @returns The render target texture if the shadow map is present otherwise, null
  11241. */
  11242. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11243. /**
  11244. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11245. * @param subMesh The submesh we want to render in the shadow map
  11246. * @param useInstances Defines wether will draw in the map using instances
  11247. * @returns true if ready otherwise, false
  11248. */
  11249. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11250. /**
  11251. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11252. * @param defines Defines of the material we want to update
  11253. * @param lightIndex Index of the light in the enabled light list of the material
  11254. */
  11255. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  11256. /**
  11257. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11258. * defined in the generator but impacting the effect).
  11259. * It implies the unifroms available on the materials are the standard BJS ones.
  11260. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11261. * @param effect The effect we are binfing the information for
  11262. */
  11263. bindShadowLight(lightIndex: string, effect: Effect): void;
  11264. /**
  11265. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11266. * (eq to shadow prjection matrix * light transform matrix)
  11267. * @returns The transform matrix used to create the shadow map
  11268. */
  11269. getTransformMatrix(): Matrix;
  11270. /**
  11271. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11272. * Cube and 2D textures for instance.
  11273. */
  11274. recreateShadowMap(): void;
  11275. /**
  11276. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11277. * @param onCompiled Callback triggered at the and of the effects compilation
  11278. * @param options Sets of optional options forcing the compilation with different modes
  11279. */
  11280. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11281. useInstances: boolean;
  11282. }>): void;
  11283. /**
  11284. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11285. * @param options Sets of optional options forcing the compilation with different modes
  11286. * @returns A promise that resolves when the compilation completes
  11287. */
  11288. forceCompilationAsync(options?: Partial<{
  11289. useInstances: boolean;
  11290. }>): Promise<void>;
  11291. /**
  11292. * Serializes the shadow generator setup to a json object.
  11293. * @returns The serialized JSON object
  11294. */
  11295. serialize(): any;
  11296. /**
  11297. * Disposes the Shadow map and related Textures and effects.
  11298. */
  11299. dispose(): void;
  11300. }
  11301. /**
  11302. * Default implementation IShadowGenerator.
  11303. * This is the main object responsible of generating shadows in the framework.
  11304. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  11305. */
  11306. export class ShadowGenerator implements IShadowGenerator {
  11307. /**
  11308. * Shadow generator mode None: no filtering applied.
  11309. */
  11310. static readonly FILTER_NONE: number;
  11311. /**
  11312. * Shadow generator mode ESM: Exponential Shadow Mapping.
  11313. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11314. */
  11315. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  11316. /**
  11317. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  11318. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  11319. */
  11320. static readonly FILTER_POISSONSAMPLING: number;
  11321. /**
  11322. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  11323. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11324. */
  11325. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  11326. /**
  11327. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  11328. * edge artifacts on steep falloff.
  11329. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11330. */
  11331. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  11332. /**
  11333. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  11334. * edge artifacts on steep falloff.
  11335. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11336. */
  11337. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  11338. /**
  11339. * Shadow generator mode PCF: Percentage Closer Filtering
  11340. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11341. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  11342. */
  11343. static readonly FILTER_PCF: number;
  11344. /**
  11345. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  11346. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11347. * Contact Hardening
  11348. */
  11349. static readonly FILTER_PCSS: number;
  11350. /**
  11351. * Reserved for PCF and PCSS
  11352. * Highest Quality.
  11353. *
  11354. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  11355. *
  11356. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  11357. */
  11358. static readonly QUALITY_HIGH: number;
  11359. /**
  11360. * Reserved for PCF and PCSS
  11361. * Good tradeoff for quality/perf cross devices
  11362. *
  11363. * Execute PCF on a 3*3 kernel.
  11364. *
  11365. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  11366. */
  11367. static readonly QUALITY_MEDIUM: number;
  11368. /**
  11369. * Reserved for PCF and PCSS
  11370. * The lowest quality but the fastest.
  11371. *
  11372. * Execute PCF on a 1*1 kernel.
  11373. *
  11374. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  11375. */
  11376. static readonly QUALITY_LOW: number;
  11377. /** Gets or sets the custom shader name to use */
  11378. customShaderOptions: ICustomShaderOptions;
  11379. /**
  11380. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  11381. */
  11382. onBeforeShadowMapRenderObservable: Observable<Effect>;
  11383. /**
  11384. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  11385. */
  11386. onAfterShadowMapRenderObservable: Observable<Effect>;
  11387. /**
  11388. * Observable triggered before a mesh is rendered in the shadow map.
  11389. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  11390. */
  11391. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  11392. /**
  11393. * Observable triggered after a mesh is rendered in the shadow map.
  11394. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  11395. */
  11396. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  11397. private _bias;
  11398. /**
  11399. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  11400. */
  11401. /**
  11402. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  11403. */
  11404. bias: number;
  11405. private _normalBias;
  11406. /**
  11407. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11408. */
  11409. /**
  11410. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11411. */
  11412. normalBias: number;
  11413. private _blurBoxOffset;
  11414. /**
  11415. * Gets the blur box offset: offset applied during the blur pass.
  11416. * Only useful if useKernelBlur = false
  11417. */
  11418. /**
  11419. * Sets the blur box offset: offset applied during the blur pass.
  11420. * Only useful if useKernelBlur = false
  11421. */
  11422. blurBoxOffset: number;
  11423. private _blurScale;
  11424. /**
  11425. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  11426. * 2 means half of the size.
  11427. */
  11428. /**
  11429. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  11430. * 2 means half of the size.
  11431. */
  11432. blurScale: number;
  11433. private _blurKernel;
  11434. /**
  11435. * Gets the blur kernel: kernel size of the blur pass.
  11436. * Only useful if useKernelBlur = true
  11437. */
  11438. /**
  11439. * Sets the blur kernel: kernel size of the blur pass.
  11440. * Only useful if useKernelBlur = true
  11441. */
  11442. blurKernel: number;
  11443. private _useKernelBlur;
  11444. /**
  11445. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11446. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11447. */
  11448. /**
  11449. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11450. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11451. */
  11452. useKernelBlur: boolean;
  11453. private _depthScale;
  11454. /**
  11455. * Gets the depth scale used in ESM mode.
  11456. */
  11457. /**
  11458. * Sets the depth scale used in ESM mode.
  11459. * This can override the scale stored on the light.
  11460. */
  11461. depthScale: number;
  11462. private _filter;
  11463. /**
  11464. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11465. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11466. */
  11467. /**
  11468. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11469. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11470. */
  11471. filter: number;
  11472. /**
  11473. * Gets if the current filter is set to Poisson Sampling.
  11474. */
  11475. /**
  11476. * Sets the current filter to Poisson Sampling.
  11477. */
  11478. usePoissonSampling: boolean;
  11479. /**
  11480. * Gets if the current filter is set to ESM.
  11481. */
  11482. /**
  11483. * Sets the current filter is to ESM.
  11484. */
  11485. useExponentialShadowMap: boolean;
  11486. /**
  11487. * Gets if the current filter is set to filtered ESM.
  11488. */
  11489. /**
  11490. * Gets if the current filter is set to filtered ESM.
  11491. */
  11492. useBlurExponentialShadowMap: boolean;
  11493. /**
  11494. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11495. * exponential to prevent steep falloff artifacts).
  11496. */
  11497. /**
  11498. * Sets the current filter to "close ESM" (using the inverse of the
  11499. * exponential to prevent steep falloff artifacts).
  11500. */
  11501. useCloseExponentialShadowMap: boolean;
  11502. /**
  11503. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11504. * exponential to prevent steep falloff artifacts).
  11505. */
  11506. /**
  11507. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11508. * exponential to prevent steep falloff artifacts).
  11509. */
  11510. useBlurCloseExponentialShadowMap: boolean;
  11511. /**
  11512. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11513. */
  11514. /**
  11515. * Sets the current filter to "PCF" (percentage closer filtering).
  11516. */
  11517. usePercentageCloserFiltering: boolean;
  11518. private _filteringQuality;
  11519. /**
  11520. * Gets the PCF or PCSS Quality.
  11521. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11522. */
  11523. /**
  11524. * Sets the PCF or PCSS Quality.
  11525. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11526. */
  11527. filteringQuality: number;
  11528. /**
  11529. * Gets if the current filter is set to "PCSS" (contact hardening).
  11530. */
  11531. /**
  11532. * Sets the current filter to "PCSS" (contact hardening).
  11533. */
  11534. useContactHardeningShadow: boolean;
  11535. private _contactHardeningLightSizeUVRatio;
  11536. /**
  11537. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11538. * Using a ratio helps keeping shape stability independently of the map size.
  11539. *
  11540. * It does not account for the light projection as it was having too much
  11541. * instability during the light setup or during light position changes.
  11542. *
  11543. * Only valid if useContactHardeningShadow is true.
  11544. */
  11545. /**
  11546. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11547. * Using a ratio helps keeping shape stability independently of the map size.
  11548. *
  11549. * It does not account for the light projection as it was having too much
  11550. * instability during the light setup or during light position changes.
  11551. *
  11552. * Only valid if useContactHardeningShadow is true.
  11553. */
  11554. contactHardeningLightSizeUVRatio: number;
  11555. private _darkness;
  11556. /** Gets or sets the actual darkness of a shadow */
  11557. darkness: number;
  11558. /**
  11559. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11560. * 0 means strongest and 1 would means no shadow.
  11561. * @returns the darkness.
  11562. */
  11563. getDarkness(): number;
  11564. /**
  11565. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11566. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11567. * @returns the shadow generator allowing fluent coding.
  11568. */
  11569. setDarkness(darkness: number): ShadowGenerator;
  11570. private _transparencyShadow;
  11571. /** Gets or sets the ability to have transparent shadow */
  11572. transparencyShadow: boolean;
  11573. /**
  11574. * Sets the ability to have transparent shadow (boolean).
  11575. * @param transparent True if transparent else False
  11576. * @returns the shadow generator allowing fluent coding
  11577. */
  11578. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11579. private _shadowMap;
  11580. private _shadowMap2;
  11581. /**
  11582. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11583. * @returns The render target texture if present otherwise, null
  11584. */
  11585. getShadowMap(): Nullable<RenderTargetTexture>;
  11586. /**
  11587. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11588. * @returns The render target texture if the shadow map is present otherwise, null
  11589. */
  11590. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11591. /**
  11592. * Gets the class name of that object
  11593. * @returns "ShadowGenerator"
  11594. */
  11595. getClassName(): string;
  11596. /**
  11597. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11598. * @param mesh Mesh to add
  11599. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11600. * @returns the Shadow Generator itself
  11601. */
  11602. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11603. /**
  11604. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11605. * @param mesh Mesh to remove
  11606. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11607. * @returns the Shadow Generator itself
  11608. */
  11609. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11610. /**
  11611. * Controls the extent to which the shadows fade out at the edge of the frustum
  11612. * Used only by directionals and spots
  11613. */
  11614. frustumEdgeFalloff: number;
  11615. private _light;
  11616. /**
  11617. * Returns the associated light object.
  11618. * @returns the light generating the shadow
  11619. */
  11620. getLight(): IShadowLight;
  11621. /**
  11622. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11623. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11624. * It might on the other hand introduce peter panning.
  11625. */
  11626. forceBackFacesOnly: boolean;
  11627. private _scene;
  11628. private _lightDirection;
  11629. private _effect;
  11630. private _viewMatrix;
  11631. private _projectionMatrix;
  11632. private _transformMatrix;
  11633. private _cachedPosition;
  11634. private _cachedDirection;
  11635. private _cachedDefines;
  11636. private _currentRenderID;
  11637. private _boxBlurPostprocess;
  11638. private _kernelBlurXPostprocess;
  11639. private _kernelBlurYPostprocess;
  11640. private _blurPostProcesses;
  11641. private _mapSize;
  11642. private _currentFaceIndex;
  11643. private _currentFaceIndexCache;
  11644. private _textureType;
  11645. private _defaultTextureMatrix;
  11646. /** @hidden */
  11647. static _SceneComponentInitialization: (scene: Scene) => void;
  11648. /**
  11649. * Creates a ShadowGenerator object.
  11650. * A ShadowGenerator is the required tool to use the shadows.
  11651. * Each light casting shadows needs to use its own ShadowGenerator.
  11652. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11653. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11654. * @param light The light object generating the shadows.
  11655. * @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.
  11656. */
  11657. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11658. private _initializeGenerator;
  11659. private _initializeShadowMap;
  11660. private _initializeBlurRTTAndPostProcesses;
  11661. private _renderForShadowMap;
  11662. private _renderSubMeshForShadowMap;
  11663. private _applyFilterValues;
  11664. /**
  11665. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11666. * @param onCompiled Callback triggered at the and of the effects compilation
  11667. * @param options Sets of optional options forcing the compilation with different modes
  11668. */
  11669. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11670. useInstances: boolean;
  11671. }>): void;
  11672. /**
  11673. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11674. * @param options Sets of optional options forcing the compilation with different modes
  11675. * @returns A promise that resolves when the compilation completes
  11676. */
  11677. forceCompilationAsync(options?: Partial<{
  11678. useInstances: boolean;
  11679. }>): Promise<void>;
  11680. /**
  11681. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11682. * @param subMesh The submesh we want to render in the shadow map
  11683. * @param useInstances Defines wether will draw in the map using instances
  11684. * @returns true if ready otherwise, false
  11685. */
  11686. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11687. /**
  11688. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11689. * @param defines Defines of the material we want to update
  11690. * @param lightIndex Index of the light in the enabled light list of the material
  11691. */
  11692. prepareDefines(defines: any, lightIndex: number): void;
  11693. /**
  11694. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11695. * defined in the generator but impacting the effect).
  11696. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11697. * @param effect The effect we are binfing the information for
  11698. */
  11699. bindShadowLight(lightIndex: string, effect: Effect): void;
  11700. /**
  11701. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11702. * (eq to shadow prjection matrix * light transform matrix)
  11703. * @returns The transform matrix used to create the shadow map
  11704. */
  11705. getTransformMatrix(): Matrix;
  11706. /**
  11707. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11708. * Cube and 2D textures for instance.
  11709. */
  11710. recreateShadowMap(): void;
  11711. private _disposeBlurPostProcesses;
  11712. private _disposeRTTandPostProcesses;
  11713. /**
  11714. * Disposes the ShadowGenerator.
  11715. * Returns nothing.
  11716. */
  11717. dispose(): void;
  11718. /**
  11719. * Serializes the shadow generator setup to a json object.
  11720. * @returns The serialized JSON object
  11721. */
  11722. serialize(): any;
  11723. /**
  11724. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11725. * @param parsedShadowGenerator The JSON object to parse
  11726. * @param scene The scene to create the shadow map for
  11727. * @returns The parsed shadow generator
  11728. */
  11729. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11730. }
  11731. }
  11732. declare module BABYLON {
  11733. /**
  11734. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11735. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11736. * 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.
  11737. */
  11738. export abstract class Light extends Node {
  11739. /**
  11740. * Falloff Default: light is falling off following the material specification:
  11741. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11742. */
  11743. static readonly FALLOFF_DEFAULT: number;
  11744. /**
  11745. * Falloff Physical: light is falling off following the inverse squared distance law.
  11746. */
  11747. static readonly FALLOFF_PHYSICAL: number;
  11748. /**
  11749. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11750. * to enhance interoperability with other engines.
  11751. */
  11752. static readonly FALLOFF_GLTF: number;
  11753. /**
  11754. * Falloff Standard: light is falling off like in the standard material
  11755. * to enhance interoperability with other materials.
  11756. */
  11757. static readonly FALLOFF_STANDARD: number;
  11758. /**
  11759. * If every light affecting the material is in this lightmapMode,
  11760. * material.lightmapTexture adds or multiplies
  11761. * (depends on material.useLightmapAsShadowmap)
  11762. * after every other light calculations.
  11763. */
  11764. static readonly LIGHTMAP_DEFAULT: number;
  11765. /**
  11766. * material.lightmapTexture as only diffuse lighting from this light
  11767. * adds only specular lighting from this light
  11768. * adds dynamic shadows
  11769. */
  11770. static readonly LIGHTMAP_SPECULAR: number;
  11771. /**
  11772. * material.lightmapTexture as only lighting
  11773. * no light calculation from this light
  11774. * only adds dynamic shadows from this light
  11775. */
  11776. static readonly LIGHTMAP_SHADOWSONLY: number;
  11777. /**
  11778. * Each light type uses the default quantity according to its type:
  11779. * point/spot lights use luminous intensity
  11780. * directional lights use illuminance
  11781. */
  11782. static readonly INTENSITYMODE_AUTOMATIC: number;
  11783. /**
  11784. * lumen (lm)
  11785. */
  11786. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11787. /**
  11788. * candela (lm/sr)
  11789. */
  11790. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11791. /**
  11792. * lux (lm/m^2)
  11793. */
  11794. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11795. /**
  11796. * nit (cd/m^2)
  11797. */
  11798. static readonly INTENSITYMODE_LUMINANCE: number;
  11799. /**
  11800. * Light type const id of the point light.
  11801. */
  11802. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11803. /**
  11804. * Light type const id of the directional light.
  11805. */
  11806. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11807. /**
  11808. * Light type const id of the spot light.
  11809. */
  11810. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11811. /**
  11812. * Light type const id of the hemispheric light.
  11813. */
  11814. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11815. /**
  11816. * Diffuse gives the basic color to an object.
  11817. */
  11818. diffuse: Color3;
  11819. /**
  11820. * Specular produces a highlight color on an object.
  11821. * Note: This is note affecting PBR materials.
  11822. */
  11823. specular: Color3;
  11824. /**
  11825. * Defines the falloff type for this light. This lets overrriding how punctual light are
  11826. * falling off base on range or angle.
  11827. * This can be set to any values in Light.FALLOFF_x.
  11828. *
  11829. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  11830. * other types of materials.
  11831. */
  11832. falloffType: number;
  11833. /**
  11834. * Strength of the light.
  11835. * Note: By default it is define in the framework own unit.
  11836. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11837. */
  11838. intensity: number;
  11839. private _range;
  11840. protected _inverseSquaredRange: number;
  11841. /**
  11842. * Defines how far from the source the light is impacting in scene units.
  11843. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11844. */
  11845. /**
  11846. * Defines how far from the source the light is impacting in scene units.
  11847. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11848. */
  11849. range: number;
  11850. /**
  11851. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11852. * of light.
  11853. */
  11854. private _photometricScale;
  11855. private _intensityMode;
  11856. /**
  11857. * Gets the photometric scale used to interpret the intensity.
  11858. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11859. */
  11860. /**
  11861. * Sets the photometric scale used to interpret the intensity.
  11862. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11863. */
  11864. intensityMode: number;
  11865. private _radius;
  11866. /**
  11867. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11868. */
  11869. /**
  11870. * sets the light radius used by PBR Materials to simulate soft area lights.
  11871. */
  11872. radius: number;
  11873. private _renderPriority;
  11874. /**
  11875. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11876. * exceeding the number allowed of the materials.
  11877. */
  11878. renderPriority: number;
  11879. private _shadowEnabled;
  11880. /**
  11881. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11882. * the current shadow generator.
  11883. */
  11884. /**
  11885. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11886. * the current shadow generator.
  11887. */
  11888. shadowEnabled: boolean;
  11889. private _includedOnlyMeshes;
  11890. /**
  11891. * Gets the only meshes impacted by this light.
  11892. */
  11893. /**
  11894. * Sets the only meshes impacted by this light.
  11895. */
  11896. includedOnlyMeshes: AbstractMesh[];
  11897. private _excludedMeshes;
  11898. /**
  11899. * Gets the meshes not impacted by this light.
  11900. */
  11901. /**
  11902. * Sets the meshes not impacted by this light.
  11903. */
  11904. excludedMeshes: AbstractMesh[];
  11905. private _excludeWithLayerMask;
  11906. /**
  11907. * Gets the layer id use to find what meshes are not impacted by the light.
  11908. * Inactive if 0
  11909. */
  11910. /**
  11911. * Sets the layer id use to find what meshes are not impacted by the light.
  11912. * Inactive if 0
  11913. */
  11914. excludeWithLayerMask: number;
  11915. private _includeOnlyWithLayerMask;
  11916. /**
  11917. * Gets the layer id use to find what meshes are impacted by the light.
  11918. * Inactive if 0
  11919. */
  11920. /**
  11921. * Sets the layer id use to find what meshes are impacted by the light.
  11922. * Inactive if 0
  11923. */
  11924. includeOnlyWithLayerMask: number;
  11925. private _lightmapMode;
  11926. /**
  11927. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11928. */
  11929. /**
  11930. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11931. */
  11932. lightmapMode: number;
  11933. /**
  11934. * Shadow generator associted to the light.
  11935. * @hidden Internal use only.
  11936. */
  11937. _shadowGenerator: Nullable<IShadowGenerator>;
  11938. /**
  11939. * @hidden Internal use only.
  11940. */
  11941. _excludedMeshesIds: string[];
  11942. /**
  11943. * @hidden Internal use only.
  11944. */
  11945. _includedOnlyMeshesIds: string[];
  11946. /**
  11947. * The current light unifom buffer.
  11948. * @hidden Internal use only.
  11949. */
  11950. _uniformBuffer: UniformBuffer;
  11951. /**
  11952. * Creates a Light object in the scene.
  11953. * Documentation : https://doc.babylonjs.com/babylon101/lights
  11954. * @param name The firendly name of the light
  11955. * @param scene The scene the light belongs too
  11956. */
  11957. constructor(name: string, scene: Scene);
  11958. protected abstract _buildUniformLayout(): void;
  11959. /**
  11960. * Sets the passed Effect "effect" with the Light information.
  11961. * @param effect The effect to update
  11962. * @param lightIndex The index of the light in the effect to update
  11963. * @returns The light
  11964. */
  11965. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11966. /**
  11967. * Returns the string "Light".
  11968. * @returns the class name
  11969. */
  11970. getClassName(): string;
  11971. /** @hidden */
  11972. readonly _isLight: boolean;
  11973. /**
  11974. * Converts the light information to a readable string for debug purpose.
  11975. * @param fullDetails Supports for multiple levels of logging within scene loading
  11976. * @returns the human readable light info
  11977. */
  11978. toString(fullDetails?: boolean): string;
  11979. /** @hidden */
  11980. protected _syncParentEnabledState(): void;
  11981. /**
  11982. * Set the enabled state of this node.
  11983. * @param value - the new enabled state
  11984. */
  11985. setEnabled(value: boolean): void;
  11986. /**
  11987. * Returns the Light associated shadow generator if any.
  11988. * @return the associated shadow generator.
  11989. */
  11990. getShadowGenerator(): Nullable<IShadowGenerator>;
  11991. /**
  11992. * Returns a Vector3, the absolute light position in the World.
  11993. * @returns the world space position of the light
  11994. */
  11995. getAbsolutePosition(): Vector3;
  11996. /**
  11997. * Specifies if the light will affect the passed mesh.
  11998. * @param mesh The mesh to test against the light
  11999. * @return true the mesh is affected otherwise, false.
  12000. */
  12001. canAffectMesh(mesh: AbstractMesh): boolean;
  12002. /**
  12003. * Sort function to order lights for rendering.
  12004. * @param a First Light object to compare to second.
  12005. * @param b Second Light object to compare first.
  12006. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12007. */
  12008. static CompareLightsPriority(a: Light, b: Light): number;
  12009. /**
  12010. * Releases resources associated with this node.
  12011. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12012. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12013. */
  12014. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12015. /**
  12016. * Returns the light type ID (integer).
  12017. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12018. */
  12019. getTypeID(): number;
  12020. /**
  12021. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12022. * @returns the scaled intensity in intensity mode unit
  12023. */
  12024. getScaledIntensity(): number;
  12025. /**
  12026. * Returns a new Light object, named "name", from the current one.
  12027. * @param name The name of the cloned light
  12028. * @returns the new created light
  12029. */
  12030. clone(name: string): Nullable<Light>;
  12031. /**
  12032. * Serializes the current light into a Serialization object.
  12033. * @returns the serialized object.
  12034. */
  12035. serialize(): any;
  12036. /**
  12037. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12038. * This new light is named "name" and added to the passed scene.
  12039. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12040. * @param name The friendly name of the light
  12041. * @param scene The scene the new light will belong to
  12042. * @returns the constructor function
  12043. */
  12044. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12045. /**
  12046. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12047. * @param parsedLight The JSON representation of the light
  12048. * @param scene The scene to create the parsed light in
  12049. * @returns the created light after parsing
  12050. */
  12051. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12052. private _hookArrayForExcluded;
  12053. private _hookArrayForIncludedOnly;
  12054. private _resyncMeshes;
  12055. /**
  12056. * Forces the meshes to update their light related information in their rendering used effects
  12057. * @hidden Internal Use Only
  12058. */
  12059. _markMeshesAsLightDirty(): void;
  12060. /**
  12061. * Recomputes the cached photometric scale if needed.
  12062. */
  12063. private _computePhotometricScale;
  12064. /**
  12065. * Returns the Photometric Scale according to the light type and intensity mode.
  12066. */
  12067. private _getPhotometricScale;
  12068. /**
  12069. * Reorder the light in the scene according to their defined priority.
  12070. * @hidden Internal Use Only
  12071. */
  12072. _reorderLightsInScene(): void;
  12073. /**
  12074. * Prepares the list of defines specific to the light type.
  12075. * @param defines the list of defines
  12076. * @param lightIndex defines the index of the light for the effect
  12077. */
  12078. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12079. }
  12080. }
  12081. declare module BABYLON {
  12082. /**
  12083. * Creates an instance based on a source mesh.
  12084. */
  12085. export class InstancedMesh extends AbstractMesh {
  12086. private _sourceMesh;
  12087. private _currentLOD;
  12088. /** @hidden */
  12089. _indexInSourceMeshInstanceArray: number;
  12090. constructor(name: string, source: Mesh);
  12091. /**
  12092. * Returns the string "InstancedMesh".
  12093. */
  12094. getClassName(): string;
  12095. /** Gets the list of lights affecting that mesh */
  12096. readonly lightSources: Light[];
  12097. _resyncLightSources(): void;
  12098. _resyncLighSource(light: Light): void;
  12099. _removeLightSource(light: Light): void;
  12100. /**
  12101. * If the source mesh receives shadows
  12102. */
  12103. readonly receiveShadows: boolean;
  12104. /**
  12105. * The material of the source mesh
  12106. */
  12107. readonly material: Nullable<Material>;
  12108. /**
  12109. * Visibility of the source mesh
  12110. */
  12111. readonly visibility: number;
  12112. /**
  12113. * Skeleton of the source mesh
  12114. */
  12115. readonly skeleton: Nullable<Skeleton>;
  12116. /**
  12117. * Rendering ground id of the source mesh
  12118. */
  12119. renderingGroupId: number;
  12120. /**
  12121. * Returns the total number of vertices (integer).
  12122. */
  12123. getTotalVertices(): number;
  12124. /**
  12125. * Returns a positive integer : the total number of indices in this mesh geometry.
  12126. * @returns the numner of indices or zero if the mesh has no geometry.
  12127. */
  12128. getTotalIndices(): number;
  12129. /**
  12130. * The source mesh of the instance
  12131. */
  12132. readonly sourceMesh: Mesh;
  12133. /**
  12134. * Is this node ready to be used/rendered
  12135. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  12136. * @return {boolean} is it ready
  12137. */
  12138. isReady(completeCheck?: boolean): boolean;
  12139. /**
  12140. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  12141. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  12142. * @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.
  12143. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  12144. */
  12145. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  12146. /**
  12147. * Sets the vertex data of the mesh geometry for the requested `kind`.
  12148. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  12149. * The `data` are either a numeric array either a Float32Array.
  12150. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  12151. * 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).
  12152. * Note that a new underlying VertexBuffer object is created each call.
  12153. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12154. *
  12155. * Possible `kind` values :
  12156. * - VertexBuffer.PositionKind
  12157. * - VertexBuffer.UVKind
  12158. * - VertexBuffer.UV2Kind
  12159. * - VertexBuffer.UV3Kind
  12160. * - VertexBuffer.UV4Kind
  12161. * - VertexBuffer.UV5Kind
  12162. * - VertexBuffer.UV6Kind
  12163. * - VertexBuffer.ColorKind
  12164. * - VertexBuffer.MatricesIndicesKind
  12165. * - VertexBuffer.MatricesIndicesExtraKind
  12166. * - VertexBuffer.MatricesWeightsKind
  12167. * - VertexBuffer.MatricesWeightsExtraKind
  12168. *
  12169. * Returns the Mesh.
  12170. */
  12171. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  12172. /**
  12173. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  12174. * If the mesh has no geometry, it is simply returned as it is.
  12175. * The `data` are either a numeric array either a Float32Array.
  12176. * No new underlying VertexBuffer object is created.
  12177. * 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.
  12178. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  12179. *
  12180. * Possible `kind` values :
  12181. * - VertexBuffer.PositionKind
  12182. * - VertexBuffer.UVKind
  12183. * - VertexBuffer.UV2Kind
  12184. * - VertexBuffer.UV3Kind
  12185. * - VertexBuffer.UV4Kind
  12186. * - VertexBuffer.UV5Kind
  12187. * - VertexBuffer.UV6Kind
  12188. * - VertexBuffer.ColorKind
  12189. * - VertexBuffer.MatricesIndicesKind
  12190. * - VertexBuffer.MatricesIndicesExtraKind
  12191. * - VertexBuffer.MatricesWeightsKind
  12192. * - VertexBuffer.MatricesWeightsExtraKind
  12193. *
  12194. * Returns the Mesh.
  12195. */
  12196. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  12197. /**
  12198. * Sets the mesh indices.
  12199. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  12200. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  12201. * This method creates a new index buffer each call.
  12202. * Returns the Mesh.
  12203. */
  12204. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  12205. /**
  12206. * Boolean : True if the mesh owns the requested kind of data.
  12207. */
  12208. isVerticesDataPresent(kind: string): boolean;
  12209. /**
  12210. * Returns an array of indices (IndicesArray).
  12211. */
  12212. getIndices(): Nullable<IndicesArray>;
  12213. readonly _positions: Nullable<Vector3[]>;
  12214. /**
  12215. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  12216. * This means the mesh underlying bounding box and sphere are recomputed.
  12217. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  12218. * @returns the current mesh
  12219. */
  12220. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  12221. /** @hidden */
  12222. _preActivate(): InstancedMesh;
  12223. /** @hidden */
  12224. _activate(renderId: number, intermediateRendering: boolean): boolean;
  12225. /** @hidden */
  12226. _postActivate(): void;
  12227. getWorldMatrix(): Matrix;
  12228. readonly isAnInstance: boolean;
  12229. /**
  12230. * Returns the current associated LOD AbstractMesh.
  12231. */
  12232. getLOD(camera: Camera): AbstractMesh;
  12233. /** @hidden */
  12234. _syncSubMeshes(): InstancedMesh;
  12235. /** @hidden */
  12236. _generatePointsArray(): boolean;
  12237. /**
  12238. * Creates a new InstancedMesh from the current mesh.
  12239. * - name (string) : the cloned mesh name
  12240. * - newParent (optional Node) : the optional Node to parent the clone to.
  12241. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  12242. *
  12243. * Returns the clone.
  12244. */
  12245. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  12246. /**
  12247. * Disposes the InstancedMesh.
  12248. * Returns nothing.
  12249. */
  12250. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12251. }
  12252. }
  12253. declare module BABYLON {
  12254. /**
  12255. * Defines the options associated with the creation of a shader material.
  12256. */
  12257. export interface IShaderMaterialOptions {
  12258. /**
  12259. * Does the material work in alpha blend mode
  12260. */
  12261. needAlphaBlending: boolean;
  12262. /**
  12263. * Does the material work in alpha test mode
  12264. */
  12265. needAlphaTesting: boolean;
  12266. /**
  12267. * The list of attribute names used in the shader
  12268. */
  12269. attributes: string[];
  12270. /**
  12271. * The list of unifrom names used in the shader
  12272. */
  12273. uniforms: string[];
  12274. /**
  12275. * The list of UBO names used in the shader
  12276. */
  12277. uniformBuffers: string[];
  12278. /**
  12279. * The list of sampler names used in the shader
  12280. */
  12281. samplers: string[];
  12282. /**
  12283. * The list of defines used in the shader
  12284. */
  12285. defines: string[];
  12286. }
  12287. /**
  12288. * 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.
  12289. *
  12290. * This returned material effects how the mesh will look based on the code in the shaders.
  12291. *
  12292. * @see http://doc.babylonjs.com/how_to/shader_material
  12293. */
  12294. export class ShaderMaterial extends Material {
  12295. private _shaderPath;
  12296. private _options;
  12297. private _textures;
  12298. private _textureArrays;
  12299. private _floats;
  12300. private _ints;
  12301. private _floatsArrays;
  12302. private _colors3;
  12303. private _colors3Arrays;
  12304. private _colors4;
  12305. private _colors4Arrays;
  12306. private _vectors2;
  12307. private _vectors3;
  12308. private _vectors4;
  12309. private _matrices;
  12310. private _matrices3x3;
  12311. private _matrices2x2;
  12312. private _vectors2Arrays;
  12313. private _vectors3Arrays;
  12314. private _vectors4Arrays;
  12315. private _cachedWorldViewMatrix;
  12316. private _cachedWorldViewProjectionMatrix;
  12317. private _renderId;
  12318. /**
  12319. * Instantiate a new shader material.
  12320. * 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.
  12321. * This returned material effects how the mesh will look based on the code in the shaders.
  12322. * @see http://doc.babylonjs.com/how_to/shader_material
  12323. * @param name Define the name of the material in the scene
  12324. * @param scene Define the scene the material belongs to
  12325. * @param shaderPath Defines the route to the shader code in one of three ways:
  12326. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  12327. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  12328. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  12329. * @param options Define the options used to create the shader
  12330. */
  12331. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  12332. /**
  12333. * Gets the options used to compile the shader.
  12334. * They can be modified to trigger a new compilation
  12335. */
  12336. readonly options: IShaderMaterialOptions;
  12337. /**
  12338. * Gets the current class name of the material e.g. "ShaderMaterial"
  12339. * Mainly use in serialization.
  12340. * @returns the class name
  12341. */
  12342. getClassName(): string;
  12343. /**
  12344. * Specifies if the material will require alpha blending
  12345. * @returns a boolean specifying if alpha blending is needed
  12346. */
  12347. needAlphaBlending(): boolean;
  12348. /**
  12349. * Specifies if this material should be rendered in alpha test mode
  12350. * @returns a boolean specifying if an alpha test is needed.
  12351. */
  12352. needAlphaTesting(): boolean;
  12353. private _checkUniform;
  12354. /**
  12355. * Set a texture in the shader.
  12356. * @param name Define the name of the uniform samplers as defined in the shader
  12357. * @param texture Define the texture to bind to this sampler
  12358. * @return the material itself allowing "fluent" like uniform updates
  12359. */
  12360. setTexture(name: string, texture: Texture): ShaderMaterial;
  12361. /**
  12362. * Set a texture array in the shader.
  12363. * @param name Define the name of the uniform sampler array as defined in the shader
  12364. * @param textures Define the list of textures to bind to this sampler
  12365. * @return the material itself allowing "fluent" like uniform updates
  12366. */
  12367. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12368. /**
  12369. * Set a float in the shader.
  12370. * @param name Define the name of the uniform as defined in the shader
  12371. * @param value Define the value to give to the uniform
  12372. * @return the material itself allowing "fluent" like uniform updates
  12373. */
  12374. setFloat(name: string, value: number): ShaderMaterial;
  12375. /**
  12376. * Set a int in the shader.
  12377. * @param name Define the name of the uniform as defined in the shader
  12378. * @param value Define the value to give to the uniform
  12379. * @return the material itself allowing "fluent" like uniform updates
  12380. */
  12381. setInt(name: string, value: number): ShaderMaterial;
  12382. /**
  12383. * Set an array of floats in the shader.
  12384. * @param name Define the name of the uniform as defined in the shader
  12385. * @param value Define the value to give to the uniform
  12386. * @return the material itself allowing "fluent" like uniform updates
  12387. */
  12388. setFloats(name: string, value: number[]): ShaderMaterial;
  12389. /**
  12390. * Set a vec3 in the shader from a Color3.
  12391. * @param name Define the name of the uniform as defined in the shader
  12392. * @param value Define the value to give to the uniform
  12393. * @return the material itself allowing "fluent" like uniform updates
  12394. */
  12395. setColor3(name: string, value: Color3): ShaderMaterial;
  12396. /**
  12397. * Set a vec3 array in the shader from a Color3 array.
  12398. * @param name Define the name of the uniform as defined in the shader
  12399. * @param value Define the value to give to the uniform
  12400. * @return the material itself allowing "fluent" like uniform updates
  12401. */
  12402. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12403. /**
  12404. * Set a vec4 in the shader from a Color4.
  12405. * @param name Define the name of the uniform as defined in the shader
  12406. * @param value Define the value to give to the uniform
  12407. * @return the material itself allowing "fluent" like uniform updates
  12408. */
  12409. setColor4(name: string, value: Color4): ShaderMaterial;
  12410. /**
  12411. * Set a vec4 array in the shader from a Color4 array.
  12412. * @param name Define the name of the uniform as defined in the shader
  12413. * @param value Define the value to give to the uniform
  12414. * @return the material itself allowing "fluent" like uniform updates
  12415. */
  12416. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  12417. /**
  12418. * Set a vec2 in the shader from a Vector2.
  12419. * @param name Define the name of the uniform as defined in the shader
  12420. * @param value Define the value to give to the uniform
  12421. * @return the material itself allowing "fluent" like uniform updates
  12422. */
  12423. setVector2(name: string, value: Vector2): ShaderMaterial;
  12424. /**
  12425. * Set a vec3 in the shader from a Vector3.
  12426. * @param name Define the name of the uniform as defined in the shader
  12427. * @param value Define the value to give to the uniform
  12428. * @return the material itself allowing "fluent" like uniform updates
  12429. */
  12430. setVector3(name: string, value: Vector3): ShaderMaterial;
  12431. /**
  12432. * Set a vec4 in the shader from a Vector4.
  12433. * @param name Define the name of the uniform as defined in the shader
  12434. * @param value Define the value to give to the uniform
  12435. * @return the material itself allowing "fluent" like uniform updates
  12436. */
  12437. setVector4(name: string, value: Vector4): ShaderMaterial;
  12438. /**
  12439. * Set a mat4 in the shader from a Matrix.
  12440. * @param name Define the name of the uniform as defined in the shader
  12441. * @param value Define the value to give to the uniform
  12442. * @return the material itself allowing "fluent" like uniform updates
  12443. */
  12444. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12445. /**
  12446. * Set a mat3 in the shader from a Float32Array.
  12447. * @param name Define the name of the uniform as defined in the shader
  12448. * @param value Define the value to give to the uniform
  12449. * @return the material itself allowing "fluent" like uniform updates
  12450. */
  12451. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12452. /**
  12453. * Set a mat2 in the shader from a Float32Array.
  12454. * @param name Define the name of the uniform as defined in the shader
  12455. * @param value Define the value to give to the uniform
  12456. * @return the material itself allowing "fluent" like uniform updates
  12457. */
  12458. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12459. /**
  12460. * Set a vec2 array in the shader from a number array.
  12461. * @param name Define the name of the uniform as defined in the shader
  12462. * @param value Define the value to give to the uniform
  12463. * @return the material itself allowing "fluent" like uniform updates
  12464. */
  12465. setArray2(name: string, value: number[]): ShaderMaterial;
  12466. /**
  12467. * Set a vec3 array in the shader from a number array.
  12468. * @param name Define the name of the uniform as defined in the shader
  12469. * @param value Define the value to give to the uniform
  12470. * @return the material itself allowing "fluent" like uniform updates
  12471. */
  12472. setArray3(name: string, value: number[]): ShaderMaterial;
  12473. /**
  12474. * Set a vec4 array in the shader from a number array.
  12475. * @param name Define the name of the uniform as defined in the shader
  12476. * @param value Define the value to give to the uniform
  12477. * @return the material itself allowing "fluent" like uniform updates
  12478. */
  12479. setArray4(name: string, value: number[]): ShaderMaterial;
  12480. private _checkCache;
  12481. /**
  12482. * Specifies that the submesh is ready to be used
  12483. * @param mesh defines the mesh to check
  12484. * @param subMesh defines which submesh to check
  12485. * @param useInstances specifies that instances should be used
  12486. * @returns a boolean indicating that the submesh is ready or not
  12487. */
  12488. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12489. /**
  12490. * Checks if the material is ready to render the requested mesh
  12491. * @param mesh Define the mesh to render
  12492. * @param useInstances Define whether or not the material is used with instances
  12493. * @returns true if ready, otherwise false
  12494. */
  12495. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12496. /**
  12497. * Binds the world matrix to the material
  12498. * @param world defines the world transformation matrix
  12499. */
  12500. bindOnlyWorldMatrix(world: Matrix): void;
  12501. /**
  12502. * Binds the material to the mesh
  12503. * @param world defines the world transformation matrix
  12504. * @param mesh defines the mesh to bind the material to
  12505. */
  12506. bind(world: Matrix, mesh?: Mesh): void;
  12507. /**
  12508. * Gets the active textures from the material
  12509. * @returns an array of textures
  12510. */
  12511. getActiveTextures(): BaseTexture[];
  12512. /**
  12513. * Specifies if the material uses a texture
  12514. * @param texture defines the texture to check against the material
  12515. * @returns a boolean specifying if the material uses the texture
  12516. */
  12517. hasTexture(texture: BaseTexture): boolean;
  12518. /**
  12519. * Makes a duplicate of the material, and gives it a new name
  12520. * @param name defines the new name for the duplicated material
  12521. * @returns the cloned material
  12522. */
  12523. clone(name: string): ShaderMaterial;
  12524. /**
  12525. * Disposes the material
  12526. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12527. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12528. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  12529. */
  12530. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  12531. /**
  12532. * Serializes this material in a JSON representation
  12533. * @returns the serialized material object
  12534. */
  12535. serialize(): any;
  12536. /**
  12537. * Creates a shader material from parsed shader material data
  12538. * @param source defines the JSON represnetation of the material
  12539. * @param scene defines the hosting scene
  12540. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  12541. * @returns a new material
  12542. */
  12543. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12544. }
  12545. }
  12546. declare module BABYLON {
  12547. /** @hidden */
  12548. export var clipPlaneFragmentDeclaration: {
  12549. name: string;
  12550. shader: string;
  12551. };
  12552. }
  12553. declare module BABYLON {
  12554. /** @hidden */
  12555. export var clipPlaneFragment: {
  12556. name: string;
  12557. shader: string;
  12558. };
  12559. }
  12560. declare module BABYLON {
  12561. /** @hidden */
  12562. export var colorPixelShader: {
  12563. name: string;
  12564. shader: string;
  12565. };
  12566. }
  12567. declare module BABYLON {
  12568. /** @hidden */
  12569. export var clipPlaneVertexDeclaration: {
  12570. name: string;
  12571. shader: string;
  12572. };
  12573. }
  12574. declare module BABYLON {
  12575. /** @hidden */
  12576. export var clipPlaneVertex: {
  12577. name: string;
  12578. shader: string;
  12579. };
  12580. }
  12581. declare module BABYLON {
  12582. /** @hidden */
  12583. export var colorVertexShader: {
  12584. name: string;
  12585. shader: string;
  12586. };
  12587. }
  12588. declare module BABYLON {
  12589. /**
  12590. * Line mesh
  12591. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  12592. */
  12593. export class LinesMesh extends Mesh {
  12594. /**
  12595. * If vertex color should be applied to the mesh
  12596. */
  12597. readonly useVertexColor?: boolean | undefined;
  12598. /**
  12599. * If vertex alpha should be applied to the mesh
  12600. */
  12601. readonly useVertexAlpha?: boolean | undefined;
  12602. /**
  12603. * Color of the line (Default: White)
  12604. */
  12605. color: Color3;
  12606. /**
  12607. * Alpha of the line (Default: 1)
  12608. */
  12609. alpha: number;
  12610. /**
  12611. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12612. * This margin is expressed in world space coordinates, so its value may vary.
  12613. * Default value is 0.1
  12614. */
  12615. intersectionThreshold: number;
  12616. private _colorShader;
  12617. private color4;
  12618. /**
  12619. * Creates a new LinesMesh
  12620. * @param name defines the name
  12621. * @param scene defines the hosting scene
  12622. * @param parent defines the parent mesh if any
  12623. * @param source defines the optional source LinesMesh used to clone data from
  12624. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  12625. * When false, achieved by calling a clone(), also passing False.
  12626. * This will make creation of children, recursive.
  12627. * @param useVertexColor defines if this LinesMesh supports vertex color
  12628. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  12629. */
  12630. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  12631. /**
  12632. * If vertex color should be applied to the mesh
  12633. */
  12634. useVertexColor?: boolean | undefined,
  12635. /**
  12636. * If vertex alpha should be applied to the mesh
  12637. */
  12638. useVertexAlpha?: boolean | undefined);
  12639. private _addClipPlaneDefine;
  12640. private _removeClipPlaneDefine;
  12641. isReady(): boolean;
  12642. /**
  12643. * Returns the string "LineMesh"
  12644. */
  12645. getClassName(): string;
  12646. /**
  12647. * @hidden
  12648. */
  12649. /**
  12650. * @hidden
  12651. */
  12652. material: Material;
  12653. /**
  12654. * @hidden
  12655. */
  12656. readonly checkCollisions: boolean;
  12657. /** @hidden */
  12658. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  12659. /** @hidden */
  12660. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  12661. /**
  12662. * Disposes of the line mesh
  12663. * @param doNotRecurse If children should be disposed
  12664. */
  12665. dispose(doNotRecurse?: boolean): void;
  12666. /**
  12667. * Returns a new LineMesh object cloned from the current one.
  12668. */
  12669. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  12670. /**
  12671. * Creates a new InstancedLinesMesh object from the mesh model.
  12672. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  12673. * @param name defines the name of the new instance
  12674. * @returns a new InstancedLinesMesh
  12675. */
  12676. createInstance(name: string): InstancedLinesMesh;
  12677. }
  12678. /**
  12679. * Creates an instance based on a source LinesMesh
  12680. */
  12681. export class InstancedLinesMesh extends InstancedMesh {
  12682. /**
  12683. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12684. * This margin is expressed in world space coordinates, so its value may vary.
  12685. * Initilized with the intersectionThreshold value of the source LinesMesh
  12686. */
  12687. intersectionThreshold: number;
  12688. constructor(name: string, source: LinesMesh);
  12689. /**
  12690. * Returns the string "InstancedLinesMesh".
  12691. */
  12692. getClassName(): string;
  12693. }
  12694. }
  12695. declare module BABYLON {
  12696. /**
  12697. * Mesh representing the gorund
  12698. */
  12699. export class GroundMesh extends Mesh {
  12700. /** If octree should be generated */
  12701. generateOctree: boolean;
  12702. private _heightQuads;
  12703. /** @hidden */
  12704. _subdivisionsX: number;
  12705. /** @hidden */
  12706. _subdivisionsY: number;
  12707. /** @hidden */
  12708. _width: number;
  12709. /** @hidden */
  12710. _height: number;
  12711. /** @hidden */
  12712. _minX: number;
  12713. /** @hidden */
  12714. _maxX: number;
  12715. /** @hidden */
  12716. _minZ: number;
  12717. /** @hidden */
  12718. _maxZ: number;
  12719. constructor(name: string, scene: Scene);
  12720. /**
  12721. * "GroundMesh"
  12722. * @returns "GroundMesh"
  12723. */
  12724. getClassName(): string;
  12725. /**
  12726. * The minimum of x and y subdivisions
  12727. */
  12728. readonly subdivisions: number;
  12729. /**
  12730. * X subdivisions
  12731. */
  12732. readonly subdivisionsX: number;
  12733. /**
  12734. * Y subdivisions
  12735. */
  12736. readonly subdivisionsY: number;
  12737. /**
  12738. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  12739. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  12740. * @param chunksCount the number of subdivisions for x and y
  12741. * @param octreeBlocksSize (Default: 32)
  12742. */
  12743. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  12744. /**
  12745. * Returns a height (y) value in the Worl system :
  12746. * the ground altitude at the coordinates (x, z) expressed in the World system.
  12747. * @param x x coordinate
  12748. * @param z z coordinate
  12749. * @returns the ground y position if (x, z) are outside the ground surface.
  12750. */
  12751. getHeightAtCoordinates(x: number, z: number): number;
  12752. /**
  12753. * Returns a normalized vector (Vector3) orthogonal to the ground
  12754. * at the ground coordinates (x, z) expressed in the World system.
  12755. * @param x x coordinate
  12756. * @param z z coordinate
  12757. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  12758. */
  12759. getNormalAtCoordinates(x: number, z: number): Vector3;
  12760. /**
  12761. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  12762. * at the ground coordinates (x, z) expressed in the World system.
  12763. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  12764. * @param x x coordinate
  12765. * @param z z coordinate
  12766. * @param ref vector to store the result
  12767. * @returns the GroundMesh.
  12768. */
  12769. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  12770. /**
  12771. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  12772. * if the ground has been updated.
  12773. * This can be used in the render loop.
  12774. * @returns the GroundMesh.
  12775. */
  12776. updateCoordinateHeights(): GroundMesh;
  12777. private _getFacetAt;
  12778. private _initHeightQuads;
  12779. private _computeHeightQuads;
  12780. /**
  12781. * Serializes this ground mesh
  12782. * @param serializationObject object to write serialization to
  12783. */
  12784. serialize(serializationObject: any): void;
  12785. /**
  12786. * Parses a serialized ground mesh
  12787. * @param parsedMesh the serialized mesh
  12788. * @param scene the scene to create the ground mesh in
  12789. * @returns the created ground mesh
  12790. */
  12791. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  12792. }
  12793. }
  12794. declare module BABYLON {
  12795. /**
  12796. * Interface for Physics-Joint data
  12797. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12798. */
  12799. export interface PhysicsJointData {
  12800. /**
  12801. * The main pivot of the joint
  12802. */
  12803. mainPivot?: Vector3;
  12804. /**
  12805. * The connected pivot of the joint
  12806. */
  12807. connectedPivot?: Vector3;
  12808. /**
  12809. * The main axis of the joint
  12810. */
  12811. mainAxis?: Vector3;
  12812. /**
  12813. * The connected axis of the joint
  12814. */
  12815. connectedAxis?: Vector3;
  12816. /**
  12817. * The collision of the joint
  12818. */
  12819. collision?: boolean;
  12820. /**
  12821. * Native Oimo/Cannon/Energy data
  12822. */
  12823. nativeParams?: any;
  12824. }
  12825. /**
  12826. * This is a holder class for the physics joint created by the physics plugin
  12827. * It holds a set of functions to control the underlying joint
  12828. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12829. */
  12830. export class PhysicsJoint {
  12831. /**
  12832. * The type of the physics joint
  12833. */
  12834. type: number;
  12835. /**
  12836. * The data for the physics joint
  12837. */
  12838. jointData: PhysicsJointData;
  12839. private _physicsJoint;
  12840. protected _physicsPlugin: IPhysicsEnginePlugin;
  12841. /**
  12842. * Initializes the physics joint
  12843. * @param type The type of the physics joint
  12844. * @param jointData The data for the physics joint
  12845. */
  12846. constructor(
  12847. /**
  12848. * The type of the physics joint
  12849. */
  12850. type: number,
  12851. /**
  12852. * The data for the physics joint
  12853. */
  12854. jointData: PhysicsJointData);
  12855. /**
  12856. * Gets the physics joint
  12857. */
  12858. /**
  12859. * Sets the physics joint
  12860. */
  12861. physicsJoint: any;
  12862. /**
  12863. * Sets the physics plugin
  12864. */
  12865. physicsPlugin: IPhysicsEnginePlugin;
  12866. /**
  12867. * Execute a function that is physics-plugin specific.
  12868. * @param {Function} func the function that will be executed.
  12869. * It accepts two parameters: the physics world and the physics joint
  12870. */
  12871. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  12872. /**
  12873. * Distance-Joint type
  12874. */
  12875. static DistanceJoint: number;
  12876. /**
  12877. * Hinge-Joint type
  12878. */
  12879. static HingeJoint: number;
  12880. /**
  12881. * Ball-and-Socket joint type
  12882. */
  12883. static BallAndSocketJoint: number;
  12884. /**
  12885. * Wheel-Joint type
  12886. */
  12887. static WheelJoint: number;
  12888. /**
  12889. * Slider-Joint type
  12890. */
  12891. static SliderJoint: number;
  12892. /**
  12893. * Prismatic-Joint type
  12894. */
  12895. static PrismaticJoint: number;
  12896. /**
  12897. * Universal-Joint type
  12898. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  12899. */
  12900. static UniversalJoint: number;
  12901. /**
  12902. * Hinge-Joint 2 type
  12903. */
  12904. static Hinge2Joint: number;
  12905. /**
  12906. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  12907. */
  12908. static PointToPointJoint: number;
  12909. /**
  12910. * Spring-Joint type
  12911. */
  12912. static SpringJoint: number;
  12913. /**
  12914. * Lock-Joint type
  12915. */
  12916. static LockJoint: number;
  12917. }
  12918. /**
  12919. * A class representing a physics distance joint
  12920. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12921. */
  12922. export class DistanceJoint extends PhysicsJoint {
  12923. /**
  12924. *
  12925. * @param jointData The data for the Distance-Joint
  12926. */
  12927. constructor(jointData: DistanceJointData);
  12928. /**
  12929. * Update the predefined distance.
  12930. * @param maxDistance The maximum preferred distance
  12931. * @param minDistance The minimum preferred distance
  12932. */
  12933. updateDistance(maxDistance: number, minDistance?: number): void;
  12934. }
  12935. /**
  12936. * Represents a Motor-Enabled Joint
  12937. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12938. */
  12939. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  12940. /**
  12941. * Initializes the Motor-Enabled Joint
  12942. * @param type The type of the joint
  12943. * @param jointData The physica joint data for the joint
  12944. */
  12945. constructor(type: number, jointData: PhysicsJointData);
  12946. /**
  12947. * Set the motor values.
  12948. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12949. * @param force the force to apply
  12950. * @param maxForce max force for this motor.
  12951. */
  12952. setMotor(force?: number, maxForce?: number): void;
  12953. /**
  12954. * Set the motor's limits.
  12955. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12956. * @param upperLimit The upper limit of the motor
  12957. * @param lowerLimit The lower limit of the motor
  12958. */
  12959. setLimit(upperLimit: number, lowerLimit?: number): void;
  12960. }
  12961. /**
  12962. * This class represents a single physics Hinge-Joint
  12963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12964. */
  12965. export class HingeJoint extends MotorEnabledJoint {
  12966. /**
  12967. * Initializes the Hinge-Joint
  12968. * @param jointData The joint data for the Hinge-Joint
  12969. */
  12970. constructor(jointData: PhysicsJointData);
  12971. /**
  12972. * Set the motor values.
  12973. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12974. * @param {number} force the force to apply
  12975. * @param {number} maxForce max force for this motor.
  12976. */
  12977. setMotor(force?: number, maxForce?: number): void;
  12978. /**
  12979. * Set the motor's limits.
  12980. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12981. * @param upperLimit The upper limit of the motor
  12982. * @param lowerLimit The lower limit of the motor
  12983. */
  12984. setLimit(upperLimit: number, lowerLimit?: number): void;
  12985. }
  12986. /**
  12987. * This class represents a dual hinge physics joint (same as wheel joint)
  12988. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12989. */
  12990. export class Hinge2Joint extends MotorEnabledJoint {
  12991. /**
  12992. * Initializes the Hinge2-Joint
  12993. * @param jointData The joint data for the Hinge2-Joint
  12994. */
  12995. constructor(jointData: PhysicsJointData);
  12996. /**
  12997. * Set the motor values.
  12998. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12999. * @param {number} targetSpeed the speed the motor is to reach
  13000. * @param {number} maxForce max force for this motor.
  13001. * @param {motorIndex} the motor's index, 0 or 1.
  13002. */
  13003. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  13004. /**
  13005. * Set the motor limits.
  13006. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13007. * @param {number} upperLimit the upper limit
  13008. * @param {number} lowerLimit lower limit
  13009. * @param {motorIndex} the motor's index, 0 or 1.
  13010. */
  13011. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13012. }
  13013. /**
  13014. * Interface for a motor enabled joint
  13015. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13016. */
  13017. export interface IMotorEnabledJoint {
  13018. /**
  13019. * Physics joint
  13020. */
  13021. physicsJoint: any;
  13022. /**
  13023. * Sets the motor of the motor-enabled joint
  13024. * @param force The force of the motor
  13025. * @param maxForce The maximum force of the motor
  13026. * @param motorIndex The index of the motor
  13027. */
  13028. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  13029. /**
  13030. * Sets the limit of the motor
  13031. * @param upperLimit The upper limit of the motor
  13032. * @param lowerLimit The lower limit of the motor
  13033. * @param motorIndex The index of the motor
  13034. */
  13035. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13036. }
  13037. /**
  13038. * Joint data for a Distance-Joint
  13039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13040. */
  13041. export interface DistanceJointData extends PhysicsJointData {
  13042. /**
  13043. * Max distance the 2 joint objects can be apart
  13044. */
  13045. maxDistance: number;
  13046. }
  13047. /**
  13048. * Joint data from a spring joint
  13049. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13050. */
  13051. export interface SpringJointData extends PhysicsJointData {
  13052. /**
  13053. * Length of the spring
  13054. */
  13055. length: number;
  13056. /**
  13057. * Stiffness of the spring
  13058. */
  13059. stiffness: number;
  13060. /**
  13061. * Damping of the spring
  13062. */
  13063. damping: number;
  13064. /** this callback will be called when applying the force to the impostors. */
  13065. forceApplicationCallback: () => void;
  13066. }
  13067. }
  13068. declare module BABYLON {
  13069. /**
  13070. * Holds the data for the raycast result
  13071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13072. */
  13073. export class PhysicsRaycastResult {
  13074. private _hasHit;
  13075. private _hitDistance;
  13076. private _hitNormalWorld;
  13077. private _hitPointWorld;
  13078. private _rayFromWorld;
  13079. private _rayToWorld;
  13080. /**
  13081. * Gets if there was a hit
  13082. */
  13083. readonly hasHit: boolean;
  13084. /**
  13085. * Gets the distance from the hit
  13086. */
  13087. readonly hitDistance: number;
  13088. /**
  13089. * Gets the hit normal/direction in the world
  13090. */
  13091. readonly hitNormalWorld: Vector3;
  13092. /**
  13093. * Gets the hit point in the world
  13094. */
  13095. readonly hitPointWorld: Vector3;
  13096. /**
  13097. * Gets the ray "start point" of the ray in the world
  13098. */
  13099. readonly rayFromWorld: Vector3;
  13100. /**
  13101. * Gets the ray "end point" of the ray in the world
  13102. */
  13103. readonly rayToWorld: Vector3;
  13104. /**
  13105. * Sets the hit data (normal & point in world space)
  13106. * @param hitNormalWorld defines the normal in world space
  13107. * @param hitPointWorld defines the point in world space
  13108. */
  13109. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  13110. /**
  13111. * Sets the distance from the start point to the hit point
  13112. * @param distance
  13113. */
  13114. setHitDistance(distance: number): void;
  13115. /**
  13116. * Calculates the distance manually
  13117. */
  13118. calculateHitDistance(): void;
  13119. /**
  13120. * Resets all the values to default
  13121. * @param from The from point on world space
  13122. * @param to The to point on world space
  13123. */
  13124. reset(from?: Vector3, to?: Vector3): void;
  13125. }
  13126. /**
  13127. * Interface for the size containing width and height
  13128. */
  13129. interface IXYZ {
  13130. /**
  13131. * X
  13132. */
  13133. x: number;
  13134. /**
  13135. * Y
  13136. */
  13137. y: number;
  13138. /**
  13139. * Z
  13140. */
  13141. z: number;
  13142. }
  13143. }
  13144. declare module BABYLON {
  13145. /**
  13146. * Interface used to describe a physics joint
  13147. */
  13148. export interface PhysicsImpostorJoint {
  13149. /** Defines the main impostor to which the joint is linked */
  13150. mainImpostor: PhysicsImpostor;
  13151. /** Defines the impostor that is connected to the main impostor using this joint */
  13152. connectedImpostor: PhysicsImpostor;
  13153. /** Defines the joint itself */
  13154. joint: PhysicsJoint;
  13155. }
  13156. /** @hidden */
  13157. export interface IPhysicsEnginePlugin {
  13158. world: any;
  13159. name: string;
  13160. setGravity(gravity: Vector3): void;
  13161. setTimeStep(timeStep: number): void;
  13162. getTimeStep(): number;
  13163. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  13164. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13165. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13166. generatePhysicsBody(impostor: PhysicsImpostor): void;
  13167. removePhysicsBody(impostor: PhysicsImpostor): void;
  13168. generateJoint(joint: PhysicsImpostorJoint): void;
  13169. removeJoint(joint: PhysicsImpostorJoint): void;
  13170. isSupported(): boolean;
  13171. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13172. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13173. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13174. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13175. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13176. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13177. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13178. getBodyMass(impostor: PhysicsImpostor): number;
  13179. getBodyFriction(impostor: PhysicsImpostor): number;
  13180. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  13181. getBodyRestitution(impostor: PhysicsImpostor): number;
  13182. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  13183. getBodyPressure?(impostor: PhysicsImpostor): number;
  13184. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  13185. getBodyStiffness?(impostor: PhysicsImpostor): number;
  13186. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  13187. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  13188. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  13189. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  13190. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  13191. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13192. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13193. sleepBody(impostor: PhysicsImpostor): void;
  13194. wakeUpBody(impostor: PhysicsImpostor): void;
  13195. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13196. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  13197. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  13198. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13199. getRadius(impostor: PhysicsImpostor): number;
  13200. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  13201. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  13202. dispose(): void;
  13203. }
  13204. /**
  13205. * Interface used to define a physics engine
  13206. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  13207. */
  13208. export interface IPhysicsEngine {
  13209. /**
  13210. * Gets the gravity vector used by the simulation
  13211. */
  13212. gravity: Vector3;
  13213. /**
  13214. * Sets the gravity vector used by the simulation
  13215. * @param gravity defines the gravity vector to use
  13216. */
  13217. setGravity(gravity: Vector3): void;
  13218. /**
  13219. * Set the time step of the physics engine.
  13220. * Default is 1/60.
  13221. * To slow it down, enter 1/600 for example.
  13222. * To speed it up, 1/30
  13223. * @param newTimeStep the new timestep to apply to this world.
  13224. */
  13225. setTimeStep(newTimeStep: number): void;
  13226. /**
  13227. * Get the time step of the physics engine.
  13228. * @returns the current time step
  13229. */
  13230. getTimeStep(): number;
  13231. /**
  13232. * Release all resources
  13233. */
  13234. dispose(): void;
  13235. /**
  13236. * Gets the name of the current physics plugin
  13237. * @returns the name of the plugin
  13238. */
  13239. getPhysicsPluginName(): string;
  13240. /**
  13241. * Adding a new impostor for the impostor tracking.
  13242. * This will be done by the impostor itself.
  13243. * @param impostor the impostor to add
  13244. */
  13245. addImpostor(impostor: PhysicsImpostor): void;
  13246. /**
  13247. * Remove an impostor from the engine.
  13248. * This impostor and its mesh will not longer be updated by the physics engine.
  13249. * @param impostor the impostor to remove
  13250. */
  13251. removeImpostor(impostor: PhysicsImpostor): void;
  13252. /**
  13253. * Add a joint to the physics engine
  13254. * @param mainImpostor defines the main impostor to which the joint is added.
  13255. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  13256. * @param joint defines the joint that will connect both impostors.
  13257. */
  13258. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13259. /**
  13260. * Removes a joint from the simulation
  13261. * @param mainImpostor defines the impostor used with the joint
  13262. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  13263. * @param joint defines the joint to remove
  13264. */
  13265. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13266. /**
  13267. * Gets the current plugin used to run the simulation
  13268. * @returns current plugin
  13269. */
  13270. getPhysicsPlugin(): IPhysicsEnginePlugin;
  13271. /**
  13272. * Gets the list of physic impostors
  13273. * @returns an array of PhysicsImpostor
  13274. */
  13275. getImpostors(): Array<PhysicsImpostor>;
  13276. /**
  13277. * Gets the impostor for a physics enabled object
  13278. * @param object defines the object impersonated by the impostor
  13279. * @returns the PhysicsImpostor or null if not found
  13280. */
  13281. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13282. /**
  13283. * Gets the impostor for a physics body object
  13284. * @param body defines physics body used by the impostor
  13285. * @returns the PhysicsImpostor or null if not found
  13286. */
  13287. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  13288. /**
  13289. * Does a raycast in the physics world
  13290. * @param from when should the ray start?
  13291. * @param to when should the ray end?
  13292. * @returns PhysicsRaycastResult
  13293. */
  13294. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13295. /**
  13296. * Called by the scene. No need to call it.
  13297. * @param delta defines the timespam between frames
  13298. */
  13299. _step(delta: number): void;
  13300. }
  13301. }
  13302. declare module BABYLON {
  13303. /**
  13304. * The interface for the physics imposter parameters
  13305. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13306. */
  13307. export interface PhysicsImpostorParameters {
  13308. /**
  13309. * The mass of the physics imposter
  13310. */
  13311. mass: number;
  13312. /**
  13313. * The friction of the physics imposter
  13314. */
  13315. friction?: number;
  13316. /**
  13317. * The coefficient of restitution of the physics imposter
  13318. */
  13319. restitution?: number;
  13320. /**
  13321. * The native options of the physics imposter
  13322. */
  13323. nativeOptions?: any;
  13324. /**
  13325. * Specifies if the parent should be ignored
  13326. */
  13327. ignoreParent?: boolean;
  13328. /**
  13329. * Specifies if bi-directional transformations should be disabled
  13330. */
  13331. disableBidirectionalTransformation?: boolean;
  13332. /**
  13333. * The pressure inside the physics imposter, soft object only
  13334. */
  13335. pressure?: number;
  13336. /**
  13337. * The stiffness the physics imposter, soft object only
  13338. */
  13339. stiffness?: number;
  13340. /**
  13341. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  13342. */
  13343. velocityIterations?: number;
  13344. /**
  13345. * The number of iterations used in maintaining consistent vertex positions, soft object only
  13346. */
  13347. positionIterations?: number;
  13348. /**
  13349. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  13350. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  13351. * Add to fix multiple points
  13352. */
  13353. fixedPoints?: number;
  13354. /**
  13355. * The collision margin around a soft object
  13356. */
  13357. margin?: number;
  13358. /**
  13359. * The collision margin around a soft object
  13360. */
  13361. damping?: number;
  13362. /**
  13363. * The path for a rope based on an extrusion
  13364. */
  13365. path?: any;
  13366. /**
  13367. * The shape of an extrusion used for a rope based on an extrusion
  13368. */
  13369. shape?: any;
  13370. }
  13371. /**
  13372. * Interface for a physics-enabled object
  13373. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13374. */
  13375. export interface IPhysicsEnabledObject {
  13376. /**
  13377. * The position of the physics-enabled object
  13378. */
  13379. position: Vector3;
  13380. /**
  13381. * The rotation of the physics-enabled object
  13382. */
  13383. rotationQuaternion: Nullable<Quaternion>;
  13384. /**
  13385. * The scale of the physics-enabled object
  13386. */
  13387. scaling: Vector3;
  13388. /**
  13389. * The rotation of the physics-enabled object
  13390. */
  13391. rotation?: Vector3;
  13392. /**
  13393. * The parent of the physics-enabled object
  13394. */
  13395. parent?: any;
  13396. /**
  13397. * The bounding info of the physics-enabled object
  13398. * @returns The bounding info of the physics-enabled object
  13399. */
  13400. getBoundingInfo(): BoundingInfo;
  13401. /**
  13402. * Computes the world matrix
  13403. * @param force Specifies if the world matrix should be computed by force
  13404. * @returns A world matrix
  13405. */
  13406. computeWorldMatrix(force: boolean): Matrix;
  13407. /**
  13408. * Gets the world matrix
  13409. * @returns A world matrix
  13410. */
  13411. getWorldMatrix?(): Matrix;
  13412. /**
  13413. * Gets the child meshes
  13414. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  13415. * @returns An array of abstract meshes
  13416. */
  13417. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  13418. /**
  13419. * Gets the vertex data
  13420. * @param kind The type of vertex data
  13421. * @returns A nullable array of numbers, or a float32 array
  13422. */
  13423. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  13424. /**
  13425. * Gets the indices from the mesh
  13426. * @returns A nullable array of index arrays
  13427. */
  13428. getIndices?(): Nullable<IndicesArray>;
  13429. /**
  13430. * Gets the scene from the mesh
  13431. * @returns the indices array or null
  13432. */
  13433. getScene?(): Scene;
  13434. /**
  13435. * Gets the absolute position from the mesh
  13436. * @returns the absolute position
  13437. */
  13438. getAbsolutePosition(): Vector3;
  13439. /**
  13440. * Gets the absolute pivot point from the mesh
  13441. * @returns the absolute pivot point
  13442. */
  13443. getAbsolutePivotPoint(): Vector3;
  13444. /**
  13445. * Rotates the mesh
  13446. * @param axis The axis of rotation
  13447. * @param amount The amount of rotation
  13448. * @param space The space of the rotation
  13449. * @returns The rotation transform node
  13450. */
  13451. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13452. /**
  13453. * Translates the mesh
  13454. * @param axis The axis of translation
  13455. * @param distance The distance of translation
  13456. * @param space The space of the translation
  13457. * @returns The transform node
  13458. */
  13459. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13460. /**
  13461. * Sets the absolute position of the mesh
  13462. * @param absolutePosition The absolute position of the mesh
  13463. * @returns The transform node
  13464. */
  13465. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13466. /**
  13467. * Gets the class name of the mesh
  13468. * @returns The class name
  13469. */
  13470. getClassName(): string;
  13471. }
  13472. /**
  13473. * Represents a physics imposter
  13474. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13475. */
  13476. export class PhysicsImpostor {
  13477. /**
  13478. * The physics-enabled object used as the physics imposter
  13479. */
  13480. object: IPhysicsEnabledObject;
  13481. /**
  13482. * The type of the physics imposter
  13483. */
  13484. type: number;
  13485. private _options;
  13486. private _scene?;
  13487. /**
  13488. * The default object size of the imposter
  13489. */
  13490. static DEFAULT_OBJECT_SIZE: Vector3;
  13491. /**
  13492. * The identity quaternion of the imposter
  13493. */
  13494. static IDENTITY_QUATERNION: Quaternion;
  13495. /** @hidden */
  13496. _pluginData: any;
  13497. private _physicsEngine;
  13498. private _physicsBody;
  13499. private _bodyUpdateRequired;
  13500. private _onBeforePhysicsStepCallbacks;
  13501. private _onAfterPhysicsStepCallbacks;
  13502. /** @hidden */
  13503. _onPhysicsCollideCallbacks: Array<{
  13504. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  13505. otherImpostors: Array<PhysicsImpostor>;
  13506. }>;
  13507. private _deltaPosition;
  13508. private _deltaRotation;
  13509. private _deltaRotationConjugated;
  13510. /** @hidden */
  13511. _isFromLine: boolean;
  13512. private _parent;
  13513. private _isDisposed;
  13514. private static _tmpVecs;
  13515. private static _tmpQuat;
  13516. /**
  13517. * Specifies if the physics imposter is disposed
  13518. */
  13519. readonly isDisposed: boolean;
  13520. /**
  13521. * Gets the mass of the physics imposter
  13522. */
  13523. mass: number;
  13524. /**
  13525. * Gets the coefficient of friction
  13526. */
  13527. /**
  13528. * Sets the coefficient of friction
  13529. */
  13530. friction: number;
  13531. /**
  13532. * Gets the coefficient of restitution
  13533. */
  13534. /**
  13535. * Sets the coefficient of restitution
  13536. */
  13537. restitution: number;
  13538. /**
  13539. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  13540. */
  13541. /**
  13542. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  13543. */
  13544. pressure: number;
  13545. /**
  13546. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13547. */
  13548. /**
  13549. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13550. */
  13551. stiffness: number;
  13552. /**
  13553. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13554. */
  13555. /**
  13556. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13557. */
  13558. velocityIterations: number;
  13559. /**
  13560. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13561. */
  13562. /**
  13563. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13564. */
  13565. positionIterations: number;
  13566. /**
  13567. * The unique id of the physics imposter
  13568. * set by the physics engine when adding this impostor to the array
  13569. */
  13570. uniqueId: number;
  13571. /**
  13572. * @hidden
  13573. */
  13574. soft: boolean;
  13575. /**
  13576. * @hidden
  13577. */
  13578. segments: number;
  13579. private _joints;
  13580. /**
  13581. * Initializes the physics imposter
  13582. * @param object The physics-enabled object used as the physics imposter
  13583. * @param type The type of the physics imposter
  13584. * @param _options The options for the physics imposter
  13585. * @param _scene The Babylon scene
  13586. */
  13587. constructor(
  13588. /**
  13589. * The physics-enabled object used as the physics imposter
  13590. */
  13591. object: IPhysicsEnabledObject,
  13592. /**
  13593. * The type of the physics imposter
  13594. */
  13595. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  13596. /**
  13597. * This function will completly initialize this impostor.
  13598. * It will create a new body - but only if this mesh has no parent.
  13599. * If it has, this impostor will not be used other than to define the impostor
  13600. * of the child mesh.
  13601. * @hidden
  13602. */
  13603. _init(): void;
  13604. private _getPhysicsParent;
  13605. /**
  13606. * Should a new body be generated.
  13607. * @returns boolean specifying if body initialization is required
  13608. */
  13609. isBodyInitRequired(): boolean;
  13610. /**
  13611. * Sets the updated scaling
  13612. * @param updated Specifies if the scaling is updated
  13613. */
  13614. setScalingUpdated(): void;
  13615. /**
  13616. * Force a regeneration of this or the parent's impostor's body.
  13617. * Use under cautious - This will remove all joints already implemented.
  13618. */
  13619. forceUpdate(): void;
  13620. /**
  13621. * Gets the body that holds this impostor. Either its own, or its parent.
  13622. */
  13623. /**
  13624. * Set the physics body. Used mainly by the physics engine/plugin
  13625. */
  13626. physicsBody: any;
  13627. /**
  13628. * Get the parent of the physics imposter
  13629. * @returns Physics imposter or null
  13630. */
  13631. /**
  13632. * Sets the parent of the physics imposter
  13633. */
  13634. parent: Nullable<PhysicsImpostor>;
  13635. /**
  13636. * Resets the update flags
  13637. */
  13638. resetUpdateFlags(): void;
  13639. /**
  13640. * Gets the object extend size
  13641. * @returns the object extend size
  13642. */
  13643. getObjectExtendSize(): Vector3;
  13644. /**
  13645. * Gets the object center
  13646. * @returns The object center
  13647. */
  13648. getObjectCenter(): Vector3;
  13649. /**
  13650. * Get a specific parametes from the options parameter
  13651. * @param paramName The object parameter name
  13652. * @returns The object parameter
  13653. */
  13654. getParam(paramName: string): any;
  13655. /**
  13656. * Sets a specific parameter in the options given to the physics plugin
  13657. * @param paramName The parameter name
  13658. * @param value The value of the parameter
  13659. */
  13660. setParam(paramName: string, value: number): void;
  13661. /**
  13662. * Specifically change the body's mass option. Won't recreate the physics body object
  13663. * @param mass The mass of the physics imposter
  13664. */
  13665. setMass(mass: number): void;
  13666. /**
  13667. * Gets the linear velocity
  13668. * @returns linear velocity or null
  13669. */
  13670. getLinearVelocity(): Nullable<Vector3>;
  13671. /**
  13672. * Sets the linear velocity
  13673. * @param velocity linear velocity or null
  13674. */
  13675. setLinearVelocity(velocity: Nullable<Vector3>): void;
  13676. /**
  13677. * Gets the angular velocity
  13678. * @returns angular velocity or null
  13679. */
  13680. getAngularVelocity(): Nullable<Vector3>;
  13681. /**
  13682. * Sets the angular velocity
  13683. * @param velocity The velocity or null
  13684. */
  13685. setAngularVelocity(velocity: Nullable<Vector3>): void;
  13686. /**
  13687. * Execute a function with the physics plugin native code
  13688. * Provide a function the will have two variables - the world object and the physics body object
  13689. * @param func The function to execute with the physics plugin native code
  13690. */
  13691. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  13692. /**
  13693. * Register a function that will be executed before the physics world is stepping forward
  13694. * @param func The function to execute before the physics world is stepped forward
  13695. */
  13696. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13697. /**
  13698. * Unregister a function that will be executed before the physics world is stepping forward
  13699. * @param func The function to execute before the physics world is stepped forward
  13700. */
  13701. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13702. /**
  13703. * Register a function that will be executed after the physics step
  13704. * @param func The function to execute after physics step
  13705. */
  13706. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13707. /**
  13708. * Unregisters a function that will be executed after the physics step
  13709. * @param func The function to execute after physics step
  13710. */
  13711. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13712. /**
  13713. * register a function that will be executed when this impostor collides against a different body
  13714. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  13715. * @param func Callback that is executed on collision
  13716. */
  13717. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  13718. /**
  13719. * Unregisters the physics imposter on contact
  13720. * @param collideAgainst The physics object to collide against
  13721. * @param func Callback to execute on collision
  13722. */
  13723. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  13724. private _tmpQuat;
  13725. private _tmpQuat2;
  13726. /**
  13727. * Get the parent rotation
  13728. * @returns The parent rotation
  13729. */
  13730. getParentsRotation(): Quaternion;
  13731. /**
  13732. * this function is executed by the physics engine.
  13733. */
  13734. beforeStep: () => void;
  13735. /**
  13736. * this function is executed by the physics engine
  13737. */
  13738. afterStep: () => void;
  13739. /**
  13740. * Legacy collision detection event support
  13741. */
  13742. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  13743. /**
  13744. * event and body object due to cannon's event-based architecture.
  13745. */
  13746. onCollide: (e: {
  13747. body: any;
  13748. }) => void;
  13749. /**
  13750. * Apply a force
  13751. * @param force The force to apply
  13752. * @param contactPoint The contact point for the force
  13753. * @returns The physics imposter
  13754. */
  13755. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13756. /**
  13757. * Apply an impulse
  13758. * @param force The impulse force
  13759. * @param contactPoint The contact point for the impulse force
  13760. * @returns The physics imposter
  13761. */
  13762. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13763. /**
  13764. * A help function to create a joint
  13765. * @param otherImpostor A physics imposter used to create a joint
  13766. * @param jointType The type of joint
  13767. * @param jointData The data for the joint
  13768. * @returns The physics imposter
  13769. */
  13770. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  13771. /**
  13772. * Add a joint to this impostor with a different impostor
  13773. * @param otherImpostor A physics imposter used to add a joint
  13774. * @param joint The joint to add
  13775. * @returns The physics imposter
  13776. */
  13777. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  13778. /**
  13779. * Add an anchor to a cloth impostor
  13780. * @param otherImpostor rigid impostor to anchor to
  13781. * @param width ratio across width from 0 to 1
  13782. * @param height ratio up height from 0 to 1
  13783. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  13784. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  13785. * @returns impostor the soft imposter
  13786. */
  13787. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13788. /**
  13789. * Add a hook to a rope impostor
  13790. * @param otherImpostor rigid impostor to anchor to
  13791. * @param length ratio across rope from 0 to 1
  13792. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  13793. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  13794. * @returns impostor the rope imposter
  13795. */
  13796. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13797. /**
  13798. * Will keep this body still, in a sleep mode.
  13799. * @returns the physics imposter
  13800. */
  13801. sleep(): PhysicsImpostor;
  13802. /**
  13803. * Wake the body up.
  13804. * @returns The physics imposter
  13805. */
  13806. wakeUp(): PhysicsImpostor;
  13807. /**
  13808. * Clones the physics imposter
  13809. * @param newObject The physics imposter clones to this physics-enabled object
  13810. * @returns A nullable physics imposter
  13811. */
  13812. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13813. /**
  13814. * Disposes the physics imposter
  13815. */
  13816. dispose(): void;
  13817. /**
  13818. * Sets the delta position
  13819. * @param position The delta position amount
  13820. */
  13821. setDeltaPosition(position: Vector3): void;
  13822. /**
  13823. * Sets the delta rotation
  13824. * @param rotation The delta rotation amount
  13825. */
  13826. setDeltaRotation(rotation: Quaternion): void;
  13827. /**
  13828. * Gets the box size of the physics imposter and stores the result in the input parameter
  13829. * @param result Stores the box size
  13830. * @returns The physics imposter
  13831. */
  13832. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  13833. /**
  13834. * Gets the radius of the physics imposter
  13835. * @returns Radius of the physics imposter
  13836. */
  13837. getRadius(): number;
  13838. /**
  13839. * Sync a bone with this impostor
  13840. * @param bone The bone to sync to the impostor.
  13841. * @param boneMesh The mesh that the bone is influencing.
  13842. * @param jointPivot The pivot of the joint / bone in local space.
  13843. * @param distToJoint Optional distance from the impostor to the joint.
  13844. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  13845. */
  13846. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  13847. /**
  13848. * Sync impostor to a bone
  13849. * @param bone The bone that the impostor will be synced to.
  13850. * @param boneMesh The mesh that the bone is influencing.
  13851. * @param jointPivot The pivot of the joint / bone in local space.
  13852. * @param distToJoint Optional distance from the impostor to the joint.
  13853. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  13854. * @param boneAxis Optional vector3 axis the bone is aligned with
  13855. */
  13856. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  13857. /**
  13858. * No-Imposter type
  13859. */
  13860. static NoImpostor: number;
  13861. /**
  13862. * Sphere-Imposter type
  13863. */
  13864. static SphereImpostor: number;
  13865. /**
  13866. * Box-Imposter type
  13867. */
  13868. static BoxImpostor: number;
  13869. /**
  13870. * Plane-Imposter type
  13871. */
  13872. static PlaneImpostor: number;
  13873. /**
  13874. * Mesh-imposter type
  13875. */
  13876. static MeshImpostor: number;
  13877. /**
  13878. * Capsule-Impostor type (Ammo.js plugin only)
  13879. */
  13880. static CapsuleImpostor: number;
  13881. /**
  13882. * Cylinder-Imposter type
  13883. */
  13884. static CylinderImpostor: number;
  13885. /**
  13886. * Particle-Imposter type
  13887. */
  13888. static ParticleImpostor: number;
  13889. /**
  13890. * Heightmap-Imposter type
  13891. */
  13892. static HeightmapImpostor: number;
  13893. /**
  13894. * ConvexHull-Impostor type (Ammo.js plugin only)
  13895. */
  13896. static ConvexHullImpostor: number;
  13897. /**
  13898. * Rope-Imposter type
  13899. */
  13900. static RopeImpostor: number;
  13901. /**
  13902. * Cloth-Imposter type
  13903. */
  13904. static ClothImpostor: number;
  13905. /**
  13906. * Softbody-Imposter type
  13907. */
  13908. static SoftbodyImpostor: number;
  13909. }
  13910. }
  13911. declare module BABYLON {
  13912. /**
  13913. * @hidden
  13914. **/
  13915. export class _CreationDataStorage {
  13916. closePath?: boolean;
  13917. closeArray?: boolean;
  13918. idx: number[];
  13919. dashSize: number;
  13920. gapSize: number;
  13921. path3D: Path3D;
  13922. pathArray: Vector3[][];
  13923. arc: number;
  13924. radius: number;
  13925. cap: number;
  13926. tessellation: number;
  13927. }
  13928. /**
  13929. * @hidden
  13930. **/
  13931. class _InstanceDataStorage {
  13932. visibleInstances: any;
  13933. batchCache: _InstancesBatch;
  13934. instancesBufferSize: number;
  13935. instancesBuffer: Nullable<Buffer>;
  13936. instancesData: Float32Array;
  13937. overridenInstanceCount: number;
  13938. isFrozen: boolean;
  13939. previousBatch: Nullable<_InstancesBatch>;
  13940. hardwareInstancedRendering: boolean;
  13941. sideOrientation: number;
  13942. }
  13943. /**
  13944. * @hidden
  13945. **/
  13946. export class _InstancesBatch {
  13947. mustReturn: boolean;
  13948. visibleInstances: Nullable<InstancedMesh[]>[];
  13949. renderSelf: boolean[];
  13950. hardwareInstancedRendering: boolean[];
  13951. }
  13952. /**
  13953. * Class used to represent renderable models
  13954. */
  13955. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  13956. /**
  13957. * Mesh side orientation : usually the external or front surface
  13958. */
  13959. static readonly FRONTSIDE: number;
  13960. /**
  13961. * Mesh side orientation : usually the internal or back surface
  13962. */
  13963. static readonly BACKSIDE: number;
  13964. /**
  13965. * Mesh side orientation : both internal and external or front and back surfaces
  13966. */
  13967. static readonly DOUBLESIDE: number;
  13968. /**
  13969. * Mesh side orientation : by default, `FRONTSIDE`
  13970. */
  13971. static readonly DEFAULTSIDE: number;
  13972. /**
  13973. * Mesh cap setting : no cap
  13974. */
  13975. static readonly NO_CAP: number;
  13976. /**
  13977. * Mesh cap setting : one cap at the beginning of the mesh
  13978. */
  13979. static readonly CAP_START: number;
  13980. /**
  13981. * Mesh cap setting : one cap at the end of the mesh
  13982. */
  13983. static readonly CAP_END: number;
  13984. /**
  13985. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  13986. */
  13987. static readonly CAP_ALL: number;
  13988. /**
  13989. * Mesh pattern setting : no flip or rotate
  13990. */
  13991. static readonly NO_FLIP: number;
  13992. /**
  13993. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  13994. */
  13995. static readonly FLIP_TILE: number;
  13996. /**
  13997. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  13998. */
  13999. static readonly ROTATE_TILE: number;
  14000. /**
  14001. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  14002. */
  14003. static readonly FLIP_ROW: number;
  14004. /**
  14005. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  14006. */
  14007. static readonly ROTATE_ROW: number;
  14008. /**
  14009. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  14010. */
  14011. static readonly FLIP_N_ROTATE_TILE: number;
  14012. /**
  14013. * Mesh pattern setting : rotate pattern and rotate
  14014. */
  14015. static readonly FLIP_N_ROTATE_ROW: number;
  14016. /**
  14017. * Mesh tile positioning : part tiles same on left/right or top/bottom
  14018. */
  14019. static readonly CENTER: number;
  14020. /**
  14021. * Mesh tile positioning : part tiles on left
  14022. */
  14023. static readonly LEFT: number;
  14024. /**
  14025. * Mesh tile positioning : part tiles on right
  14026. */
  14027. static readonly RIGHT: number;
  14028. /**
  14029. * Mesh tile positioning : part tiles on top
  14030. */
  14031. static readonly TOP: number;
  14032. /**
  14033. * Mesh tile positioning : part tiles on bottom
  14034. */
  14035. static readonly BOTTOM: number;
  14036. /**
  14037. * Gets the default side orientation.
  14038. * @param orientation the orientation to value to attempt to get
  14039. * @returns the default orientation
  14040. * @hidden
  14041. */
  14042. static _GetDefaultSideOrientation(orientation?: number): number;
  14043. private _internalMeshDataInfo;
  14044. /**
  14045. * An event triggered before rendering the mesh
  14046. */
  14047. readonly onBeforeRenderObservable: Observable<Mesh>;
  14048. /**
  14049. * An event triggered before binding the mesh
  14050. */
  14051. readonly onBeforeBindObservable: Observable<Mesh>;
  14052. /**
  14053. * An event triggered after rendering the mesh
  14054. */
  14055. readonly onAfterRenderObservable: Observable<Mesh>;
  14056. /**
  14057. * An event triggered before drawing the mesh
  14058. */
  14059. readonly onBeforeDrawObservable: Observable<Mesh>;
  14060. private _onBeforeDrawObserver;
  14061. /**
  14062. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  14063. */
  14064. onBeforeDraw: () => void;
  14065. /**
  14066. * Gets the delay loading state of the mesh (when delay loading is turned on)
  14067. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  14068. */
  14069. delayLoadState: number;
  14070. /**
  14071. * Gets the list of instances created from this mesh
  14072. * it is not supposed to be modified manually.
  14073. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  14074. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14075. */
  14076. instances: InstancedMesh[];
  14077. /**
  14078. * Gets the file containing delay loading data for this mesh
  14079. */
  14080. delayLoadingFile: string;
  14081. /** @hidden */
  14082. _binaryInfo: any;
  14083. /**
  14084. * User defined function used to change how LOD level selection is done
  14085. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  14086. */
  14087. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  14088. /**
  14089. * Gets or sets the morph target manager
  14090. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  14091. */
  14092. morphTargetManager: Nullable<MorphTargetManager>;
  14093. /** @hidden */
  14094. _creationDataStorage: Nullable<_CreationDataStorage>;
  14095. /** @hidden */
  14096. _geometry: Nullable<Geometry>;
  14097. /** @hidden */
  14098. _delayInfo: Array<string>;
  14099. /** @hidden */
  14100. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  14101. /** @hidden */
  14102. _instanceDataStorage: _InstanceDataStorage;
  14103. private _effectiveMaterial;
  14104. /** @hidden */
  14105. _shouldGenerateFlatShading: boolean;
  14106. /** @hidden */
  14107. _originalBuilderSideOrientation: number;
  14108. /**
  14109. * Use this property to change the original side orientation defined at construction time
  14110. */
  14111. overrideMaterialSideOrientation: Nullable<number>;
  14112. /**
  14113. * Gets the source mesh (the one used to clone this one from)
  14114. */
  14115. readonly source: Nullable<Mesh>;
  14116. /**
  14117. * Gets or sets a boolean indicating that this mesh does not use index buffer
  14118. */
  14119. isUnIndexed: boolean;
  14120. /**
  14121. * @constructor
  14122. * @param name The value used by scene.getMeshByName() to do a lookup.
  14123. * @param scene The scene to add this mesh to.
  14124. * @param parent The parent of this mesh, if it has one
  14125. * @param source An optional Mesh from which geometry is shared, cloned.
  14126. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  14127. * When false, achieved by calling a clone(), also passing False.
  14128. * This will make creation of children, recursive.
  14129. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  14130. */
  14131. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  14132. /**
  14133. * Gets the class name
  14134. * @returns the string "Mesh".
  14135. */
  14136. getClassName(): string;
  14137. /** @hidden */
  14138. readonly _isMesh: boolean;
  14139. /**
  14140. * Returns a description of this mesh
  14141. * @param fullDetails define if full details about this mesh must be used
  14142. * @returns a descriptive string representing this mesh
  14143. */
  14144. toString(fullDetails?: boolean): string;
  14145. /** @hidden */
  14146. _unBindEffect(): void;
  14147. /**
  14148. * Gets a boolean indicating if this mesh has LOD
  14149. */
  14150. readonly hasLODLevels: boolean;
  14151. /**
  14152. * Gets the list of MeshLODLevel associated with the current mesh
  14153. * @returns an array of MeshLODLevel
  14154. */
  14155. getLODLevels(): MeshLODLevel[];
  14156. private _sortLODLevels;
  14157. /**
  14158. * Add a mesh as LOD level triggered at the given distance.
  14159. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14160. * @param distance The distance from the center of the object to show this level
  14161. * @param mesh The mesh to be added as LOD level (can be null)
  14162. * @return This mesh (for chaining)
  14163. */
  14164. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  14165. /**
  14166. * Returns the LOD level mesh at the passed distance or null if not found.
  14167. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14168. * @param distance The distance from the center of the object to show this level
  14169. * @returns a Mesh or `null`
  14170. */
  14171. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  14172. /**
  14173. * Remove a mesh from the LOD array
  14174. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14175. * @param mesh defines the mesh to be removed
  14176. * @return This mesh (for chaining)
  14177. */
  14178. removeLODLevel(mesh: Mesh): Mesh;
  14179. /**
  14180. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  14181. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14182. * @param camera defines the camera to use to compute distance
  14183. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  14184. * @return This mesh (for chaining)
  14185. */
  14186. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  14187. /**
  14188. * Gets the mesh internal Geometry object
  14189. */
  14190. readonly geometry: Nullable<Geometry>;
  14191. /**
  14192. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  14193. * @returns the total number of vertices
  14194. */
  14195. getTotalVertices(): number;
  14196. /**
  14197. * Returns the content of an associated vertex buffer
  14198. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14199. * - VertexBuffer.PositionKind
  14200. * - VertexBuffer.UVKind
  14201. * - VertexBuffer.UV2Kind
  14202. * - VertexBuffer.UV3Kind
  14203. * - VertexBuffer.UV4Kind
  14204. * - VertexBuffer.UV5Kind
  14205. * - VertexBuffer.UV6Kind
  14206. * - VertexBuffer.ColorKind
  14207. * - VertexBuffer.MatricesIndicesKind
  14208. * - VertexBuffer.MatricesIndicesExtraKind
  14209. * - VertexBuffer.MatricesWeightsKind
  14210. * - VertexBuffer.MatricesWeightsExtraKind
  14211. * @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
  14212. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  14213. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  14214. */
  14215. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14216. /**
  14217. * Returns the mesh VertexBuffer object from the requested `kind`
  14218. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14219. * - VertexBuffer.PositionKind
  14220. * - VertexBuffer.NormalKind
  14221. * - VertexBuffer.UVKind
  14222. * - VertexBuffer.UV2Kind
  14223. * - VertexBuffer.UV3Kind
  14224. * - VertexBuffer.UV4Kind
  14225. * - VertexBuffer.UV5Kind
  14226. * - VertexBuffer.UV6Kind
  14227. * - VertexBuffer.ColorKind
  14228. * - VertexBuffer.MatricesIndicesKind
  14229. * - VertexBuffer.MatricesIndicesExtraKind
  14230. * - VertexBuffer.MatricesWeightsKind
  14231. * - VertexBuffer.MatricesWeightsExtraKind
  14232. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  14233. */
  14234. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14235. /**
  14236. * Tests if a specific vertex buffer is associated with this mesh
  14237. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14238. * - VertexBuffer.PositionKind
  14239. * - VertexBuffer.NormalKind
  14240. * - VertexBuffer.UVKind
  14241. * - VertexBuffer.UV2Kind
  14242. * - VertexBuffer.UV3Kind
  14243. * - VertexBuffer.UV4Kind
  14244. * - VertexBuffer.UV5Kind
  14245. * - VertexBuffer.UV6Kind
  14246. * - VertexBuffer.ColorKind
  14247. * - VertexBuffer.MatricesIndicesKind
  14248. * - VertexBuffer.MatricesIndicesExtraKind
  14249. * - VertexBuffer.MatricesWeightsKind
  14250. * - VertexBuffer.MatricesWeightsExtraKind
  14251. * @returns a boolean
  14252. */
  14253. isVerticesDataPresent(kind: string): boolean;
  14254. /**
  14255. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  14256. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14257. * - VertexBuffer.PositionKind
  14258. * - VertexBuffer.UVKind
  14259. * - VertexBuffer.UV2Kind
  14260. * - VertexBuffer.UV3Kind
  14261. * - VertexBuffer.UV4Kind
  14262. * - VertexBuffer.UV5Kind
  14263. * - VertexBuffer.UV6Kind
  14264. * - VertexBuffer.ColorKind
  14265. * - VertexBuffer.MatricesIndicesKind
  14266. * - VertexBuffer.MatricesIndicesExtraKind
  14267. * - VertexBuffer.MatricesWeightsKind
  14268. * - VertexBuffer.MatricesWeightsExtraKind
  14269. * @returns a boolean
  14270. */
  14271. isVertexBufferUpdatable(kind: string): boolean;
  14272. /**
  14273. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  14274. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14275. * - VertexBuffer.PositionKind
  14276. * - VertexBuffer.NormalKind
  14277. * - VertexBuffer.UVKind
  14278. * - VertexBuffer.UV2Kind
  14279. * - VertexBuffer.UV3Kind
  14280. * - VertexBuffer.UV4Kind
  14281. * - VertexBuffer.UV5Kind
  14282. * - VertexBuffer.UV6Kind
  14283. * - VertexBuffer.ColorKind
  14284. * - VertexBuffer.MatricesIndicesKind
  14285. * - VertexBuffer.MatricesIndicesExtraKind
  14286. * - VertexBuffer.MatricesWeightsKind
  14287. * - VertexBuffer.MatricesWeightsExtraKind
  14288. * @returns an array of strings
  14289. */
  14290. getVerticesDataKinds(): string[];
  14291. /**
  14292. * Returns a positive integer : the total number of indices in this mesh geometry.
  14293. * @returns the numner of indices or zero if the mesh has no geometry.
  14294. */
  14295. getTotalIndices(): number;
  14296. /**
  14297. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  14298. * @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.
  14299. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  14300. * @returns the indices array or an empty array if the mesh has no geometry
  14301. */
  14302. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  14303. readonly isBlocked: boolean;
  14304. /**
  14305. * Determine if the current mesh is ready to be rendered
  14306. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14307. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  14308. * @returns true if all associated assets are ready (material, textures, shaders)
  14309. */
  14310. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  14311. /**
  14312. * 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.
  14313. */
  14314. readonly areNormalsFrozen: boolean;
  14315. /**
  14316. * 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.
  14317. * @returns the current mesh
  14318. */
  14319. freezeNormals(): Mesh;
  14320. /**
  14321. * 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
  14322. * @returns the current mesh
  14323. */
  14324. unfreezeNormals(): Mesh;
  14325. /**
  14326. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  14327. */
  14328. overridenInstanceCount: number;
  14329. /** @hidden */
  14330. _preActivate(): Mesh;
  14331. /** @hidden */
  14332. _preActivateForIntermediateRendering(renderId: number): Mesh;
  14333. /** @hidden */
  14334. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  14335. /**
  14336. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  14337. * This means the mesh underlying bounding box and sphere are recomputed.
  14338. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  14339. * @returns the current mesh
  14340. */
  14341. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  14342. /** @hidden */
  14343. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  14344. /**
  14345. * This function will subdivide the mesh into multiple submeshes
  14346. * @param count defines the expected number of submeshes
  14347. */
  14348. subdivide(count: number): void;
  14349. /**
  14350. * Copy a FloatArray into a specific associated vertex buffer
  14351. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14352. * - VertexBuffer.PositionKind
  14353. * - VertexBuffer.UVKind
  14354. * - VertexBuffer.UV2Kind
  14355. * - VertexBuffer.UV3Kind
  14356. * - VertexBuffer.UV4Kind
  14357. * - VertexBuffer.UV5Kind
  14358. * - VertexBuffer.UV6Kind
  14359. * - VertexBuffer.ColorKind
  14360. * - VertexBuffer.MatricesIndicesKind
  14361. * - VertexBuffer.MatricesIndicesExtraKind
  14362. * - VertexBuffer.MatricesWeightsKind
  14363. * - VertexBuffer.MatricesWeightsExtraKind
  14364. * @param data defines the data source
  14365. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14366. * @param stride defines the data stride size (can be null)
  14367. * @returns the current mesh
  14368. */
  14369. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14370. /**
  14371. * Flags an associated vertex buffer as updatable
  14372. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  14373. * - VertexBuffer.PositionKind
  14374. * - VertexBuffer.UVKind
  14375. * - VertexBuffer.UV2Kind
  14376. * - VertexBuffer.UV3Kind
  14377. * - VertexBuffer.UV4Kind
  14378. * - VertexBuffer.UV5Kind
  14379. * - VertexBuffer.UV6Kind
  14380. * - VertexBuffer.ColorKind
  14381. * - VertexBuffer.MatricesIndicesKind
  14382. * - VertexBuffer.MatricesIndicesExtraKind
  14383. * - VertexBuffer.MatricesWeightsKind
  14384. * - VertexBuffer.MatricesWeightsExtraKind
  14385. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14386. */
  14387. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  14388. /**
  14389. * Sets the mesh global Vertex Buffer
  14390. * @param buffer defines the buffer to use
  14391. * @returns the current mesh
  14392. */
  14393. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  14394. /**
  14395. * Update a specific associated vertex buffer
  14396. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14397. * - VertexBuffer.PositionKind
  14398. * - VertexBuffer.UVKind
  14399. * - VertexBuffer.UV2Kind
  14400. * - VertexBuffer.UV3Kind
  14401. * - VertexBuffer.UV4Kind
  14402. * - VertexBuffer.UV5Kind
  14403. * - VertexBuffer.UV6Kind
  14404. * - VertexBuffer.ColorKind
  14405. * - VertexBuffer.MatricesIndicesKind
  14406. * - VertexBuffer.MatricesIndicesExtraKind
  14407. * - VertexBuffer.MatricesWeightsKind
  14408. * - VertexBuffer.MatricesWeightsExtraKind
  14409. * @param data defines the data source
  14410. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  14411. * @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)
  14412. * @returns the current mesh
  14413. */
  14414. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14415. /**
  14416. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  14417. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  14418. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  14419. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  14420. * @returns the current mesh
  14421. */
  14422. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  14423. /**
  14424. * Creates a un-shared specific occurence of the geometry for the mesh.
  14425. * @returns the current mesh
  14426. */
  14427. makeGeometryUnique(): Mesh;
  14428. /**
  14429. * Set the index buffer of this mesh
  14430. * @param indices defines the source data
  14431. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  14432. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  14433. * @returns the current mesh
  14434. */
  14435. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  14436. /**
  14437. * Update the current index buffer
  14438. * @param indices defines the source data
  14439. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  14440. * @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)
  14441. * @returns the current mesh
  14442. */
  14443. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  14444. /**
  14445. * Invert the geometry to move from a right handed system to a left handed one.
  14446. * @returns the current mesh
  14447. */
  14448. toLeftHanded(): Mesh;
  14449. /** @hidden */
  14450. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  14451. /** @hidden */
  14452. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  14453. /**
  14454. * Registers for this mesh a javascript function called just before the rendering process
  14455. * @param func defines the function to call before rendering this mesh
  14456. * @returns the current mesh
  14457. */
  14458. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14459. /**
  14460. * Disposes a previously registered javascript function called before the rendering
  14461. * @param func defines the function to remove
  14462. * @returns the current mesh
  14463. */
  14464. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14465. /**
  14466. * Registers for this mesh a javascript function called just after the rendering is complete
  14467. * @param func defines the function to call after rendering this mesh
  14468. * @returns the current mesh
  14469. */
  14470. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14471. /**
  14472. * Disposes a previously registered javascript function called after the rendering.
  14473. * @param func defines the function to remove
  14474. * @returns the current mesh
  14475. */
  14476. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14477. /** @hidden */
  14478. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  14479. /** @hidden */
  14480. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  14481. /** @hidden */
  14482. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  14483. /** @hidden */
  14484. _rebuild(): void;
  14485. /** @hidden */
  14486. _freeze(): void;
  14487. /** @hidden */
  14488. _unFreeze(): void;
  14489. /**
  14490. * 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
  14491. * @param subMesh defines the subMesh to render
  14492. * @param enableAlphaMode defines if alpha mode can be changed
  14493. * @returns the current mesh
  14494. */
  14495. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  14496. private _onBeforeDraw;
  14497. /**
  14498. * Renormalize the mesh and patch it up if there are no weights
  14499. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  14500. * However in the case of zero weights then we set just a single influence to 1.
  14501. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  14502. */
  14503. cleanMatrixWeights(): void;
  14504. private normalizeSkinFourWeights;
  14505. private normalizeSkinWeightsAndExtra;
  14506. /**
  14507. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  14508. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  14509. * the user know there was an issue with importing the mesh
  14510. * @returns a validation object with skinned, valid and report string
  14511. */
  14512. validateSkinning(): {
  14513. skinned: boolean;
  14514. valid: boolean;
  14515. report: string;
  14516. };
  14517. /** @hidden */
  14518. _checkDelayState(): Mesh;
  14519. private _queueLoad;
  14520. /**
  14521. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  14522. * A mesh is in the frustum if its bounding box intersects the frustum
  14523. * @param frustumPlanes defines the frustum to test
  14524. * @returns true if the mesh is in the frustum planes
  14525. */
  14526. isInFrustum(frustumPlanes: Plane[]): boolean;
  14527. /**
  14528. * Sets the mesh material by the material or multiMaterial `id` property
  14529. * @param id is a string identifying the material or the multiMaterial
  14530. * @returns the current mesh
  14531. */
  14532. setMaterialByID(id: string): Mesh;
  14533. /**
  14534. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  14535. * @returns an array of IAnimatable
  14536. */
  14537. getAnimatables(): IAnimatable[];
  14538. /**
  14539. * Modifies the mesh geometry according to the passed transformation matrix.
  14540. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  14541. * The mesh normals are modified using the same transformation.
  14542. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14543. * @param transform defines the transform matrix to use
  14544. * @see http://doc.babylonjs.com/resources/baking_transformations
  14545. * @returns the current mesh
  14546. */
  14547. bakeTransformIntoVertices(transform: Matrix): Mesh;
  14548. /**
  14549. * Modifies the mesh geometry according to its own current World Matrix.
  14550. * The mesh World Matrix is then reset.
  14551. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  14552. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14553. * @see http://doc.babylonjs.com/resources/baking_transformations
  14554. * @returns the current mesh
  14555. */
  14556. bakeCurrentTransformIntoVertices(): Mesh;
  14557. /** @hidden */
  14558. readonly _positions: Nullable<Vector3[]>;
  14559. /** @hidden */
  14560. _resetPointsArrayCache(): Mesh;
  14561. /** @hidden */
  14562. _generatePointsArray(): boolean;
  14563. /**
  14564. * Returns a new Mesh object generated from the current mesh properties.
  14565. * This method must not get confused with createInstance()
  14566. * @param name is a string, the name given to the new mesh
  14567. * @param newParent can be any Node object (default `null`)
  14568. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  14569. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  14570. * @returns a new mesh
  14571. */
  14572. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  14573. /**
  14574. * Releases resources associated with this mesh.
  14575. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14576. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14577. */
  14578. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14579. /**
  14580. * Modifies the mesh geometry according to a displacement map.
  14581. * 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.
  14582. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14583. * @param url is a string, the URL from the image file is to be downloaded.
  14584. * @param minHeight is the lower limit of the displacement.
  14585. * @param maxHeight is the upper limit of the displacement.
  14586. * @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.
  14587. * @param uvOffset is an optional vector2 used to offset UV.
  14588. * @param uvScale is an optional vector2 used to scale UV.
  14589. * @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.
  14590. * @returns the Mesh.
  14591. */
  14592. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14593. /**
  14594. * Modifies the mesh geometry according to a displacementMap buffer.
  14595. * 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.
  14596. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14597. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  14598. * @param heightMapWidth is the width of the buffer image.
  14599. * @param heightMapHeight is the height of the buffer image.
  14600. * @param minHeight is the lower limit of the displacement.
  14601. * @param maxHeight is the upper limit of the displacement.
  14602. * @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.
  14603. * @param uvOffset is an optional vector2 used to offset UV.
  14604. * @param uvScale is an optional vector2 used to scale UV.
  14605. * @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.
  14606. * @returns the Mesh.
  14607. */
  14608. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14609. /**
  14610. * Modify the mesh to get a flat shading rendering.
  14611. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  14612. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  14613. * @returns current mesh
  14614. */
  14615. convertToFlatShadedMesh(): Mesh;
  14616. /**
  14617. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  14618. * In other words, more vertices, no more indices and a single bigger VBO.
  14619. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  14620. * @returns current mesh
  14621. */
  14622. convertToUnIndexedMesh(): Mesh;
  14623. /**
  14624. * Inverses facet orientations.
  14625. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14626. * @param flipNormals will also inverts the normals
  14627. * @returns current mesh
  14628. */
  14629. flipFaces(flipNormals?: boolean): Mesh;
  14630. /**
  14631. * Increase the number of facets and hence vertices in a mesh
  14632. * Vertex normals are interpolated from existing vertex normals
  14633. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14634. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  14635. */
  14636. increaseVertices(numberPerEdge: number): void;
  14637. /**
  14638. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  14639. * This will undo any application of covertToFlatShadedMesh
  14640. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14641. */
  14642. forceSharedVertices(): void;
  14643. /** @hidden */
  14644. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  14645. /** @hidden */
  14646. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  14647. /**
  14648. * Creates a new InstancedMesh object from the mesh model.
  14649. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14650. * @param name defines the name of the new instance
  14651. * @returns a new InstancedMesh
  14652. */
  14653. createInstance(name: string): InstancedMesh;
  14654. /**
  14655. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  14656. * After this call, all the mesh instances have the same submeshes than the current mesh.
  14657. * @returns the current mesh
  14658. */
  14659. synchronizeInstances(): Mesh;
  14660. /**
  14661. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  14662. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  14663. * This should be used together with the simplification to avoid disappearing triangles.
  14664. * @param successCallback an optional success callback to be called after the optimization finished.
  14665. * @returns the current mesh
  14666. */
  14667. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  14668. /**
  14669. * Serialize current mesh
  14670. * @param serializationObject defines the object which will receive the serialization data
  14671. */
  14672. serialize(serializationObject: any): void;
  14673. /** @hidden */
  14674. _syncGeometryWithMorphTargetManager(): void;
  14675. /** @hidden */
  14676. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  14677. /**
  14678. * Returns a new Mesh object parsed from the source provided.
  14679. * @param parsedMesh is the source
  14680. * @param scene defines the hosting scene
  14681. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  14682. * @returns a new Mesh
  14683. */
  14684. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  14685. /**
  14686. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  14687. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14688. * @param name defines the name of the mesh to create
  14689. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  14690. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  14691. * @param closePath creates a seam between the first and the last points of each path of the path array
  14692. * @param offset is taken in account only if the `pathArray` is containing a single path
  14693. * @param scene defines the hosting scene
  14694. * @param updatable defines if the mesh must be flagged as updatable
  14695. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14696. * @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)
  14697. * @returns a new Mesh
  14698. */
  14699. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14700. /**
  14701. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  14702. * @param name defines the name of the mesh to create
  14703. * @param radius sets the radius size (float) of the polygon (default 0.5)
  14704. * @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
  14705. * @param scene defines the hosting scene
  14706. * @param updatable defines if the mesh must be flagged as updatable
  14707. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14708. * @returns a new Mesh
  14709. */
  14710. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14711. /**
  14712. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  14713. * @param name defines the name of the mesh to create
  14714. * @param size sets the size (float) of each box side (default 1)
  14715. * @param scene defines the hosting scene
  14716. * @param updatable defines if the mesh must be flagged as updatable
  14717. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14718. * @returns a new Mesh
  14719. */
  14720. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14721. /**
  14722. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  14723. * @param name defines the name of the mesh to create
  14724. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14725. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14726. * @param scene defines the hosting scene
  14727. * @param updatable defines if the mesh must be flagged as updatable
  14728. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14729. * @returns a new Mesh
  14730. */
  14731. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14732. /**
  14733. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  14734. * @param name defines the name of the mesh to create
  14735. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14736. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14737. * @param scene defines the hosting scene
  14738. * @returns a new Mesh
  14739. */
  14740. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  14741. /**
  14742. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  14743. * @param name defines the name of the mesh to create
  14744. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  14745. * @param diameterTop set the top cap diameter (floats, default 1)
  14746. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  14747. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  14748. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  14749. * @param scene defines the hosting scene
  14750. * @param updatable defines if the mesh must be flagged as updatable
  14751. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14752. * @returns a new Mesh
  14753. */
  14754. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  14755. /**
  14756. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  14757. * @param name defines the name of the mesh to create
  14758. * @param diameter sets the diameter size (float) of the torus (default 1)
  14759. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  14760. * @param tessellation sets the number of torus sides (postive integer, default 16)
  14761. * @param scene defines the hosting scene
  14762. * @param updatable defines if the mesh must be flagged as updatable
  14763. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14764. * @returns a new Mesh
  14765. */
  14766. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14767. /**
  14768. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  14769. * @param name defines the name of the mesh to create
  14770. * @param radius sets the global radius size (float) of the torus knot (default 2)
  14771. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  14772. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  14773. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  14774. * @param p the number of windings on X axis (positive integers, default 2)
  14775. * @param q the number of windings on Y axis (positive integers, default 3)
  14776. * @param scene defines the hosting scene
  14777. * @param updatable defines if the mesh must be flagged as updatable
  14778. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14779. * @returns a new Mesh
  14780. */
  14781. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14782. /**
  14783. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  14784. * @param name defines the name of the mesh to create
  14785. * @param points is an array successive Vector3
  14786. * @param scene defines the hosting scene
  14787. * @param updatable defines if the mesh must be flagged as updatable
  14788. * @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).
  14789. * @returns a new Mesh
  14790. */
  14791. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  14792. /**
  14793. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  14794. * @param name defines the name of the mesh to create
  14795. * @param points is an array successive Vector3
  14796. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  14797. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  14798. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  14799. * @param scene defines the hosting scene
  14800. * @param updatable defines if the mesh must be flagged as updatable
  14801. * @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)
  14802. * @returns a new Mesh
  14803. */
  14804. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  14805. /**
  14806. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  14807. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  14808. * 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.
  14809. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14810. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  14811. * Remember you can only change the shape positions, not their number when updating a polygon.
  14812. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  14813. * @param name defines the name of the mesh to create
  14814. * @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
  14815. * @param scene defines the hosting scene
  14816. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  14817. * @param updatable defines if the mesh must be flagged as updatable
  14818. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14819. * @param earcutInjection can be used to inject your own earcut reference
  14820. * @returns a new Mesh
  14821. */
  14822. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  14823. /**
  14824. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  14825. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  14826. * @param name defines the name of the mesh to create
  14827. * @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
  14828. * @param depth defines the height of extrusion
  14829. * @param scene defines the hosting scene
  14830. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  14831. * @param updatable defines if the mesh must be flagged as updatable
  14832. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14833. * @param earcutInjection can be used to inject your own earcut reference
  14834. * @returns a new Mesh
  14835. */
  14836. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  14837. /**
  14838. * Creates an extruded shape mesh.
  14839. * 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
  14840. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14841. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  14842. * @param name defines the name of the mesh to create
  14843. * @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
  14844. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  14845. * @param scale is the value to scale the shape
  14846. * @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
  14847. * @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
  14848. * @param scene defines the hosting scene
  14849. * @param updatable defines if the mesh must be flagged as updatable
  14850. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14851. * @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)
  14852. * @returns a new Mesh
  14853. */
  14854. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14855. /**
  14856. * Creates an custom extruded shape mesh.
  14857. * The custom extrusion is a parametric shape.
  14858. * It has no predefined shape. Its final shape will depend on the input parameters.
  14859. * Please consider using the same method from the MeshBuilder class instead
  14860. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  14861. * @param name defines the name of the mesh to create
  14862. * @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
  14863. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  14864. * @param scaleFunction is a custom Javascript function called on each path point
  14865. * @param rotationFunction is a custom Javascript function called on each path point
  14866. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  14867. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  14868. * @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
  14869. * @param scene defines the hosting scene
  14870. * @param updatable defines if the mesh must be flagged as updatable
  14871. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14872. * @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)
  14873. * @returns a new Mesh
  14874. */
  14875. 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;
  14876. /**
  14877. * Creates lathe mesh.
  14878. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  14879. * Please consider using the same method from the MeshBuilder class instead
  14880. * @param name defines the name of the mesh to create
  14881. * @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
  14882. * @param radius is the radius value of the lathe
  14883. * @param tessellation is the side number of the lathe.
  14884. * @param scene defines the hosting scene
  14885. * @param updatable defines if the mesh must be flagged as updatable
  14886. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14887. * @returns a new Mesh
  14888. */
  14889. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14890. /**
  14891. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  14892. * @param name defines the name of the mesh to create
  14893. * @param size sets the size (float) of both sides of the plane at once (default 1)
  14894. * @param scene defines the hosting scene
  14895. * @param updatable defines if the mesh must be flagged as updatable
  14896. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14897. * @returns a new Mesh
  14898. */
  14899. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14900. /**
  14901. * Creates a ground mesh.
  14902. * Please consider using the same method from the MeshBuilder class instead
  14903. * @param name defines the name of the mesh to create
  14904. * @param width set the width of the ground
  14905. * @param height set the height of the ground
  14906. * @param subdivisions sets the number of subdivisions per side
  14907. * @param scene defines the hosting scene
  14908. * @param updatable defines if the mesh must be flagged as updatable
  14909. * @returns a new Mesh
  14910. */
  14911. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  14912. /**
  14913. * Creates a tiled ground mesh.
  14914. * Please consider using the same method from the MeshBuilder class instead
  14915. * @param name defines the name of the mesh to create
  14916. * @param xmin set the ground minimum X coordinate
  14917. * @param zmin set the ground minimum Y coordinate
  14918. * @param xmax set the ground maximum X coordinate
  14919. * @param zmax set the ground maximum Z coordinate
  14920. * @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
  14921. * @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
  14922. * @param scene defines the hosting scene
  14923. * @param updatable defines if the mesh must be flagged as updatable
  14924. * @returns a new Mesh
  14925. */
  14926. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  14927. w: number;
  14928. h: number;
  14929. }, precision: {
  14930. w: number;
  14931. h: number;
  14932. }, scene: Scene, updatable?: boolean): Mesh;
  14933. /**
  14934. * Creates a ground mesh from a height map.
  14935. * Please consider using the same method from the MeshBuilder class instead
  14936. * @see http://doc.babylonjs.com/babylon101/height_map
  14937. * @param name defines the name of the mesh to create
  14938. * @param url sets the URL of the height map image resource
  14939. * @param width set the ground width size
  14940. * @param height set the ground height size
  14941. * @param subdivisions sets the number of subdivision per side
  14942. * @param minHeight is the minimum altitude on the ground
  14943. * @param maxHeight is the maximum altitude on the ground
  14944. * @param scene defines the hosting scene
  14945. * @param updatable defines if the mesh must be flagged as updatable
  14946. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  14947. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  14948. * @returns a new Mesh
  14949. */
  14950. 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;
  14951. /**
  14952. * Creates a tube mesh.
  14953. * The tube is a parametric shape.
  14954. * It has no predefined shape. Its final shape will depend on the input parameters.
  14955. * Please consider using the same method from the MeshBuilder class instead
  14956. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14957. * @param name defines the name of the mesh to create
  14958. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  14959. * @param radius sets the tube radius size
  14960. * @param tessellation is the number of sides on the tubular surface
  14961. * @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
  14962. * @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
  14963. * @param scene defines the hosting scene
  14964. * @param updatable defines if the mesh must be flagged as updatable
  14965. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14966. * @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)
  14967. * @returns a new Mesh
  14968. */
  14969. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  14970. (i: number, distance: number): number;
  14971. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14972. /**
  14973. * Creates a polyhedron mesh.
  14974. * Please consider using the same method from the MeshBuilder class instead.
  14975. * * 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
  14976. * * The parameter `size` (positive float, default 1) sets the polygon size
  14977. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  14978. * * 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`
  14979. * * 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
  14980. * * 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)`)
  14981. * * 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
  14982. * * 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
  14983. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14984. * * 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
  14985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  14986. * @param name defines the name of the mesh to create
  14987. * @param options defines the options used to create the mesh
  14988. * @param scene defines the hosting scene
  14989. * @returns a new Mesh
  14990. */
  14991. static CreatePolyhedron(name: string, options: {
  14992. type?: number;
  14993. size?: number;
  14994. sizeX?: number;
  14995. sizeY?: number;
  14996. sizeZ?: number;
  14997. custom?: any;
  14998. faceUV?: Vector4[];
  14999. faceColors?: Color4[];
  15000. updatable?: boolean;
  15001. sideOrientation?: number;
  15002. }, scene: Scene): Mesh;
  15003. /**
  15004. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  15005. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  15006. * * 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`)
  15007. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  15008. * * 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
  15009. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15010. * * 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
  15011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15012. * @param name defines the name of the mesh
  15013. * @param options defines the options used to create the mesh
  15014. * @param scene defines the hosting scene
  15015. * @returns a new Mesh
  15016. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  15017. */
  15018. static CreateIcoSphere(name: string, options: {
  15019. radius?: number;
  15020. flat?: boolean;
  15021. subdivisions?: number;
  15022. sideOrientation?: number;
  15023. updatable?: boolean;
  15024. }, scene: Scene): Mesh;
  15025. /**
  15026. * Creates a decal mesh.
  15027. * Please consider using the same method from the MeshBuilder class instead.
  15028. * A decal is a mesh usually applied as a model onto the surface of another mesh
  15029. * @param name defines the name of the mesh
  15030. * @param sourceMesh defines the mesh receiving the decal
  15031. * @param position sets the position of the decal in world coordinates
  15032. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  15033. * @param size sets the decal scaling
  15034. * @param angle sets the angle to rotate the decal
  15035. * @returns a new Mesh
  15036. */
  15037. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  15038. /**
  15039. * Prepare internal position array for software CPU skinning
  15040. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  15041. */
  15042. setPositionsForCPUSkinning(): Float32Array;
  15043. /**
  15044. * Prepare internal normal array for software CPU skinning
  15045. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15046. */
  15047. setNormalsForCPUSkinning(): Float32Array;
  15048. /**
  15049. * Updates the vertex buffer by applying transformation from the bones
  15050. * @param skeleton defines the skeleton to apply to current mesh
  15051. * @returns the current mesh
  15052. */
  15053. applySkeleton(skeleton: Skeleton): Mesh;
  15054. /**
  15055. * 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
  15056. * @param meshes defines the list of meshes to scan
  15057. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  15058. */
  15059. static MinMax(meshes: AbstractMesh[]): {
  15060. min: Vector3;
  15061. max: Vector3;
  15062. };
  15063. /**
  15064. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  15065. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  15066. * @returns a vector3
  15067. */
  15068. static Center(meshesOrMinMaxVector: {
  15069. min: Vector3;
  15070. max: Vector3;
  15071. } | AbstractMesh[]): Vector3;
  15072. /**
  15073. * Merge the array of meshes into a single mesh for performance reasons.
  15074. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  15075. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  15076. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  15077. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  15078. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  15079. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  15080. * @returns a new mesh
  15081. */
  15082. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  15083. /** @hidden */
  15084. addInstance(instance: InstancedMesh): void;
  15085. /** @hidden */
  15086. removeInstance(instance: InstancedMesh): void;
  15087. }
  15088. }
  15089. declare module BABYLON {
  15090. /**
  15091. * Interface used to define Action
  15092. */
  15093. export interface IAction {
  15094. /**
  15095. * Trigger for the action
  15096. */
  15097. trigger: number;
  15098. /** Options of the trigger */
  15099. triggerOptions: any;
  15100. /**
  15101. * Gets the trigger parameters
  15102. * @returns the trigger parameters
  15103. */
  15104. getTriggerParameter(): any;
  15105. /**
  15106. * Internal only - executes current action event
  15107. * @hidden
  15108. */
  15109. _executeCurrent(evt?: ActionEvent): void;
  15110. /**
  15111. * Serialize placeholder for child classes
  15112. * @param parent of child
  15113. * @returns the serialized object
  15114. */
  15115. serialize(parent: any): any;
  15116. /**
  15117. * Internal only
  15118. * @hidden
  15119. */
  15120. _prepare(): void;
  15121. /**
  15122. * Internal only - manager for action
  15123. * @hidden
  15124. */
  15125. _actionManager: AbstractActionManager;
  15126. /**
  15127. * Adds action to chain of actions, may be a DoNothingAction
  15128. * @param action defines the next action to execute
  15129. * @returns The action passed in
  15130. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15131. */
  15132. then(action: IAction): IAction;
  15133. }
  15134. /**
  15135. * The action to be carried out following a trigger
  15136. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  15137. */
  15138. export class Action implements IAction {
  15139. /** the trigger, with or without parameters, for the action */
  15140. triggerOptions: any;
  15141. /**
  15142. * Trigger for the action
  15143. */
  15144. trigger: number;
  15145. /**
  15146. * Internal only - manager for action
  15147. * @hidden
  15148. */
  15149. _actionManager: ActionManager;
  15150. private _nextActiveAction;
  15151. private _child;
  15152. private _condition?;
  15153. private _triggerParameter;
  15154. /**
  15155. * An event triggered prior to action being executed.
  15156. */
  15157. onBeforeExecuteObservable: Observable<Action>;
  15158. /**
  15159. * Creates a new Action
  15160. * @param triggerOptions the trigger, with or without parameters, for the action
  15161. * @param condition an optional determinant of action
  15162. */
  15163. constructor(
  15164. /** the trigger, with or without parameters, for the action */
  15165. triggerOptions: any, condition?: Condition);
  15166. /**
  15167. * Internal only
  15168. * @hidden
  15169. */
  15170. _prepare(): void;
  15171. /**
  15172. * Gets the trigger parameters
  15173. * @returns the trigger parameters
  15174. */
  15175. getTriggerParameter(): any;
  15176. /**
  15177. * Internal only - executes current action event
  15178. * @hidden
  15179. */
  15180. _executeCurrent(evt?: ActionEvent): void;
  15181. /**
  15182. * Execute placeholder for child classes
  15183. * @param evt optional action event
  15184. */
  15185. execute(evt?: ActionEvent): void;
  15186. /**
  15187. * Skips to next active action
  15188. */
  15189. skipToNextActiveAction(): void;
  15190. /**
  15191. * Adds action to chain of actions, may be a DoNothingAction
  15192. * @param action defines the next action to execute
  15193. * @returns The action passed in
  15194. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15195. */
  15196. then(action: Action): Action;
  15197. /**
  15198. * Internal only
  15199. * @hidden
  15200. */
  15201. _getProperty(propertyPath: string): string;
  15202. /**
  15203. * Internal only
  15204. * @hidden
  15205. */
  15206. _getEffectiveTarget(target: any, propertyPath: string): any;
  15207. /**
  15208. * Serialize placeholder for child classes
  15209. * @param parent of child
  15210. * @returns the serialized object
  15211. */
  15212. serialize(parent: any): any;
  15213. /**
  15214. * Internal only called by serialize
  15215. * @hidden
  15216. */
  15217. protected _serialize(serializedAction: any, parent?: any): any;
  15218. /**
  15219. * Internal only
  15220. * @hidden
  15221. */
  15222. static _SerializeValueAsString: (value: any) => string;
  15223. /**
  15224. * Internal only
  15225. * @hidden
  15226. */
  15227. static _GetTargetProperty: (target: Scene | Node) => {
  15228. name: string;
  15229. targetType: string;
  15230. value: string;
  15231. };
  15232. }
  15233. }
  15234. declare module BABYLON {
  15235. /**
  15236. * A Condition applied to an Action
  15237. */
  15238. export class Condition {
  15239. /**
  15240. * Internal only - manager for action
  15241. * @hidden
  15242. */
  15243. _actionManager: ActionManager;
  15244. /**
  15245. * Internal only
  15246. * @hidden
  15247. */
  15248. _evaluationId: number;
  15249. /**
  15250. * Internal only
  15251. * @hidden
  15252. */
  15253. _currentResult: boolean;
  15254. /**
  15255. * Creates a new Condition
  15256. * @param actionManager the manager of the action the condition is applied to
  15257. */
  15258. constructor(actionManager: ActionManager);
  15259. /**
  15260. * Check if the current condition is valid
  15261. * @returns a boolean
  15262. */
  15263. isValid(): boolean;
  15264. /**
  15265. * Internal only
  15266. * @hidden
  15267. */
  15268. _getProperty(propertyPath: string): string;
  15269. /**
  15270. * Internal only
  15271. * @hidden
  15272. */
  15273. _getEffectiveTarget(target: any, propertyPath: string): any;
  15274. /**
  15275. * Serialize placeholder for child classes
  15276. * @returns the serialized object
  15277. */
  15278. serialize(): any;
  15279. /**
  15280. * Internal only
  15281. * @hidden
  15282. */
  15283. protected _serialize(serializedCondition: any): any;
  15284. }
  15285. /**
  15286. * Defines specific conditional operators as extensions of Condition
  15287. */
  15288. export class ValueCondition extends Condition {
  15289. /** path to specify the property of the target the conditional operator uses */
  15290. propertyPath: string;
  15291. /** the value compared by the conditional operator against the current value of the property */
  15292. value: any;
  15293. /** the conditional operator, default ValueCondition.IsEqual */
  15294. operator: number;
  15295. /**
  15296. * Internal only
  15297. * @hidden
  15298. */
  15299. private static _IsEqual;
  15300. /**
  15301. * Internal only
  15302. * @hidden
  15303. */
  15304. private static _IsDifferent;
  15305. /**
  15306. * Internal only
  15307. * @hidden
  15308. */
  15309. private static _IsGreater;
  15310. /**
  15311. * Internal only
  15312. * @hidden
  15313. */
  15314. private static _IsLesser;
  15315. /**
  15316. * returns the number for IsEqual
  15317. */
  15318. static readonly IsEqual: number;
  15319. /**
  15320. * Returns the number for IsDifferent
  15321. */
  15322. static readonly IsDifferent: number;
  15323. /**
  15324. * Returns the number for IsGreater
  15325. */
  15326. static readonly IsGreater: number;
  15327. /**
  15328. * Returns the number for IsLesser
  15329. */
  15330. static readonly IsLesser: number;
  15331. /**
  15332. * Internal only The action manager for the condition
  15333. * @hidden
  15334. */
  15335. _actionManager: ActionManager;
  15336. /**
  15337. * Internal only
  15338. * @hidden
  15339. */
  15340. private _target;
  15341. /**
  15342. * Internal only
  15343. * @hidden
  15344. */
  15345. private _effectiveTarget;
  15346. /**
  15347. * Internal only
  15348. * @hidden
  15349. */
  15350. private _property;
  15351. /**
  15352. * Creates a new ValueCondition
  15353. * @param actionManager manager for the action the condition applies to
  15354. * @param target for the action
  15355. * @param propertyPath path to specify the property of the target the conditional operator uses
  15356. * @param value the value compared by the conditional operator against the current value of the property
  15357. * @param operator the conditional operator, default ValueCondition.IsEqual
  15358. */
  15359. constructor(actionManager: ActionManager, target: any,
  15360. /** path to specify the property of the target the conditional operator uses */
  15361. propertyPath: string,
  15362. /** the value compared by the conditional operator against the current value of the property */
  15363. value: any,
  15364. /** the conditional operator, default ValueCondition.IsEqual */
  15365. operator?: number);
  15366. /**
  15367. * Compares the given value with the property value for the specified conditional operator
  15368. * @returns the result of the comparison
  15369. */
  15370. isValid(): boolean;
  15371. /**
  15372. * Serialize the ValueCondition into a JSON compatible object
  15373. * @returns serialization object
  15374. */
  15375. serialize(): any;
  15376. /**
  15377. * Gets the name of the conditional operator for the ValueCondition
  15378. * @param operator the conditional operator
  15379. * @returns the name
  15380. */
  15381. static GetOperatorName(operator: number): string;
  15382. }
  15383. /**
  15384. * Defines a predicate condition as an extension of Condition
  15385. */
  15386. export class PredicateCondition extends Condition {
  15387. /** defines the predicate function used to validate the condition */
  15388. predicate: () => boolean;
  15389. /**
  15390. * Internal only - manager for action
  15391. * @hidden
  15392. */
  15393. _actionManager: ActionManager;
  15394. /**
  15395. * Creates a new PredicateCondition
  15396. * @param actionManager manager for the action the condition applies to
  15397. * @param predicate defines the predicate function used to validate the condition
  15398. */
  15399. constructor(actionManager: ActionManager,
  15400. /** defines the predicate function used to validate the condition */
  15401. predicate: () => boolean);
  15402. /**
  15403. * @returns the validity of the predicate condition
  15404. */
  15405. isValid(): boolean;
  15406. }
  15407. /**
  15408. * Defines a state condition as an extension of Condition
  15409. */
  15410. export class StateCondition extends Condition {
  15411. /** Value to compare with target state */
  15412. value: string;
  15413. /**
  15414. * Internal only - manager for action
  15415. * @hidden
  15416. */
  15417. _actionManager: ActionManager;
  15418. /**
  15419. * Internal only
  15420. * @hidden
  15421. */
  15422. private _target;
  15423. /**
  15424. * Creates a new StateCondition
  15425. * @param actionManager manager for the action the condition applies to
  15426. * @param target of the condition
  15427. * @param value to compare with target state
  15428. */
  15429. constructor(actionManager: ActionManager, target: any,
  15430. /** Value to compare with target state */
  15431. value: string);
  15432. /**
  15433. * Gets a boolean indicating if the current condition is met
  15434. * @returns the validity of the state
  15435. */
  15436. isValid(): boolean;
  15437. /**
  15438. * Serialize the StateCondition into a JSON compatible object
  15439. * @returns serialization object
  15440. */
  15441. serialize(): any;
  15442. }
  15443. }
  15444. declare module BABYLON {
  15445. /**
  15446. * This defines an action responsible to toggle a boolean once triggered.
  15447. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15448. */
  15449. export class SwitchBooleanAction extends Action {
  15450. /**
  15451. * The path to the boolean property in the target object
  15452. */
  15453. propertyPath: string;
  15454. private _target;
  15455. private _effectiveTarget;
  15456. private _property;
  15457. /**
  15458. * Instantiate the action
  15459. * @param triggerOptions defines the trigger options
  15460. * @param target defines the object containing the boolean
  15461. * @param propertyPath defines the path to the boolean property in the target object
  15462. * @param condition defines the trigger related conditions
  15463. */
  15464. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  15465. /** @hidden */
  15466. _prepare(): void;
  15467. /**
  15468. * Execute the action toggle the boolean value.
  15469. */
  15470. execute(): void;
  15471. /**
  15472. * Serializes the actions and its related information.
  15473. * @param parent defines the object to serialize in
  15474. * @returns the serialized object
  15475. */
  15476. serialize(parent: any): any;
  15477. }
  15478. /**
  15479. * This defines an action responsible to set a the state field of the target
  15480. * to a desired value once triggered.
  15481. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15482. */
  15483. export class SetStateAction extends Action {
  15484. /**
  15485. * The value to store in the state field.
  15486. */
  15487. value: string;
  15488. private _target;
  15489. /**
  15490. * Instantiate the action
  15491. * @param triggerOptions defines the trigger options
  15492. * @param target defines the object containing the state property
  15493. * @param value defines the value to store in the state field
  15494. * @param condition defines the trigger related conditions
  15495. */
  15496. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  15497. /**
  15498. * Execute the action and store the value on the target state property.
  15499. */
  15500. execute(): void;
  15501. /**
  15502. * Serializes the actions and its related information.
  15503. * @param parent defines the object to serialize in
  15504. * @returns the serialized object
  15505. */
  15506. serialize(parent: any): any;
  15507. }
  15508. /**
  15509. * This defines an action responsible to set a property of the target
  15510. * to a desired value once triggered.
  15511. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15512. */
  15513. export class SetValueAction extends Action {
  15514. /**
  15515. * The path of the property to set in the target.
  15516. */
  15517. propertyPath: string;
  15518. /**
  15519. * The value to set in the property
  15520. */
  15521. value: any;
  15522. private _target;
  15523. private _effectiveTarget;
  15524. private _property;
  15525. /**
  15526. * Instantiate the action
  15527. * @param triggerOptions defines the trigger options
  15528. * @param target defines the object containing the property
  15529. * @param propertyPath defines the path of the property to set in the target
  15530. * @param value defines the value to set in the property
  15531. * @param condition defines the trigger related conditions
  15532. */
  15533. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15534. /** @hidden */
  15535. _prepare(): void;
  15536. /**
  15537. * Execute the action and set the targetted property to the desired value.
  15538. */
  15539. execute(): void;
  15540. /**
  15541. * Serializes the actions and its related information.
  15542. * @param parent defines the object to serialize in
  15543. * @returns the serialized object
  15544. */
  15545. serialize(parent: any): any;
  15546. }
  15547. /**
  15548. * This defines an action responsible to increment the target value
  15549. * to a desired value once triggered.
  15550. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15551. */
  15552. export class IncrementValueAction extends Action {
  15553. /**
  15554. * The path of the property to increment in the target.
  15555. */
  15556. propertyPath: string;
  15557. /**
  15558. * The value we should increment the property by.
  15559. */
  15560. value: any;
  15561. private _target;
  15562. private _effectiveTarget;
  15563. private _property;
  15564. /**
  15565. * Instantiate the action
  15566. * @param triggerOptions defines the trigger options
  15567. * @param target defines the object containing the property
  15568. * @param propertyPath defines the path of the property to increment in the target
  15569. * @param value defines the value value we should increment the property by
  15570. * @param condition defines the trigger related conditions
  15571. */
  15572. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15573. /** @hidden */
  15574. _prepare(): void;
  15575. /**
  15576. * Execute the action and increment the target of the value amount.
  15577. */
  15578. execute(): void;
  15579. /**
  15580. * Serializes the actions and its related information.
  15581. * @param parent defines the object to serialize in
  15582. * @returns the serialized object
  15583. */
  15584. serialize(parent: any): any;
  15585. }
  15586. /**
  15587. * This defines an action responsible to start an animation once triggered.
  15588. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15589. */
  15590. export class PlayAnimationAction extends Action {
  15591. /**
  15592. * Where the animation should start (animation frame)
  15593. */
  15594. from: number;
  15595. /**
  15596. * Where the animation should stop (animation frame)
  15597. */
  15598. to: number;
  15599. /**
  15600. * Define if the animation should loop or stop after the first play.
  15601. */
  15602. loop?: boolean;
  15603. private _target;
  15604. /**
  15605. * Instantiate the action
  15606. * @param triggerOptions defines the trigger options
  15607. * @param target defines the target animation or animation name
  15608. * @param from defines from where the animation should start (animation frame)
  15609. * @param end defines where the animation should stop (animation frame)
  15610. * @param loop defines if the animation should loop or stop after the first play
  15611. * @param condition defines the trigger related conditions
  15612. */
  15613. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  15614. /** @hidden */
  15615. _prepare(): void;
  15616. /**
  15617. * Execute the action and play the animation.
  15618. */
  15619. execute(): void;
  15620. /**
  15621. * Serializes the actions and its related information.
  15622. * @param parent defines the object to serialize in
  15623. * @returns the serialized object
  15624. */
  15625. serialize(parent: any): any;
  15626. }
  15627. /**
  15628. * This defines an action responsible to stop an animation once triggered.
  15629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15630. */
  15631. export class StopAnimationAction extends Action {
  15632. private _target;
  15633. /**
  15634. * Instantiate the action
  15635. * @param triggerOptions defines the trigger options
  15636. * @param target defines the target animation or animation name
  15637. * @param condition defines the trigger related conditions
  15638. */
  15639. constructor(triggerOptions: any, target: any, condition?: Condition);
  15640. /** @hidden */
  15641. _prepare(): void;
  15642. /**
  15643. * Execute the action and stop the animation.
  15644. */
  15645. execute(): void;
  15646. /**
  15647. * Serializes the actions and its related information.
  15648. * @param parent defines the object to serialize in
  15649. * @returns the serialized object
  15650. */
  15651. serialize(parent: any): any;
  15652. }
  15653. /**
  15654. * This defines an action responsible that does nothing once triggered.
  15655. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15656. */
  15657. export class DoNothingAction extends Action {
  15658. /**
  15659. * Instantiate the action
  15660. * @param triggerOptions defines the trigger options
  15661. * @param condition defines the trigger related conditions
  15662. */
  15663. constructor(triggerOptions?: any, condition?: Condition);
  15664. /**
  15665. * Execute the action and do nothing.
  15666. */
  15667. execute(): void;
  15668. /**
  15669. * Serializes the actions and its related information.
  15670. * @param parent defines the object to serialize in
  15671. * @returns the serialized object
  15672. */
  15673. serialize(parent: any): any;
  15674. }
  15675. /**
  15676. * This defines an action responsible to trigger several actions once triggered.
  15677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15678. */
  15679. export class CombineAction extends Action {
  15680. /**
  15681. * The list of aggregated animations to run.
  15682. */
  15683. children: Action[];
  15684. /**
  15685. * Instantiate the action
  15686. * @param triggerOptions defines the trigger options
  15687. * @param children defines the list of aggregated animations to run
  15688. * @param condition defines the trigger related conditions
  15689. */
  15690. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  15691. /** @hidden */
  15692. _prepare(): void;
  15693. /**
  15694. * Execute the action and executes all the aggregated actions.
  15695. */
  15696. execute(evt: ActionEvent): void;
  15697. /**
  15698. * Serializes the actions and its related information.
  15699. * @param parent defines the object to serialize in
  15700. * @returns the serialized object
  15701. */
  15702. serialize(parent: any): any;
  15703. }
  15704. /**
  15705. * This defines an action responsible to run code (external event) once triggered.
  15706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15707. */
  15708. export class ExecuteCodeAction extends Action {
  15709. /**
  15710. * The callback function to run.
  15711. */
  15712. func: (evt: ActionEvent) => void;
  15713. /**
  15714. * Instantiate the action
  15715. * @param triggerOptions defines the trigger options
  15716. * @param func defines the callback function to run
  15717. * @param condition defines the trigger related conditions
  15718. */
  15719. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  15720. /**
  15721. * Execute the action and run the attached code.
  15722. */
  15723. execute(evt: ActionEvent): void;
  15724. }
  15725. /**
  15726. * This defines an action responsible to set the parent property of the target once triggered.
  15727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15728. */
  15729. export class SetParentAction extends Action {
  15730. private _parent;
  15731. private _target;
  15732. /**
  15733. * Instantiate the action
  15734. * @param triggerOptions defines the trigger options
  15735. * @param target defines the target containing the parent property
  15736. * @param parent defines from where the animation should start (animation frame)
  15737. * @param condition defines the trigger related conditions
  15738. */
  15739. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  15740. /** @hidden */
  15741. _prepare(): void;
  15742. /**
  15743. * Execute the action and set the parent property.
  15744. */
  15745. execute(): void;
  15746. /**
  15747. * Serializes the actions and its related information.
  15748. * @param parent defines the object to serialize in
  15749. * @returns the serialized object
  15750. */
  15751. serialize(parent: any): any;
  15752. }
  15753. }
  15754. declare module BABYLON {
  15755. /**
  15756. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  15757. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  15758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15759. */
  15760. export class ActionManager extends AbstractActionManager {
  15761. /**
  15762. * Nothing
  15763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15764. */
  15765. static readonly NothingTrigger: number;
  15766. /**
  15767. * On pick
  15768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15769. */
  15770. static readonly OnPickTrigger: number;
  15771. /**
  15772. * On left pick
  15773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15774. */
  15775. static readonly OnLeftPickTrigger: number;
  15776. /**
  15777. * On right pick
  15778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15779. */
  15780. static readonly OnRightPickTrigger: number;
  15781. /**
  15782. * On center pick
  15783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15784. */
  15785. static readonly OnCenterPickTrigger: number;
  15786. /**
  15787. * On pick down
  15788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15789. */
  15790. static readonly OnPickDownTrigger: number;
  15791. /**
  15792. * On double pick
  15793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15794. */
  15795. static readonly OnDoublePickTrigger: number;
  15796. /**
  15797. * On pick up
  15798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15799. */
  15800. static readonly OnPickUpTrigger: number;
  15801. /**
  15802. * On pick out.
  15803. * This trigger will only be raised if you also declared a OnPickDown
  15804. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15805. */
  15806. static readonly OnPickOutTrigger: number;
  15807. /**
  15808. * On long press
  15809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15810. */
  15811. static readonly OnLongPressTrigger: number;
  15812. /**
  15813. * On pointer over
  15814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15815. */
  15816. static readonly OnPointerOverTrigger: number;
  15817. /**
  15818. * On pointer out
  15819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15820. */
  15821. static readonly OnPointerOutTrigger: number;
  15822. /**
  15823. * On every frame
  15824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15825. */
  15826. static readonly OnEveryFrameTrigger: number;
  15827. /**
  15828. * On intersection enter
  15829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15830. */
  15831. static readonly OnIntersectionEnterTrigger: number;
  15832. /**
  15833. * On intersection exit
  15834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15835. */
  15836. static readonly OnIntersectionExitTrigger: number;
  15837. /**
  15838. * On key down
  15839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15840. */
  15841. static readonly OnKeyDownTrigger: number;
  15842. /**
  15843. * On key up
  15844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15845. */
  15846. static readonly OnKeyUpTrigger: number;
  15847. private _scene;
  15848. /**
  15849. * Creates a new action manager
  15850. * @param scene defines the hosting scene
  15851. */
  15852. constructor(scene: Scene);
  15853. /**
  15854. * Releases all associated resources
  15855. */
  15856. dispose(): void;
  15857. /**
  15858. * Gets hosting scene
  15859. * @returns the hosting scene
  15860. */
  15861. getScene(): Scene;
  15862. /**
  15863. * Does this action manager handles actions of any of the given triggers
  15864. * @param triggers defines the triggers to be tested
  15865. * @return a boolean indicating whether one (or more) of the triggers is handled
  15866. */
  15867. hasSpecificTriggers(triggers: number[]): boolean;
  15868. /**
  15869. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  15870. * speed.
  15871. * @param triggerA defines the trigger to be tested
  15872. * @param triggerB defines the trigger to be tested
  15873. * @return a boolean indicating whether one (or more) of the triggers is handled
  15874. */
  15875. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  15876. /**
  15877. * Does this action manager handles actions of a given trigger
  15878. * @param trigger defines the trigger to be tested
  15879. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  15880. * @return whether the trigger is handled
  15881. */
  15882. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  15883. /**
  15884. * Does this action manager has pointer triggers
  15885. */
  15886. readonly hasPointerTriggers: boolean;
  15887. /**
  15888. * Does this action manager has pick triggers
  15889. */
  15890. readonly hasPickTriggers: boolean;
  15891. /**
  15892. * Registers an action to this action manager
  15893. * @param action defines the action to be registered
  15894. * @return the action amended (prepared) after registration
  15895. */
  15896. registerAction(action: IAction): Nullable<IAction>;
  15897. /**
  15898. * Unregisters an action to this action manager
  15899. * @param action defines the action to be unregistered
  15900. * @return a boolean indicating whether the action has been unregistered
  15901. */
  15902. unregisterAction(action: IAction): Boolean;
  15903. /**
  15904. * Process a specific trigger
  15905. * @param trigger defines the trigger to process
  15906. * @param evt defines the event details to be processed
  15907. */
  15908. processTrigger(trigger: number, evt?: IActionEvent): void;
  15909. /** @hidden */
  15910. _getEffectiveTarget(target: any, propertyPath: string): any;
  15911. /** @hidden */
  15912. _getProperty(propertyPath: string): string;
  15913. /**
  15914. * Serialize this manager to a JSON object
  15915. * @param name defines the property name to store this manager
  15916. * @returns a JSON representation of this manager
  15917. */
  15918. serialize(name: string): any;
  15919. /**
  15920. * Creates a new ActionManager from a JSON data
  15921. * @param parsedActions defines the JSON data to read from
  15922. * @param object defines the hosting mesh
  15923. * @param scene defines the hosting scene
  15924. */
  15925. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  15926. /**
  15927. * Get a trigger name by index
  15928. * @param trigger defines the trigger index
  15929. * @returns a trigger name
  15930. */
  15931. static GetTriggerName(trigger: number): string;
  15932. }
  15933. }
  15934. declare module BABYLON {
  15935. /**
  15936. * Class representing a ray with position and direction
  15937. */
  15938. export class Ray {
  15939. /** origin point */
  15940. origin: Vector3;
  15941. /** direction */
  15942. direction: Vector3;
  15943. /** length of the ray */
  15944. length: number;
  15945. private static readonly TmpVector3;
  15946. private _tmpRay;
  15947. /**
  15948. * Creates a new ray
  15949. * @param origin origin point
  15950. * @param direction direction
  15951. * @param length length of the ray
  15952. */
  15953. constructor(
  15954. /** origin point */
  15955. origin: Vector3,
  15956. /** direction */
  15957. direction: Vector3,
  15958. /** length of the ray */
  15959. length?: number);
  15960. /**
  15961. * Checks if the ray intersects a box
  15962. * @param minimum bound of the box
  15963. * @param maximum bound of the box
  15964. * @param intersectionTreshold extra extend to be added to the box in all direction
  15965. * @returns if the box was hit
  15966. */
  15967. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  15968. /**
  15969. * Checks if the ray intersects a box
  15970. * @param box the bounding box to check
  15971. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  15972. * @returns if the box was hit
  15973. */
  15974. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  15975. /**
  15976. * If the ray hits a sphere
  15977. * @param sphere the bounding sphere to check
  15978. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  15979. * @returns true if it hits the sphere
  15980. */
  15981. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  15982. /**
  15983. * If the ray hits a triange
  15984. * @param vertex0 triangle vertex
  15985. * @param vertex1 triangle vertex
  15986. * @param vertex2 triangle vertex
  15987. * @returns intersection information if hit
  15988. */
  15989. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  15990. /**
  15991. * Checks if ray intersects a plane
  15992. * @param plane the plane to check
  15993. * @returns the distance away it was hit
  15994. */
  15995. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  15996. /**
  15997. * Checks if ray intersects a mesh
  15998. * @param mesh the mesh to check
  15999. * @param fastCheck if only the bounding box should checked
  16000. * @returns picking info of the intersecton
  16001. */
  16002. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  16003. /**
  16004. * Checks if ray intersects a mesh
  16005. * @param meshes the meshes to check
  16006. * @param fastCheck if only the bounding box should checked
  16007. * @param results array to store result in
  16008. * @returns Array of picking infos
  16009. */
  16010. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  16011. private _comparePickingInfo;
  16012. private static smallnum;
  16013. private static rayl;
  16014. /**
  16015. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  16016. * @param sega the first point of the segment to test the intersection against
  16017. * @param segb the second point of the segment to test the intersection against
  16018. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  16019. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  16020. */
  16021. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  16022. /**
  16023. * Update the ray from viewport position
  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 this ray updated
  16032. */
  16033. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16034. /**
  16035. * Creates a ray with origin and direction of 0,0,0
  16036. * @returns the new ray
  16037. */
  16038. static Zero(): Ray;
  16039. /**
  16040. * Creates a new ray from screen space and viewport
  16041. * @param x position
  16042. * @param y y position
  16043. * @param viewportWidth viewport width
  16044. * @param viewportHeight viewport height
  16045. * @param world world matrix
  16046. * @param view view matrix
  16047. * @param projection projection matrix
  16048. * @returns new ray
  16049. */
  16050. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16051. /**
  16052. * 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
  16053. * transformed to the given world matrix.
  16054. * @param origin The origin point
  16055. * @param end The end point
  16056. * @param world a matrix to transform the ray to. Default is the identity matrix.
  16057. * @returns the new ray
  16058. */
  16059. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  16060. /**
  16061. * Transforms a ray by a matrix
  16062. * @param ray ray to transform
  16063. * @param matrix matrix to apply
  16064. * @returns the resulting new ray
  16065. */
  16066. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  16067. /**
  16068. * Transforms a ray by a matrix
  16069. * @param ray ray to transform
  16070. * @param matrix matrix to apply
  16071. * @param result ray to store result in
  16072. */
  16073. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  16074. /**
  16075. * Unproject a ray from screen space to object space
  16076. * @param sourceX defines the screen space x coordinate to use
  16077. * @param sourceY defines the screen space y coordinate to use
  16078. * @param viewportWidth defines the current width of the viewport
  16079. * @param viewportHeight defines the current height of the viewport
  16080. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16081. * @param view defines the view matrix to use
  16082. * @param projection defines the projection matrix to use
  16083. */
  16084. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  16085. }
  16086. /**
  16087. * Type used to define predicate used to select faces when a mesh intersection is detected
  16088. */
  16089. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  16090. interface Scene {
  16091. /** @hidden */
  16092. _tempPickingRay: Nullable<Ray>;
  16093. /** @hidden */
  16094. _cachedRayForTransform: Ray;
  16095. /** @hidden */
  16096. _pickWithRayInverseMatrix: Matrix;
  16097. /** @hidden */
  16098. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  16099. /** @hidden */
  16100. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  16101. }
  16102. }
  16103. declare module BABYLON {
  16104. interface Scene {
  16105. /** @hidden */
  16106. _pointerOverSprite: Nullable<Sprite>;
  16107. /** @hidden */
  16108. _pickedDownSprite: Nullable<Sprite>;
  16109. /** @hidden */
  16110. _tempSpritePickingRay: Nullable<Ray>;
  16111. /**
  16112. * All of the sprite managers added to this scene
  16113. * @see http://doc.babylonjs.com/babylon101/sprites
  16114. */
  16115. spriteManagers: Array<ISpriteManager>;
  16116. /**
  16117. * An event triggered when sprites rendering is about to start
  16118. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16119. */
  16120. onBeforeSpritesRenderingObservable: Observable<Scene>;
  16121. /**
  16122. * An event triggered when sprites rendering is done
  16123. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16124. */
  16125. onAfterSpritesRenderingObservable: Observable<Scene>;
  16126. /** @hidden */
  16127. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16128. /** Launch a ray to try to pick a sprite in the scene
  16129. * @param x position on screen
  16130. * @param y position on screen
  16131. * @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
  16132. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16133. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  16134. * @returns a PickingInfo
  16135. */
  16136. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16137. /** Use the given ray to pick a sprite in the scene
  16138. * @param ray The ray (in world space) to use to pick meshes
  16139. * @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
  16140. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16141. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  16142. * @returns a PickingInfo
  16143. */
  16144. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16145. /**
  16146. * Force the sprite under the pointer
  16147. * @param sprite defines the sprite to use
  16148. */
  16149. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  16150. /**
  16151. * Gets the sprite under the pointer
  16152. * @returns a Sprite or null if no sprite is under the pointer
  16153. */
  16154. getPointerOverSprite(): Nullable<Sprite>;
  16155. }
  16156. /**
  16157. * Defines the sprite scene component responsible to manage sprites
  16158. * in a given scene.
  16159. */
  16160. export class SpriteSceneComponent implements ISceneComponent {
  16161. /**
  16162. * The component name helpfull to identify the component in the list of scene components.
  16163. */
  16164. readonly name: string;
  16165. /**
  16166. * The scene the component belongs to.
  16167. */
  16168. scene: Scene;
  16169. /** @hidden */
  16170. private _spritePredicate;
  16171. /**
  16172. * Creates a new instance of the component for the given scene
  16173. * @param scene Defines the scene to register the component in
  16174. */
  16175. constructor(scene: Scene);
  16176. /**
  16177. * Registers the component in a given scene
  16178. */
  16179. register(): void;
  16180. /**
  16181. * Rebuilds the elements related to this component in case of
  16182. * context lost for instance.
  16183. */
  16184. rebuild(): void;
  16185. /**
  16186. * Disposes the component and the associated ressources.
  16187. */
  16188. dispose(): void;
  16189. private _pickSpriteButKeepRay;
  16190. private _pointerMove;
  16191. private _pointerDown;
  16192. private _pointerUp;
  16193. }
  16194. }
  16195. declare module BABYLON {
  16196. /** @hidden */
  16197. export var fogFragmentDeclaration: {
  16198. name: string;
  16199. shader: string;
  16200. };
  16201. }
  16202. declare module BABYLON {
  16203. /** @hidden */
  16204. export var fogFragment: {
  16205. name: string;
  16206. shader: string;
  16207. };
  16208. }
  16209. declare module BABYLON {
  16210. /** @hidden */
  16211. export var spritesPixelShader: {
  16212. name: string;
  16213. shader: string;
  16214. };
  16215. }
  16216. declare module BABYLON {
  16217. /** @hidden */
  16218. export var fogVertexDeclaration: {
  16219. name: string;
  16220. shader: string;
  16221. };
  16222. }
  16223. declare module BABYLON {
  16224. /** @hidden */
  16225. export var spritesVertexShader: {
  16226. name: string;
  16227. shader: string;
  16228. };
  16229. }
  16230. declare module BABYLON {
  16231. /**
  16232. * Defines the minimum interface to fullfil in order to be a sprite manager.
  16233. */
  16234. export interface ISpriteManager extends IDisposable {
  16235. /**
  16236. * Restricts the camera to viewing objects with the same layerMask.
  16237. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  16238. */
  16239. layerMask: number;
  16240. /**
  16241. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  16242. */
  16243. isPickable: boolean;
  16244. /**
  16245. * Specifies the rendering group id for this mesh (0 by default)
  16246. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  16247. */
  16248. renderingGroupId: number;
  16249. /**
  16250. * Defines the list of sprites managed by the manager.
  16251. */
  16252. sprites: Array<Sprite>;
  16253. /**
  16254. * Tests the intersection of a sprite with a specific ray.
  16255. * @param ray The ray we are sending to test the collision
  16256. * @param camera The camera space we are sending rays in
  16257. * @param predicate A predicate allowing excluding sprites from the list of object to test
  16258. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  16259. * @returns picking info or null.
  16260. */
  16261. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16262. /**
  16263. * Renders the list of sprites on screen.
  16264. */
  16265. render(): void;
  16266. }
  16267. /**
  16268. * Class used to manage multiple sprites on the same spritesheet
  16269. * @see http://doc.babylonjs.com/babylon101/sprites
  16270. */
  16271. export class SpriteManager implements ISpriteManager {
  16272. /** defines the manager's name */
  16273. name: string;
  16274. /** Gets the list of sprites */
  16275. sprites: Sprite[];
  16276. /** Gets or sets the rendering group id (0 by default) */
  16277. renderingGroupId: number;
  16278. /** Gets or sets camera layer mask */
  16279. layerMask: number;
  16280. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  16281. fogEnabled: boolean;
  16282. /** Gets or sets a boolean indicating if the sprites are pickable */
  16283. isPickable: boolean;
  16284. /** Defines the default width of a cell in the spritesheet */
  16285. cellWidth: number;
  16286. /** Defines the default height of a cell in the spritesheet */
  16287. cellHeight: number;
  16288. /**
  16289. * An event triggered when the manager is disposed.
  16290. */
  16291. onDisposeObservable: Observable<SpriteManager>;
  16292. private _onDisposeObserver;
  16293. /**
  16294. * Callback called when the manager is disposed
  16295. */
  16296. onDispose: () => void;
  16297. private _capacity;
  16298. private _spriteTexture;
  16299. private _epsilon;
  16300. private _scene;
  16301. private _vertexData;
  16302. private _buffer;
  16303. private _vertexBuffers;
  16304. private _indexBuffer;
  16305. private _effectBase;
  16306. private _effectFog;
  16307. /**
  16308. * Gets or sets the spritesheet texture
  16309. */
  16310. texture: Texture;
  16311. /**
  16312. * Creates a new sprite manager
  16313. * @param name defines the manager's name
  16314. * @param imgUrl defines the sprite sheet url
  16315. * @param capacity defines the maximum allowed number of sprites
  16316. * @param cellSize defines the size of a sprite cell
  16317. * @param scene defines the hosting scene
  16318. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  16319. * @param samplingMode defines the smapling mode to use with spritesheet
  16320. */
  16321. constructor(
  16322. /** defines the manager's name */
  16323. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  16324. private _appendSpriteVertex;
  16325. /**
  16326. * Intersects the sprites with a ray
  16327. * @param ray defines the ray to intersect with
  16328. * @param camera defines the current active camera
  16329. * @param predicate defines a predicate used to select candidate sprites
  16330. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  16331. * @returns null if no hit or a PickingInfo
  16332. */
  16333. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16334. /**
  16335. * Render all child sprites
  16336. */
  16337. render(): void;
  16338. /**
  16339. * Release associated resources
  16340. */
  16341. dispose(): void;
  16342. }
  16343. }
  16344. declare module BABYLON {
  16345. /**
  16346. * Class used to represent a sprite
  16347. * @see http://doc.babylonjs.com/babylon101/sprites
  16348. */
  16349. export class Sprite {
  16350. /** defines the name */
  16351. name: string;
  16352. /** Gets or sets the current world position */
  16353. position: Vector3;
  16354. /** Gets or sets the main color */
  16355. color: Color4;
  16356. /** Gets or sets the width */
  16357. width: number;
  16358. /** Gets or sets the height */
  16359. height: number;
  16360. /** Gets or sets rotation angle */
  16361. angle: number;
  16362. /** Gets or sets the cell index in the sprite sheet */
  16363. cellIndex: number;
  16364. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  16365. invertU: number;
  16366. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  16367. invertV: number;
  16368. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  16369. disposeWhenFinishedAnimating: boolean;
  16370. /** Gets the list of attached animations */
  16371. animations: Animation[];
  16372. /** Gets or sets a boolean indicating if the sprite can be picked */
  16373. isPickable: boolean;
  16374. /**
  16375. * Gets or sets the associated action manager
  16376. */
  16377. actionManager: Nullable<ActionManager>;
  16378. private _animationStarted;
  16379. private _loopAnimation;
  16380. private _fromIndex;
  16381. private _toIndex;
  16382. private _delay;
  16383. private _direction;
  16384. private _manager;
  16385. private _time;
  16386. private _onAnimationEnd;
  16387. /**
  16388. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  16389. */
  16390. isVisible: boolean;
  16391. /**
  16392. * Gets or sets the sprite size
  16393. */
  16394. size: number;
  16395. /**
  16396. * Creates a new Sprite
  16397. * @param name defines the name
  16398. * @param manager defines the manager
  16399. */
  16400. constructor(
  16401. /** defines the name */
  16402. name: string, manager: ISpriteManager);
  16403. /**
  16404. * Starts an animation
  16405. * @param from defines the initial key
  16406. * @param to defines the end key
  16407. * @param loop defines if the animation must loop
  16408. * @param delay defines the start delay (in ms)
  16409. * @param onAnimationEnd defines a callback to call when animation ends
  16410. */
  16411. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  16412. /** Stops current animation (if any) */
  16413. stopAnimation(): void;
  16414. /** @hidden */
  16415. _animate(deltaTime: number): void;
  16416. /** Release associated resources */
  16417. dispose(): void;
  16418. }
  16419. }
  16420. declare module BABYLON {
  16421. /**
  16422. * Information about the result of picking within a scene
  16423. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  16424. */
  16425. export class PickingInfo {
  16426. /** @hidden */
  16427. _pickingUnavailable: boolean;
  16428. /**
  16429. * If the pick collided with an object
  16430. */
  16431. hit: boolean;
  16432. /**
  16433. * Distance away where the pick collided
  16434. */
  16435. distance: number;
  16436. /**
  16437. * The location of pick collision
  16438. */
  16439. pickedPoint: Nullable<Vector3>;
  16440. /**
  16441. * The mesh corresponding the the pick collision
  16442. */
  16443. pickedMesh: Nullable<AbstractMesh>;
  16444. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  16445. bu: number;
  16446. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  16447. bv: number;
  16448. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  16449. faceId: number;
  16450. /** Id of the the submesh that was picked */
  16451. subMeshId: number;
  16452. /** If a sprite was picked, this will be the sprite the pick collided with */
  16453. pickedSprite: Nullable<Sprite>;
  16454. /**
  16455. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  16456. */
  16457. originMesh: Nullable<AbstractMesh>;
  16458. /**
  16459. * The ray that was used to perform the picking.
  16460. */
  16461. ray: Nullable<Ray>;
  16462. /**
  16463. * Gets the normal correspodning to the face the pick collided with
  16464. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  16465. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  16466. * @returns The normal correspodning to the face the pick collided with
  16467. */
  16468. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  16469. /**
  16470. * Gets the texture coordinates of where the pick occured
  16471. * @returns the vector containing the coordnates of the texture
  16472. */
  16473. getTextureCoordinates(): Nullable<Vector2>;
  16474. }
  16475. }
  16476. declare module BABYLON {
  16477. /**
  16478. * Gather the list of pointer event types as constants.
  16479. */
  16480. export class PointerEventTypes {
  16481. /**
  16482. * 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.
  16483. */
  16484. static readonly POINTERDOWN: number;
  16485. /**
  16486. * The pointerup event is fired when a pointer is no longer active.
  16487. */
  16488. static readonly POINTERUP: number;
  16489. /**
  16490. * The pointermove event is fired when a pointer changes coordinates.
  16491. */
  16492. static readonly POINTERMOVE: number;
  16493. /**
  16494. * The pointerwheel event is fired when a mouse wheel has been rotated.
  16495. */
  16496. static readonly POINTERWHEEL: number;
  16497. /**
  16498. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  16499. */
  16500. static readonly POINTERPICK: number;
  16501. /**
  16502. * The pointertap event is fired when a the object has been touched and released without drag.
  16503. */
  16504. static readonly POINTERTAP: number;
  16505. /**
  16506. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  16507. */
  16508. static readonly POINTERDOUBLETAP: number;
  16509. }
  16510. /**
  16511. * Base class of pointer info types.
  16512. */
  16513. export class PointerInfoBase {
  16514. /**
  16515. * Defines the type of event (PointerEventTypes)
  16516. */
  16517. type: number;
  16518. /**
  16519. * Defines the related dom event
  16520. */
  16521. event: PointerEvent | MouseWheelEvent;
  16522. /**
  16523. * Instantiates the base class of pointers info.
  16524. * @param type Defines the type of event (PointerEventTypes)
  16525. * @param event Defines the related dom event
  16526. */
  16527. constructor(
  16528. /**
  16529. * Defines the type of event (PointerEventTypes)
  16530. */
  16531. type: number,
  16532. /**
  16533. * Defines the related dom event
  16534. */
  16535. event: PointerEvent | MouseWheelEvent);
  16536. }
  16537. /**
  16538. * This class is used to store pointer related info for the onPrePointerObservable event.
  16539. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  16540. */
  16541. export class PointerInfoPre extends PointerInfoBase {
  16542. /**
  16543. * Ray from a pointer if availible (eg. 6dof controller)
  16544. */
  16545. ray: Nullable<Ray>;
  16546. /**
  16547. * Defines the local position of the pointer on the canvas.
  16548. */
  16549. localPosition: Vector2;
  16550. /**
  16551. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  16552. */
  16553. skipOnPointerObservable: boolean;
  16554. /**
  16555. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  16556. * @param type Defines the type of event (PointerEventTypes)
  16557. * @param event Defines the related dom event
  16558. * @param localX Defines the local x coordinates of the pointer when the event occured
  16559. * @param localY Defines the local y coordinates of the pointer when the event occured
  16560. */
  16561. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  16562. }
  16563. /**
  16564. * This type contains all the data related to a pointer event in Babylon.js.
  16565. * 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.
  16566. */
  16567. export class PointerInfo extends PointerInfoBase {
  16568. /**
  16569. * Defines the picking info associated to the info (if any)\
  16570. */
  16571. pickInfo: Nullable<PickingInfo>;
  16572. /**
  16573. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  16574. * @param type Defines the type of event (PointerEventTypes)
  16575. * @param event Defines the related dom event
  16576. * @param pickInfo Defines the picking info associated to the info (if any)\
  16577. */
  16578. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  16579. /**
  16580. * Defines the picking info associated to the info (if any)\
  16581. */
  16582. pickInfo: Nullable<PickingInfo>);
  16583. }
  16584. /**
  16585. * Data relating to a touch event on the screen.
  16586. */
  16587. export interface PointerTouch {
  16588. /**
  16589. * X coordinate of touch.
  16590. */
  16591. x: number;
  16592. /**
  16593. * Y coordinate of touch.
  16594. */
  16595. y: number;
  16596. /**
  16597. * Id of touch. Unique for each finger.
  16598. */
  16599. pointerId: number;
  16600. /**
  16601. * Event type passed from DOM.
  16602. */
  16603. type: any;
  16604. }
  16605. }
  16606. declare module BABYLON {
  16607. /**
  16608. * Manage the mouse inputs to control the movement of a free camera.
  16609. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16610. */
  16611. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  16612. /**
  16613. * Define if touch is enabled in the mouse input
  16614. */
  16615. touchEnabled: boolean;
  16616. /**
  16617. * Defines the camera the input is attached to.
  16618. */
  16619. camera: FreeCamera;
  16620. /**
  16621. * Defines the buttons associated with the input to handle camera move.
  16622. */
  16623. buttons: number[];
  16624. /**
  16625. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  16626. */
  16627. angularSensibility: number;
  16628. private _pointerInput;
  16629. private _onMouseMove;
  16630. private _observer;
  16631. private previousPosition;
  16632. /**
  16633. * Observable for when a pointer move event occurs containing the move offset
  16634. */
  16635. onPointerMovedObservable: Observable<{
  16636. offsetX: number;
  16637. offsetY: number;
  16638. }>;
  16639. /**
  16640. * @hidden
  16641. * If the camera should be rotated automatically based on pointer movement
  16642. */
  16643. _allowCameraRotation: boolean;
  16644. /**
  16645. * Manage the mouse inputs to control the movement of a free camera.
  16646. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16647. * @param touchEnabled Defines if touch is enabled or not
  16648. */
  16649. constructor(
  16650. /**
  16651. * Define if touch is enabled in the mouse input
  16652. */
  16653. touchEnabled?: boolean);
  16654. /**
  16655. * Attach the input controls to a specific dom element to get the input from.
  16656. * @param element Defines the element the controls should be listened from
  16657. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16658. */
  16659. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16660. /**
  16661. * Called on JS contextmenu event.
  16662. * Override this method to provide functionality.
  16663. */
  16664. protected onContextMenu(evt: PointerEvent): void;
  16665. /**
  16666. * Detach the current controls from the specified dom element.
  16667. * @param element Defines the element to stop listening the inputs from
  16668. */
  16669. detachControl(element: Nullable<HTMLElement>): void;
  16670. /**
  16671. * Gets the class name of the current intput.
  16672. * @returns the class name
  16673. */
  16674. getClassName(): string;
  16675. /**
  16676. * Get the friendly name associated with the input class.
  16677. * @returns the input friendly name
  16678. */
  16679. getSimpleName(): string;
  16680. }
  16681. }
  16682. declare module BABYLON {
  16683. /**
  16684. * Manage the touch inputs to control the movement of a free camera.
  16685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16686. */
  16687. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  16688. /**
  16689. * Defines the camera the input is attached to.
  16690. */
  16691. camera: FreeCamera;
  16692. /**
  16693. * Defines the touch sensibility for rotation.
  16694. * The higher the faster.
  16695. */
  16696. touchAngularSensibility: number;
  16697. /**
  16698. * Defines the touch sensibility for move.
  16699. * The higher the faster.
  16700. */
  16701. touchMoveSensibility: number;
  16702. private _offsetX;
  16703. private _offsetY;
  16704. private _pointerPressed;
  16705. private _pointerInput;
  16706. private _observer;
  16707. private _onLostFocus;
  16708. /**
  16709. * Attach the input controls to a specific dom element to get the input from.
  16710. * @param element Defines the element the controls should be listened from
  16711. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16712. */
  16713. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16714. /**
  16715. * Detach the current controls from the specified dom element.
  16716. * @param element Defines the element to stop listening the inputs from
  16717. */
  16718. detachControl(element: Nullable<HTMLElement>): void;
  16719. /**
  16720. * Update the current camera state depending on the inputs that have been used this frame.
  16721. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  16722. */
  16723. checkInputs(): void;
  16724. /**
  16725. * Gets the class name of the current intput.
  16726. * @returns the class name
  16727. */
  16728. getClassName(): string;
  16729. /**
  16730. * Get the friendly name associated with the input class.
  16731. * @returns the input friendly name
  16732. */
  16733. getSimpleName(): string;
  16734. }
  16735. }
  16736. declare module BABYLON {
  16737. /**
  16738. * Default Inputs manager for the FreeCamera.
  16739. * It groups all the default supported inputs for ease of use.
  16740. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16741. */
  16742. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  16743. /**
  16744. * @hidden
  16745. */
  16746. _mouseInput: Nullable<FreeCameraMouseInput>;
  16747. /**
  16748. * Instantiates a new FreeCameraInputsManager.
  16749. * @param camera Defines the camera the inputs belong to
  16750. */
  16751. constructor(camera: FreeCamera);
  16752. /**
  16753. * Add keyboard input support to the input manager.
  16754. * @returns the current input manager
  16755. */
  16756. addKeyboard(): FreeCameraInputsManager;
  16757. /**
  16758. * Add mouse input support to the input manager.
  16759. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  16760. * @returns the current input manager
  16761. */
  16762. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  16763. /**
  16764. * Removes the mouse input support from the manager
  16765. * @returns the current input manager
  16766. */
  16767. removeMouse(): FreeCameraInputsManager;
  16768. /**
  16769. * Add touch input support to the input manager.
  16770. * @returns the current input manager
  16771. */
  16772. addTouch(): FreeCameraInputsManager;
  16773. /**
  16774. * Remove all attached input methods from a camera
  16775. */
  16776. clear(): void;
  16777. }
  16778. }
  16779. declare module BABYLON {
  16780. /**
  16781. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  16782. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  16783. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  16784. */
  16785. export class FreeCamera extends TargetCamera {
  16786. /**
  16787. * Define the collision ellipsoid of the camera.
  16788. * This is helpful to simulate a camera body like the player body around the camera
  16789. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  16790. */
  16791. ellipsoid: Vector3;
  16792. /**
  16793. * Define an offset for the position of the ellipsoid around the camera.
  16794. * This can be helpful to determine the center of the body near the gravity center of the body
  16795. * instead of its head.
  16796. */
  16797. ellipsoidOffset: Vector3;
  16798. /**
  16799. * Enable or disable collisions of the camera with the rest of the scene objects.
  16800. */
  16801. checkCollisions: boolean;
  16802. /**
  16803. * Enable or disable gravity on the camera.
  16804. */
  16805. applyGravity: boolean;
  16806. /**
  16807. * Define the input manager associated to the camera.
  16808. */
  16809. inputs: FreeCameraInputsManager;
  16810. /**
  16811. * Gets the input sensibility for a mouse input. (default is 2000.0)
  16812. * Higher values reduce sensitivity.
  16813. */
  16814. /**
  16815. * Sets the input sensibility for a mouse input. (default is 2000.0)
  16816. * Higher values reduce sensitivity.
  16817. */
  16818. angularSensibility: number;
  16819. /**
  16820. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  16821. */
  16822. keysUp: number[];
  16823. /**
  16824. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  16825. */
  16826. keysDown: number[];
  16827. /**
  16828. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  16829. */
  16830. keysLeft: number[];
  16831. /**
  16832. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  16833. */
  16834. keysRight: number[];
  16835. /**
  16836. * Event raised when the camera collide with a mesh in the scene.
  16837. */
  16838. onCollide: (collidedMesh: AbstractMesh) => void;
  16839. private _collider;
  16840. private _needMoveForGravity;
  16841. private _oldPosition;
  16842. private _diffPosition;
  16843. private _newPosition;
  16844. /** @hidden */
  16845. _localDirection: Vector3;
  16846. /** @hidden */
  16847. _transformedDirection: Vector3;
  16848. /**
  16849. * Instantiates a Free Camera.
  16850. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  16851. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  16852. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  16853. * @param name Define the name of the camera in the scene
  16854. * @param position Define the start position of the camera in the scene
  16855. * @param scene Define the scene the camera belongs to
  16856. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  16857. */
  16858. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  16859. /**
  16860. * Attached controls to the current camera.
  16861. * @param element Defines the element the controls should be listened from
  16862. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16863. */
  16864. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16865. /**
  16866. * Detach the current controls from the camera.
  16867. * The camera will stop reacting to inputs.
  16868. * @param element Defines the element to stop listening the inputs from
  16869. */
  16870. detachControl(element: HTMLElement): void;
  16871. private _collisionMask;
  16872. /**
  16873. * Define a collision mask to limit the list of object the camera can collide with
  16874. */
  16875. collisionMask: number;
  16876. /** @hidden */
  16877. _collideWithWorld(displacement: Vector3): void;
  16878. private _onCollisionPositionChange;
  16879. /** @hidden */
  16880. _checkInputs(): void;
  16881. /** @hidden */
  16882. _decideIfNeedsToMove(): boolean;
  16883. /** @hidden */
  16884. _updatePosition(): void;
  16885. /**
  16886. * Destroy the camera and release the current resources hold by it.
  16887. */
  16888. dispose(): void;
  16889. /**
  16890. * Gets the current object class name.
  16891. * @return the class name
  16892. */
  16893. getClassName(): string;
  16894. }
  16895. }
  16896. declare module BABYLON {
  16897. /**
  16898. * Represents a gamepad control stick position
  16899. */
  16900. export class StickValues {
  16901. /**
  16902. * The x component of the control stick
  16903. */
  16904. x: number;
  16905. /**
  16906. * The y component of the control stick
  16907. */
  16908. y: number;
  16909. /**
  16910. * Initializes the gamepad x and y control stick values
  16911. * @param x The x component of the gamepad control stick value
  16912. * @param y The y component of the gamepad control stick value
  16913. */
  16914. constructor(
  16915. /**
  16916. * The x component of the control stick
  16917. */
  16918. x: number,
  16919. /**
  16920. * The y component of the control stick
  16921. */
  16922. y: number);
  16923. }
  16924. /**
  16925. * An interface which manages callbacks for gamepad button changes
  16926. */
  16927. export interface GamepadButtonChanges {
  16928. /**
  16929. * Called when a gamepad has been changed
  16930. */
  16931. changed: boolean;
  16932. /**
  16933. * Called when a gamepad press event has been triggered
  16934. */
  16935. pressChanged: boolean;
  16936. /**
  16937. * Called when a touch event has been triggered
  16938. */
  16939. touchChanged: boolean;
  16940. /**
  16941. * Called when a value has changed
  16942. */
  16943. valueChanged: boolean;
  16944. }
  16945. /**
  16946. * Represents a gamepad
  16947. */
  16948. export class Gamepad {
  16949. /**
  16950. * The id of the gamepad
  16951. */
  16952. id: string;
  16953. /**
  16954. * The index of the gamepad
  16955. */
  16956. index: number;
  16957. /**
  16958. * The browser gamepad
  16959. */
  16960. browserGamepad: any;
  16961. /**
  16962. * Specifies what type of gamepad this represents
  16963. */
  16964. type: number;
  16965. private _leftStick;
  16966. private _rightStick;
  16967. /** @hidden */
  16968. _isConnected: boolean;
  16969. private _leftStickAxisX;
  16970. private _leftStickAxisY;
  16971. private _rightStickAxisX;
  16972. private _rightStickAxisY;
  16973. /**
  16974. * Triggered when the left control stick has been changed
  16975. */
  16976. private _onleftstickchanged;
  16977. /**
  16978. * Triggered when the right control stick has been changed
  16979. */
  16980. private _onrightstickchanged;
  16981. /**
  16982. * Represents a gamepad controller
  16983. */
  16984. static GAMEPAD: number;
  16985. /**
  16986. * Represents a generic controller
  16987. */
  16988. static GENERIC: number;
  16989. /**
  16990. * Represents an XBox controller
  16991. */
  16992. static XBOX: number;
  16993. /**
  16994. * Represents a pose-enabled controller
  16995. */
  16996. static POSE_ENABLED: number;
  16997. /**
  16998. * Specifies whether the left control stick should be Y-inverted
  16999. */
  17000. protected _invertLeftStickY: boolean;
  17001. /**
  17002. * Specifies if the gamepad has been connected
  17003. */
  17004. readonly isConnected: boolean;
  17005. /**
  17006. * Initializes the gamepad
  17007. * @param id The id of the gamepad
  17008. * @param index The index of the gamepad
  17009. * @param browserGamepad The browser gamepad
  17010. * @param leftStickX The x component of the left joystick
  17011. * @param leftStickY The y component of the left joystick
  17012. * @param rightStickX The x component of the right joystick
  17013. * @param rightStickY The y component of the right joystick
  17014. */
  17015. constructor(
  17016. /**
  17017. * The id of the gamepad
  17018. */
  17019. id: string,
  17020. /**
  17021. * The index of the gamepad
  17022. */
  17023. index: number,
  17024. /**
  17025. * The browser gamepad
  17026. */
  17027. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  17028. /**
  17029. * Callback triggered when the left joystick has changed
  17030. * @param callback
  17031. */
  17032. onleftstickchanged(callback: (values: StickValues) => void): void;
  17033. /**
  17034. * Callback triggered when the right joystick has changed
  17035. * @param callback
  17036. */
  17037. onrightstickchanged(callback: (values: StickValues) => void): void;
  17038. /**
  17039. * Gets the left joystick
  17040. */
  17041. /**
  17042. * Sets the left joystick values
  17043. */
  17044. leftStick: StickValues;
  17045. /**
  17046. * Gets the right joystick
  17047. */
  17048. /**
  17049. * Sets the right joystick value
  17050. */
  17051. rightStick: StickValues;
  17052. /**
  17053. * Updates the gamepad joystick positions
  17054. */
  17055. update(): void;
  17056. /**
  17057. * Disposes the gamepad
  17058. */
  17059. dispose(): void;
  17060. }
  17061. /**
  17062. * Represents a generic gamepad
  17063. */
  17064. export class GenericPad extends Gamepad {
  17065. private _buttons;
  17066. private _onbuttondown;
  17067. private _onbuttonup;
  17068. /**
  17069. * Observable triggered when a button has been pressed
  17070. */
  17071. onButtonDownObservable: Observable<number>;
  17072. /**
  17073. * Observable triggered when a button has been released
  17074. */
  17075. onButtonUpObservable: Observable<number>;
  17076. /**
  17077. * Callback triggered when a button has been pressed
  17078. * @param callback Called when a button has been pressed
  17079. */
  17080. onbuttondown(callback: (buttonPressed: number) => void): void;
  17081. /**
  17082. * Callback triggered when a button has been released
  17083. * @param callback Called when a button has been released
  17084. */
  17085. onbuttonup(callback: (buttonReleased: number) => void): void;
  17086. /**
  17087. * Initializes the generic gamepad
  17088. * @param id The id of the generic gamepad
  17089. * @param index The index of the generic gamepad
  17090. * @param browserGamepad The browser gamepad
  17091. */
  17092. constructor(id: string, index: number, browserGamepad: any);
  17093. private _setButtonValue;
  17094. /**
  17095. * Updates the generic gamepad
  17096. */
  17097. update(): void;
  17098. /**
  17099. * Disposes the generic gamepad
  17100. */
  17101. dispose(): void;
  17102. }
  17103. }
  17104. declare module BABYLON {
  17105. /**
  17106. * Defines the types of pose enabled controllers that are supported
  17107. */
  17108. export enum PoseEnabledControllerType {
  17109. /**
  17110. * HTC Vive
  17111. */
  17112. VIVE = 0,
  17113. /**
  17114. * Oculus Rift
  17115. */
  17116. OCULUS = 1,
  17117. /**
  17118. * Windows mixed reality
  17119. */
  17120. WINDOWS = 2,
  17121. /**
  17122. * Samsung gear VR
  17123. */
  17124. GEAR_VR = 3,
  17125. /**
  17126. * Google Daydream
  17127. */
  17128. DAYDREAM = 4,
  17129. /**
  17130. * Generic
  17131. */
  17132. GENERIC = 5
  17133. }
  17134. /**
  17135. * Defines the MutableGamepadButton interface for the state of a gamepad button
  17136. */
  17137. export interface MutableGamepadButton {
  17138. /**
  17139. * Value of the button/trigger
  17140. */
  17141. value: number;
  17142. /**
  17143. * If the button/trigger is currently touched
  17144. */
  17145. touched: boolean;
  17146. /**
  17147. * If the button/trigger is currently pressed
  17148. */
  17149. pressed: boolean;
  17150. }
  17151. /**
  17152. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  17153. * @hidden
  17154. */
  17155. export interface ExtendedGamepadButton extends GamepadButton {
  17156. /**
  17157. * If the button/trigger is currently pressed
  17158. */
  17159. readonly pressed: boolean;
  17160. /**
  17161. * If the button/trigger is currently touched
  17162. */
  17163. readonly touched: boolean;
  17164. /**
  17165. * Value of the button/trigger
  17166. */
  17167. readonly value: number;
  17168. }
  17169. /** @hidden */
  17170. export interface _GamePadFactory {
  17171. /**
  17172. * Returns wether or not the current gamepad can be created for this type of controller.
  17173. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17174. * @returns true if it can be created, otherwise false
  17175. */
  17176. canCreate(gamepadInfo: any): boolean;
  17177. /**
  17178. * Creates a new instance of the Gamepad.
  17179. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17180. * @returns the new gamepad instance
  17181. */
  17182. create(gamepadInfo: any): Gamepad;
  17183. }
  17184. /**
  17185. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17186. */
  17187. export class PoseEnabledControllerHelper {
  17188. /** @hidden */
  17189. static _ControllerFactories: _GamePadFactory[];
  17190. /** @hidden */
  17191. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  17192. /**
  17193. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17194. * @param vrGamepad the gamepad to initialized
  17195. * @returns a vr controller of the type the gamepad identified as
  17196. */
  17197. static InitiateController(vrGamepad: any): Gamepad;
  17198. }
  17199. /**
  17200. * Defines the PoseEnabledController object that contains state of a vr capable controller
  17201. */
  17202. export class PoseEnabledController extends Gamepad implements PoseControlled {
  17203. private _deviceRoomPosition;
  17204. private _deviceRoomRotationQuaternion;
  17205. /**
  17206. * The device position in babylon space
  17207. */
  17208. devicePosition: Vector3;
  17209. /**
  17210. * The device rotation in babylon space
  17211. */
  17212. deviceRotationQuaternion: Quaternion;
  17213. /**
  17214. * The scale factor of the device in babylon space
  17215. */
  17216. deviceScaleFactor: number;
  17217. /**
  17218. * (Likely devicePosition should be used instead) The device position in its room space
  17219. */
  17220. position: Vector3;
  17221. /**
  17222. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  17223. */
  17224. rotationQuaternion: Quaternion;
  17225. /**
  17226. * The type of controller (Eg. Windows mixed reality)
  17227. */
  17228. controllerType: PoseEnabledControllerType;
  17229. protected _calculatedPosition: Vector3;
  17230. private _calculatedRotation;
  17231. /**
  17232. * The raw pose from the device
  17233. */
  17234. rawPose: DevicePose;
  17235. private _trackPosition;
  17236. private _maxRotationDistFromHeadset;
  17237. private _draggedRoomRotation;
  17238. /**
  17239. * @hidden
  17240. */
  17241. _disableTrackPosition(fixedPosition: Vector3): void;
  17242. /**
  17243. * Internal, the mesh attached to the controller
  17244. * @hidden
  17245. */
  17246. _mesh: Nullable<AbstractMesh>;
  17247. private _poseControlledCamera;
  17248. private _leftHandSystemQuaternion;
  17249. /**
  17250. * Internal, matrix used to convert room space to babylon space
  17251. * @hidden
  17252. */
  17253. _deviceToWorld: Matrix;
  17254. /**
  17255. * Node to be used when casting a ray from the controller
  17256. * @hidden
  17257. */
  17258. _pointingPoseNode: Nullable<TransformNode>;
  17259. /**
  17260. * Name of the child mesh that can be used to cast a ray from the controller
  17261. */
  17262. static readonly POINTING_POSE: string;
  17263. /**
  17264. * Creates a new PoseEnabledController from a gamepad
  17265. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  17266. */
  17267. constructor(browserGamepad: any);
  17268. private _workingMatrix;
  17269. /**
  17270. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  17271. */
  17272. update(): void;
  17273. /**
  17274. * Updates only the pose device and mesh without doing any button event checking
  17275. */
  17276. protected _updatePoseAndMesh(): void;
  17277. /**
  17278. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  17279. * @param poseData raw pose fromthe device
  17280. */
  17281. updateFromDevice(poseData: DevicePose): void;
  17282. /**
  17283. * @hidden
  17284. */
  17285. _meshAttachedObservable: Observable<AbstractMesh>;
  17286. /**
  17287. * Attaches a mesh to the controller
  17288. * @param mesh the mesh to be attached
  17289. */
  17290. attachToMesh(mesh: AbstractMesh): void;
  17291. /**
  17292. * Attaches the controllers mesh to a camera
  17293. * @param camera the camera the mesh should be attached to
  17294. */
  17295. attachToPoseControlledCamera(camera: TargetCamera): void;
  17296. /**
  17297. * Disposes of the controller
  17298. */
  17299. dispose(): void;
  17300. /**
  17301. * The mesh that is attached to the controller
  17302. */
  17303. readonly mesh: Nullable<AbstractMesh>;
  17304. /**
  17305. * Gets the ray of the controller in the direction the controller is pointing
  17306. * @param length the length the resulting ray should be
  17307. * @returns a ray in the direction the controller is pointing
  17308. */
  17309. getForwardRay(length?: number): Ray;
  17310. }
  17311. }
  17312. declare module BABYLON {
  17313. /**
  17314. * Defines the WebVRController object that represents controllers tracked in 3D space
  17315. */
  17316. export abstract class WebVRController extends PoseEnabledController {
  17317. /**
  17318. * Internal, the default controller model for the controller
  17319. */
  17320. protected _defaultModel: AbstractMesh;
  17321. /**
  17322. * Fired when the trigger state has changed
  17323. */
  17324. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  17325. /**
  17326. * Fired when the main button state has changed
  17327. */
  17328. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17329. /**
  17330. * Fired when the secondary button state has changed
  17331. */
  17332. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17333. /**
  17334. * Fired when the pad state has changed
  17335. */
  17336. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  17337. /**
  17338. * Fired when controllers stick values have changed
  17339. */
  17340. onPadValuesChangedObservable: Observable<StickValues>;
  17341. /**
  17342. * Array of button availible on the controller
  17343. */
  17344. protected _buttons: Array<MutableGamepadButton>;
  17345. private _onButtonStateChange;
  17346. /**
  17347. * Fired when a controller button's state has changed
  17348. * @param callback the callback containing the button that was modified
  17349. */
  17350. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  17351. /**
  17352. * X and Y axis corresponding to the controllers joystick
  17353. */
  17354. pad: StickValues;
  17355. /**
  17356. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  17357. */
  17358. hand: string;
  17359. /**
  17360. * The default controller model for the controller
  17361. */
  17362. readonly defaultModel: AbstractMesh;
  17363. /**
  17364. * Creates a new WebVRController from a gamepad
  17365. * @param vrGamepad the gamepad that the WebVRController should be created from
  17366. */
  17367. constructor(vrGamepad: any);
  17368. /**
  17369. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  17370. */
  17371. update(): void;
  17372. /**
  17373. * Function to be called when a button is modified
  17374. */
  17375. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  17376. /**
  17377. * Loads a mesh and attaches it to the controller
  17378. * @param scene the scene the mesh should be added to
  17379. * @param meshLoaded callback for when the mesh has been loaded
  17380. */
  17381. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  17382. private _setButtonValue;
  17383. private _changes;
  17384. private _checkChanges;
  17385. /**
  17386. * Disposes of th webVRCOntroller
  17387. */
  17388. dispose(): void;
  17389. }
  17390. }
  17391. declare module BABYLON {
  17392. /**
  17393. * The HemisphericLight simulates the ambient environment light,
  17394. * so the passed direction is the light reflection direction, not the incoming direction.
  17395. */
  17396. export class HemisphericLight extends Light {
  17397. /**
  17398. * The groundColor is the light in the opposite direction to the one specified during creation.
  17399. * 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.
  17400. */
  17401. groundColor: Color3;
  17402. /**
  17403. * The light reflection direction, not the incoming direction.
  17404. */
  17405. direction: Vector3;
  17406. /**
  17407. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  17408. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  17409. * The HemisphericLight can't cast shadows.
  17410. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17411. * @param name The friendly name of the light
  17412. * @param direction The direction of the light reflection
  17413. * @param scene The scene the light belongs to
  17414. */
  17415. constructor(name: string, direction: Vector3, scene: Scene);
  17416. protected _buildUniformLayout(): void;
  17417. /**
  17418. * Returns the string "HemisphericLight".
  17419. * @return The class name
  17420. */
  17421. getClassName(): string;
  17422. /**
  17423. * Sets the HemisphericLight direction towards the passed target (Vector3).
  17424. * Returns the updated direction.
  17425. * @param target The target the direction should point to
  17426. * @return The computed direction
  17427. */
  17428. setDirectionToTarget(target: Vector3): Vector3;
  17429. /**
  17430. * Returns the shadow generator associated to the light.
  17431. * @returns Always null for hemispheric lights because it does not support shadows.
  17432. */
  17433. getShadowGenerator(): Nullable<IShadowGenerator>;
  17434. /**
  17435. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  17436. * @param effect The effect to update
  17437. * @param lightIndex The index of the light in the effect to update
  17438. * @returns The hemispheric light
  17439. */
  17440. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  17441. /**
  17442. * Computes the world matrix of the node
  17443. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  17444. * @param useWasUpdatedFlag defines a reserved property
  17445. * @returns the world matrix
  17446. */
  17447. computeWorldMatrix(): Matrix;
  17448. /**
  17449. * Returns the integer 3.
  17450. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17451. */
  17452. getTypeID(): number;
  17453. /**
  17454. * Prepares the list of defines specific to the light type.
  17455. * @param defines the list of defines
  17456. * @param lightIndex defines the index of the light for the effect
  17457. */
  17458. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17459. }
  17460. }
  17461. declare module BABYLON {
  17462. /** @hidden */
  17463. export var vrMultiviewToSingleviewPixelShader: {
  17464. name: string;
  17465. shader: string;
  17466. };
  17467. }
  17468. declare module BABYLON {
  17469. /**
  17470. * Renders to multiple views with a single draw call
  17471. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  17472. */
  17473. export class MultiviewRenderTarget extends RenderTargetTexture {
  17474. /**
  17475. * Creates a multiview render target
  17476. * @param scene scene used with the render target
  17477. * @param size the size of the render target (used for each view)
  17478. */
  17479. constructor(scene: Scene, size?: number | {
  17480. width: number;
  17481. height: number;
  17482. } | {
  17483. ratio: number;
  17484. });
  17485. /**
  17486. * @hidden
  17487. * @param faceIndex the face index, if its a cube texture
  17488. */
  17489. _bindFrameBuffer(faceIndex?: number): void;
  17490. /**
  17491. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17492. * @returns the view count
  17493. */
  17494. getViewCount(): number;
  17495. }
  17496. }
  17497. declare module BABYLON {
  17498. interface Engine {
  17499. /**
  17500. * Creates a new multiview render target
  17501. * @param width defines the width of the texture
  17502. * @param height defines the height of the texture
  17503. * @returns the created multiview texture
  17504. */
  17505. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  17506. /**
  17507. * Binds a multiview framebuffer to be drawn to
  17508. * @param multiviewTexture texture to bind
  17509. */
  17510. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  17511. }
  17512. interface Camera {
  17513. /**
  17514. * @hidden
  17515. * 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)
  17516. */
  17517. _useMultiviewToSingleView: boolean;
  17518. /**
  17519. * @hidden
  17520. * 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)
  17521. */
  17522. _multiviewTexture: Nullable<RenderTargetTexture>;
  17523. /**
  17524. * @hidden
  17525. * ensures the multiview texture of the camera exists and has the specified width/height
  17526. * @param width height to set on the multiview texture
  17527. * @param height width to set on the multiview texture
  17528. */
  17529. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  17530. }
  17531. interface Scene {
  17532. /** @hidden */
  17533. _transformMatrixR: Matrix;
  17534. /** @hidden */
  17535. _multiviewSceneUbo: Nullable<UniformBuffer>;
  17536. /** @hidden */
  17537. _createMultiviewUbo(): void;
  17538. /** @hidden */
  17539. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  17540. /** @hidden */
  17541. _renderMultiviewToSingleView(camera: Camera): void;
  17542. }
  17543. }
  17544. declare module BABYLON {
  17545. /**
  17546. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  17547. * This will not be used for webXR as it supports displaying texture arrays directly
  17548. */
  17549. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  17550. /**
  17551. * Initializes a VRMultiviewToSingleview
  17552. * @param name name of the post process
  17553. * @param camera camera to be applied to
  17554. * @param scaleFactor scaling factor to the size of the output texture
  17555. */
  17556. constructor(name: string, camera: Camera, scaleFactor: number);
  17557. }
  17558. }
  17559. declare module BABYLON {
  17560. interface Engine {
  17561. /** @hidden */
  17562. _vrDisplay: any;
  17563. /** @hidden */
  17564. _vrSupported: boolean;
  17565. /** @hidden */
  17566. _oldSize: Size;
  17567. /** @hidden */
  17568. _oldHardwareScaleFactor: number;
  17569. /** @hidden */
  17570. _vrExclusivePointerMode: boolean;
  17571. /** @hidden */
  17572. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  17573. /** @hidden */
  17574. _onVRDisplayPointerRestricted: () => void;
  17575. /** @hidden */
  17576. _onVRDisplayPointerUnrestricted: () => void;
  17577. /** @hidden */
  17578. _onVrDisplayConnect: Nullable<(display: any) => void>;
  17579. /** @hidden */
  17580. _onVrDisplayDisconnect: Nullable<() => void>;
  17581. /** @hidden */
  17582. _onVrDisplayPresentChange: Nullable<() => void>;
  17583. /**
  17584. * Observable signaled when VR display mode changes
  17585. */
  17586. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  17587. /**
  17588. * Observable signaled when VR request present is complete
  17589. */
  17590. onVRRequestPresentComplete: Observable<boolean>;
  17591. /**
  17592. * Observable signaled when VR request present starts
  17593. */
  17594. onVRRequestPresentStart: Observable<Engine>;
  17595. /**
  17596. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  17597. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  17598. */
  17599. isInVRExclusivePointerMode: boolean;
  17600. /**
  17601. * Gets a boolean indicating if a webVR device was detected
  17602. * @returns true if a webVR device was detected
  17603. */
  17604. isVRDevicePresent(): boolean;
  17605. /**
  17606. * Gets the current webVR device
  17607. * @returns the current webVR device (or null)
  17608. */
  17609. getVRDevice(): any;
  17610. /**
  17611. * Initializes a webVR display and starts listening to display change events
  17612. * The onVRDisplayChangedObservable will be notified upon these changes
  17613. * @returns A promise containing a VRDisplay and if vr is supported
  17614. */
  17615. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  17616. /** @hidden */
  17617. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  17618. /**
  17619. * Call this function to switch to webVR mode
  17620. * Will do nothing if webVR is not supported or if there is no webVR device
  17621. * @see http://doc.babylonjs.com/how_to/webvr_camera
  17622. */
  17623. enableVR(): void;
  17624. /** @hidden */
  17625. _onVRFullScreenTriggered(): void;
  17626. }
  17627. }
  17628. declare module BABYLON {
  17629. /**
  17630. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  17631. * IMPORTANT!! The data is right-hand data.
  17632. * @export
  17633. * @interface DevicePose
  17634. */
  17635. export interface DevicePose {
  17636. /**
  17637. * The position of the device, values in array are [x,y,z].
  17638. */
  17639. readonly position: Nullable<Float32Array>;
  17640. /**
  17641. * The linearVelocity of the device, values in array are [x,y,z].
  17642. */
  17643. readonly linearVelocity: Nullable<Float32Array>;
  17644. /**
  17645. * The linearAcceleration of the device, values in array are [x,y,z].
  17646. */
  17647. readonly linearAcceleration: Nullable<Float32Array>;
  17648. /**
  17649. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  17650. */
  17651. readonly orientation: Nullable<Float32Array>;
  17652. /**
  17653. * The angularVelocity of the device, values in array are [x,y,z].
  17654. */
  17655. readonly angularVelocity: Nullable<Float32Array>;
  17656. /**
  17657. * The angularAcceleration of the device, values in array are [x,y,z].
  17658. */
  17659. readonly angularAcceleration: Nullable<Float32Array>;
  17660. }
  17661. /**
  17662. * Interface representing a pose controlled object in Babylon.
  17663. * A pose controlled object has both regular pose values as well as pose values
  17664. * from an external device such as a VR head mounted display
  17665. */
  17666. export interface PoseControlled {
  17667. /**
  17668. * The position of the object in babylon space.
  17669. */
  17670. position: Vector3;
  17671. /**
  17672. * The rotation quaternion of the object in babylon space.
  17673. */
  17674. rotationQuaternion: Quaternion;
  17675. /**
  17676. * The position of the device in babylon space.
  17677. */
  17678. devicePosition?: Vector3;
  17679. /**
  17680. * The rotation quaternion of the device in babylon space.
  17681. */
  17682. deviceRotationQuaternion: Quaternion;
  17683. /**
  17684. * The raw pose coming from the device.
  17685. */
  17686. rawPose: Nullable<DevicePose>;
  17687. /**
  17688. * The scale of the device to be used when translating from device space to babylon space.
  17689. */
  17690. deviceScaleFactor: number;
  17691. /**
  17692. * Updates the poseControlled values based on the input device pose.
  17693. * @param poseData the pose data to update the object with
  17694. */
  17695. updateFromDevice(poseData: DevicePose): void;
  17696. }
  17697. /**
  17698. * Set of options to customize the webVRCamera
  17699. */
  17700. export interface WebVROptions {
  17701. /**
  17702. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  17703. */
  17704. trackPosition?: boolean;
  17705. /**
  17706. * Sets the scale of the vrDevice in babylon space. (default: 1)
  17707. */
  17708. positionScale?: number;
  17709. /**
  17710. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  17711. */
  17712. displayName?: string;
  17713. /**
  17714. * Should the native controller meshes be initialized. (default: true)
  17715. */
  17716. controllerMeshes?: boolean;
  17717. /**
  17718. * Creating a default HemiLight only on controllers. (default: true)
  17719. */
  17720. defaultLightingOnControllers?: boolean;
  17721. /**
  17722. * If you don't want to use the default VR button of the helper. (default: false)
  17723. */
  17724. useCustomVRButton?: boolean;
  17725. /**
  17726. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  17727. */
  17728. customVRButton?: HTMLButtonElement;
  17729. /**
  17730. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  17731. */
  17732. rayLength?: number;
  17733. /**
  17734. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  17735. */
  17736. defaultHeight?: number;
  17737. /**
  17738. * If multiview should be used if availible (default: false)
  17739. */
  17740. useMultiview?: boolean;
  17741. }
  17742. /**
  17743. * This represents a WebVR camera.
  17744. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  17745. * @example http://doc.babylonjs.com/how_to/webvr_camera
  17746. */
  17747. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  17748. private webVROptions;
  17749. /**
  17750. * @hidden
  17751. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  17752. */
  17753. _vrDevice: any;
  17754. /**
  17755. * The rawPose of the vrDevice.
  17756. */
  17757. rawPose: Nullable<DevicePose>;
  17758. private _onVREnabled;
  17759. private _specsVersion;
  17760. private _attached;
  17761. private _frameData;
  17762. protected _descendants: Array<Node>;
  17763. private _deviceRoomPosition;
  17764. /** @hidden */
  17765. _deviceRoomRotationQuaternion: Quaternion;
  17766. private _standingMatrix;
  17767. /**
  17768. * Represents device position in babylon space.
  17769. */
  17770. devicePosition: Vector3;
  17771. /**
  17772. * Represents device rotation in babylon space.
  17773. */
  17774. deviceRotationQuaternion: Quaternion;
  17775. /**
  17776. * The scale of the device to be used when translating from device space to babylon space.
  17777. */
  17778. deviceScaleFactor: number;
  17779. private _deviceToWorld;
  17780. private _worldToDevice;
  17781. /**
  17782. * References to the webVR controllers for the vrDevice.
  17783. */
  17784. controllers: Array<WebVRController>;
  17785. /**
  17786. * Emits an event when a controller is attached.
  17787. */
  17788. onControllersAttachedObservable: Observable<WebVRController[]>;
  17789. /**
  17790. * Emits an event when a controller's mesh has been loaded;
  17791. */
  17792. onControllerMeshLoadedObservable: Observable<WebVRController>;
  17793. /**
  17794. * Emits an event when the HMD's pose has been updated.
  17795. */
  17796. onPoseUpdatedFromDeviceObservable: Observable<any>;
  17797. private _poseSet;
  17798. /**
  17799. * If the rig cameras be used as parent instead of this camera.
  17800. */
  17801. rigParenting: boolean;
  17802. private _lightOnControllers;
  17803. private _defaultHeight?;
  17804. /**
  17805. * Instantiates a WebVRFreeCamera.
  17806. * @param name The name of the WebVRFreeCamera
  17807. * @param position The starting anchor position for the camera
  17808. * @param scene The scene the camera belongs to
  17809. * @param webVROptions a set of customizable options for the webVRCamera
  17810. */
  17811. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  17812. /**
  17813. * Gets the device distance from the ground in meters.
  17814. * @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.
  17815. */
  17816. deviceDistanceToRoomGround(): number;
  17817. /**
  17818. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17819. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  17820. */
  17821. useStandingMatrix(callback?: (bool: boolean) => void): void;
  17822. /**
  17823. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17824. * @returns A promise with a boolean set to if the standing matrix is supported.
  17825. */
  17826. useStandingMatrixAsync(): Promise<boolean>;
  17827. /**
  17828. * Disposes the camera
  17829. */
  17830. dispose(): void;
  17831. /**
  17832. * Gets a vrController by name.
  17833. * @param name The name of the controller to retreive
  17834. * @returns the controller matching the name specified or null if not found
  17835. */
  17836. getControllerByName(name: string): Nullable<WebVRController>;
  17837. private _leftController;
  17838. /**
  17839. * The controller corresponding to the users left hand.
  17840. */
  17841. readonly leftController: Nullable<WebVRController>;
  17842. private _rightController;
  17843. /**
  17844. * The controller corresponding to the users right hand.
  17845. */
  17846. readonly rightController: Nullable<WebVRController>;
  17847. /**
  17848. * Casts a ray forward from the vrCamera's gaze.
  17849. * @param length Length of the ray (default: 100)
  17850. * @returns the ray corresponding to the gaze
  17851. */
  17852. getForwardRay(length?: number): Ray;
  17853. /**
  17854. * @hidden
  17855. * Updates the camera based on device's frame data
  17856. */
  17857. _checkInputs(): void;
  17858. /**
  17859. * Updates the poseControlled values based on the input device pose.
  17860. * @param poseData Pose coming from the device
  17861. */
  17862. updateFromDevice(poseData: DevicePose): void;
  17863. private _htmlElementAttached;
  17864. private _detachIfAttached;
  17865. /**
  17866. * WebVR's attach control will start broadcasting frames to the device.
  17867. * Note that in certain browsers (chrome for example) this function must be called
  17868. * within a user-interaction callback. Example:
  17869. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  17870. *
  17871. * @param element html element to attach the vrDevice to
  17872. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  17873. */
  17874. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17875. /**
  17876. * Detaches the camera from the html element and disables VR
  17877. *
  17878. * @param element html element to detach from
  17879. */
  17880. detachControl(element: HTMLElement): void;
  17881. /**
  17882. * @returns the name of this class
  17883. */
  17884. getClassName(): string;
  17885. /**
  17886. * Calls resetPose on the vrDisplay
  17887. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  17888. */
  17889. resetToCurrentRotation(): void;
  17890. /**
  17891. * @hidden
  17892. * Updates the rig cameras (left and right eye)
  17893. */
  17894. _updateRigCameras(): void;
  17895. private _workingVector;
  17896. private _oneVector;
  17897. private _workingMatrix;
  17898. private updateCacheCalled;
  17899. private _correctPositionIfNotTrackPosition;
  17900. /**
  17901. * @hidden
  17902. * Updates the cached values of the camera
  17903. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  17904. */
  17905. _updateCache(ignoreParentClass?: boolean): void;
  17906. /**
  17907. * @hidden
  17908. * Get current device position in babylon world
  17909. */
  17910. _computeDevicePosition(): void;
  17911. /**
  17912. * Updates the current device position and rotation in the babylon world
  17913. */
  17914. update(): void;
  17915. /**
  17916. * @hidden
  17917. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  17918. * @returns an identity matrix
  17919. */
  17920. _getViewMatrix(): Matrix;
  17921. private _tmpMatrix;
  17922. /**
  17923. * This function is called by the two RIG cameras.
  17924. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  17925. * @hidden
  17926. */
  17927. _getWebVRViewMatrix(): Matrix;
  17928. /** @hidden */
  17929. _getWebVRProjectionMatrix(): Matrix;
  17930. private _onGamepadConnectedObserver;
  17931. private _onGamepadDisconnectedObserver;
  17932. private _updateCacheWhenTrackingDisabledObserver;
  17933. /**
  17934. * Initializes the controllers and their meshes
  17935. */
  17936. initControllers(): void;
  17937. }
  17938. }
  17939. declare module BABYLON {
  17940. /**
  17941. * Size options for a post process
  17942. */
  17943. export type PostProcessOptions = {
  17944. width: number;
  17945. height: number;
  17946. };
  17947. /**
  17948. * PostProcess can be used to apply a shader to a texture after it has been rendered
  17949. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  17950. */
  17951. export class PostProcess {
  17952. /** Name of the PostProcess. */
  17953. name: string;
  17954. /**
  17955. * Gets or sets the unique id of the post process
  17956. */
  17957. uniqueId: number;
  17958. /**
  17959. * Width of the texture to apply the post process on
  17960. */
  17961. width: number;
  17962. /**
  17963. * Height of the texture to apply the post process on
  17964. */
  17965. height: number;
  17966. /**
  17967. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  17968. * @hidden
  17969. */
  17970. _outputTexture: Nullable<InternalTexture>;
  17971. /**
  17972. * Sampling mode used by the shader
  17973. * See https://doc.babylonjs.com/classes/3.1/texture
  17974. */
  17975. renderTargetSamplingMode: number;
  17976. /**
  17977. * Clear color to use when screen clearing
  17978. */
  17979. clearColor: Color4;
  17980. /**
  17981. * If the buffer needs to be cleared before applying the post process. (default: true)
  17982. * Should be set to false if shader will overwrite all previous pixels.
  17983. */
  17984. autoClear: boolean;
  17985. /**
  17986. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  17987. */
  17988. alphaMode: number;
  17989. /**
  17990. * Sets the setAlphaBlendConstants of the babylon engine
  17991. */
  17992. alphaConstants: Color4;
  17993. /**
  17994. * Animations to be used for the post processing
  17995. */
  17996. animations: Animation[];
  17997. /**
  17998. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  17999. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  18000. */
  18001. enablePixelPerfectMode: boolean;
  18002. /**
  18003. * Force the postprocess to be applied without taking in account viewport
  18004. */
  18005. forceFullscreenViewport: boolean;
  18006. /**
  18007. * List of inspectable custom properties (used by the Inspector)
  18008. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18009. */
  18010. inspectableCustomProperties: IInspectable[];
  18011. /**
  18012. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  18013. *
  18014. * | Value | Type | Description |
  18015. * | ----- | ----------------------------------- | ----------- |
  18016. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  18017. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  18018. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  18019. *
  18020. */
  18021. scaleMode: number;
  18022. /**
  18023. * Force textures to be a power of two (default: false)
  18024. */
  18025. alwaysForcePOT: boolean;
  18026. private _samples;
  18027. /**
  18028. * Number of sample textures (default: 1)
  18029. */
  18030. samples: number;
  18031. /**
  18032. * Modify the scale of the post process to be the same as the viewport (default: false)
  18033. */
  18034. adaptScaleToCurrentViewport: boolean;
  18035. private _camera;
  18036. private _scene;
  18037. private _engine;
  18038. private _options;
  18039. private _reusable;
  18040. private _textureType;
  18041. /**
  18042. * Smart array of input and output textures for the post process.
  18043. * @hidden
  18044. */
  18045. _textures: SmartArray<InternalTexture>;
  18046. /**
  18047. * The index in _textures that corresponds to the output texture.
  18048. * @hidden
  18049. */
  18050. _currentRenderTextureInd: number;
  18051. private _effect;
  18052. private _samplers;
  18053. private _fragmentUrl;
  18054. private _vertexUrl;
  18055. private _parameters;
  18056. private _scaleRatio;
  18057. protected _indexParameters: any;
  18058. private _shareOutputWithPostProcess;
  18059. private _texelSize;
  18060. private _forcedOutputTexture;
  18061. /**
  18062. * Returns the fragment url or shader name used in the post process.
  18063. * @returns the fragment url or name in the shader store.
  18064. */
  18065. getEffectName(): string;
  18066. /**
  18067. * An event triggered when the postprocess is activated.
  18068. */
  18069. onActivateObservable: Observable<Camera>;
  18070. private _onActivateObserver;
  18071. /**
  18072. * A function that is added to the onActivateObservable
  18073. */
  18074. onActivate: Nullable<(camera: Camera) => void>;
  18075. /**
  18076. * An event triggered when the postprocess changes its size.
  18077. */
  18078. onSizeChangedObservable: Observable<PostProcess>;
  18079. private _onSizeChangedObserver;
  18080. /**
  18081. * A function that is added to the onSizeChangedObservable
  18082. */
  18083. onSizeChanged: (postProcess: PostProcess) => void;
  18084. /**
  18085. * An event triggered when the postprocess applies its effect.
  18086. */
  18087. onApplyObservable: Observable<Effect>;
  18088. private _onApplyObserver;
  18089. /**
  18090. * A function that is added to the onApplyObservable
  18091. */
  18092. onApply: (effect: Effect) => void;
  18093. /**
  18094. * An event triggered before rendering the postprocess
  18095. */
  18096. onBeforeRenderObservable: Observable<Effect>;
  18097. private _onBeforeRenderObserver;
  18098. /**
  18099. * A function that is added to the onBeforeRenderObservable
  18100. */
  18101. onBeforeRender: (effect: Effect) => void;
  18102. /**
  18103. * An event triggered after rendering the postprocess
  18104. */
  18105. onAfterRenderObservable: Observable<Effect>;
  18106. private _onAfterRenderObserver;
  18107. /**
  18108. * A function that is added to the onAfterRenderObservable
  18109. */
  18110. onAfterRender: (efect: Effect) => void;
  18111. /**
  18112. * 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
  18113. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  18114. */
  18115. inputTexture: InternalTexture;
  18116. /**
  18117. * Gets the camera which post process is applied to.
  18118. * @returns The camera the post process is applied to.
  18119. */
  18120. getCamera(): Camera;
  18121. /**
  18122. * Gets the texel size of the postprocess.
  18123. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  18124. */
  18125. readonly texelSize: Vector2;
  18126. /**
  18127. * Creates a new instance PostProcess
  18128. * @param name The name of the PostProcess.
  18129. * @param fragmentUrl The url of the fragment shader to be used.
  18130. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  18131. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  18132. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18133. * @param camera The camera to apply the render pass to.
  18134. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18135. * @param engine The engine which the post process will be applied. (default: current engine)
  18136. * @param reusable If the post process can be reused on the same frame. (default: false)
  18137. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  18138. * @param textureType Type of textures used when performing the post process. (default: 0)
  18139. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  18140. * @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
  18141. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  18142. */
  18143. constructor(
  18144. /** Name of the PostProcess. */
  18145. 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);
  18146. /**
  18147. * Gets a string idenfifying the name of the class
  18148. * @returns "PostProcess" string
  18149. */
  18150. getClassName(): string;
  18151. /**
  18152. * Gets the engine which this post process belongs to.
  18153. * @returns The engine the post process was enabled with.
  18154. */
  18155. getEngine(): Engine;
  18156. /**
  18157. * The effect that is created when initializing the post process.
  18158. * @returns The created effect corresponding the the postprocess.
  18159. */
  18160. getEffect(): Effect;
  18161. /**
  18162. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  18163. * @param postProcess The post process to share the output with.
  18164. * @returns This post process.
  18165. */
  18166. shareOutputWith(postProcess: PostProcess): PostProcess;
  18167. /**
  18168. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  18169. * This should be called if the post process that shares output with this post process is disabled/disposed.
  18170. */
  18171. useOwnOutput(): void;
  18172. /**
  18173. * Updates the effect with the current post process compile time values and recompiles the shader.
  18174. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18175. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18176. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18177. * @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
  18178. * @param onCompiled Called when the shader has been compiled.
  18179. * @param onError Called if there is an error when compiling a shader.
  18180. */
  18181. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18182. /**
  18183. * The post process is reusable if it can be used multiple times within one frame.
  18184. * @returns If the post process is reusable
  18185. */
  18186. isReusable(): boolean;
  18187. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  18188. markTextureDirty(): void;
  18189. /**
  18190. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  18191. * 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.
  18192. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  18193. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  18194. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  18195. * @returns The target texture that was bound to be written to.
  18196. */
  18197. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  18198. /**
  18199. * If the post process is supported.
  18200. */
  18201. readonly isSupported: boolean;
  18202. /**
  18203. * The aspect ratio of the output texture.
  18204. */
  18205. readonly aspectRatio: number;
  18206. /**
  18207. * Get a value indicating if the post-process is ready to be used
  18208. * @returns true if the post-process is ready (shader is compiled)
  18209. */
  18210. isReady(): boolean;
  18211. /**
  18212. * Binds all textures and uniforms to the shader, this will be run on every pass.
  18213. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  18214. */
  18215. apply(): Nullable<Effect>;
  18216. private _disposeTextures;
  18217. /**
  18218. * Disposes the post process.
  18219. * @param camera The camera to dispose the post process on.
  18220. */
  18221. dispose(camera?: Camera): void;
  18222. }
  18223. }
  18224. declare module BABYLON {
  18225. /** @hidden */
  18226. export var kernelBlurVaryingDeclaration: {
  18227. name: string;
  18228. shader: string;
  18229. };
  18230. }
  18231. declare module BABYLON {
  18232. /** @hidden */
  18233. export var kernelBlurFragment: {
  18234. name: string;
  18235. shader: string;
  18236. };
  18237. }
  18238. declare module BABYLON {
  18239. /** @hidden */
  18240. export var kernelBlurFragment2: {
  18241. name: string;
  18242. shader: string;
  18243. };
  18244. }
  18245. declare module BABYLON {
  18246. /** @hidden */
  18247. export var kernelBlurPixelShader: {
  18248. name: string;
  18249. shader: string;
  18250. };
  18251. }
  18252. declare module BABYLON {
  18253. /** @hidden */
  18254. export var kernelBlurVertex: {
  18255. name: string;
  18256. shader: string;
  18257. };
  18258. }
  18259. declare module BABYLON {
  18260. /** @hidden */
  18261. export var kernelBlurVertexShader: {
  18262. name: string;
  18263. shader: string;
  18264. };
  18265. }
  18266. declare module BABYLON {
  18267. /**
  18268. * The Blur Post Process which blurs an image based on a kernel and direction.
  18269. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  18270. */
  18271. export class BlurPostProcess extends PostProcess {
  18272. /** The direction in which to blur the image. */
  18273. direction: Vector2;
  18274. private blockCompilation;
  18275. protected _kernel: number;
  18276. protected _idealKernel: number;
  18277. protected _packedFloat: boolean;
  18278. private _staticDefines;
  18279. /**
  18280. * Sets the length in pixels of the blur sample region
  18281. */
  18282. /**
  18283. * Gets the length in pixels of the blur sample region
  18284. */
  18285. kernel: number;
  18286. /**
  18287. * Sets wether or not the blur needs to unpack/repack floats
  18288. */
  18289. /**
  18290. * Gets wether or not the blur is unpacking/repacking floats
  18291. */
  18292. packedFloat: boolean;
  18293. /**
  18294. * Creates a new instance BlurPostProcess
  18295. * @param name The name of the effect.
  18296. * @param direction The direction in which to blur the image.
  18297. * @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.
  18298. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18299. * @param camera The camera to apply the render pass to.
  18300. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18301. * @param engine The engine which the post process will be applied. (default: current engine)
  18302. * @param reusable If the post process can be reused on the same frame. (default: false)
  18303. * @param textureType Type of textures used when performing the post process. (default: 0)
  18304. * @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)
  18305. */
  18306. constructor(name: string,
  18307. /** The direction in which to blur the image. */
  18308. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  18309. /**
  18310. * Updates the effect with the current post process compile time values and recompiles the shader.
  18311. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18312. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18313. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18314. * @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
  18315. * @param onCompiled Called when the shader has been compiled.
  18316. * @param onError Called if there is an error when compiling a shader.
  18317. */
  18318. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18319. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18320. /**
  18321. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  18322. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  18323. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  18324. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  18325. * The gaps between physical kernels are compensated for in the weighting of the samples
  18326. * @param idealKernel Ideal blur kernel.
  18327. * @return Nearest best kernel.
  18328. */
  18329. protected _nearestBestKernel(idealKernel: number): number;
  18330. /**
  18331. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  18332. * @param x The point on the Gaussian distribution to sample.
  18333. * @return the value of the Gaussian function at x.
  18334. */
  18335. protected _gaussianWeight(x: number): number;
  18336. /**
  18337. * Generates a string that can be used as a floating point number in GLSL.
  18338. * @param x Value to print.
  18339. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  18340. * @return GLSL float string.
  18341. */
  18342. protected _glslFloat(x: number, decimalFigures?: number): string;
  18343. }
  18344. }
  18345. declare module BABYLON {
  18346. /**
  18347. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18348. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18349. * You can then easily use it as a reflectionTexture on a flat surface.
  18350. * In case the surface is not a plane, please consider relying on reflection probes.
  18351. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18352. */
  18353. export class MirrorTexture extends RenderTargetTexture {
  18354. private scene;
  18355. /**
  18356. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18357. * 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.
  18358. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18359. */
  18360. mirrorPlane: Plane;
  18361. /**
  18362. * Define the blur ratio used to blur the reflection if needed.
  18363. */
  18364. blurRatio: number;
  18365. /**
  18366. * Define the adaptive blur kernel used to blur the reflection if needed.
  18367. * This will autocompute the closest best match for the `blurKernel`
  18368. */
  18369. adaptiveBlurKernel: number;
  18370. /**
  18371. * Define the blur kernel used to blur the reflection if needed.
  18372. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18373. */
  18374. blurKernel: number;
  18375. /**
  18376. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18377. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18378. */
  18379. blurKernelX: number;
  18380. /**
  18381. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18382. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18383. */
  18384. blurKernelY: number;
  18385. private _autoComputeBlurKernel;
  18386. protected _onRatioRescale(): void;
  18387. private _updateGammaSpace;
  18388. private _imageProcessingConfigChangeObserver;
  18389. private _transformMatrix;
  18390. private _mirrorMatrix;
  18391. private _savedViewMatrix;
  18392. private _blurX;
  18393. private _blurY;
  18394. private _adaptiveBlurKernel;
  18395. private _blurKernelX;
  18396. private _blurKernelY;
  18397. private _blurRatio;
  18398. /**
  18399. * Instantiates a Mirror Texture.
  18400. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18401. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18402. * You can then easily use it as a reflectionTexture on a flat surface.
  18403. * In case the surface is not a plane, please consider relying on reflection probes.
  18404. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18405. * @param name
  18406. * @param size
  18407. * @param scene
  18408. * @param generateMipMaps
  18409. * @param type
  18410. * @param samplingMode
  18411. * @param generateDepthBuffer
  18412. */
  18413. constructor(name: string, size: number | {
  18414. width: number;
  18415. height: number;
  18416. } | {
  18417. ratio: number;
  18418. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18419. private _preparePostProcesses;
  18420. /**
  18421. * Clone the mirror texture.
  18422. * @returns the cloned texture
  18423. */
  18424. clone(): MirrorTexture;
  18425. /**
  18426. * Serialize the texture to a JSON representation you could use in Parse later on
  18427. * @returns the serialized JSON representation
  18428. */
  18429. serialize(): any;
  18430. /**
  18431. * Dispose the texture and release its associated resources.
  18432. */
  18433. dispose(): void;
  18434. }
  18435. }
  18436. declare module BABYLON {
  18437. /**
  18438. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18439. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18440. */
  18441. export class Texture extends BaseTexture {
  18442. /** @hidden */
  18443. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  18444. /** @hidden */
  18445. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  18446. /** @hidden */
  18447. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  18448. /** nearest is mag = nearest and min = nearest and mip = linear */
  18449. static readonly NEAREST_SAMPLINGMODE: number;
  18450. /** nearest is mag = nearest and min = nearest and mip = linear */
  18451. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18452. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18453. static readonly BILINEAR_SAMPLINGMODE: number;
  18454. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18455. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18456. /** Trilinear is mag = linear and min = linear and mip = linear */
  18457. static readonly TRILINEAR_SAMPLINGMODE: number;
  18458. /** Trilinear is mag = linear and min = linear and mip = linear */
  18459. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18460. /** mag = nearest and min = nearest and mip = nearest */
  18461. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18462. /** mag = nearest and min = linear and mip = nearest */
  18463. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18464. /** mag = nearest and min = linear and mip = linear */
  18465. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18466. /** mag = nearest and min = linear and mip = none */
  18467. static readonly NEAREST_LINEAR: number;
  18468. /** mag = nearest and min = nearest and mip = none */
  18469. static readonly NEAREST_NEAREST: number;
  18470. /** mag = linear and min = nearest and mip = nearest */
  18471. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18472. /** mag = linear and min = nearest and mip = linear */
  18473. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18474. /** mag = linear and min = linear and mip = none */
  18475. static readonly LINEAR_LINEAR: number;
  18476. /** mag = linear and min = nearest and mip = none */
  18477. static readonly LINEAR_NEAREST: number;
  18478. /** Explicit coordinates mode */
  18479. static readonly EXPLICIT_MODE: number;
  18480. /** Spherical coordinates mode */
  18481. static readonly SPHERICAL_MODE: number;
  18482. /** Planar coordinates mode */
  18483. static readonly PLANAR_MODE: number;
  18484. /** Cubic coordinates mode */
  18485. static readonly CUBIC_MODE: number;
  18486. /** Projection coordinates mode */
  18487. static readonly PROJECTION_MODE: number;
  18488. /** Inverse Cubic coordinates mode */
  18489. static readonly SKYBOX_MODE: number;
  18490. /** Inverse Cubic coordinates mode */
  18491. static readonly INVCUBIC_MODE: number;
  18492. /** Equirectangular coordinates mode */
  18493. static readonly EQUIRECTANGULAR_MODE: number;
  18494. /** Equirectangular Fixed coordinates mode */
  18495. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18496. /** Equirectangular Fixed Mirrored coordinates mode */
  18497. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18498. /** Texture is not repeating outside of 0..1 UVs */
  18499. static readonly CLAMP_ADDRESSMODE: number;
  18500. /** Texture is repeating outside of 0..1 UVs */
  18501. static readonly WRAP_ADDRESSMODE: number;
  18502. /** Texture is repeating and mirrored */
  18503. static readonly MIRROR_ADDRESSMODE: number;
  18504. /**
  18505. * 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
  18506. */
  18507. static UseSerializedUrlIfAny: boolean;
  18508. /**
  18509. * Define the url of the texture.
  18510. */
  18511. url: Nullable<string>;
  18512. /**
  18513. * Define an offset on the texture to offset the u coordinates of the UVs
  18514. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18515. */
  18516. uOffset: number;
  18517. /**
  18518. * Define an offset on the texture to offset the v coordinates of the UVs
  18519. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18520. */
  18521. vOffset: number;
  18522. /**
  18523. * Define an offset on the texture to scale the u coordinates of the UVs
  18524. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18525. */
  18526. uScale: number;
  18527. /**
  18528. * Define an offset on the texture to scale the v coordinates of the UVs
  18529. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18530. */
  18531. vScale: number;
  18532. /**
  18533. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18534. * @see http://doc.babylonjs.com/how_to/more_materials
  18535. */
  18536. uAng: number;
  18537. /**
  18538. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18539. * @see http://doc.babylonjs.com/how_to/more_materials
  18540. */
  18541. vAng: number;
  18542. /**
  18543. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18544. * @see http://doc.babylonjs.com/how_to/more_materials
  18545. */
  18546. wAng: number;
  18547. /**
  18548. * Defines the center of rotation (U)
  18549. */
  18550. uRotationCenter: number;
  18551. /**
  18552. * Defines the center of rotation (V)
  18553. */
  18554. vRotationCenter: number;
  18555. /**
  18556. * Defines the center of rotation (W)
  18557. */
  18558. wRotationCenter: number;
  18559. /**
  18560. * Are mip maps generated for this texture or not.
  18561. */
  18562. readonly noMipmap: boolean;
  18563. /**
  18564. * List of inspectable custom properties (used by the Inspector)
  18565. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18566. */
  18567. inspectableCustomProperties: Nullable<IInspectable[]>;
  18568. private _noMipmap;
  18569. /** @hidden */
  18570. _invertY: boolean;
  18571. private _rowGenerationMatrix;
  18572. private _cachedTextureMatrix;
  18573. private _projectionModeMatrix;
  18574. private _t0;
  18575. private _t1;
  18576. private _t2;
  18577. private _cachedUOffset;
  18578. private _cachedVOffset;
  18579. private _cachedUScale;
  18580. private _cachedVScale;
  18581. private _cachedUAng;
  18582. private _cachedVAng;
  18583. private _cachedWAng;
  18584. private _cachedProjectionMatrixId;
  18585. private _cachedCoordinatesMode;
  18586. /** @hidden */
  18587. protected _initialSamplingMode: number;
  18588. /** @hidden */
  18589. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18590. private _deleteBuffer;
  18591. protected _format: Nullable<number>;
  18592. private _delayedOnLoad;
  18593. private _delayedOnError;
  18594. /**
  18595. * Observable triggered once the texture has been loaded.
  18596. */
  18597. onLoadObservable: Observable<Texture>;
  18598. protected _isBlocking: boolean;
  18599. /**
  18600. * Is the texture preventing material to render while loading.
  18601. * If false, a default texture will be used instead of the loading one during the preparation step.
  18602. */
  18603. isBlocking: boolean;
  18604. /**
  18605. * Get the current sampling mode associated with the texture.
  18606. */
  18607. readonly samplingMode: number;
  18608. /**
  18609. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18610. */
  18611. readonly invertY: boolean;
  18612. /**
  18613. * Instantiates a new texture.
  18614. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18615. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18616. * @param url define the url of the picture to load as a texture
  18617. * @param scene define the scene the texture will belong to
  18618. * @param noMipmap define if the texture will require mip maps or not
  18619. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18620. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18621. * @param onLoad define a callback triggered when the texture has been loaded
  18622. * @param onError define a callback triggered when an error occurred during the loading session
  18623. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18624. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18625. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18626. */
  18627. 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);
  18628. /**
  18629. * Update the url (and optional buffer) of this texture if url was null during construction.
  18630. * @param url the url of the texture
  18631. * @param buffer the buffer of the texture (defaults to null)
  18632. * @param onLoad callback called when the texture is loaded (defaults to null)
  18633. */
  18634. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18635. /**
  18636. * Finish the loading sequence of a texture flagged as delayed load.
  18637. * @hidden
  18638. */
  18639. delayLoad(): void;
  18640. private _prepareRowForTextureGeneration;
  18641. /**
  18642. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18643. * @returns the transform matrix of the texture.
  18644. */
  18645. getTextureMatrix(): Matrix;
  18646. /**
  18647. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18648. * @returns The reflection texture transform
  18649. */
  18650. getReflectionTextureMatrix(): Matrix;
  18651. /**
  18652. * Clones the texture.
  18653. * @returns the cloned texture
  18654. */
  18655. clone(): Texture;
  18656. /**
  18657. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18658. * @returns The JSON representation of the texture
  18659. */
  18660. serialize(): any;
  18661. /**
  18662. * Get the current class name of the texture useful for serialization or dynamic coding.
  18663. * @returns "Texture"
  18664. */
  18665. getClassName(): string;
  18666. /**
  18667. * Dispose the texture and release its associated resources.
  18668. */
  18669. dispose(): void;
  18670. /**
  18671. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18672. * @param parsedTexture Define the JSON representation of the texture
  18673. * @param scene Define the scene the parsed texture should be instantiated in
  18674. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18675. * @returns The parsed texture if successful
  18676. */
  18677. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18678. /**
  18679. * Creates a texture from its base 64 representation.
  18680. * @param data Define the base64 payload without the data: prefix
  18681. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18682. * @param scene Define the scene the texture should belong to
  18683. * @param noMipmap Forces the texture to not create mip map information if true
  18684. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18685. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18686. * @param onLoad define a callback triggered when the texture has been loaded
  18687. * @param onError define a callback triggered when an error occurred during the loading session
  18688. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18689. * @returns the created texture
  18690. */
  18691. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18692. /**
  18693. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18694. * @param data Define the base64 payload without the data: prefix
  18695. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18696. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18697. * @param scene Define the scene the texture should belong to
  18698. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18699. * @param noMipmap Forces the texture to not create mip map information if true
  18700. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18701. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18702. * @param onLoad define a callback triggered when the texture has been loaded
  18703. * @param onError define a callback triggered when an error occurred during the loading session
  18704. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18705. * @returns the created texture
  18706. */
  18707. 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;
  18708. }
  18709. }
  18710. declare module BABYLON {
  18711. /**
  18712. * PostProcessManager is used to manage one or more post processes or post process pipelines
  18713. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  18714. */
  18715. export class PostProcessManager {
  18716. private _scene;
  18717. private _indexBuffer;
  18718. private _vertexBuffers;
  18719. /**
  18720. * Creates a new instance PostProcess
  18721. * @param scene The scene that the post process is associated with.
  18722. */
  18723. constructor(scene: Scene);
  18724. private _prepareBuffers;
  18725. private _buildIndexBuffer;
  18726. /**
  18727. * Rebuilds the vertex buffers of the manager.
  18728. * @hidden
  18729. */
  18730. _rebuild(): void;
  18731. /**
  18732. * Prepares a frame to be run through a post process.
  18733. * @param sourceTexture The input texture to the post procesess. (default: null)
  18734. * @param postProcesses An array of post processes to be run. (default: null)
  18735. * @returns True if the post processes were able to be run.
  18736. * @hidden
  18737. */
  18738. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  18739. /**
  18740. * Manually render a set of post processes to a texture.
  18741. * @param postProcesses An array of post processes to be run.
  18742. * @param targetTexture The target texture to render to.
  18743. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  18744. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  18745. * @param lodLevel defines which lod of the texture to render to
  18746. */
  18747. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  18748. /**
  18749. * Finalize the result of the output of the postprocesses.
  18750. * @param doNotPresent If true the result will not be displayed to the screen.
  18751. * @param targetTexture The target texture to render to.
  18752. * @param faceIndex The index of the face to bind the target texture to.
  18753. * @param postProcesses The array of post processes to render.
  18754. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  18755. * @hidden
  18756. */
  18757. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  18758. /**
  18759. * Disposes of the post process manager.
  18760. */
  18761. dispose(): void;
  18762. }
  18763. }
  18764. declare module BABYLON {
  18765. interface AbstractScene {
  18766. /**
  18767. * The list of procedural textures added to the scene
  18768. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18769. */
  18770. proceduralTextures: Array<ProceduralTexture>;
  18771. }
  18772. /**
  18773. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  18774. * in a given scene.
  18775. */
  18776. export class ProceduralTextureSceneComponent implements ISceneComponent {
  18777. /**
  18778. * The component name helpfull to identify the component in the list of scene components.
  18779. */
  18780. readonly name: string;
  18781. /**
  18782. * The scene the component belongs to.
  18783. */
  18784. scene: Scene;
  18785. /**
  18786. * Creates a new instance of the component for the given scene
  18787. * @param scene Defines the scene to register the component in
  18788. */
  18789. constructor(scene: Scene);
  18790. /**
  18791. * Registers the component in a given scene
  18792. */
  18793. register(): void;
  18794. /**
  18795. * Rebuilds the elements related to this component in case of
  18796. * context lost for instance.
  18797. */
  18798. rebuild(): void;
  18799. /**
  18800. * Disposes the component and the associated ressources.
  18801. */
  18802. dispose(): void;
  18803. private _beforeClear;
  18804. }
  18805. }
  18806. declare module BABYLON {
  18807. interface Engine {
  18808. /**
  18809. * Creates a new render target cube texture
  18810. * @param size defines the size of the texture
  18811. * @param options defines the options used to create the texture
  18812. * @returns a new render target cube texture stored in an InternalTexture
  18813. */
  18814. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  18815. }
  18816. }
  18817. declare module BABYLON {
  18818. /** @hidden */
  18819. export var proceduralVertexShader: {
  18820. name: string;
  18821. shader: string;
  18822. };
  18823. }
  18824. declare module BABYLON {
  18825. /**
  18826. * 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.
  18827. * This is the base class of any Procedural texture and contains most of the shareable code.
  18828. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18829. */
  18830. export class ProceduralTexture extends Texture {
  18831. isCube: boolean;
  18832. /**
  18833. * Define if the texture is enabled or not (disabled texture will not render)
  18834. */
  18835. isEnabled: boolean;
  18836. /**
  18837. * Define if the texture must be cleared before rendering (default is true)
  18838. */
  18839. autoClear: boolean;
  18840. /**
  18841. * Callback called when the texture is generated
  18842. */
  18843. onGenerated: () => void;
  18844. /**
  18845. * Event raised when the texture is generated
  18846. */
  18847. onGeneratedObservable: Observable<ProceduralTexture>;
  18848. /** @hidden */
  18849. _generateMipMaps: boolean;
  18850. /** @hidden **/
  18851. _effect: Effect;
  18852. /** @hidden */
  18853. _textures: {
  18854. [key: string]: Texture;
  18855. };
  18856. private _size;
  18857. private _currentRefreshId;
  18858. private _refreshRate;
  18859. private _vertexBuffers;
  18860. private _indexBuffer;
  18861. private _uniforms;
  18862. private _samplers;
  18863. private _fragment;
  18864. private _floats;
  18865. private _ints;
  18866. private _floatsArrays;
  18867. private _colors3;
  18868. private _colors4;
  18869. private _vectors2;
  18870. private _vectors3;
  18871. private _matrices;
  18872. private _fallbackTexture;
  18873. private _fallbackTextureUsed;
  18874. private _engine;
  18875. private _cachedDefines;
  18876. private _contentUpdateId;
  18877. private _contentData;
  18878. /**
  18879. * Instantiates a new procedural texture.
  18880. * 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.
  18881. * This is the base class of any Procedural texture and contains most of the shareable code.
  18882. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18883. * @param name Define the name of the texture
  18884. * @param size Define the size of the texture to create
  18885. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  18886. * @param scene Define the scene the texture belongs to
  18887. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  18888. * @param generateMipMaps Define if the texture should creates mip maps or not
  18889. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  18890. */
  18891. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  18892. /**
  18893. * The effect that is created when initializing the post process.
  18894. * @returns The created effect corresponding the the postprocess.
  18895. */
  18896. getEffect(): Effect;
  18897. /**
  18898. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  18899. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  18900. */
  18901. getContent(): Nullable<ArrayBufferView>;
  18902. private _createIndexBuffer;
  18903. /** @hidden */
  18904. _rebuild(): void;
  18905. /**
  18906. * Resets the texture in order to recreate its associated resources.
  18907. * This can be called in case of context loss
  18908. */
  18909. reset(): void;
  18910. protected _getDefines(): string;
  18911. /**
  18912. * Is the texture ready to be used ? (rendered at least once)
  18913. * @returns true if ready, otherwise, false.
  18914. */
  18915. isReady(): boolean;
  18916. /**
  18917. * Resets the refresh counter of the texture and start bak from scratch.
  18918. * Could be useful to regenerate the texture if it is setup to render only once.
  18919. */
  18920. resetRefreshCounter(): void;
  18921. /**
  18922. * Set the fragment shader to use in order to render the texture.
  18923. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  18924. */
  18925. setFragment(fragment: any): void;
  18926. /**
  18927. * Define the refresh rate of the texture or the rendering frequency.
  18928. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18929. */
  18930. refreshRate: number;
  18931. /** @hidden */
  18932. _shouldRender(): boolean;
  18933. /**
  18934. * Get the size the texture is rendering at.
  18935. * @returns the size (texture is always squared)
  18936. */
  18937. getRenderSize(): number;
  18938. /**
  18939. * Resize the texture to new value.
  18940. * @param size Define the new size the texture should have
  18941. * @param generateMipMaps Define whether the new texture should create mip maps
  18942. */
  18943. resize(size: number, generateMipMaps: boolean): void;
  18944. private _checkUniform;
  18945. /**
  18946. * Set a texture in the shader program used to render.
  18947. * @param name Define the name of the uniform samplers as defined in the shader
  18948. * @param texture Define the texture to bind to this sampler
  18949. * @return the texture itself allowing "fluent" like uniform updates
  18950. */
  18951. setTexture(name: string, texture: Texture): ProceduralTexture;
  18952. /**
  18953. * Set a float in the shader.
  18954. * @param name Define the name of the uniform as defined in the shader
  18955. * @param value Define the value to give to the uniform
  18956. * @return the texture itself allowing "fluent" like uniform updates
  18957. */
  18958. setFloat(name: string, value: number): ProceduralTexture;
  18959. /**
  18960. * Set a int in the shader.
  18961. * @param name Define the name of the uniform as defined in the shader
  18962. * @param value Define the value to give to the uniform
  18963. * @return the texture itself allowing "fluent" like uniform updates
  18964. */
  18965. setInt(name: string, value: number): ProceduralTexture;
  18966. /**
  18967. * Set an array of floats in the shader.
  18968. * @param name Define the name of the uniform as defined in the shader
  18969. * @param value Define the value to give to the uniform
  18970. * @return the texture itself allowing "fluent" like uniform updates
  18971. */
  18972. setFloats(name: string, value: number[]): ProceduralTexture;
  18973. /**
  18974. * Set a vec3 in the shader from a Color3.
  18975. * @param name Define the name of the uniform as defined in the shader
  18976. * @param value Define the value to give to the uniform
  18977. * @return the texture itself allowing "fluent" like uniform updates
  18978. */
  18979. setColor3(name: string, value: Color3): ProceduralTexture;
  18980. /**
  18981. * Set a vec4 in the shader from a Color4.
  18982. * @param name Define the name of the uniform as defined in the shader
  18983. * @param value Define the value to give to the uniform
  18984. * @return the texture itself allowing "fluent" like uniform updates
  18985. */
  18986. setColor4(name: string, value: Color4): ProceduralTexture;
  18987. /**
  18988. * Set a vec2 in the shader from a Vector2.
  18989. * @param name Define the name of the uniform as defined in the shader
  18990. * @param value Define the value to give to the uniform
  18991. * @return the texture itself allowing "fluent" like uniform updates
  18992. */
  18993. setVector2(name: string, value: Vector2): ProceduralTexture;
  18994. /**
  18995. * Set a vec3 in the shader from a Vector3.
  18996. * @param name Define the name of the uniform as defined in the shader
  18997. * @param value Define the value to give to the uniform
  18998. * @return the texture itself allowing "fluent" like uniform updates
  18999. */
  19000. setVector3(name: string, value: Vector3): ProceduralTexture;
  19001. /**
  19002. * Set a mat4 in the shader from a MAtrix.
  19003. * @param name Define the name of the uniform as defined in the shader
  19004. * @param value Define the value to give to the uniform
  19005. * @return the texture itself allowing "fluent" like uniform updates
  19006. */
  19007. setMatrix(name: string, value: Matrix): ProceduralTexture;
  19008. /**
  19009. * Render the texture to its associated render target.
  19010. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  19011. */
  19012. render(useCameraPostProcess?: boolean): void;
  19013. /**
  19014. * Clone the texture.
  19015. * @returns the cloned texture
  19016. */
  19017. clone(): ProceduralTexture;
  19018. /**
  19019. * Dispose the texture and release its asoociated resources.
  19020. */
  19021. dispose(): void;
  19022. }
  19023. }
  19024. declare module BABYLON {
  19025. /**
  19026. * This represents the base class for particle system in Babylon.
  19027. * 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.
  19028. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19029. * @example https://doc.babylonjs.com/babylon101/particles
  19030. */
  19031. export class BaseParticleSystem {
  19032. /**
  19033. * Source color is added to the destination color without alpha affecting the result
  19034. */
  19035. static BLENDMODE_ONEONE: number;
  19036. /**
  19037. * Blend current color and particle color using particle’s alpha
  19038. */
  19039. static BLENDMODE_STANDARD: number;
  19040. /**
  19041. * Add current color and particle color multiplied by particle’s alpha
  19042. */
  19043. static BLENDMODE_ADD: number;
  19044. /**
  19045. * Multiply current color with particle color
  19046. */
  19047. static BLENDMODE_MULTIPLY: number;
  19048. /**
  19049. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  19050. */
  19051. static BLENDMODE_MULTIPLYADD: number;
  19052. /**
  19053. * List of animations used by the particle system.
  19054. */
  19055. animations: Animation[];
  19056. /**
  19057. * The id of the Particle system.
  19058. */
  19059. id: string;
  19060. /**
  19061. * The friendly name of the Particle system.
  19062. */
  19063. name: string;
  19064. /**
  19065. * The rendering group used by the Particle system to chose when to render.
  19066. */
  19067. renderingGroupId: number;
  19068. /**
  19069. * The emitter represents the Mesh or position we are attaching the particle system to.
  19070. */
  19071. emitter: Nullable<AbstractMesh | Vector3>;
  19072. /**
  19073. * The maximum number of particles to emit per frame
  19074. */
  19075. emitRate: number;
  19076. /**
  19077. * If you want to launch only a few particles at once, that can be done, as well.
  19078. */
  19079. manualEmitCount: number;
  19080. /**
  19081. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19082. */
  19083. updateSpeed: number;
  19084. /**
  19085. * The amount of time the particle system is running (depends of the overall update speed).
  19086. */
  19087. targetStopDuration: number;
  19088. /**
  19089. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19090. */
  19091. disposeOnStop: boolean;
  19092. /**
  19093. * Minimum power of emitting particles.
  19094. */
  19095. minEmitPower: number;
  19096. /**
  19097. * Maximum power of emitting particles.
  19098. */
  19099. maxEmitPower: number;
  19100. /**
  19101. * Minimum life time of emitting particles.
  19102. */
  19103. minLifeTime: number;
  19104. /**
  19105. * Maximum life time of emitting particles.
  19106. */
  19107. maxLifeTime: number;
  19108. /**
  19109. * Minimum Size of emitting particles.
  19110. */
  19111. minSize: number;
  19112. /**
  19113. * Maximum Size of emitting particles.
  19114. */
  19115. maxSize: number;
  19116. /**
  19117. * Minimum scale of emitting particles on X axis.
  19118. */
  19119. minScaleX: number;
  19120. /**
  19121. * Maximum scale of emitting particles on X axis.
  19122. */
  19123. maxScaleX: number;
  19124. /**
  19125. * Minimum scale of emitting particles on Y axis.
  19126. */
  19127. minScaleY: number;
  19128. /**
  19129. * Maximum scale of emitting particles on Y axis.
  19130. */
  19131. maxScaleY: number;
  19132. /**
  19133. * Gets or sets the minimal initial rotation in radians.
  19134. */
  19135. minInitialRotation: number;
  19136. /**
  19137. * Gets or sets the maximal initial rotation in radians.
  19138. */
  19139. maxInitialRotation: number;
  19140. /**
  19141. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19142. */
  19143. minAngularSpeed: number;
  19144. /**
  19145. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19146. */
  19147. maxAngularSpeed: number;
  19148. /**
  19149. * The texture used to render each particle. (this can be a spritesheet)
  19150. */
  19151. particleTexture: Nullable<Texture>;
  19152. /**
  19153. * The layer mask we are rendering the particles through.
  19154. */
  19155. layerMask: number;
  19156. /**
  19157. * This can help using your own shader to render the particle system.
  19158. * The according effect will be created
  19159. */
  19160. customShader: any;
  19161. /**
  19162. * By default particle system starts as soon as they are created. This prevents the
  19163. * automatic start to happen and let you decide when to start emitting particles.
  19164. */
  19165. preventAutoStart: boolean;
  19166. private _noiseTexture;
  19167. /**
  19168. * Gets or sets a texture used to add random noise to particle positions
  19169. */
  19170. noiseTexture: Nullable<ProceduralTexture>;
  19171. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19172. noiseStrength: Vector3;
  19173. /**
  19174. * Callback triggered when the particle animation is ending.
  19175. */
  19176. onAnimationEnd: Nullable<() => void>;
  19177. /**
  19178. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19179. */
  19180. blendMode: number;
  19181. /**
  19182. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19183. * to override the particles.
  19184. */
  19185. forceDepthWrite: boolean;
  19186. /** 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 */
  19187. preWarmCycles: number;
  19188. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  19189. preWarmStepOffset: number;
  19190. /**
  19191. * 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)
  19192. */
  19193. spriteCellChangeSpeed: number;
  19194. /**
  19195. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19196. */
  19197. startSpriteCellID: number;
  19198. /**
  19199. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19200. */
  19201. endSpriteCellID: number;
  19202. /**
  19203. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19204. */
  19205. spriteCellWidth: number;
  19206. /**
  19207. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19208. */
  19209. spriteCellHeight: number;
  19210. /**
  19211. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19212. */
  19213. spriteRandomStartCell: boolean;
  19214. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19215. translationPivot: Vector2;
  19216. /** @hidden */
  19217. protected _isAnimationSheetEnabled: boolean;
  19218. /**
  19219. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19220. */
  19221. beginAnimationOnStart: boolean;
  19222. /**
  19223. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19224. */
  19225. beginAnimationFrom: number;
  19226. /**
  19227. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19228. */
  19229. beginAnimationTo: number;
  19230. /**
  19231. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19232. */
  19233. beginAnimationLoop: boolean;
  19234. /**
  19235. * Gets or sets a world offset applied to all particles
  19236. */
  19237. worldOffset: Vector3;
  19238. /**
  19239. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  19240. */
  19241. isAnimationSheetEnabled: boolean;
  19242. /**
  19243. * Get hosting scene
  19244. * @returns the scene
  19245. */
  19246. getScene(): Scene;
  19247. /**
  19248. * You can use gravity if you want to give an orientation to your particles.
  19249. */
  19250. gravity: Vector3;
  19251. protected _colorGradients: Nullable<Array<ColorGradient>>;
  19252. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  19253. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  19254. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  19255. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  19256. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  19257. protected _dragGradients: Nullable<Array<FactorGradient>>;
  19258. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  19259. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  19260. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  19261. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  19262. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  19263. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  19264. /**
  19265. * Defines the delay in milliseconds before starting the system (0 by default)
  19266. */
  19267. startDelay: number;
  19268. /**
  19269. * Gets the current list of drag gradients.
  19270. * You must use addDragGradient and removeDragGradient to udpate this list
  19271. * @returns the list of drag gradients
  19272. */
  19273. getDragGradients(): Nullable<Array<FactorGradient>>;
  19274. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19275. limitVelocityDamping: number;
  19276. /**
  19277. * Gets the current list of limit velocity gradients.
  19278. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19279. * @returns the list of limit velocity gradients
  19280. */
  19281. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19282. /**
  19283. * Gets the current list of color gradients.
  19284. * You must use addColorGradient and removeColorGradient to udpate this list
  19285. * @returns the list of color gradients
  19286. */
  19287. getColorGradients(): Nullable<Array<ColorGradient>>;
  19288. /**
  19289. * Gets the current list of size gradients.
  19290. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19291. * @returns the list of size gradients
  19292. */
  19293. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19294. /**
  19295. * Gets the current list of color remap gradients.
  19296. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19297. * @returns the list of color remap gradients
  19298. */
  19299. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19300. /**
  19301. * Gets the current list of alpha remap gradients.
  19302. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19303. * @returns the list of alpha remap gradients
  19304. */
  19305. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19306. /**
  19307. * Gets the current list of life time gradients.
  19308. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19309. * @returns the list of life time gradients
  19310. */
  19311. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19312. /**
  19313. * Gets the current list of angular speed gradients.
  19314. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19315. * @returns the list of angular speed gradients
  19316. */
  19317. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19318. /**
  19319. * Gets the current list of velocity gradients.
  19320. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19321. * @returns the list of velocity gradients
  19322. */
  19323. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19324. /**
  19325. * Gets the current list of start size gradients.
  19326. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19327. * @returns the list of start size gradients
  19328. */
  19329. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19330. /**
  19331. * Gets the current list of emit rate gradients.
  19332. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19333. * @returns the list of emit rate gradients
  19334. */
  19335. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19336. /**
  19337. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19338. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19339. */
  19340. direction1: Vector3;
  19341. /**
  19342. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19343. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19344. */
  19345. direction2: Vector3;
  19346. /**
  19347. * 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.
  19348. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19349. */
  19350. minEmitBox: Vector3;
  19351. /**
  19352. * 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.
  19353. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19354. */
  19355. maxEmitBox: Vector3;
  19356. /**
  19357. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19358. */
  19359. color1: Color4;
  19360. /**
  19361. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19362. */
  19363. color2: Color4;
  19364. /**
  19365. * Color the particle will have at the end of its lifetime
  19366. */
  19367. colorDead: Color4;
  19368. /**
  19369. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  19370. */
  19371. textureMask: Color4;
  19372. /**
  19373. * The particle emitter type defines the emitter used by the particle system.
  19374. * It can be for example box, sphere, or cone...
  19375. */
  19376. particleEmitterType: IParticleEmitterType;
  19377. /** @hidden */
  19378. _isSubEmitter: boolean;
  19379. /**
  19380. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19381. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19382. */
  19383. billboardMode: number;
  19384. protected _isBillboardBased: boolean;
  19385. /**
  19386. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19387. */
  19388. isBillboardBased: boolean;
  19389. /**
  19390. * The scene the particle system belongs to.
  19391. */
  19392. protected _scene: Scene;
  19393. /**
  19394. * Local cache of defines for image processing.
  19395. */
  19396. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  19397. /**
  19398. * Default configuration related to image processing available in the standard Material.
  19399. */
  19400. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19401. /**
  19402. * Gets the image processing configuration used either in this material.
  19403. */
  19404. /**
  19405. * Sets the Default image processing configuration used either in the this material.
  19406. *
  19407. * If sets to null, the scene one is in use.
  19408. */
  19409. imageProcessingConfiguration: ImageProcessingConfiguration;
  19410. /**
  19411. * Attaches a new image processing configuration to the Standard Material.
  19412. * @param configuration
  19413. */
  19414. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19415. /** @hidden */
  19416. protected _reset(): void;
  19417. /** @hidden */
  19418. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  19419. /**
  19420. * Instantiates a particle system.
  19421. * 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.
  19422. * @param name The name of the particle system
  19423. */
  19424. constructor(name: string);
  19425. /**
  19426. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19427. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19428. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19429. * @returns the emitter
  19430. */
  19431. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19432. /**
  19433. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19434. * @param radius The radius of the hemisphere to emit from
  19435. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19436. * @returns the emitter
  19437. */
  19438. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  19439. /**
  19440. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19441. * @param radius The radius of the sphere to emit from
  19442. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19443. * @returns the emitter
  19444. */
  19445. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  19446. /**
  19447. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19448. * @param radius The radius of the sphere to emit from
  19449. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19450. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19451. * @returns the emitter
  19452. */
  19453. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19454. /**
  19455. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19456. * @param radius The radius of the emission cylinder
  19457. * @param height The height of the emission cylinder
  19458. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19459. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19460. * @returns the emitter
  19461. */
  19462. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  19463. /**
  19464. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19465. * @param radius The radius of the cylinder to emit from
  19466. * @param height The height of the emission cylinder
  19467. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19468. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19469. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19470. * @returns the emitter
  19471. */
  19472. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  19473. /**
  19474. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19475. * @param radius The radius of the cone to emit from
  19476. * @param angle The base angle of the cone
  19477. * @returns the emitter
  19478. */
  19479. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19480. /**
  19481. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19482. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19483. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19484. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19485. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19486. * @returns the emitter
  19487. */
  19488. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19489. }
  19490. }
  19491. declare module BABYLON {
  19492. /**
  19493. * Type of sub emitter
  19494. */
  19495. export enum SubEmitterType {
  19496. /**
  19497. * Attached to the particle over it's lifetime
  19498. */
  19499. ATTACHED = 0,
  19500. /**
  19501. * Created when the particle dies
  19502. */
  19503. END = 1
  19504. }
  19505. /**
  19506. * Sub emitter class used to emit particles from an existing particle
  19507. */
  19508. export class SubEmitter {
  19509. /**
  19510. * the particle system to be used by the sub emitter
  19511. */
  19512. particleSystem: ParticleSystem;
  19513. /**
  19514. * Type of the submitter (Default: END)
  19515. */
  19516. type: SubEmitterType;
  19517. /**
  19518. * 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)
  19519. * Note: This only is supported when using an emitter of type Mesh
  19520. */
  19521. inheritDirection: boolean;
  19522. /**
  19523. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  19524. */
  19525. inheritedVelocityAmount: number;
  19526. /**
  19527. * Creates a sub emitter
  19528. * @param particleSystem the particle system to be used by the sub emitter
  19529. */
  19530. constructor(
  19531. /**
  19532. * the particle system to be used by the sub emitter
  19533. */
  19534. particleSystem: ParticleSystem);
  19535. /**
  19536. * Clones the sub emitter
  19537. * @returns the cloned sub emitter
  19538. */
  19539. clone(): SubEmitter;
  19540. /**
  19541. * Serialize current object to a JSON object
  19542. * @returns the serialized object
  19543. */
  19544. serialize(): any;
  19545. /** @hidden */
  19546. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  19547. /**
  19548. * Creates a new SubEmitter from a serialized JSON version
  19549. * @param serializationObject defines the JSON object to read from
  19550. * @param scene defines the hosting scene
  19551. * @param rootUrl defines the rootUrl for data loading
  19552. * @returns a new SubEmitter
  19553. */
  19554. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  19555. /** Release associated resources */
  19556. dispose(): void;
  19557. }
  19558. }
  19559. declare module BABYLON {
  19560. /** @hidden */
  19561. export var imageProcessingDeclaration: {
  19562. name: string;
  19563. shader: string;
  19564. };
  19565. }
  19566. declare module BABYLON {
  19567. /** @hidden */
  19568. export var imageProcessingFunctions: {
  19569. name: string;
  19570. shader: string;
  19571. };
  19572. }
  19573. declare module BABYLON {
  19574. /** @hidden */
  19575. export var particlesPixelShader: {
  19576. name: string;
  19577. shader: string;
  19578. };
  19579. }
  19580. declare module BABYLON {
  19581. /** @hidden */
  19582. export var particlesVertexShader: {
  19583. name: string;
  19584. shader: string;
  19585. };
  19586. }
  19587. declare module BABYLON {
  19588. /**
  19589. * This represents a particle system in Babylon.
  19590. * 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.
  19591. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19592. * @example https://doc.babylonjs.com/babylon101/particles
  19593. */
  19594. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  19595. /**
  19596. * Billboard mode will only apply to Y axis
  19597. */
  19598. static readonly BILLBOARDMODE_Y: number;
  19599. /**
  19600. * Billboard mode will apply to all axes
  19601. */
  19602. static readonly BILLBOARDMODE_ALL: number;
  19603. /**
  19604. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  19605. */
  19606. static readonly BILLBOARDMODE_STRETCHED: number;
  19607. /**
  19608. * This function can be defined to provide custom update for active particles.
  19609. * This function will be called instead of regular update (age, position, color, etc.).
  19610. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  19611. */
  19612. updateFunction: (particles: Particle[]) => void;
  19613. private _emitterWorldMatrix;
  19614. /**
  19615. * This function can be defined to specify initial direction for every new particle.
  19616. * It by default use the emitterType defined function
  19617. */
  19618. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  19619. /**
  19620. * This function can be defined to specify initial position for every new particle.
  19621. * It by default use the emitterType defined function
  19622. */
  19623. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  19624. /**
  19625. * @hidden
  19626. */
  19627. _inheritedVelocityOffset: Vector3;
  19628. /**
  19629. * An event triggered when the system is disposed
  19630. */
  19631. onDisposeObservable: Observable<ParticleSystem>;
  19632. private _onDisposeObserver;
  19633. /**
  19634. * Sets a callback that will be triggered when the system is disposed
  19635. */
  19636. onDispose: () => void;
  19637. private _particles;
  19638. private _epsilon;
  19639. private _capacity;
  19640. private _stockParticles;
  19641. private _newPartsExcess;
  19642. private _vertexData;
  19643. private _vertexBuffer;
  19644. private _vertexBuffers;
  19645. private _spriteBuffer;
  19646. private _indexBuffer;
  19647. private _effect;
  19648. private _customEffect;
  19649. private _cachedDefines;
  19650. private _scaledColorStep;
  19651. private _colorDiff;
  19652. private _scaledDirection;
  19653. private _scaledGravity;
  19654. private _currentRenderId;
  19655. private _alive;
  19656. private _useInstancing;
  19657. private _started;
  19658. private _stopped;
  19659. private _actualFrame;
  19660. private _scaledUpdateSpeed;
  19661. private _vertexBufferSize;
  19662. /** @hidden */
  19663. _currentEmitRateGradient: Nullable<FactorGradient>;
  19664. /** @hidden */
  19665. _currentEmitRate1: number;
  19666. /** @hidden */
  19667. _currentEmitRate2: number;
  19668. /** @hidden */
  19669. _currentStartSizeGradient: Nullable<FactorGradient>;
  19670. /** @hidden */
  19671. _currentStartSize1: number;
  19672. /** @hidden */
  19673. _currentStartSize2: number;
  19674. private readonly _rawTextureWidth;
  19675. private _rampGradientsTexture;
  19676. private _useRampGradients;
  19677. /** Gets or sets a boolean indicating that ramp gradients must be used
  19678. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19679. */
  19680. useRampGradients: boolean;
  19681. /**
  19682. * 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.
  19683. * 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: [])
  19684. */
  19685. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  19686. private _subEmitters;
  19687. /**
  19688. * @hidden
  19689. * If the particle systems emitter should be disposed when the particle system is disposed
  19690. */
  19691. _disposeEmitterOnDispose: boolean;
  19692. /**
  19693. * The current active Sub-systems, this property is used by the root particle system only.
  19694. */
  19695. activeSubSystems: Array<ParticleSystem>;
  19696. private _rootParticleSystem;
  19697. /**
  19698. * Gets the current list of active particles
  19699. */
  19700. readonly particles: Particle[];
  19701. /**
  19702. * Returns the string "ParticleSystem"
  19703. * @returns a string containing the class name
  19704. */
  19705. getClassName(): string;
  19706. /**
  19707. * Instantiates a particle system.
  19708. * 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.
  19709. * @param name The name of the particle system
  19710. * @param capacity The max number of particles alive at the same time
  19711. * @param scene The scene the particle system belongs to
  19712. * @param customEffect a custom effect used to change the way particles are rendered by default
  19713. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  19714. * @param epsilon Offset used to render the particles
  19715. */
  19716. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  19717. private _addFactorGradient;
  19718. private _removeFactorGradient;
  19719. /**
  19720. * Adds a new life time gradient
  19721. * @param gradient defines the gradient to use (between 0 and 1)
  19722. * @param factor defines the life time factor to affect to the specified gradient
  19723. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19724. * @returns the current particle system
  19725. */
  19726. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19727. /**
  19728. * Remove a specific life time gradient
  19729. * @param gradient defines the gradient to remove
  19730. * @returns the current particle system
  19731. */
  19732. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19733. /**
  19734. * Adds a new size gradient
  19735. * @param gradient defines the gradient to use (between 0 and 1)
  19736. * @param factor defines the size factor to affect to the specified gradient
  19737. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19738. * @returns the current particle system
  19739. */
  19740. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19741. /**
  19742. * Remove a specific size gradient
  19743. * @param gradient defines the gradient to remove
  19744. * @returns the current particle system
  19745. */
  19746. removeSizeGradient(gradient: number): IParticleSystem;
  19747. /**
  19748. * Adds a new color remap gradient
  19749. * @param gradient defines the gradient to use (between 0 and 1)
  19750. * @param min defines the color remap minimal range
  19751. * @param max defines the color remap maximal range
  19752. * @returns the current particle system
  19753. */
  19754. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19755. /**
  19756. * Remove a specific color remap gradient
  19757. * @param gradient defines the gradient to remove
  19758. * @returns the current particle system
  19759. */
  19760. removeColorRemapGradient(gradient: number): IParticleSystem;
  19761. /**
  19762. * Adds a new alpha remap gradient
  19763. * @param gradient defines the gradient to use (between 0 and 1)
  19764. * @param min defines the alpha remap minimal range
  19765. * @param max defines the alpha remap maximal range
  19766. * @returns the current particle system
  19767. */
  19768. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19769. /**
  19770. * Remove a specific alpha remap gradient
  19771. * @param gradient defines the gradient to remove
  19772. * @returns the current particle system
  19773. */
  19774. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  19775. /**
  19776. * Adds a new angular speed gradient
  19777. * @param gradient defines the gradient to use (between 0 and 1)
  19778. * @param factor defines the angular speed to affect to the specified gradient
  19779. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19780. * @returns the current particle system
  19781. */
  19782. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19783. /**
  19784. * Remove a specific angular speed gradient
  19785. * @param gradient defines the gradient to remove
  19786. * @returns the current particle system
  19787. */
  19788. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19789. /**
  19790. * Adds a new velocity gradient
  19791. * @param gradient defines the gradient to use (between 0 and 1)
  19792. * @param factor defines the velocity to affect to the specified gradient
  19793. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19794. * @returns the current particle system
  19795. */
  19796. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19797. /**
  19798. * Remove a specific velocity gradient
  19799. * @param gradient defines the gradient to remove
  19800. * @returns the current particle system
  19801. */
  19802. removeVelocityGradient(gradient: number): IParticleSystem;
  19803. /**
  19804. * Adds a new limit velocity gradient
  19805. * @param gradient defines the gradient to use (between 0 and 1)
  19806. * @param factor defines the limit velocity value to affect to the specified gradient
  19807. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19808. * @returns the current particle system
  19809. */
  19810. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19811. /**
  19812. * Remove a specific limit velocity gradient
  19813. * @param gradient defines the gradient to remove
  19814. * @returns the current particle system
  19815. */
  19816. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19817. /**
  19818. * Adds a new drag gradient
  19819. * @param gradient defines the gradient to use (between 0 and 1)
  19820. * @param factor defines the drag value to affect to the specified gradient
  19821. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19822. * @returns the current particle system
  19823. */
  19824. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19825. /**
  19826. * Remove a specific drag gradient
  19827. * @param gradient defines the gradient to remove
  19828. * @returns the current particle system
  19829. */
  19830. removeDragGradient(gradient: number): IParticleSystem;
  19831. /**
  19832. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19833. * @param gradient defines the gradient to use (between 0 and 1)
  19834. * @param factor defines the emit rate value to affect to the specified gradient
  19835. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19836. * @returns the current particle system
  19837. */
  19838. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19839. /**
  19840. * Remove a specific emit rate gradient
  19841. * @param gradient defines the gradient to remove
  19842. * @returns the current particle system
  19843. */
  19844. removeEmitRateGradient(gradient: number): IParticleSystem;
  19845. /**
  19846. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19847. * @param gradient defines the gradient to use (between 0 and 1)
  19848. * @param factor defines the start size value to affect to the specified gradient
  19849. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19850. * @returns the current particle system
  19851. */
  19852. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19853. /**
  19854. * Remove a specific start size gradient
  19855. * @param gradient defines the gradient to remove
  19856. * @returns the current particle system
  19857. */
  19858. removeStartSizeGradient(gradient: number): IParticleSystem;
  19859. private _createRampGradientTexture;
  19860. /**
  19861. * Gets the current list of ramp gradients.
  19862. * You must use addRampGradient and removeRampGradient to udpate this list
  19863. * @returns the list of ramp gradients
  19864. */
  19865. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19866. /**
  19867. * Adds a new ramp gradient used to remap particle colors
  19868. * @param gradient defines the gradient to use (between 0 and 1)
  19869. * @param color defines the color to affect to the specified gradient
  19870. * @returns the current particle system
  19871. */
  19872. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  19873. /**
  19874. * Remove a specific ramp gradient
  19875. * @param gradient defines the gradient to remove
  19876. * @returns the current particle system
  19877. */
  19878. removeRampGradient(gradient: number): ParticleSystem;
  19879. /**
  19880. * Adds a new color gradient
  19881. * @param gradient defines the gradient to use (between 0 and 1)
  19882. * @param color1 defines the color to affect to the specified gradient
  19883. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19884. * @returns this particle system
  19885. */
  19886. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19887. /**
  19888. * Remove a specific color gradient
  19889. * @param gradient defines the gradient to remove
  19890. * @returns this particle system
  19891. */
  19892. removeColorGradient(gradient: number): IParticleSystem;
  19893. private _fetchR;
  19894. protected _reset(): void;
  19895. private _resetEffect;
  19896. private _createVertexBuffers;
  19897. private _createIndexBuffer;
  19898. /**
  19899. * Gets the maximum number of particles active at the same time.
  19900. * @returns The max number of active particles.
  19901. */
  19902. getCapacity(): number;
  19903. /**
  19904. * Gets whether there are still active particles in the system.
  19905. * @returns True if it is alive, otherwise false.
  19906. */
  19907. isAlive(): boolean;
  19908. /**
  19909. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19910. * @returns True if it has been started, otherwise false.
  19911. */
  19912. isStarted(): boolean;
  19913. private _prepareSubEmitterInternalArray;
  19914. /**
  19915. * Starts the particle system and begins to emit
  19916. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  19917. */
  19918. start(delay?: number): void;
  19919. /**
  19920. * Stops the particle system.
  19921. * @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.
  19922. */
  19923. stop(stopSubEmitters?: boolean): void;
  19924. /**
  19925. * Remove all active particles
  19926. */
  19927. reset(): void;
  19928. /**
  19929. * @hidden (for internal use only)
  19930. */
  19931. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  19932. /**
  19933. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  19934. * Its lifetime will start back at 0.
  19935. */
  19936. recycleParticle: (particle: Particle) => void;
  19937. private _stopSubEmitters;
  19938. private _createParticle;
  19939. private _removeFromRoot;
  19940. private _emitFromParticle;
  19941. private _update;
  19942. /** @hidden */
  19943. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  19944. /** @hidden */
  19945. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  19946. /** @hidden */
  19947. private _getEffect;
  19948. /**
  19949. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  19950. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  19951. */
  19952. animate(preWarmOnly?: boolean): void;
  19953. private _appendParticleVertices;
  19954. /**
  19955. * Rebuilds the particle system.
  19956. */
  19957. rebuild(): void;
  19958. /**
  19959. * Is this system ready to be used/rendered
  19960. * @return true if the system is ready
  19961. */
  19962. isReady(): boolean;
  19963. private _render;
  19964. /**
  19965. * Renders the particle system in its current state.
  19966. * @returns the current number of particles
  19967. */
  19968. render(): number;
  19969. /**
  19970. * Disposes the particle system and free the associated resources
  19971. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19972. */
  19973. dispose(disposeTexture?: boolean): void;
  19974. /**
  19975. * Clones the particle system.
  19976. * @param name The name of the cloned object
  19977. * @param newEmitter The new emitter to use
  19978. * @returns the cloned particle system
  19979. */
  19980. clone(name: string, newEmitter: any): ParticleSystem;
  19981. /**
  19982. * Serializes the particle system to a JSON object.
  19983. * @returns the JSON object
  19984. */
  19985. serialize(): any;
  19986. /** @hidden */
  19987. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  19988. /** @hidden */
  19989. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  19990. /**
  19991. * Parses a JSON object to create a particle system.
  19992. * @param parsedParticleSystem The JSON object to parse
  19993. * @param scene The scene to create the particle system in
  19994. * @param rootUrl The root url to use to load external dependencies like texture
  19995. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  19996. * @returns the Parsed particle system
  19997. */
  19998. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  19999. }
  20000. }
  20001. declare module BABYLON {
  20002. /**
  20003. * A particle represents one of the element emitted by a particle system.
  20004. * This is mainly define by its coordinates, direction, velocity and age.
  20005. */
  20006. export class Particle {
  20007. /**
  20008. * The particle system the particle belongs to.
  20009. */
  20010. particleSystem: ParticleSystem;
  20011. private static _Count;
  20012. /**
  20013. * Unique ID of the particle
  20014. */
  20015. id: number;
  20016. /**
  20017. * The world position of the particle in the scene.
  20018. */
  20019. position: Vector3;
  20020. /**
  20021. * The world direction of the particle in the scene.
  20022. */
  20023. direction: Vector3;
  20024. /**
  20025. * The color of the particle.
  20026. */
  20027. color: Color4;
  20028. /**
  20029. * The color change of the particle per step.
  20030. */
  20031. colorStep: Color4;
  20032. /**
  20033. * Defines how long will the life of the particle be.
  20034. */
  20035. lifeTime: number;
  20036. /**
  20037. * The current age of the particle.
  20038. */
  20039. age: number;
  20040. /**
  20041. * The current size of the particle.
  20042. */
  20043. size: number;
  20044. /**
  20045. * The current scale of the particle.
  20046. */
  20047. scale: Vector2;
  20048. /**
  20049. * The current angle of the particle.
  20050. */
  20051. angle: number;
  20052. /**
  20053. * Defines how fast is the angle changing.
  20054. */
  20055. angularSpeed: number;
  20056. /**
  20057. * Defines the cell index used by the particle to be rendered from a sprite.
  20058. */
  20059. cellIndex: number;
  20060. /**
  20061. * The information required to support color remapping
  20062. */
  20063. remapData: Vector4;
  20064. /** @hidden */
  20065. _randomCellOffset?: number;
  20066. /** @hidden */
  20067. _initialDirection: Nullable<Vector3>;
  20068. /** @hidden */
  20069. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  20070. /** @hidden */
  20071. _initialStartSpriteCellID: number;
  20072. /** @hidden */
  20073. _initialEndSpriteCellID: number;
  20074. /** @hidden */
  20075. _currentColorGradient: Nullable<ColorGradient>;
  20076. /** @hidden */
  20077. _currentColor1: Color4;
  20078. /** @hidden */
  20079. _currentColor2: Color4;
  20080. /** @hidden */
  20081. _currentSizeGradient: Nullable<FactorGradient>;
  20082. /** @hidden */
  20083. _currentSize1: number;
  20084. /** @hidden */
  20085. _currentSize2: number;
  20086. /** @hidden */
  20087. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  20088. /** @hidden */
  20089. _currentAngularSpeed1: number;
  20090. /** @hidden */
  20091. _currentAngularSpeed2: number;
  20092. /** @hidden */
  20093. _currentVelocityGradient: Nullable<FactorGradient>;
  20094. /** @hidden */
  20095. _currentVelocity1: number;
  20096. /** @hidden */
  20097. _currentVelocity2: number;
  20098. /** @hidden */
  20099. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  20100. /** @hidden */
  20101. _currentLimitVelocity1: number;
  20102. /** @hidden */
  20103. _currentLimitVelocity2: number;
  20104. /** @hidden */
  20105. _currentDragGradient: Nullable<FactorGradient>;
  20106. /** @hidden */
  20107. _currentDrag1: number;
  20108. /** @hidden */
  20109. _currentDrag2: number;
  20110. /** @hidden */
  20111. _randomNoiseCoordinates1: Vector3;
  20112. /** @hidden */
  20113. _randomNoiseCoordinates2: Vector3;
  20114. /**
  20115. * Creates a new instance Particle
  20116. * @param particleSystem the particle system the particle belongs to
  20117. */
  20118. constructor(
  20119. /**
  20120. * The particle system the particle belongs to.
  20121. */
  20122. particleSystem: ParticleSystem);
  20123. private updateCellInfoFromSystem;
  20124. /**
  20125. * Defines how the sprite cell index is updated for the particle
  20126. */
  20127. updateCellIndex(): void;
  20128. /** @hidden */
  20129. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  20130. /** @hidden */
  20131. _inheritParticleInfoToSubEmitters(): void;
  20132. /** @hidden */
  20133. _reset(): void;
  20134. /**
  20135. * Copy the properties of particle to another one.
  20136. * @param other the particle to copy the information to.
  20137. */
  20138. copyTo(other: Particle): void;
  20139. }
  20140. }
  20141. declare module BABYLON {
  20142. /**
  20143. * Particle emitter represents a volume emitting particles.
  20144. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  20145. */
  20146. export interface IParticleEmitterType {
  20147. /**
  20148. * Called by the particle System when the direction is computed for the created particle.
  20149. * @param worldMatrix is the world matrix of the particle system
  20150. * @param directionToUpdate is the direction vector to update with the result
  20151. * @param particle is the particle we are computed the direction for
  20152. */
  20153. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20154. /**
  20155. * Called by the particle System when the position is computed for the created particle.
  20156. * @param worldMatrix is the world matrix of the particle system
  20157. * @param positionToUpdate is the position vector to update with the result
  20158. * @param particle is the particle we are computed the position for
  20159. */
  20160. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20161. /**
  20162. * Clones the current emitter and returns a copy of it
  20163. * @returns the new emitter
  20164. */
  20165. clone(): IParticleEmitterType;
  20166. /**
  20167. * Called by the GPUParticleSystem to setup the update shader
  20168. * @param effect defines the update shader
  20169. */
  20170. applyToShader(effect: Effect): void;
  20171. /**
  20172. * Returns a string to use to update the GPU particles update shader
  20173. * @returns the effect defines string
  20174. */
  20175. getEffectDefines(): string;
  20176. /**
  20177. * Returns a string representing the class name
  20178. * @returns a string containing the class name
  20179. */
  20180. getClassName(): string;
  20181. /**
  20182. * Serializes the particle system to a JSON object.
  20183. * @returns the JSON object
  20184. */
  20185. serialize(): any;
  20186. /**
  20187. * Parse properties from a JSON object
  20188. * @param serializationObject defines the JSON object
  20189. */
  20190. parse(serializationObject: any): void;
  20191. }
  20192. }
  20193. declare module BABYLON {
  20194. /**
  20195. * Particle emitter emitting particles from the inside of a box.
  20196. * It emits the particles randomly between 2 given directions.
  20197. */
  20198. export class BoxParticleEmitter implements IParticleEmitterType {
  20199. /**
  20200. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20201. */
  20202. direction1: Vector3;
  20203. /**
  20204. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20205. */
  20206. direction2: Vector3;
  20207. /**
  20208. * 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.
  20209. */
  20210. minEmitBox: Vector3;
  20211. /**
  20212. * 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.
  20213. */
  20214. maxEmitBox: Vector3;
  20215. /**
  20216. * Creates a new instance BoxParticleEmitter
  20217. */
  20218. constructor();
  20219. /**
  20220. * Called by the particle System when the direction is computed for the created particle.
  20221. * @param worldMatrix is the world matrix of the particle system
  20222. * @param directionToUpdate is the direction vector to update with the result
  20223. * @param particle is the particle we are computed the direction for
  20224. */
  20225. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20226. /**
  20227. * Called by the particle System when the position is computed for the created particle.
  20228. * @param worldMatrix is the world matrix of the particle system
  20229. * @param positionToUpdate is the position vector to update with the result
  20230. * @param particle is the particle we are computed the position for
  20231. */
  20232. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20233. /**
  20234. * Clones the current emitter and returns a copy of it
  20235. * @returns the new emitter
  20236. */
  20237. clone(): BoxParticleEmitter;
  20238. /**
  20239. * Called by the GPUParticleSystem to setup the update shader
  20240. * @param effect defines the update shader
  20241. */
  20242. applyToShader(effect: Effect): void;
  20243. /**
  20244. * Returns a string to use to update the GPU particles update shader
  20245. * @returns a string containng the defines string
  20246. */
  20247. getEffectDefines(): string;
  20248. /**
  20249. * Returns the string "BoxParticleEmitter"
  20250. * @returns a string containing the class name
  20251. */
  20252. getClassName(): string;
  20253. /**
  20254. * Serializes the particle system to a JSON object.
  20255. * @returns the JSON object
  20256. */
  20257. serialize(): any;
  20258. /**
  20259. * Parse properties from a JSON object
  20260. * @param serializationObject defines the JSON object
  20261. */
  20262. parse(serializationObject: any): void;
  20263. }
  20264. }
  20265. declare module BABYLON {
  20266. /**
  20267. * Particle emitter emitting particles from the inside of a cone.
  20268. * It emits the particles alongside the cone volume from the base to the particle.
  20269. * The emission direction might be randomized.
  20270. */
  20271. export class ConeParticleEmitter implements IParticleEmitterType {
  20272. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20273. directionRandomizer: number;
  20274. private _radius;
  20275. private _angle;
  20276. private _height;
  20277. /**
  20278. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  20279. */
  20280. radiusRange: number;
  20281. /**
  20282. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  20283. */
  20284. heightRange: number;
  20285. /**
  20286. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  20287. */
  20288. emitFromSpawnPointOnly: boolean;
  20289. /**
  20290. * Gets or sets the radius of the emission cone
  20291. */
  20292. radius: number;
  20293. /**
  20294. * Gets or sets the angle of the emission cone
  20295. */
  20296. angle: number;
  20297. private _buildHeight;
  20298. /**
  20299. * Creates a new instance ConeParticleEmitter
  20300. * @param radius the radius of the emission cone (1 by default)
  20301. * @param angle the cone base angle (PI by default)
  20302. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  20303. */
  20304. constructor(radius?: number, angle?: number,
  20305. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20306. directionRandomizer?: number);
  20307. /**
  20308. * Called by the particle System when the direction is computed for the created particle.
  20309. * @param worldMatrix is the world matrix of the particle system
  20310. * @param directionToUpdate is the direction vector to update with the result
  20311. * @param particle is the particle we are computed the direction for
  20312. */
  20313. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20314. /**
  20315. * Called by the particle System when the position is computed for the created particle.
  20316. * @param worldMatrix is the world matrix of the particle system
  20317. * @param positionToUpdate is the position vector to update with the result
  20318. * @param particle is the particle we are computed the position for
  20319. */
  20320. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20321. /**
  20322. * Clones the current emitter and returns a copy of it
  20323. * @returns the new emitter
  20324. */
  20325. clone(): ConeParticleEmitter;
  20326. /**
  20327. * Called by the GPUParticleSystem to setup the update shader
  20328. * @param effect defines the update shader
  20329. */
  20330. applyToShader(effect: Effect): void;
  20331. /**
  20332. * Returns a string to use to update the GPU particles update shader
  20333. * @returns a string containng the defines string
  20334. */
  20335. getEffectDefines(): string;
  20336. /**
  20337. * Returns the string "ConeParticleEmitter"
  20338. * @returns a string containing the class name
  20339. */
  20340. getClassName(): string;
  20341. /**
  20342. * Serializes the particle system to a JSON object.
  20343. * @returns the JSON object
  20344. */
  20345. serialize(): any;
  20346. /**
  20347. * Parse properties from a JSON object
  20348. * @param serializationObject defines the JSON object
  20349. */
  20350. parse(serializationObject: any): void;
  20351. }
  20352. }
  20353. declare module BABYLON {
  20354. /**
  20355. * Particle emitter emitting particles from the inside of a cylinder.
  20356. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  20357. */
  20358. export class CylinderParticleEmitter implements IParticleEmitterType {
  20359. /**
  20360. * The radius of the emission cylinder.
  20361. */
  20362. radius: number;
  20363. /**
  20364. * The height of the emission cylinder.
  20365. */
  20366. height: number;
  20367. /**
  20368. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20369. */
  20370. radiusRange: number;
  20371. /**
  20372. * How much to randomize the particle direction [0-1].
  20373. */
  20374. directionRandomizer: number;
  20375. /**
  20376. * Creates a new instance CylinderParticleEmitter
  20377. * @param radius the radius of the emission cylinder (1 by default)
  20378. * @param height the height of the emission cylinder (1 by default)
  20379. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20380. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20381. */
  20382. constructor(
  20383. /**
  20384. * The radius of the emission cylinder.
  20385. */
  20386. radius?: number,
  20387. /**
  20388. * The height of the emission cylinder.
  20389. */
  20390. height?: number,
  20391. /**
  20392. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20393. */
  20394. radiusRange?: number,
  20395. /**
  20396. * How much to randomize the particle direction [0-1].
  20397. */
  20398. directionRandomizer?: number);
  20399. /**
  20400. * Called by the particle System when the direction is computed for the created particle.
  20401. * @param worldMatrix is the world matrix of the particle system
  20402. * @param directionToUpdate is the direction vector to update with the result
  20403. * @param particle is the particle we are computed the direction for
  20404. */
  20405. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20406. /**
  20407. * Called by the particle System when the position is computed for the created particle.
  20408. * @param worldMatrix is the world matrix of the particle system
  20409. * @param positionToUpdate is the position vector to update with the result
  20410. * @param particle is the particle we are computed the position for
  20411. */
  20412. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20413. /**
  20414. * Clones the current emitter and returns a copy of it
  20415. * @returns the new emitter
  20416. */
  20417. clone(): CylinderParticleEmitter;
  20418. /**
  20419. * Called by the GPUParticleSystem to setup the update shader
  20420. * @param effect defines the update shader
  20421. */
  20422. applyToShader(effect: Effect): void;
  20423. /**
  20424. * Returns a string to use to update the GPU particles update shader
  20425. * @returns a string containng the defines string
  20426. */
  20427. getEffectDefines(): string;
  20428. /**
  20429. * Returns the string "CylinderParticleEmitter"
  20430. * @returns a string containing the class name
  20431. */
  20432. getClassName(): string;
  20433. /**
  20434. * Serializes the particle system to a JSON object.
  20435. * @returns the JSON object
  20436. */
  20437. serialize(): any;
  20438. /**
  20439. * Parse properties from a JSON object
  20440. * @param serializationObject defines the JSON object
  20441. */
  20442. parse(serializationObject: any): void;
  20443. }
  20444. /**
  20445. * Particle emitter emitting particles from the inside of a cylinder.
  20446. * It emits the particles randomly between two vectors.
  20447. */
  20448. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  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. * Creates a new instance CylinderDirectedParticleEmitter
  20459. * @param radius the radius of the emission cylinder (1 by default)
  20460. * @param height the height of the emission cylinder (1 by default)
  20461. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20462. * @param direction1 the min limit of the emission direction (up vector by default)
  20463. * @param direction2 the max limit of the emission direction (up vector by default)
  20464. */
  20465. constructor(radius?: number, height?: number, radiusRange?: number,
  20466. /**
  20467. * The min limit of the emission direction.
  20468. */
  20469. direction1?: Vector3,
  20470. /**
  20471. * The max limit of the emission direction.
  20472. */
  20473. direction2?: Vector3);
  20474. /**
  20475. * Called by the particle System when the direction is computed for the created particle.
  20476. * @param worldMatrix is the world matrix of the particle system
  20477. * @param directionToUpdate is the direction vector to update with the result
  20478. * @param particle is the particle we are computed the direction for
  20479. */
  20480. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20481. /**
  20482. * Clones the current emitter and returns a copy of it
  20483. * @returns the new emitter
  20484. */
  20485. clone(): CylinderDirectedParticleEmitter;
  20486. /**
  20487. * Called by the GPUParticleSystem to setup the update shader
  20488. * @param effect defines the update shader
  20489. */
  20490. applyToShader(effect: Effect): void;
  20491. /**
  20492. * Returns a string to use to update the GPU particles update shader
  20493. * @returns a string containng the defines string
  20494. */
  20495. getEffectDefines(): string;
  20496. /**
  20497. * Returns the string "CylinderDirectedParticleEmitter"
  20498. * @returns a string containing the class name
  20499. */
  20500. getClassName(): string;
  20501. /**
  20502. * Serializes the particle system to a JSON object.
  20503. * @returns the JSON object
  20504. */
  20505. serialize(): any;
  20506. /**
  20507. * Parse properties from a JSON object
  20508. * @param serializationObject defines the JSON object
  20509. */
  20510. parse(serializationObject: any): void;
  20511. }
  20512. }
  20513. declare module BABYLON {
  20514. /**
  20515. * Particle emitter emitting particles from the inside of a hemisphere.
  20516. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  20517. */
  20518. export class HemisphericParticleEmitter implements IParticleEmitterType {
  20519. /**
  20520. * The radius of the emission hemisphere.
  20521. */
  20522. radius: number;
  20523. /**
  20524. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20525. */
  20526. radiusRange: number;
  20527. /**
  20528. * How much to randomize the particle direction [0-1].
  20529. */
  20530. directionRandomizer: number;
  20531. /**
  20532. * Creates a new instance HemisphericParticleEmitter
  20533. * @param radius the radius of the emission hemisphere (1 by default)
  20534. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20535. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20536. */
  20537. constructor(
  20538. /**
  20539. * The radius of the emission hemisphere.
  20540. */
  20541. radius?: number,
  20542. /**
  20543. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20544. */
  20545. radiusRange?: number,
  20546. /**
  20547. * How much to randomize the particle direction [0-1].
  20548. */
  20549. directionRandomizer?: number);
  20550. /**
  20551. * Called by the particle System when the direction is computed for the created particle.
  20552. * @param worldMatrix is the world matrix of the particle system
  20553. * @param directionToUpdate is the direction vector to update with the result
  20554. * @param particle is the particle we are computed the direction for
  20555. */
  20556. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20557. /**
  20558. * Called by the particle System when the position is computed for the created particle.
  20559. * @param worldMatrix is the world matrix of the particle system
  20560. * @param positionToUpdate is the position vector to update with the result
  20561. * @param particle is the particle we are computed the position for
  20562. */
  20563. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20564. /**
  20565. * Clones the current emitter and returns a copy of it
  20566. * @returns the new emitter
  20567. */
  20568. clone(): HemisphericParticleEmitter;
  20569. /**
  20570. * Called by the GPUParticleSystem to setup the update shader
  20571. * @param effect defines the update shader
  20572. */
  20573. applyToShader(effect: Effect): void;
  20574. /**
  20575. * Returns a string to use to update the GPU particles update shader
  20576. * @returns a string containng the defines string
  20577. */
  20578. getEffectDefines(): string;
  20579. /**
  20580. * Returns the string "HemisphericParticleEmitter"
  20581. * @returns a string containing the class name
  20582. */
  20583. getClassName(): string;
  20584. /**
  20585. * Serializes the particle system to a JSON object.
  20586. * @returns the JSON object
  20587. */
  20588. serialize(): any;
  20589. /**
  20590. * Parse properties from a JSON object
  20591. * @param serializationObject defines the JSON object
  20592. */
  20593. parse(serializationObject: any): void;
  20594. }
  20595. }
  20596. declare module BABYLON {
  20597. /**
  20598. * Particle emitter emitting particles from a point.
  20599. * It emits the particles randomly between 2 given directions.
  20600. */
  20601. export class PointParticleEmitter implements IParticleEmitterType {
  20602. /**
  20603. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20604. */
  20605. direction1: Vector3;
  20606. /**
  20607. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20608. */
  20609. direction2: Vector3;
  20610. /**
  20611. * Creates a new instance PointParticleEmitter
  20612. */
  20613. constructor();
  20614. /**
  20615. * Called by the particle System when the direction is computed for the created particle.
  20616. * @param worldMatrix is the world matrix of the particle system
  20617. * @param directionToUpdate is the direction vector to update with the result
  20618. * @param particle is the particle we are computed the direction for
  20619. */
  20620. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20621. /**
  20622. * Called by the particle System when the position is computed for the created particle.
  20623. * @param worldMatrix is the world matrix of the particle system
  20624. * @param positionToUpdate is the position vector to update with the result
  20625. * @param particle is the particle we are computed the position for
  20626. */
  20627. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20628. /**
  20629. * Clones the current emitter and returns a copy of it
  20630. * @returns the new emitter
  20631. */
  20632. clone(): PointParticleEmitter;
  20633. /**
  20634. * Called by the GPUParticleSystem to setup the update shader
  20635. * @param effect defines the update shader
  20636. */
  20637. applyToShader(effect: Effect): void;
  20638. /**
  20639. * Returns a string to use to update the GPU particles update shader
  20640. * @returns a string containng the defines string
  20641. */
  20642. getEffectDefines(): string;
  20643. /**
  20644. * Returns the string "PointParticleEmitter"
  20645. * @returns a string containing the class name
  20646. */
  20647. getClassName(): string;
  20648. /**
  20649. * Serializes the particle system to a JSON object.
  20650. * @returns the JSON object
  20651. */
  20652. serialize(): any;
  20653. /**
  20654. * Parse properties from a JSON object
  20655. * @param serializationObject defines the JSON object
  20656. */
  20657. parse(serializationObject: any): void;
  20658. }
  20659. }
  20660. declare module BABYLON {
  20661. /**
  20662. * Particle emitter emitting particles from the inside of a sphere.
  20663. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  20664. */
  20665. export class SphereParticleEmitter implements IParticleEmitterType {
  20666. /**
  20667. * The radius of the emission sphere.
  20668. */
  20669. radius: number;
  20670. /**
  20671. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20672. */
  20673. radiusRange: number;
  20674. /**
  20675. * How much to randomize the particle direction [0-1].
  20676. */
  20677. directionRandomizer: number;
  20678. /**
  20679. * Creates a new instance SphereParticleEmitter
  20680. * @param radius the radius of the emission sphere (1 by default)
  20681. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20682. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20683. */
  20684. constructor(
  20685. /**
  20686. * The radius of the emission sphere.
  20687. */
  20688. radius?: number,
  20689. /**
  20690. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20691. */
  20692. radiusRange?: number,
  20693. /**
  20694. * How much to randomize the particle direction [0-1].
  20695. */
  20696. directionRandomizer?: number);
  20697. /**
  20698. * Called by the particle System when the direction is computed for the created particle.
  20699. * @param worldMatrix is the world matrix of the particle system
  20700. * @param directionToUpdate is the direction vector to update with the result
  20701. * @param particle is the particle we are computed the direction for
  20702. */
  20703. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20704. /**
  20705. * Called by the particle System when the position is computed for the created particle.
  20706. * @param worldMatrix is the world matrix of the particle system
  20707. * @param positionToUpdate is the position vector to update with the result
  20708. * @param particle is the particle we are computed the position for
  20709. */
  20710. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20711. /**
  20712. * Clones the current emitter and returns a copy of it
  20713. * @returns the new emitter
  20714. */
  20715. clone(): SphereParticleEmitter;
  20716. /**
  20717. * Called by the GPUParticleSystem to setup the update shader
  20718. * @param effect defines the update shader
  20719. */
  20720. applyToShader(effect: Effect): void;
  20721. /**
  20722. * Returns a string to use to update the GPU particles update shader
  20723. * @returns a string containng the defines string
  20724. */
  20725. getEffectDefines(): string;
  20726. /**
  20727. * Returns the string "SphereParticleEmitter"
  20728. * @returns a string containing the class name
  20729. */
  20730. getClassName(): string;
  20731. /**
  20732. * Serializes the particle system to a JSON object.
  20733. * @returns the JSON object
  20734. */
  20735. serialize(): any;
  20736. /**
  20737. * Parse properties from a JSON object
  20738. * @param serializationObject defines the JSON object
  20739. */
  20740. parse(serializationObject: any): void;
  20741. }
  20742. /**
  20743. * Particle emitter emitting particles from the inside of a sphere.
  20744. * It emits the particles randomly between two vectors.
  20745. */
  20746. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  20747. /**
  20748. * The min limit of the emission direction.
  20749. */
  20750. direction1: Vector3;
  20751. /**
  20752. * The max limit of the emission direction.
  20753. */
  20754. direction2: Vector3;
  20755. /**
  20756. * Creates a new instance SphereDirectedParticleEmitter
  20757. * @param radius the radius of the emission sphere (1 by default)
  20758. * @param direction1 the min limit of the emission direction (up vector by default)
  20759. * @param direction2 the max limit of the emission direction (up vector by default)
  20760. */
  20761. constructor(radius?: number,
  20762. /**
  20763. * The min limit of the emission direction.
  20764. */
  20765. direction1?: Vector3,
  20766. /**
  20767. * The max limit of the emission direction.
  20768. */
  20769. direction2?: Vector3);
  20770. /**
  20771. * Called by the particle System when the direction is computed for the created particle.
  20772. * @param worldMatrix is the world matrix of the particle system
  20773. * @param directionToUpdate is the direction vector to update with the result
  20774. * @param particle is the particle we are computed the direction for
  20775. */
  20776. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20777. /**
  20778. * Clones the current emitter and returns a copy of it
  20779. * @returns the new emitter
  20780. */
  20781. clone(): SphereDirectedParticleEmitter;
  20782. /**
  20783. * Called by the GPUParticleSystem to setup the update shader
  20784. * @param effect defines the update shader
  20785. */
  20786. applyToShader(effect: Effect): void;
  20787. /**
  20788. * Returns a string to use to update the GPU particles update shader
  20789. * @returns a string containng the defines string
  20790. */
  20791. getEffectDefines(): string;
  20792. /**
  20793. * Returns the string "SphereDirectedParticleEmitter"
  20794. * @returns a string containing the class name
  20795. */
  20796. getClassName(): string;
  20797. /**
  20798. * Serializes the particle system to a JSON object.
  20799. * @returns the JSON object
  20800. */
  20801. serialize(): any;
  20802. /**
  20803. * Parse properties from a JSON object
  20804. * @param serializationObject defines the JSON object
  20805. */
  20806. parse(serializationObject: any): void;
  20807. }
  20808. }
  20809. declare module BABYLON {
  20810. /**
  20811. * Interface representing a particle system in Babylon.js.
  20812. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  20813. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  20814. */
  20815. export interface IParticleSystem {
  20816. /**
  20817. * List of animations used by the particle system.
  20818. */
  20819. animations: Animation[];
  20820. /**
  20821. * The id of the Particle system.
  20822. */
  20823. id: string;
  20824. /**
  20825. * The name of the Particle system.
  20826. */
  20827. name: string;
  20828. /**
  20829. * The emitter represents the Mesh or position we are attaching the particle system to.
  20830. */
  20831. emitter: Nullable<AbstractMesh | Vector3>;
  20832. /**
  20833. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  20834. */
  20835. isBillboardBased: boolean;
  20836. /**
  20837. * The rendering group used by the Particle system to chose when to render.
  20838. */
  20839. renderingGroupId: number;
  20840. /**
  20841. * The layer mask we are rendering the particles through.
  20842. */
  20843. layerMask: number;
  20844. /**
  20845. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  20846. */
  20847. updateSpeed: number;
  20848. /**
  20849. * The amount of time the particle system is running (depends of the overall update speed).
  20850. */
  20851. targetStopDuration: number;
  20852. /**
  20853. * The texture used to render each particle. (this can be a spritesheet)
  20854. */
  20855. particleTexture: Nullable<Texture>;
  20856. /**
  20857. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  20858. */
  20859. blendMode: number;
  20860. /**
  20861. * Minimum life time of emitting particles.
  20862. */
  20863. minLifeTime: number;
  20864. /**
  20865. * Maximum life time of emitting particles.
  20866. */
  20867. maxLifeTime: number;
  20868. /**
  20869. * Minimum Size of emitting particles.
  20870. */
  20871. minSize: number;
  20872. /**
  20873. * Maximum Size of emitting particles.
  20874. */
  20875. maxSize: number;
  20876. /**
  20877. * Minimum scale of emitting particles on X axis.
  20878. */
  20879. minScaleX: number;
  20880. /**
  20881. * Maximum scale of emitting particles on X axis.
  20882. */
  20883. maxScaleX: number;
  20884. /**
  20885. * Minimum scale of emitting particles on Y axis.
  20886. */
  20887. minScaleY: number;
  20888. /**
  20889. * Maximum scale of emitting particles on Y axis.
  20890. */
  20891. maxScaleY: number;
  20892. /**
  20893. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  20894. */
  20895. color1: Color4;
  20896. /**
  20897. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  20898. */
  20899. color2: Color4;
  20900. /**
  20901. * Color the particle will have at the end of its lifetime.
  20902. */
  20903. colorDead: Color4;
  20904. /**
  20905. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  20906. */
  20907. emitRate: number;
  20908. /**
  20909. * You can use gravity if you want to give an orientation to your particles.
  20910. */
  20911. gravity: Vector3;
  20912. /**
  20913. * Minimum power of emitting particles.
  20914. */
  20915. minEmitPower: number;
  20916. /**
  20917. * Maximum power of emitting particles.
  20918. */
  20919. maxEmitPower: number;
  20920. /**
  20921. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  20922. */
  20923. minAngularSpeed: number;
  20924. /**
  20925. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  20926. */
  20927. maxAngularSpeed: number;
  20928. /**
  20929. * Gets or sets the minimal initial rotation in radians.
  20930. */
  20931. minInitialRotation: number;
  20932. /**
  20933. * Gets or sets the maximal initial rotation in radians.
  20934. */
  20935. maxInitialRotation: number;
  20936. /**
  20937. * The particle emitter type defines the emitter used by the particle system.
  20938. * It can be for example box, sphere, or cone...
  20939. */
  20940. particleEmitterType: Nullable<IParticleEmitterType>;
  20941. /**
  20942. * Defines the delay in milliseconds before starting the system (0 by default)
  20943. */
  20944. startDelay: number;
  20945. /**
  20946. * 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
  20947. */
  20948. preWarmCycles: number;
  20949. /**
  20950. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  20951. */
  20952. preWarmStepOffset: number;
  20953. /**
  20954. * 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)
  20955. */
  20956. spriteCellChangeSpeed: number;
  20957. /**
  20958. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  20959. */
  20960. startSpriteCellID: number;
  20961. /**
  20962. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  20963. */
  20964. endSpriteCellID: number;
  20965. /**
  20966. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  20967. */
  20968. spriteCellWidth: number;
  20969. /**
  20970. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  20971. */
  20972. spriteCellHeight: number;
  20973. /**
  20974. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  20975. */
  20976. spriteRandomStartCell: boolean;
  20977. /**
  20978. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  20979. */
  20980. isAnimationSheetEnabled: boolean;
  20981. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  20982. translationPivot: Vector2;
  20983. /**
  20984. * Gets or sets a texture used to add random noise to particle positions
  20985. */
  20986. noiseTexture: Nullable<BaseTexture>;
  20987. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  20988. noiseStrength: Vector3;
  20989. /**
  20990. * Gets or sets the billboard mode to use when isBillboardBased = true.
  20991. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  20992. */
  20993. billboardMode: number;
  20994. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  20995. limitVelocityDamping: number;
  20996. /**
  20997. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  20998. */
  20999. beginAnimationOnStart: boolean;
  21000. /**
  21001. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  21002. */
  21003. beginAnimationFrom: number;
  21004. /**
  21005. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  21006. */
  21007. beginAnimationTo: number;
  21008. /**
  21009. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  21010. */
  21011. beginAnimationLoop: boolean;
  21012. /**
  21013. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  21014. */
  21015. disposeOnStop: boolean;
  21016. /**
  21017. * Gets the maximum number of particles active at the same time.
  21018. * @returns The max number of active particles.
  21019. */
  21020. getCapacity(): number;
  21021. /**
  21022. * Gets if the system has been started. (Note: this will still be true after stop is called)
  21023. * @returns True if it has been started, otherwise false.
  21024. */
  21025. isStarted(): boolean;
  21026. /**
  21027. * Animates the particle system for this frame.
  21028. */
  21029. animate(): void;
  21030. /**
  21031. * Renders the particle system in its current state.
  21032. * @returns the current number of particles
  21033. */
  21034. render(): number;
  21035. /**
  21036. * Dispose the particle system and frees its associated resources.
  21037. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  21038. */
  21039. dispose(disposeTexture?: boolean): void;
  21040. /**
  21041. * Clones the particle system.
  21042. * @param name The name of the cloned object
  21043. * @param newEmitter The new emitter to use
  21044. * @returns the cloned particle system
  21045. */
  21046. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  21047. /**
  21048. * Serializes the particle system to a JSON object.
  21049. * @returns the JSON object
  21050. */
  21051. serialize(): any;
  21052. /**
  21053. * Rebuild the particle system
  21054. */
  21055. rebuild(): void;
  21056. /**
  21057. * Starts the particle system and begins to emit
  21058. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  21059. */
  21060. start(delay?: number): void;
  21061. /**
  21062. * Stops the particle system.
  21063. */
  21064. stop(): void;
  21065. /**
  21066. * Remove all active particles
  21067. */
  21068. reset(): void;
  21069. /**
  21070. * Is this system ready to be used/rendered
  21071. * @return true if the system is ready
  21072. */
  21073. isReady(): boolean;
  21074. /**
  21075. * Adds a new color gradient
  21076. * @param gradient defines the gradient to use (between 0 and 1)
  21077. * @param color1 defines the color to affect to the specified gradient
  21078. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  21079. * @returns the current particle system
  21080. */
  21081. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  21082. /**
  21083. * Remove a specific color gradient
  21084. * @param gradient defines the gradient to remove
  21085. * @returns the current particle system
  21086. */
  21087. removeColorGradient(gradient: number): IParticleSystem;
  21088. /**
  21089. * Adds a new size gradient
  21090. * @param gradient defines the gradient to use (between 0 and 1)
  21091. * @param factor defines the size factor to affect to the specified gradient
  21092. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21093. * @returns the current particle system
  21094. */
  21095. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21096. /**
  21097. * Remove a specific size gradient
  21098. * @param gradient defines the gradient to remove
  21099. * @returns the current particle system
  21100. */
  21101. removeSizeGradient(gradient: number): IParticleSystem;
  21102. /**
  21103. * Gets the current list of color gradients.
  21104. * You must use addColorGradient and removeColorGradient to udpate this list
  21105. * @returns the list of color gradients
  21106. */
  21107. getColorGradients(): Nullable<Array<ColorGradient>>;
  21108. /**
  21109. * Gets the current list of size gradients.
  21110. * You must use addSizeGradient and removeSizeGradient to udpate this list
  21111. * @returns the list of size gradients
  21112. */
  21113. getSizeGradients(): Nullable<Array<FactorGradient>>;
  21114. /**
  21115. * Gets the current list of angular speed gradients.
  21116. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  21117. * @returns the list of angular speed gradients
  21118. */
  21119. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  21120. /**
  21121. * Adds a new angular speed gradient
  21122. * @param gradient defines the gradient to use (between 0 and 1)
  21123. * @param factor defines the angular speed to affect to the specified gradient
  21124. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21125. * @returns the current particle system
  21126. */
  21127. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21128. /**
  21129. * Remove a specific angular speed gradient
  21130. * @param gradient defines the gradient to remove
  21131. * @returns the current particle system
  21132. */
  21133. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  21134. /**
  21135. * Gets the current list of velocity gradients.
  21136. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  21137. * @returns the list of velocity gradients
  21138. */
  21139. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  21140. /**
  21141. * Adds a new velocity gradient
  21142. * @param gradient defines the gradient to use (between 0 and 1)
  21143. * @param factor defines the velocity to affect to the specified gradient
  21144. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21145. * @returns the current particle system
  21146. */
  21147. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21148. /**
  21149. * Remove a specific velocity gradient
  21150. * @param gradient defines the gradient to remove
  21151. * @returns the current particle system
  21152. */
  21153. removeVelocityGradient(gradient: number): IParticleSystem;
  21154. /**
  21155. * Gets the current list of limit velocity gradients.
  21156. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  21157. * @returns the list of limit velocity gradients
  21158. */
  21159. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  21160. /**
  21161. * Adds a new limit velocity gradient
  21162. * @param gradient defines the gradient to use (between 0 and 1)
  21163. * @param factor defines the limit velocity to affect to the specified gradient
  21164. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21165. * @returns the current particle system
  21166. */
  21167. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21168. /**
  21169. * Remove a specific limit velocity gradient
  21170. * @param gradient defines the gradient to remove
  21171. * @returns the current particle system
  21172. */
  21173. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  21174. /**
  21175. * Adds a new drag gradient
  21176. * @param gradient defines the gradient to use (between 0 and 1)
  21177. * @param factor defines the drag to affect to the specified gradient
  21178. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21179. * @returns the current particle system
  21180. */
  21181. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21182. /**
  21183. * Remove a specific drag gradient
  21184. * @param gradient defines the gradient to remove
  21185. * @returns the current particle system
  21186. */
  21187. removeDragGradient(gradient: number): IParticleSystem;
  21188. /**
  21189. * Gets the current list of drag gradients.
  21190. * You must use addDragGradient and removeDragGradient to udpate this list
  21191. * @returns the list of drag gradients
  21192. */
  21193. getDragGradients(): Nullable<Array<FactorGradient>>;
  21194. /**
  21195. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  21196. * @param gradient defines the gradient to use (between 0 and 1)
  21197. * @param factor defines the emit rate to affect to the specified gradient
  21198. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21199. * @returns the current particle system
  21200. */
  21201. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21202. /**
  21203. * Remove a specific emit rate gradient
  21204. * @param gradient defines the gradient to remove
  21205. * @returns the current particle system
  21206. */
  21207. removeEmitRateGradient(gradient: number): IParticleSystem;
  21208. /**
  21209. * Gets the current list of emit rate gradients.
  21210. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  21211. * @returns the list of emit rate gradients
  21212. */
  21213. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  21214. /**
  21215. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  21216. * @param gradient defines the gradient to use (between 0 and 1)
  21217. * @param factor defines the start size to affect to the specified gradient
  21218. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21219. * @returns the current particle system
  21220. */
  21221. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21222. /**
  21223. * Remove a specific start size gradient
  21224. * @param gradient defines the gradient to remove
  21225. * @returns the current particle system
  21226. */
  21227. removeStartSizeGradient(gradient: number): IParticleSystem;
  21228. /**
  21229. * Gets the current list of start size gradients.
  21230. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  21231. * @returns the list of start size gradients
  21232. */
  21233. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  21234. /**
  21235. * Adds a new life time gradient
  21236. * @param gradient defines the gradient to use (between 0 and 1)
  21237. * @param factor defines the life time factor to affect to the specified gradient
  21238. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21239. * @returns the current particle system
  21240. */
  21241. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21242. /**
  21243. * Remove a specific life time gradient
  21244. * @param gradient defines the gradient to remove
  21245. * @returns the current particle system
  21246. */
  21247. removeLifeTimeGradient(gradient: number): IParticleSystem;
  21248. /**
  21249. * Gets the current list of life time gradients.
  21250. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  21251. * @returns the list of life time gradients
  21252. */
  21253. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  21254. /**
  21255. * Gets the current list of color gradients.
  21256. * You must use addColorGradient and removeColorGradient to udpate this list
  21257. * @returns the list of color gradients
  21258. */
  21259. getColorGradients(): Nullable<Array<ColorGradient>>;
  21260. /**
  21261. * Adds a new ramp gradient used to remap particle colors
  21262. * @param gradient defines the gradient to use (between 0 and 1)
  21263. * @param color defines the color to affect to the specified gradient
  21264. * @returns the current particle system
  21265. */
  21266. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  21267. /**
  21268. * Gets the current list of ramp gradients.
  21269. * You must use addRampGradient and removeRampGradient to udpate this list
  21270. * @returns the list of ramp gradients
  21271. */
  21272. getRampGradients(): Nullable<Array<Color3Gradient>>;
  21273. /** Gets or sets a boolean indicating that ramp gradients must be used
  21274. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  21275. */
  21276. useRampGradients: boolean;
  21277. /**
  21278. * Adds a new color remap gradient
  21279. * @param gradient defines the gradient to use (between 0 and 1)
  21280. * @param min defines the color remap minimal range
  21281. * @param max defines the color remap maximal range
  21282. * @returns the current particle system
  21283. */
  21284. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21285. /**
  21286. * Gets the current list of color remap gradients.
  21287. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  21288. * @returns the list of color remap gradients
  21289. */
  21290. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  21291. /**
  21292. * Adds a new alpha remap gradient
  21293. * @param gradient defines the gradient to use (between 0 and 1)
  21294. * @param min defines the alpha remap minimal range
  21295. * @param max defines the alpha remap maximal range
  21296. * @returns the current particle system
  21297. */
  21298. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21299. /**
  21300. * Gets the current list of alpha remap gradients.
  21301. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  21302. * @returns the list of alpha remap gradients
  21303. */
  21304. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  21305. /**
  21306. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  21307. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21308. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21309. * @returns the emitter
  21310. */
  21311. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  21312. /**
  21313. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  21314. * @param radius The radius of the hemisphere to emit from
  21315. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21316. * @returns the emitter
  21317. */
  21318. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  21319. /**
  21320. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  21321. * @param radius The radius of the sphere to emit from
  21322. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21323. * @returns the emitter
  21324. */
  21325. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  21326. /**
  21327. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  21328. * @param radius The radius of the sphere to emit from
  21329. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  21330. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  21331. * @returns the emitter
  21332. */
  21333. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21334. /**
  21335. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  21336. * @param radius The radius of the emission cylinder
  21337. * @param height The height of the emission cylinder
  21338. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  21339. * @param directionRandomizer How much to randomize the particle direction [0-1]
  21340. * @returns the emitter
  21341. */
  21342. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  21343. /**
  21344. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  21345. * @param radius The radius of the cylinder to emit from
  21346. * @param height The height of the emission cylinder
  21347. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21348. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  21349. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  21350. * @returns the emitter
  21351. */
  21352. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21353. /**
  21354. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  21355. * @param radius The radius of the cone to emit from
  21356. * @param angle The base angle of the cone
  21357. * @returns the emitter
  21358. */
  21359. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  21360. /**
  21361. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  21362. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21363. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21364. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21365. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21366. * @returns the emitter
  21367. */
  21368. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  21369. /**
  21370. * Get hosting scene
  21371. * @returns the scene
  21372. */
  21373. getScene(): Scene;
  21374. }
  21375. }
  21376. declare module BABYLON {
  21377. /** @hidden */
  21378. export var linePixelShader: {
  21379. name: string;
  21380. shader: string;
  21381. };
  21382. }
  21383. declare module BABYLON {
  21384. /** @hidden */
  21385. export var lineVertexShader: {
  21386. name: string;
  21387. shader: string;
  21388. };
  21389. }
  21390. declare module BABYLON {
  21391. interface AbstractMesh {
  21392. /**
  21393. * Gets the edgesRenderer associated with the mesh
  21394. */
  21395. edgesRenderer: Nullable<EdgesRenderer>;
  21396. }
  21397. interface LinesMesh {
  21398. /**
  21399. * Enables the edge rendering mode on the mesh.
  21400. * This mode makes the mesh edges visible
  21401. * @param epsilon defines the maximal distance between two angles to detect a face
  21402. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21403. * @returns the currentAbstractMesh
  21404. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21405. */
  21406. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21407. }
  21408. interface InstancedLinesMesh {
  21409. /**
  21410. * Enables the edge rendering mode on the mesh.
  21411. * This mode makes the mesh edges visible
  21412. * @param epsilon defines the maximal distance between two angles to detect a face
  21413. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21414. * @returns the current InstancedLinesMesh
  21415. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21416. */
  21417. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  21418. }
  21419. /**
  21420. * Defines the minimum contract an Edges renderer should follow.
  21421. */
  21422. export interface IEdgesRenderer extends IDisposable {
  21423. /**
  21424. * Gets or sets a boolean indicating if the edgesRenderer is active
  21425. */
  21426. isEnabled: boolean;
  21427. /**
  21428. * Renders the edges of the attached mesh,
  21429. */
  21430. render(): void;
  21431. /**
  21432. * Checks wether or not the edges renderer is ready to render.
  21433. * @return true if ready, otherwise false.
  21434. */
  21435. isReady(): boolean;
  21436. }
  21437. /**
  21438. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  21439. */
  21440. export class EdgesRenderer implements IEdgesRenderer {
  21441. /**
  21442. * Define the size of the edges with an orthographic camera
  21443. */
  21444. edgesWidthScalerForOrthographic: number;
  21445. /**
  21446. * Define the size of the edges with a perspective camera
  21447. */
  21448. edgesWidthScalerForPerspective: number;
  21449. protected _source: AbstractMesh;
  21450. protected _linesPositions: number[];
  21451. protected _linesNormals: number[];
  21452. protected _linesIndices: number[];
  21453. protected _epsilon: number;
  21454. protected _indicesCount: number;
  21455. protected _lineShader: ShaderMaterial;
  21456. protected _ib: DataBuffer;
  21457. protected _buffers: {
  21458. [key: string]: Nullable<VertexBuffer>;
  21459. };
  21460. protected _checkVerticesInsteadOfIndices: boolean;
  21461. private _meshRebuildObserver;
  21462. private _meshDisposeObserver;
  21463. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  21464. isEnabled: boolean;
  21465. /**
  21466. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  21467. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  21468. * @param source Mesh used to create edges
  21469. * @param epsilon sum of angles in adjacency to check for edge
  21470. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  21471. * @param generateEdgesLines - should generate Lines or only prepare resources.
  21472. */
  21473. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  21474. protected _prepareRessources(): void;
  21475. /** @hidden */
  21476. _rebuild(): void;
  21477. /**
  21478. * Releases the required resources for the edges renderer
  21479. */
  21480. dispose(): void;
  21481. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  21482. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  21483. /**
  21484. * Checks if the pair of p0 and p1 is en edge
  21485. * @param faceIndex
  21486. * @param edge
  21487. * @param faceNormals
  21488. * @param p0
  21489. * @param p1
  21490. * @private
  21491. */
  21492. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  21493. /**
  21494. * push line into the position, normal and index buffer
  21495. * @protected
  21496. */
  21497. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  21498. /**
  21499. * Generates lines edges from adjacencjes
  21500. * @private
  21501. */
  21502. _generateEdgesLines(): void;
  21503. /**
  21504. * Checks wether or not the edges renderer is ready to render.
  21505. * @return true if ready, otherwise false.
  21506. */
  21507. isReady(): boolean;
  21508. /**
  21509. * Renders the edges of the attached mesh,
  21510. */
  21511. render(): void;
  21512. }
  21513. /**
  21514. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  21515. */
  21516. export class LineEdgesRenderer extends EdgesRenderer {
  21517. /**
  21518. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  21519. * @param source LineMesh used to generate edges
  21520. * @param epsilon not important (specified angle for edge detection)
  21521. * @param checkVerticesInsteadOfIndices not important for LineMesh
  21522. */
  21523. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  21524. /**
  21525. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  21526. */
  21527. _generateEdgesLines(): void;
  21528. }
  21529. }
  21530. declare module BABYLON {
  21531. /**
  21532. * This represents the object necessary to create a rendering group.
  21533. * This is exclusively used and created by the rendering manager.
  21534. * To modify the behavior, you use the available helpers in your scene or meshes.
  21535. * @hidden
  21536. */
  21537. export class RenderingGroup {
  21538. index: number;
  21539. private static _zeroVector;
  21540. private _scene;
  21541. private _opaqueSubMeshes;
  21542. private _transparentSubMeshes;
  21543. private _alphaTestSubMeshes;
  21544. private _depthOnlySubMeshes;
  21545. private _particleSystems;
  21546. private _spriteManagers;
  21547. private _opaqueSortCompareFn;
  21548. private _alphaTestSortCompareFn;
  21549. private _transparentSortCompareFn;
  21550. private _renderOpaque;
  21551. private _renderAlphaTest;
  21552. private _renderTransparent;
  21553. /** @hidden */
  21554. _edgesRenderers: SmartArray<IEdgesRenderer>;
  21555. onBeforeTransparentRendering: () => void;
  21556. /**
  21557. * Set the opaque sort comparison function.
  21558. * If null the sub meshes will be render in the order they were created
  21559. */
  21560. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21561. /**
  21562. * Set the alpha test sort comparison function.
  21563. * If null the sub meshes will be render in the order they were created
  21564. */
  21565. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21566. /**
  21567. * Set the transparent sort comparison function.
  21568. * If null the sub meshes will be render in the order they were created
  21569. */
  21570. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21571. /**
  21572. * Creates a new rendering group.
  21573. * @param index The rendering group index
  21574. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  21575. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  21576. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  21577. */
  21578. 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>);
  21579. /**
  21580. * Render all the sub meshes contained in the group.
  21581. * @param customRenderFunction Used to override the default render behaviour of the group.
  21582. * @returns true if rendered some submeshes.
  21583. */
  21584. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  21585. /**
  21586. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  21587. * @param subMeshes The submeshes to render
  21588. */
  21589. private renderOpaqueSorted;
  21590. /**
  21591. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  21592. * @param subMeshes The submeshes to render
  21593. */
  21594. private renderAlphaTestSorted;
  21595. /**
  21596. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  21597. * @param subMeshes The submeshes to render
  21598. */
  21599. private renderTransparentSorted;
  21600. /**
  21601. * Renders the submeshes in a specified order.
  21602. * @param subMeshes The submeshes to sort before render
  21603. * @param sortCompareFn The comparison function use to sort
  21604. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  21605. * @param transparent Specifies to activate blending if true
  21606. */
  21607. private static renderSorted;
  21608. /**
  21609. * Renders the submeshes in the order they were dispatched (no sort applied).
  21610. * @param subMeshes The submeshes to render
  21611. */
  21612. private static renderUnsorted;
  21613. /**
  21614. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21615. * are rendered back to front if in the same alpha index.
  21616. *
  21617. * @param a The first submesh
  21618. * @param b The second submesh
  21619. * @returns The result of the comparison
  21620. */
  21621. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  21622. /**
  21623. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21624. * are rendered back to front.
  21625. *
  21626. * @param a The first submesh
  21627. * @param b The second submesh
  21628. * @returns The result of the comparison
  21629. */
  21630. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  21631. /**
  21632. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21633. * are rendered front to back (prevent overdraw).
  21634. *
  21635. * @param a The first submesh
  21636. * @param b The second submesh
  21637. * @returns The result of the comparison
  21638. */
  21639. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  21640. /**
  21641. * Resets the different lists of submeshes to prepare a new frame.
  21642. */
  21643. prepare(): void;
  21644. dispose(): void;
  21645. /**
  21646. * Inserts the submesh in its correct queue depending on its material.
  21647. * @param subMesh The submesh to dispatch
  21648. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  21649. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  21650. */
  21651. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  21652. dispatchSprites(spriteManager: ISpriteManager): void;
  21653. dispatchParticles(particleSystem: IParticleSystem): void;
  21654. private _renderParticles;
  21655. private _renderSprites;
  21656. }
  21657. }
  21658. declare module BABYLON {
  21659. /**
  21660. * Interface describing the different options available in the rendering manager
  21661. * regarding Auto Clear between groups.
  21662. */
  21663. export interface IRenderingManagerAutoClearSetup {
  21664. /**
  21665. * Defines whether or not autoclear is enable.
  21666. */
  21667. autoClear: boolean;
  21668. /**
  21669. * Defines whether or not to autoclear the depth buffer.
  21670. */
  21671. depth: boolean;
  21672. /**
  21673. * Defines whether or not to autoclear the stencil buffer.
  21674. */
  21675. stencil: boolean;
  21676. }
  21677. /**
  21678. * This class is used by the onRenderingGroupObservable
  21679. */
  21680. export class RenderingGroupInfo {
  21681. /**
  21682. * The Scene that being rendered
  21683. */
  21684. scene: Scene;
  21685. /**
  21686. * The camera currently used for the rendering pass
  21687. */
  21688. camera: Nullable<Camera>;
  21689. /**
  21690. * The ID of the renderingGroup being processed
  21691. */
  21692. renderingGroupId: number;
  21693. }
  21694. /**
  21695. * This is the manager responsible of all the rendering for meshes sprites and particles.
  21696. * It is enable to manage the different groups as well as the different necessary sort functions.
  21697. * This should not be used directly aside of the few static configurations
  21698. */
  21699. export class RenderingManager {
  21700. /**
  21701. * The max id used for rendering groups (not included)
  21702. */
  21703. static MAX_RENDERINGGROUPS: number;
  21704. /**
  21705. * The min id used for rendering groups (included)
  21706. */
  21707. static MIN_RENDERINGGROUPS: number;
  21708. /**
  21709. * Used to globally prevent autoclearing scenes.
  21710. */
  21711. static AUTOCLEAR: boolean;
  21712. /**
  21713. * @hidden
  21714. */
  21715. _useSceneAutoClearSetup: boolean;
  21716. private _scene;
  21717. private _renderingGroups;
  21718. private _depthStencilBufferAlreadyCleaned;
  21719. private _autoClearDepthStencil;
  21720. private _customOpaqueSortCompareFn;
  21721. private _customAlphaTestSortCompareFn;
  21722. private _customTransparentSortCompareFn;
  21723. private _renderingGroupInfo;
  21724. /**
  21725. * Instantiates a new rendering group for a particular scene
  21726. * @param scene Defines the scene the groups belongs to
  21727. */
  21728. constructor(scene: Scene);
  21729. private _clearDepthStencilBuffer;
  21730. /**
  21731. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  21732. * @hidden
  21733. */
  21734. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  21735. /**
  21736. * Resets the different information of the group to prepare a new frame
  21737. * @hidden
  21738. */
  21739. reset(): void;
  21740. /**
  21741. * Dispose and release the group and its associated resources.
  21742. * @hidden
  21743. */
  21744. dispose(): void;
  21745. /**
  21746. * Clear the info related to rendering groups preventing retention points during dispose.
  21747. */
  21748. freeRenderingGroups(): void;
  21749. private _prepareRenderingGroup;
  21750. /**
  21751. * Add a sprite manager to the rendering manager in order to render it this frame.
  21752. * @param spriteManager Define the sprite manager to render
  21753. */
  21754. dispatchSprites(spriteManager: ISpriteManager): void;
  21755. /**
  21756. * Add a particle system to the rendering manager in order to render it this frame.
  21757. * @param particleSystem Define the particle system to render
  21758. */
  21759. dispatchParticles(particleSystem: IParticleSystem): void;
  21760. /**
  21761. * Add a submesh to the manager in order to render it this frame
  21762. * @param subMesh The submesh to dispatch
  21763. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  21764. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  21765. */
  21766. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  21767. /**
  21768. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21769. * This allowed control for front to back rendering or reversly depending of the special needs.
  21770. *
  21771. * @param renderingGroupId The rendering group id corresponding to its index
  21772. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21773. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21774. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21775. */
  21776. 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;
  21777. /**
  21778. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21779. *
  21780. * @param renderingGroupId The rendering group id corresponding to its index
  21781. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21782. * @param depth Automatically clears depth between groups if true and autoClear is true.
  21783. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  21784. */
  21785. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  21786. /**
  21787. * Gets the current auto clear configuration for one rendering group of the rendering
  21788. * manager.
  21789. * @param index the rendering group index to get the information for
  21790. * @returns The auto clear setup for the requested rendering group
  21791. */
  21792. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  21793. }
  21794. }
  21795. declare module BABYLON {
  21796. /**
  21797. * This Helps creating a texture that will be created from a camera in your scene.
  21798. * It is basically a dynamic texture that could be used to create special effects for instance.
  21799. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21800. */
  21801. export class RenderTargetTexture extends Texture {
  21802. isCube: boolean;
  21803. /**
  21804. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21805. */
  21806. static readonly REFRESHRATE_RENDER_ONCE: number;
  21807. /**
  21808. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21809. */
  21810. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21811. /**
  21812. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21813. * the central point of your effect and can save a lot of performances.
  21814. */
  21815. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21816. /**
  21817. * Use this predicate to dynamically define the list of mesh you want to render.
  21818. * If set, the renderList property will be overwritten.
  21819. */
  21820. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21821. private _renderList;
  21822. /**
  21823. * Use this list to define the list of mesh you want to render.
  21824. */
  21825. renderList: Nullable<Array<AbstractMesh>>;
  21826. private _hookArray;
  21827. /**
  21828. * Define if particles should be rendered in your texture.
  21829. */
  21830. renderParticles: boolean;
  21831. /**
  21832. * Define if sprites should be rendered in your texture.
  21833. */
  21834. renderSprites: boolean;
  21835. /**
  21836. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21837. */
  21838. coordinatesMode: number;
  21839. /**
  21840. * Define the camera used to render the texture.
  21841. */
  21842. activeCamera: Nullable<Camera>;
  21843. /**
  21844. * Override the render function of the texture with your own one.
  21845. */
  21846. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21847. /**
  21848. * Define if camera post processes should be use while rendering the texture.
  21849. */
  21850. useCameraPostProcesses: boolean;
  21851. /**
  21852. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21853. */
  21854. ignoreCameraViewport: boolean;
  21855. private _postProcessManager;
  21856. private _postProcesses;
  21857. private _resizeObserver;
  21858. /**
  21859. * An event triggered when the texture is unbind.
  21860. */
  21861. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21862. /**
  21863. * An event triggered when the texture is unbind.
  21864. */
  21865. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21866. private _onAfterUnbindObserver;
  21867. /**
  21868. * Set a after unbind callback in the texture.
  21869. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21870. */
  21871. onAfterUnbind: () => void;
  21872. /**
  21873. * An event triggered before rendering the texture
  21874. */
  21875. onBeforeRenderObservable: Observable<number>;
  21876. private _onBeforeRenderObserver;
  21877. /**
  21878. * Set a before render callback in the texture.
  21879. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21880. */
  21881. onBeforeRender: (faceIndex: number) => void;
  21882. /**
  21883. * An event triggered after rendering the texture
  21884. */
  21885. onAfterRenderObservable: Observable<number>;
  21886. private _onAfterRenderObserver;
  21887. /**
  21888. * Set a after render callback in the texture.
  21889. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21890. */
  21891. onAfterRender: (faceIndex: number) => void;
  21892. /**
  21893. * An event triggered after the texture clear
  21894. */
  21895. onClearObservable: Observable<Engine>;
  21896. private _onClearObserver;
  21897. /**
  21898. * Set a clear callback in the texture.
  21899. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21900. */
  21901. onClear: (Engine: Engine) => void;
  21902. /**
  21903. * Define the clear color of the Render Target if it should be different from the scene.
  21904. */
  21905. clearColor: Color4;
  21906. protected _size: number | {
  21907. width: number;
  21908. height: number;
  21909. };
  21910. protected _initialSizeParameter: number | {
  21911. width: number;
  21912. height: number;
  21913. } | {
  21914. ratio: number;
  21915. };
  21916. protected _sizeRatio: Nullable<number>;
  21917. /** @hidden */
  21918. _generateMipMaps: boolean;
  21919. protected _renderingManager: RenderingManager;
  21920. /** @hidden */
  21921. _waitingRenderList: string[];
  21922. protected _doNotChangeAspectRatio: boolean;
  21923. protected _currentRefreshId: number;
  21924. protected _refreshRate: number;
  21925. protected _textureMatrix: Matrix;
  21926. protected _samples: number;
  21927. protected _renderTargetOptions: RenderTargetCreationOptions;
  21928. /**
  21929. * Gets render target creation options that were used.
  21930. */
  21931. readonly renderTargetOptions: RenderTargetCreationOptions;
  21932. protected _engine: Engine;
  21933. protected _onRatioRescale(): void;
  21934. /**
  21935. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21936. * It must define where the camera used to render the texture is set
  21937. */
  21938. boundingBoxPosition: Vector3;
  21939. private _boundingBoxSize;
  21940. /**
  21941. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21942. * When defined, the cubemap will switch to local mode
  21943. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21944. * @example https://www.babylonjs-playground.com/#RNASML
  21945. */
  21946. boundingBoxSize: Vector3;
  21947. /**
  21948. * In case the RTT has been created with a depth texture, get the associated
  21949. * depth texture.
  21950. * Otherwise, return null.
  21951. */
  21952. depthStencilTexture: Nullable<InternalTexture>;
  21953. /**
  21954. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21955. * or used a shadow, depth texture...
  21956. * @param name The friendly name of the texture
  21957. * @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)
  21958. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21959. * @param generateMipMaps True if mip maps need to be generated after render.
  21960. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21961. * @param type The type of the buffer in the RTT (int, half float, float...)
  21962. * @param isCube True if a cube texture needs to be created
  21963. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21964. * @param generateDepthBuffer True to generate a depth buffer
  21965. * @param generateStencilBuffer True to generate a stencil buffer
  21966. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21967. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21968. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21969. */
  21970. constructor(name: string, size: number | {
  21971. width: number;
  21972. height: number;
  21973. } | {
  21974. ratio: number;
  21975. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21976. /**
  21977. * Creates a depth stencil texture.
  21978. * This is only available in WebGL 2 or with the depth texture extension available.
  21979. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21980. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21981. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21982. */
  21983. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21984. private _processSizeParameter;
  21985. /**
  21986. * Define the number of samples to use in case of MSAA.
  21987. * It defaults to one meaning no MSAA has been enabled.
  21988. */
  21989. samples: number;
  21990. /**
  21991. * Resets the refresh counter of the texture and start bak from scratch.
  21992. * Could be useful to regenerate the texture if it is setup to render only once.
  21993. */
  21994. resetRefreshCounter(): void;
  21995. /**
  21996. * Define the refresh rate of the texture or the rendering frequency.
  21997. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21998. */
  21999. refreshRate: number;
  22000. /**
  22001. * Adds a post process to the render target rendering passes.
  22002. * @param postProcess define the post process to add
  22003. */
  22004. addPostProcess(postProcess: PostProcess): void;
  22005. /**
  22006. * Clear all the post processes attached to the render target
  22007. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  22008. */
  22009. clearPostProcesses(dispose?: boolean): void;
  22010. /**
  22011. * Remove one of the post process from the list of attached post processes to the texture
  22012. * @param postProcess define the post process to remove from the list
  22013. */
  22014. removePostProcess(postProcess: PostProcess): void;
  22015. /** @hidden */
  22016. _shouldRender(): boolean;
  22017. /**
  22018. * Gets the actual render size of the texture.
  22019. * @returns the width of the render size
  22020. */
  22021. getRenderSize(): number;
  22022. /**
  22023. * Gets the actual render width of the texture.
  22024. * @returns the width of the render size
  22025. */
  22026. getRenderWidth(): number;
  22027. /**
  22028. * Gets the actual render height of the texture.
  22029. * @returns the height of the render size
  22030. */
  22031. getRenderHeight(): number;
  22032. /**
  22033. * Get if the texture can be rescaled or not.
  22034. */
  22035. readonly canRescale: boolean;
  22036. /**
  22037. * Resize the texture using a ratio.
  22038. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  22039. */
  22040. scale(ratio: number): void;
  22041. /**
  22042. * Get the texture reflection matrix used to rotate/transform the reflection.
  22043. * @returns the reflection matrix
  22044. */
  22045. getReflectionTextureMatrix(): Matrix;
  22046. /**
  22047. * Resize the texture to a new desired size.
  22048. * Be carrefull as it will recreate all the data in the new texture.
  22049. * @param size Define the new size. It can be:
  22050. * - a number for squared texture,
  22051. * - an object containing { width: number, height: number }
  22052. * - or an object containing a ratio { ratio: number }
  22053. */
  22054. resize(size: number | {
  22055. width: number;
  22056. height: number;
  22057. } | {
  22058. ratio: number;
  22059. }): void;
  22060. /**
  22061. * Renders all the objects from the render list into the texture.
  22062. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  22063. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  22064. */
  22065. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  22066. private _bestReflectionRenderTargetDimension;
  22067. /**
  22068. * @hidden
  22069. * @param faceIndex face index to bind to if this is a cubetexture
  22070. */
  22071. _bindFrameBuffer(faceIndex?: number): void;
  22072. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  22073. private renderToTarget;
  22074. /**
  22075. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22076. * This allowed control for front to back rendering or reversly depending of the special needs.
  22077. *
  22078. * @param renderingGroupId The rendering group id corresponding to its index
  22079. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22080. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22081. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22082. */
  22083. 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;
  22084. /**
  22085. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22086. *
  22087. * @param renderingGroupId The rendering group id corresponding to its index
  22088. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22089. */
  22090. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  22091. /**
  22092. * Clones the texture.
  22093. * @returns the cloned texture
  22094. */
  22095. clone(): RenderTargetTexture;
  22096. /**
  22097. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  22098. * @returns The JSON representation of the texture
  22099. */
  22100. serialize(): any;
  22101. /**
  22102. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  22103. */
  22104. disposeFramebufferObjects(): void;
  22105. /**
  22106. * Dispose the texture and release its associated resources.
  22107. */
  22108. dispose(): void;
  22109. /** @hidden */
  22110. _rebuild(): void;
  22111. /**
  22112. * Clear the info related to rendering groups preventing retention point in material dispose.
  22113. */
  22114. freeRenderingGroups(): void;
  22115. /**
  22116. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  22117. * @returns the view count
  22118. */
  22119. getViewCount(): number;
  22120. }
  22121. }
  22122. declare module BABYLON {
  22123. /**
  22124. * Base class for the main features of a material in Babylon.js
  22125. */
  22126. export class Material implements IAnimatable {
  22127. /**
  22128. * Returns the triangle fill mode
  22129. */
  22130. static readonly TriangleFillMode: number;
  22131. /**
  22132. * Returns the wireframe mode
  22133. */
  22134. static readonly WireFrameFillMode: number;
  22135. /**
  22136. * Returns the point fill mode
  22137. */
  22138. static readonly PointFillMode: number;
  22139. /**
  22140. * Returns the point list draw mode
  22141. */
  22142. static readonly PointListDrawMode: number;
  22143. /**
  22144. * Returns the line list draw mode
  22145. */
  22146. static readonly LineListDrawMode: number;
  22147. /**
  22148. * Returns the line loop draw mode
  22149. */
  22150. static readonly LineLoopDrawMode: number;
  22151. /**
  22152. * Returns the line strip draw mode
  22153. */
  22154. static readonly LineStripDrawMode: number;
  22155. /**
  22156. * Returns the triangle strip draw mode
  22157. */
  22158. static readonly TriangleStripDrawMode: number;
  22159. /**
  22160. * Returns the triangle fan draw mode
  22161. */
  22162. static readonly TriangleFanDrawMode: number;
  22163. /**
  22164. * Stores the clock-wise side orientation
  22165. */
  22166. static readonly ClockWiseSideOrientation: number;
  22167. /**
  22168. * Stores the counter clock-wise side orientation
  22169. */
  22170. static readonly CounterClockWiseSideOrientation: number;
  22171. /**
  22172. * The dirty texture flag value
  22173. */
  22174. static readonly TextureDirtyFlag: number;
  22175. /**
  22176. * The dirty light flag value
  22177. */
  22178. static readonly LightDirtyFlag: number;
  22179. /**
  22180. * The dirty fresnel flag value
  22181. */
  22182. static readonly FresnelDirtyFlag: number;
  22183. /**
  22184. * The dirty attribute flag value
  22185. */
  22186. static readonly AttributesDirtyFlag: number;
  22187. /**
  22188. * The dirty misc flag value
  22189. */
  22190. static readonly MiscDirtyFlag: number;
  22191. /**
  22192. * The all dirty flag value
  22193. */
  22194. static readonly AllDirtyFlag: number;
  22195. /**
  22196. * The ID of the material
  22197. */
  22198. id: string;
  22199. /**
  22200. * Gets or sets the unique id of the material
  22201. */
  22202. uniqueId: number;
  22203. /**
  22204. * The name of the material
  22205. */
  22206. name: string;
  22207. /**
  22208. * Gets or sets user defined metadata
  22209. */
  22210. metadata: any;
  22211. /**
  22212. * For internal use only. Please do not use.
  22213. */
  22214. reservedDataStore: any;
  22215. /**
  22216. * Specifies if the ready state should be checked on each call
  22217. */
  22218. checkReadyOnEveryCall: boolean;
  22219. /**
  22220. * Specifies if the ready state should be checked once
  22221. */
  22222. checkReadyOnlyOnce: boolean;
  22223. /**
  22224. * The state of the material
  22225. */
  22226. state: string;
  22227. /**
  22228. * The alpha value of the material
  22229. */
  22230. protected _alpha: number;
  22231. /**
  22232. * List of inspectable custom properties (used by the Inspector)
  22233. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22234. */
  22235. inspectableCustomProperties: IInspectable[];
  22236. /**
  22237. * Sets the alpha value of the material
  22238. */
  22239. /**
  22240. * Gets the alpha value of the material
  22241. */
  22242. alpha: number;
  22243. /**
  22244. * Specifies if back face culling is enabled
  22245. */
  22246. protected _backFaceCulling: boolean;
  22247. /**
  22248. * Sets the back-face culling state
  22249. */
  22250. /**
  22251. * Gets the back-face culling state
  22252. */
  22253. backFaceCulling: boolean;
  22254. /**
  22255. * Stores the value for side orientation
  22256. */
  22257. sideOrientation: number;
  22258. /**
  22259. * Callback triggered when the material is compiled
  22260. */
  22261. onCompiled: Nullable<(effect: Effect) => void>;
  22262. /**
  22263. * Callback triggered when an error occurs
  22264. */
  22265. onError: Nullable<(effect: Effect, errors: string) => void>;
  22266. /**
  22267. * Callback triggered to get the render target textures
  22268. */
  22269. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22270. /**
  22271. * Gets a boolean indicating that current material needs to register RTT
  22272. */
  22273. readonly hasRenderTargetTextures: boolean;
  22274. /**
  22275. * Specifies if the material should be serialized
  22276. */
  22277. doNotSerialize: boolean;
  22278. /**
  22279. * @hidden
  22280. */
  22281. _storeEffectOnSubMeshes: boolean;
  22282. /**
  22283. * Stores the animations for the material
  22284. */
  22285. animations: Nullable<Array<Animation>>;
  22286. /**
  22287. * An event triggered when the material is disposed
  22288. */
  22289. onDisposeObservable: Observable<Material>;
  22290. /**
  22291. * An observer which watches for dispose events
  22292. */
  22293. private _onDisposeObserver;
  22294. private _onUnBindObservable;
  22295. /**
  22296. * Called during a dispose event
  22297. */
  22298. onDispose: () => void;
  22299. private _onBindObservable;
  22300. /**
  22301. * An event triggered when the material is bound
  22302. */
  22303. readonly onBindObservable: Observable<AbstractMesh>;
  22304. /**
  22305. * An observer which watches for bind events
  22306. */
  22307. private _onBindObserver;
  22308. /**
  22309. * Called during a bind event
  22310. */
  22311. onBind: (Mesh: AbstractMesh) => void;
  22312. /**
  22313. * An event triggered when the material is unbound
  22314. */
  22315. readonly onUnBindObservable: Observable<Material>;
  22316. /**
  22317. * Stores the value of the alpha mode
  22318. */
  22319. private _alphaMode;
  22320. /**
  22321. * Sets the value of the alpha mode.
  22322. *
  22323. * | Value | Type | Description |
  22324. * | --- | --- | --- |
  22325. * | 0 | ALPHA_DISABLE | |
  22326. * | 1 | ALPHA_ADD | |
  22327. * | 2 | ALPHA_COMBINE | |
  22328. * | 3 | ALPHA_SUBTRACT | |
  22329. * | 4 | ALPHA_MULTIPLY | |
  22330. * | 5 | ALPHA_MAXIMIZED | |
  22331. * | 6 | ALPHA_ONEONE | |
  22332. * | 7 | ALPHA_PREMULTIPLIED | |
  22333. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22334. * | 9 | ALPHA_INTERPOLATE | |
  22335. * | 10 | ALPHA_SCREENMODE | |
  22336. *
  22337. */
  22338. /**
  22339. * Gets the value of the alpha mode
  22340. */
  22341. alphaMode: number;
  22342. /**
  22343. * Stores the state of the need depth pre-pass value
  22344. */
  22345. private _needDepthPrePass;
  22346. /**
  22347. * Sets the need depth pre-pass value
  22348. */
  22349. /**
  22350. * Gets the depth pre-pass value
  22351. */
  22352. needDepthPrePass: boolean;
  22353. /**
  22354. * Specifies if depth writing should be disabled
  22355. */
  22356. disableDepthWrite: boolean;
  22357. /**
  22358. * Specifies if depth writing should be forced
  22359. */
  22360. forceDepthWrite: boolean;
  22361. /**
  22362. * Specifies if there should be a separate pass for culling
  22363. */
  22364. separateCullingPass: boolean;
  22365. /**
  22366. * Stores the state specifing if fog should be enabled
  22367. */
  22368. private _fogEnabled;
  22369. /**
  22370. * Sets the state for enabling fog
  22371. */
  22372. /**
  22373. * Gets the value of the fog enabled state
  22374. */
  22375. fogEnabled: boolean;
  22376. /**
  22377. * Stores the size of points
  22378. */
  22379. pointSize: number;
  22380. /**
  22381. * Stores the z offset value
  22382. */
  22383. zOffset: number;
  22384. /**
  22385. * Gets a value specifying if wireframe mode is enabled
  22386. */
  22387. /**
  22388. * Sets the state of wireframe mode
  22389. */
  22390. wireframe: boolean;
  22391. /**
  22392. * Gets the value specifying if point clouds are enabled
  22393. */
  22394. /**
  22395. * Sets the state of point cloud mode
  22396. */
  22397. pointsCloud: boolean;
  22398. /**
  22399. * Gets the material fill mode
  22400. */
  22401. /**
  22402. * Sets the material fill mode
  22403. */
  22404. fillMode: number;
  22405. /**
  22406. * @hidden
  22407. * Stores the effects for the material
  22408. */
  22409. _effect: Nullable<Effect>;
  22410. /**
  22411. * @hidden
  22412. * Specifies if the material was previously ready
  22413. */
  22414. _wasPreviouslyReady: boolean;
  22415. /**
  22416. * Specifies if uniform buffers should be used
  22417. */
  22418. private _useUBO;
  22419. /**
  22420. * Stores a reference to the scene
  22421. */
  22422. private _scene;
  22423. /**
  22424. * Stores the fill mode state
  22425. */
  22426. private _fillMode;
  22427. /**
  22428. * Specifies if the depth write state should be cached
  22429. */
  22430. private _cachedDepthWriteState;
  22431. /**
  22432. * Stores the uniform buffer
  22433. */
  22434. protected _uniformBuffer: UniformBuffer;
  22435. /** @hidden */
  22436. _indexInSceneMaterialArray: number;
  22437. /** @hidden */
  22438. meshMap: Nullable<{
  22439. [id: string]: AbstractMesh | undefined;
  22440. }>;
  22441. /**
  22442. * Creates a material instance
  22443. * @param name defines the name of the material
  22444. * @param scene defines the scene to reference
  22445. * @param doNotAdd specifies if the material should be added to the scene
  22446. */
  22447. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22448. /**
  22449. * Returns a string representation of the current material
  22450. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22451. * @returns a string with material information
  22452. */
  22453. toString(fullDetails?: boolean): string;
  22454. /**
  22455. * Gets the class name of the material
  22456. * @returns a string with the class name of the material
  22457. */
  22458. getClassName(): string;
  22459. /**
  22460. * Specifies if updates for the material been locked
  22461. */
  22462. readonly isFrozen: boolean;
  22463. /**
  22464. * Locks updates for the material
  22465. */
  22466. freeze(): void;
  22467. /**
  22468. * Unlocks updates for the material
  22469. */
  22470. unfreeze(): void;
  22471. /**
  22472. * Specifies if the material is ready to be used
  22473. * @param mesh defines the mesh to check
  22474. * @param useInstances specifies if instances should be used
  22475. * @returns a boolean indicating if the material is ready to be used
  22476. */
  22477. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22478. /**
  22479. * Specifies that the submesh is ready to be used
  22480. * @param mesh defines the mesh to check
  22481. * @param subMesh defines which submesh to check
  22482. * @param useInstances specifies that instances should be used
  22483. * @returns a boolean indicating that the submesh is ready or not
  22484. */
  22485. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22486. /**
  22487. * Returns the material effect
  22488. * @returns the effect associated with the material
  22489. */
  22490. getEffect(): Nullable<Effect>;
  22491. /**
  22492. * Returns the current scene
  22493. * @returns a Scene
  22494. */
  22495. getScene(): Scene;
  22496. /**
  22497. * Specifies if the material will require alpha blending
  22498. * @returns a boolean specifying if alpha blending is needed
  22499. */
  22500. needAlphaBlending(): boolean;
  22501. /**
  22502. * Specifies if the mesh will require alpha blending
  22503. * @param mesh defines the mesh to check
  22504. * @returns a boolean specifying if alpha blending is needed for the mesh
  22505. */
  22506. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22507. /**
  22508. * Specifies if this material should be rendered in alpha test mode
  22509. * @returns a boolean specifying if an alpha test is needed.
  22510. */
  22511. needAlphaTesting(): boolean;
  22512. /**
  22513. * Gets the texture used for the alpha test
  22514. * @returns the texture to use for alpha testing
  22515. */
  22516. getAlphaTestTexture(): Nullable<BaseTexture>;
  22517. /**
  22518. * Marks the material to indicate that it needs to be re-calculated
  22519. */
  22520. markDirty(): void;
  22521. /** @hidden */
  22522. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22523. /**
  22524. * Binds the material to the mesh
  22525. * @param world defines the world transformation matrix
  22526. * @param mesh defines the mesh to bind the material to
  22527. */
  22528. bind(world: Matrix, mesh?: Mesh): void;
  22529. /**
  22530. * Binds the submesh to the material
  22531. * @param world defines the world transformation matrix
  22532. * @param mesh defines the mesh containing the submesh
  22533. * @param subMesh defines the submesh to bind the material to
  22534. */
  22535. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22536. /**
  22537. * Binds the world matrix to the material
  22538. * @param world defines the world transformation matrix
  22539. */
  22540. bindOnlyWorldMatrix(world: Matrix): void;
  22541. /**
  22542. * Binds the scene's uniform buffer to the effect.
  22543. * @param effect defines the effect to bind to the scene uniform buffer
  22544. * @param sceneUbo defines the uniform buffer storing scene data
  22545. */
  22546. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22547. /**
  22548. * Binds the view matrix to the effect
  22549. * @param effect defines the effect to bind the view matrix to
  22550. */
  22551. bindView(effect: Effect): void;
  22552. /**
  22553. * Binds the view projection matrix to the effect
  22554. * @param effect defines the effect to bind the view projection matrix to
  22555. */
  22556. bindViewProjection(effect: Effect): void;
  22557. /**
  22558. * Specifies if material alpha testing should be turned on for the mesh
  22559. * @param mesh defines the mesh to check
  22560. */
  22561. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22562. /**
  22563. * Processes to execute after binding the material to a mesh
  22564. * @param mesh defines the rendered mesh
  22565. */
  22566. protected _afterBind(mesh?: Mesh): void;
  22567. /**
  22568. * Unbinds the material from the mesh
  22569. */
  22570. unbind(): void;
  22571. /**
  22572. * Gets the active textures from the material
  22573. * @returns an array of textures
  22574. */
  22575. getActiveTextures(): BaseTexture[];
  22576. /**
  22577. * Specifies if the material uses a texture
  22578. * @param texture defines the texture to check against the material
  22579. * @returns a boolean specifying if the material uses the texture
  22580. */
  22581. hasTexture(texture: BaseTexture): boolean;
  22582. /**
  22583. * Makes a duplicate of the material, and gives it a new name
  22584. * @param name defines the new name for the duplicated material
  22585. * @returns the cloned material
  22586. */
  22587. clone(name: string): Nullable<Material>;
  22588. /**
  22589. * Gets the meshes bound to the material
  22590. * @returns an array of meshes bound to the material
  22591. */
  22592. getBindedMeshes(): AbstractMesh[];
  22593. /**
  22594. * Force shader compilation
  22595. * @param mesh defines the mesh associated with this material
  22596. * @param onCompiled defines a function to execute once the material is compiled
  22597. * @param options defines the options to configure the compilation
  22598. */
  22599. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22600. clipPlane: boolean;
  22601. }>): void;
  22602. /**
  22603. * Force shader compilation
  22604. * @param mesh defines the mesh that will use this material
  22605. * @param options defines additional options for compiling the shaders
  22606. * @returns a promise that resolves when the compilation completes
  22607. */
  22608. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22609. clipPlane: boolean;
  22610. }>): Promise<void>;
  22611. private static readonly _AllDirtyCallBack;
  22612. private static readonly _ImageProcessingDirtyCallBack;
  22613. private static readonly _TextureDirtyCallBack;
  22614. private static readonly _FresnelDirtyCallBack;
  22615. private static readonly _MiscDirtyCallBack;
  22616. private static readonly _LightsDirtyCallBack;
  22617. private static readonly _AttributeDirtyCallBack;
  22618. private static _FresnelAndMiscDirtyCallBack;
  22619. private static _TextureAndMiscDirtyCallBack;
  22620. private static readonly _DirtyCallbackArray;
  22621. private static readonly _RunDirtyCallBacks;
  22622. /**
  22623. * Marks a define in the material to indicate that it needs to be re-computed
  22624. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22625. */
  22626. markAsDirty(flag: number): void;
  22627. /**
  22628. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22629. * @param func defines a function which checks material defines against the submeshes
  22630. */
  22631. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22632. /**
  22633. * Indicates that we need to re-calculated for all submeshes
  22634. */
  22635. protected _markAllSubMeshesAsAllDirty(): void;
  22636. /**
  22637. * Indicates that image processing needs to be re-calculated for all submeshes
  22638. */
  22639. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22640. /**
  22641. * Indicates that textures need to be re-calculated for all submeshes
  22642. */
  22643. protected _markAllSubMeshesAsTexturesDirty(): void;
  22644. /**
  22645. * Indicates that fresnel needs to be re-calculated for all submeshes
  22646. */
  22647. protected _markAllSubMeshesAsFresnelDirty(): void;
  22648. /**
  22649. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22650. */
  22651. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22652. /**
  22653. * Indicates that lights need to be re-calculated for all submeshes
  22654. */
  22655. protected _markAllSubMeshesAsLightsDirty(): void;
  22656. /**
  22657. * Indicates that attributes need to be re-calculated for all submeshes
  22658. */
  22659. protected _markAllSubMeshesAsAttributesDirty(): void;
  22660. /**
  22661. * Indicates that misc needs to be re-calculated for all submeshes
  22662. */
  22663. protected _markAllSubMeshesAsMiscDirty(): void;
  22664. /**
  22665. * Indicates that textures and misc need to be re-calculated for all submeshes
  22666. */
  22667. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22668. /**
  22669. * Disposes the material
  22670. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22671. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22672. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22673. */
  22674. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22675. /** @hidden */
  22676. private releaseVertexArrayObject;
  22677. /**
  22678. * Serializes this material
  22679. * @returns the serialized material object
  22680. */
  22681. serialize(): any;
  22682. /**
  22683. * Creates a material from parsed material data
  22684. * @param parsedMaterial defines parsed material data
  22685. * @param scene defines the hosting scene
  22686. * @param rootUrl defines the root URL to use to load textures
  22687. * @returns a new material
  22688. */
  22689. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22690. }
  22691. }
  22692. declare module BABYLON {
  22693. /**
  22694. * Base class for submeshes
  22695. */
  22696. export class BaseSubMesh {
  22697. /** @hidden */
  22698. _materialDefines: Nullable<MaterialDefines>;
  22699. /** @hidden */
  22700. _materialEffect: Nullable<Effect>;
  22701. /**
  22702. * Gets associated effect
  22703. */
  22704. readonly effect: Nullable<Effect>;
  22705. /**
  22706. * Sets associated effect (effect used to render this submesh)
  22707. * @param effect defines the effect to associate with
  22708. * @param defines defines the set of defines used to compile this effect
  22709. */
  22710. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22711. }
  22712. /**
  22713. * Defines a subdivision inside a mesh
  22714. */
  22715. export class SubMesh extends BaseSubMesh implements ICullable {
  22716. /** the material index to use */
  22717. materialIndex: number;
  22718. /** vertex index start */
  22719. verticesStart: number;
  22720. /** vertices count */
  22721. verticesCount: number;
  22722. /** index start */
  22723. indexStart: number;
  22724. /** indices count */
  22725. indexCount: number;
  22726. /** @hidden */
  22727. _linesIndexCount: number;
  22728. private _mesh;
  22729. private _renderingMesh;
  22730. private _boundingInfo;
  22731. private _linesIndexBuffer;
  22732. /** @hidden */
  22733. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22734. /** @hidden */
  22735. _trianglePlanes: Plane[];
  22736. /** @hidden */
  22737. _lastColliderTransformMatrix: Nullable<Matrix>;
  22738. /** @hidden */
  22739. _renderId: number;
  22740. /** @hidden */
  22741. _alphaIndex: number;
  22742. /** @hidden */
  22743. _distanceToCamera: number;
  22744. /** @hidden */
  22745. _id: number;
  22746. private _currentMaterial;
  22747. /**
  22748. * Add a new submesh to a mesh
  22749. * @param materialIndex defines the material index to use
  22750. * @param verticesStart defines vertex index start
  22751. * @param verticesCount defines vertices count
  22752. * @param indexStart defines index start
  22753. * @param indexCount defines indices count
  22754. * @param mesh defines the parent mesh
  22755. * @param renderingMesh defines an optional rendering mesh
  22756. * @param createBoundingBox defines if bounding box should be created for this submesh
  22757. * @returns the new submesh
  22758. */
  22759. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22760. /**
  22761. * Creates a new submesh
  22762. * @param materialIndex defines the material index to use
  22763. * @param verticesStart defines vertex index start
  22764. * @param verticesCount defines vertices count
  22765. * @param indexStart defines index start
  22766. * @param indexCount defines indices count
  22767. * @param mesh defines the parent mesh
  22768. * @param renderingMesh defines an optional rendering mesh
  22769. * @param createBoundingBox defines if bounding box should be created for this submesh
  22770. */
  22771. constructor(
  22772. /** the material index to use */
  22773. materialIndex: number,
  22774. /** vertex index start */
  22775. verticesStart: number,
  22776. /** vertices count */
  22777. verticesCount: number,
  22778. /** index start */
  22779. indexStart: number,
  22780. /** indices count */
  22781. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22782. /**
  22783. * Returns true if this submesh covers the entire parent mesh
  22784. * @ignorenaming
  22785. */
  22786. readonly IsGlobal: boolean;
  22787. /**
  22788. * Returns the submesh BoudingInfo object
  22789. * @returns current bounding info (or mesh's one if the submesh is global)
  22790. */
  22791. getBoundingInfo(): BoundingInfo;
  22792. /**
  22793. * Sets the submesh BoundingInfo
  22794. * @param boundingInfo defines the new bounding info to use
  22795. * @returns the SubMesh
  22796. */
  22797. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22798. /**
  22799. * Returns the mesh of the current submesh
  22800. * @return the parent mesh
  22801. */
  22802. getMesh(): AbstractMesh;
  22803. /**
  22804. * Returns the rendering mesh of the submesh
  22805. * @returns the rendering mesh (could be different from parent mesh)
  22806. */
  22807. getRenderingMesh(): Mesh;
  22808. /**
  22809. * Returns the submesh material
  22810. * @returns null or the current material
  22811. */
  22812. getMaterial(): Nullable<Material>;
  22813. /**
  22814. * Sets a new updated BoundingInfo object to the submesh
  22815. * @param data defines an optional position array to use to determine the bounding info
  22816. * @returns the SubMesh
  22817. */
  22818. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22819. /** @hidden */
  22820. _checkCollision(collider: Collider): boolean;
  22821. /**
  22822. * Updates the submesh BoundingInfo
  22823. * @param world defines the world matrix to use to update the bounding info
  22824. * @returns the submesh
  22825. */
  22826. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22827. /**
  22828. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22829. * @param frustumPlanes defines the frustum planes
  22830. * @returns true if the submesh is intersecting with the frustum
  22831. */
  22832. isInFrustum(frustumPlanes: Plane[]): boolean;
  22833. /**
  22834. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22835. * @param frustumPlanes defines the frustum planes
  22836. * @returns true if the submesh is inside the frustum
  22837. */
  22838. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22839. /**
  22840. * Renders the submesh
  22841. * @param enableAlphaMode defines if alpha needs to be used
  22842. * @returns the submesh
  22843. */
  22844. render(enableAlphaMode: boolean): SubMesh;
  22845. /**
  22846. * @hidden
  22847. */
  22848. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22849. /**
  22850. * Checks if the submesh intersects with a ray
  22851. * @param ray defines the ray to test
  22852. * @returns true is the passed ray intersects the submesh bounding box
  22853. */
  22854. canIntersects(ray: Ray): boolean;
  22855. /**
  22856. * Intersects current submesh with a ray
  22857. * @param ray defines the ray to test
  22858. * @param positions defines mesh's positions array
  22859. * @param indices defines mesh's indices array
  22860. * @param fastCheck defines if only bounding info should be used
  22861. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22862. * @returns intersection info or null if no intersection
  22863. */
  22864. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22865. /** @hidden */
  22866. private _intersectLines;
  22867. /** @hidden */
  22868. private _intersectUnIndexedLines;
  22869. /** @hidden */
  22870. private _intersectTriangles;
  22871. /** @hidden */
  22872. private _intersectUnIndexedTriangles;
  22873. /** @hidden */
  22874. _rebuild(): void;
  22875. /**
  22876. * Creates a new submesh from the passed mesh
  22877. * @param newMesh defines the new hosting mesh
  22878. * @param newRenderingMesh defines an optional rendering mesh
  22879. * @returns the new submesh
  22880. */
  22881. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22882. /**
  22883. * Release associated resources
  22884. */
  22885. dispose(): void;
  22886. /**
  22887. * Gets the class name
  22888. * @returns the string "SubMesh".
  22889. */
  22890. getClassName(): string;
  22891. /**
  22892. * Creates a new submesh from indices data
  22893. * @param materialIndex the index of the main mesh material
  22894. * @param startIndex the index where to start the copy in the mesh indices array
  22895. * @param indexCount the number of indices to copy then from the startIndex
  22896. * @param mesh the main mesh to create the submesh from
  22897. * @param renderingMesh the optional rendering mesh
  22898. * @returns a new submesh
  22899. */
  22900. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22901. }
  22902. }
  22903. declare module BABYLON {
  22904. /**
  22905. * Class used to store geometry data (vertex buffers + index buffer)
  22906. */
  22907. export class Geometry implements IGetSetVerticesData {
  22908. /**
  22909. * Gets or sets the ID of the geometry
  22910. */
  22911. id: string;
  22912. /**
  22913. * Gets or sets the unique ID of the geometry
  22914. */
  22915. uniqueId: number;
  22916. /**
  22917. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22918. */
  22919. delayLoadState: number;
  22920. /**
  22921. * Gets the file containing the data to load when running in delay load state
  22922. */
  22923. delayLoadingFile: Nullable<string>;
  22924. /**
  22925. * Callback called when the geometry is updated
  22926. */
  22927. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22928. private _scene;
  22929. private _engine;
  22930. private _meshes;
  22931. private _totalVertices;
  22932. /** @hidden */
  22933. _indices: IndicesArray;
  22934. /** @hidden */
  22935. _vertexBuffers: {
  22936. [key: string]: VertexBuffer;
  22937. };
  22938. private _isDisposed;
  22939. private _extend;
  22940. private _boundingBias;
  22941. /** @hidden */
  22942. _delayInfo: Array<string>;
  22943. private _indexBuffer;
  22944. private _indexBufferIsUpdatable;
  22945. /** @hidden */
  22946. _boundingInfo: Nullable<BoundingInfo>;
  22947. /** @hidden */
  22948. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22949. /** @hidden */
  22950. _softwareSkinningFrameId: number;
  22951. private _vertexArrayObjects;
  22952. private _updatable;
  22953. /** @hidden */
  22954. _positions: Nullable<Vector3[]>;
  22955. /**
  22956. * 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
  22957. */
  22958. /**
  22959. * 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
  22960. */
  22961. boundingBias: Vector2;
  22962. /**
  22963. * Static function used to attach a new empty geometry to a mesh
  22964. * @param mesh defines the mesh to attach the geometry to
  22965. * @returns the new Geometry
  22966. */
  22967. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22968. /**
  22969. * Creates a new geometry
  22970. * @param id defines the unique ID
  22971. * @param scene defines the hosting scene
  22972. * @param vertexData defines the VertexData used to get geometry data
  22973. * @param updatable defines if geometry must be updatable (false by default)
  22974. * @param mesh defines the mesh that will be associated with the geometry
  22975. */
  22976. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22977. /**
  22978. * Gets the current extend of the geometry
  22979. */
  22980. readonly extend: {
  22981. minimum: Vector3;
  22982. maximum: Vector3;
  22983. };
  22984. /**
  22985. * Gets the hosting scene
  22986. * @returns the hosting Scene
  22987. */
  22988. getScene(): Scene;
  22989. /**
  22990. * Gets the hosting engine
  22991. * @returns the hosting Engine
  22992. */
  22993. getEngine(): Engine;
  22994. /**
  22995. * Defines if the geometry is ready to use
  22996. * @returns true if the geometry is ready to be used
  22997. */
  22998. isReady(): boolean;
  22999. /**
  23000. * Gets a value indicating that the geometry should not be serialized
  23001. */
  23002. readonly doNotSerialize: boolean;
  23003. /** @hidden */
  23004. _rebuild(): void;
  23005. /**
  23006. * Affects all geometry data in one call
  23007. * @param vertexData defines the geometry data
  23008. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23009. */
  23010. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23011. /**
  23012. * Set specific vertex data
  23013. * @param kind defines the data kind (Position, normal, etc...)
  23014. * @param data defines the vertex data to use
  23015. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23016. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23017. */
  23018. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23019. /**
  23020. * Removes a specific vertex data
  23021. * @param kind defines the data kind (Position, normal, etc...)
  23022. */
  23023. removeVerticesData(kind: string): void;
  23024. /**
  23025. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23026. * @param buffer defines the vertex buffer to use
  23027. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23028. */
  23029. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23030. /**
  23031. * Update a specific vertex buffer
  23032. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23033. * It will do nothing if the buffer is not updatable
  23034. * @param kind defines the data kind (Position, normal, etc...)
  23035. * @param data defines the data to use
  23036. * @param offset defines the offset in the target buffer where to store the data
  23037. * @param useBytes set to true if the offset is in bytes
  23038. */
  23039. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23040. /**
  23041. * Update a specific vertex buffer
  23042. * This function will create a new buffer if the current one is not updatable
  23043. * @param kind defines the data kind (Position, normal, etc...)
  23044. * @param data defines the data to use
  23045. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23046. */
  23047. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23048. private _updateBoundingInfo;
  23049. /** @hidden */
  23050. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23051. /**
  23052. * Gets total number of vertices
  23053. * @returns the total number of vertices
  23054. */
  23055. getTotalVertices(): number;
  23056. /**
  23057. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23058. * @param kind defines the data kind (Position, normal, etc...)
  23059. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23060. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23061. * @returns a float array containing vertex data
  23062. */
  23063. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23064. /**
  23065. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23066. * @param kind defines the data kind (Position, normal, etc...)
  23067. * @returns true if the vertex buffer with the specified kind is updatable
  23068. */
  23069. isVertexBufferUpdatable(kind: string): boolean;
  23070. /**
  23071. * Gets a specific vertex buffer
  23072. * @param kind defines the data kind (Position, normal, etc...)
  23073. * @returns a VertexBuffer
  23074. */
  23075. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23076. /**
  23077. * Returns all vertex buffers
  23078. * @return an object holding all vertex buffers indexed by kind
  23079. */
  23080. getVertexBuffers(): Nullable<{
  23081. [key: string]: VertexBuffer;
  23082. }>;
  23083. /**
  23084. * Gets a boolean indicating if specific vertex buffer is present
  23085. * @param kind defines the data kind (Position, normal, etc...)
  23086. * @returns true if data is present
  23087. */
  23088. isVerticesDataPresent(kind: string): boolean;
  23089. /**
  23090. * Gets a list of all attached data kinds (Position, normal, etc...)
  23091. * @returns a list of string containing all kinds
  23092. */
  23093. getVerticesDataKinds(): string[];
  23094. /**
  23095. * Update index buffer
  23096. * @param indices defines the indices to store in the index buffer
  23097. * @param offset defines the offset in the target buffer where to store the data
  23098. * @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)
  23099. */
  23100. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23101. /**
  23102. * Creates a new index buffer
  23103. * @param indices defines the indices to store in the index buffer
  23104. * @param totalVertices defines the total number of vertices (could be null)
  23105. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23106. */
  23107. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23108. /**
  23109. * Return the total number of indices
  23110. * @returns the total number of indices
  23111. */
  23112. getTotalIndices(): number;
  23113. /**
  23114. * Gets the index buffer array
  23115. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23116. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23117. * @returns the index buffer array
  23118. */
  23119. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23120. /**
  23121. * Gets the index buffer
  23122. * @return the index buffer
  23123. */
  23124. getIndexBuffer(): Nullable<DataBuffer>;
  23125. /** @hidden */
  23126. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23127. /**
  23128. * Release the associated resources for a specific mesh
  23129. * @param mesh defines the source mesh
  23130. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23131. */
  23132. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23133. /**
  23134. * Apply current geometry to a given mesh
  23135. * @param mesh defines the mesh to apply geometry to
  23136. */
  23137. applyToMesh(mesh: Mesh): void;
  23138. private _updateExtend;
  23139. private _applyToMesh;
  23140. private notifyUpdate;
  23141. /**
  23142. * Load the geometry if it was flagged as delay loaded
  23143. * @param scene defines the hosting scene
  23144. * @param onLoaded defines a callback called when the geometry is loaded
  23145. */
  23146. load(scene: Scene, onLoaded?: () => void): void;
  23147. private _queueLoad;
  23148. /**
  23149. * Invert the geometry to move from a right handed system to a left handed one.
  23150. */
  23151. toLeftHanded(): void;
  23152. /** @hidden */
  23153. _resetPointsArrayCache(): void;
  23154. /** @hidden */
  23155. _generatePointsArray(): boolean;
  23156. /**
  23157. * Gets a value indicating if the geometry is disposed
  23158. * @returns true if the geometry was disposed
  23159. */
  23160. isDisposed(): boolean;
  23161. private _disposeVertexArrayObjects;
  23162. /**
  23163. * Free all associated resources
  23164. */
  23165. dispose(): void;
  23166. /**
  23167. * Clone the current geometry into a new geometry
  23168. * @param id defines the unique ID of the new geometry
  23169. * @returns a new geometry object
  23170. */
  23171. copy(id: string): Geometry;
  23172. /**
  23173. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23174. * @return a JSON representation of the current geometry data (without the vertices data)
  23175. */
  23176. serialize(): any;
  23177. private toNumberArray;
  23178. /**
  23179. * Serialize all vertices data into a JSON oject
  23180. * @returns a JSON representation of the current geometry data
  23181. */
  23182. serializeVerticeData(): any;
  23183. /**
  23184. * Extracts a clone of a mesh geometry
  23185. * @param mesh defines the source mesh
  23186. * @param id defines the unique ID of the new geometry object
  23187. * @returns the new geometry object
  23188. */
  23189. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23190. /**
  23191. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23192. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23193. * Be aware Math.random() could cause collisions, but:
  23194. * "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"
  23195. * @returns a string containing a new GUID
  23196. */
  23197. static RandomId(): string;
  23198. /** @hidden */
  23199. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23200. private static _CleanMatricesWeights;
  23201. /**
  23202. * Create a new geometry from persisted data (Using .babylon file format)
  23203. * @param parsedVertexData defines the persisted data
  23204. * @param scene defines the hosting scene
  23205. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23206. * @returns the new geometry object
  23207. */
  23208. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23209. }
  23210. }
  23211. declare module BABYLON {
  23212. /**
  23213. * Define an interface for all classes that will get and set the data on vertices
  23214. */
  23215. export interface IGetSetVerticesData {
  23216. /**
  23217. * Gets a boolean indicating if specific vertex data is present
  23218. * @param kind defines the vertex data kind to use
  23219. * @returns true is data kind is present
  23220. */
  23221. isVerticesDataPresent(kind: string): boolean;
  23222. /**
  23223. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23224. * @param kind defines the data kind (Position, normal, etc...)
  23225. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23226. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23227. * @returns a float array containing vertex data
  23228. */
  23229. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23230. /**
  23231. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23232. * @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.
  23233. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23234. * @returns the indices array or an empty array if the mesh has no geometry
  23235. */
  23236. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23237. /**
  23238. * Set specific vertex data
  23239. * @param kind defines the data kind (Position, normal, etc...)
  23240. * @param data defines the vertex data to use
  23241. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23242. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23243. */
  23244. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23245. /**
  23246. * Update a specific associated vertex buffer
  23247. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23248. * - VertexBuffer.PositionKind
  23249. * - VertexBuffer.UVKind
  23250. * - VertexBuffer.UV2Kind
  23251. * - VertexBuffer.UV3Kind
  23252. * - VertexBuffer.UV4Kind
  23253. * - VertexBuffer.UV5Kind
  23254. * - VertexBuffer.UV6Kind
  23255. * - VertexBuffer.ColorKind
  23256. * - VertexBuffer.MatricesIndicesKind
  23257. * - VertexBuffer.MatricesIndicesExtraKind
  23258. * - VertexBuffer.MatricesWeightsKind
  23259. * - VertexBuffer.MatricesWeightsExtraKind
  23260. * @param data defines the data source
  23261. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23262. * @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)
  23263. */
  23264. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23265. /**
  23266. * Creates a new index buffer
  23267. * @param indices defines the indices to store in the index buffer
  23268. * @param totalVertices defines the total number of vertices (could be null)
  23269. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23270. */
  23271. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23272. }
  23273. /**
  23274. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23275. */
  23276. export class VertexData {
  23277. /**
  23278. * Mesh side orientation : usually the external or front surface
  23279. */
  23280. static readonly FRONTSIDE: number;
  23281. /**
  23282. * Mesh side orientation : usually the internal or back surface
  23283. */
  23284. static readonly BACKSIDE: number;
  23285. /**
  23286. * Mesh side orientation : both internal and external or front and back surfaces
  23287. */
  23288. static readonly DOUBLESIDE: number;
  23289. /**
  23290. * Mesh side orientation : by default, `FRONTSIDE`
  23291. */
  23292. static readonly DEFAULTSIDE: number;
  23293. /**
  23294. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23295. */
  23296. positions: Nullable<FloatArray>;
  23297. /**
  23298. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23299. */
  23300. normals: Nullable<FloatArray>;
  23301. /**
  23302. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23303. */
  23304. tangents: Nullable<FloatArray>;
  23305. /**
  23306. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23307. */
  23308. uvs: Nullable<FloatArray>;
  23309. /**
  23310. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23311. */
  23312. uvs2: Nullable<FloatArray>;
  23313. /**
  23314. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23315. */
  23316. uvs3: Nullable<FloatArray>;
  23317. /**
  23318. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23319. */
  23320. uvs4: Nullable<FloatArray>;
  23321. /**
  23322. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23323. */
  23324. uvs5: Nullable<FloatArray>;
  23325. /**
  23326. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23327. */
  23328. uvs6: Nullable<FloatArray>;
  23329. /**
  23330. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23331. */
  23332. colors: Nullable<FloatArray>;
  23333. /**
  23334. * 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).
  23335. */
  23336. matricesIndices: Nullable<FloatArray>;
  23337. /**
  23338. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23339. */
  23340. matricesWeights: Nullable<FloatArray>;
  23341. /**
  23342. * An array extending the number of possible indices
  23343. */
  23344. matricesIndicesExtra: Nullable<FloatArray>;
  23345. /**
  23346. * An array extending the number of possible weights when the number of indices is extended
  23347. */
  23348. matricesWeightsExtra: Nullable<FloatArray>;
  23349. /**
  23350. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23351. */
  23352. indices: Nullable<IndicesArray>;
  23353. /**
  23354. * Uses the passed data array to set the set the values for the specified kind of data
  23355. * @param data a linear array of floating numbers
  23356. * @param kind the type of data that is being set, eg positions, colors etc
  23357. */
  23358. set(data: FloatArray, kind: string): void;
  23359. /**
  23360. * Associates the vertexData to the passed Mesh.
  23361. * Sets it as updatable or not (default `false`)
  23362. * @param mesh the mesh the vertexData is applied to
  23363. * @param updatable when used and having the value true allows new data to update the vertexData
  23364. * @returns the VertexData
  23365. */
  23366. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23367. /**
  23368. * Associates the vertexData to the passed Geometry.
  23369. * Sets it as updatable or not (default `false`)
  23370. * @param geometry the geometry the vertexData is applied to
  23371. * @param updatable when used and having the value true allows new data to update the vertexData
  23372. * @returns VertexData
  23373. */
  23374. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23375. /**
  23376. * Updates the associated mesh
  23377. * @param mesh the mesh to be updated
  23378. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23379. * @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
  23380. * @returns VertexData
  23381. */
  23382. updateMesh(mesh: Mesh): VertexData;
  23383. /**
  23384. * Updates the associated geometry
  23385. * @param geometry the geometry to be updated
  23386. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23387. * @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
  23388. * @returns VertexData.
  23389. */
  23390. updateGeometry(geometry: Geometry): VertexData;
  23391. private _applyTo;
  23392. private _update;
  23393. /**
  23394. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23395. * @param matrix the transforming matrix
  23396. * @returns the VertexData
  23397. */
  23398. transform(matrix: Matrix): VertexData;
  23399. /**
  23400. * Merges the passed VertexData into the current one
  23401. * @param other the VertexData to be merged into the current one
  23402. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23403. * @returns the modified VertexData
  23404. */
  23405. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23406. private _mergeElement;
  23407. private _validate;
  23408. /**
  23409. * Serializes the VertexData
  23410. * @returns a serialized object
  23411. */
  23412. serialize(): any;
  23413. /**
  23414. * Extracts the vertexData from a mesh
  23415. * @param mesh the mesh from which to extract the VertexData
  23416. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23417. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23418. * @returns the object VertexData associated to the passed mesh
  23419. */
  23420. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23421. /**
  23422. * Extracts the vertexData from the geometry
  23423. * @param geometry the geometry from which to extract the VertexData
  23424. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23425. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23426. * @returns the object VertexData associated to the passed mesh
  23427. */
  23428. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23429. private static _ExtractFrom;
  23430. /**
  23431. * Creates the VertexData for a Ribbon
  23432. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23433. * * pathArray array of paths, each of which an array of successive Vector3
  23434. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23435. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23436. * * 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
  23437. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23438. * * 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)
  23439. * * 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)
  23440. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23441. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23442. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23443. * @returns the VertexData of the ribbon
  23444. */
  23445. static CreateRibbon(options: {
  23446. pathArray: Vector3[][];
  23447. closeArray?: boolean;
  23448. closePath?: boolean;
  23449. offset?: number;
  23450. sideOrientation?: number;
  23451. frontUVs?: Vector4;
  23452. backUVs?: Vector4;
  23453. invertUV?: boolean;
  23454. uvs?: Vector2[];
  23455. colors?: Color4[];
  23456. }): VertexData;
  23457. /**
  23458. * Creates the VertexData for a box
  23459. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23460. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23461. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23462. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23463. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23464. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23465. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23466. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23467. * * 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)
  23468. * * 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)
  23469. * @returns the VertexData of the box
  23470. */
  23471. static CreateBox(options: {
  23472. size?: number;
  23473. width?: number;
  23474. height?: number;
  23475. depth?: number;
  23476. faceUV?: Vector4[];
  23477. faceColors?: Color4[];
  23478. sideOrientation?: number;
  23479. frontUVs?: Vector4;
  23480. backUVs?: Vector4;
  23481. }): VertexData;
  23482. /**
  23483. * Creates the VertexData for a tiled box
  23484. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23485. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23486. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23487. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23488. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23489. * @returns the VertexData of the box
  23490. */
  23491. static CreateTiledBox(options: {
  23492. pattern?: number;
  23493. width?: number;
  23494. height?: number;
  23495. depth?: number;
  23496. tileSize?: number;
  23497. tileWidth?: number;
  23498. tileHeight?: number;
  23499. alignHorizontal?: number;
  23500. alignVertical?: number;
  23501. faceUV?: Vector4[];
  23502. faceColors?: Color4[];
  23503. sideOrientation?: number;
  23504. }): VertexData;
  23505. /**
  23506. * Creates the VertexData for a tiled plane
  23507. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23508. * * pattern a limited pattern arrangement depending on the number
  23509. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23510. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23511. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23512. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23513. * * 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)
  23514. * * 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)
  23515. * @returns the VertexData of the tiled plane
  23516. */
  23517. static CreateTiledPlane(options: {
  23518. pattern?: number;
  23519. tileSize?: number;
  23520. tileWidth?: number;
  23521. tileHeight?: number;
  23522. size?: number;
  23523. width?: number;
  23524. height?: number;
  23525. alignHorizontal?: number;
  23526. alignVertical?: number;
  23527. sideOrientation?: number;
  23528. frontUVs?: Vector4;
  23529. backUVs?: Vector4;
  23530. }): VertexData;
  23531. /**
  23532. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23533. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23534. * * segments sets the number of horizontal strips optional, default 32
  23535. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23536. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23537. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23538. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23539. * * 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
  23540. * * 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
  23541. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23542. * * 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)
  23543. * * 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)
  23544. * @returns the VertexData of the ellipsoid
  23545. */
  23546. static CreateSphere(options: {
  23547. segments?: number;
  23548. diameter?: number;
  23549. diameterX?: number;
  23550. diameterY?: number;
  23551. diameterZ?: number;
  23552. arc?: number;
  23553. slice?: number;
  23554. sideOrientation?: number;
  23555. frontUVs?: Vector4;
  23556. backUVs?: Vector4;
  23557. }): VertexData;
  23558. /**
  23559. * Creates the VertexData for a cylinder, cone or prism
  23560. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23561. * * height sets the height (y direction) of the cylinder, optional, default 2
  23562. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23563. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23564. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23565. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23566. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23567. * * 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
  23568. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23569. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23570. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23571. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23572. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23573. * * 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)
  23574. * * 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)
  23575. * @returns the VertexData of the cylinder, cone or prism
  23576. */
  23577. static CreateCylinder(options: {
  23578. height?: number;
  23579. diameterTop?: number;
  23580. diameterBottom?: number;
  23581. diameter?: number;
  23582. tessellation?: number;
  23583. subdivisions?: number;
  23584. arc?: number;
  23585. faceColors?: Color4[];
  23586. faceUV?: Vector4[];
  23587. hasRings?: boolean;
  23588. enclose?: boolean;
  23589. sideOrientation?: number;
  23590. frontUVs?: Vector4;
  23591. backUVs?: Vector4;
  23592. }): VertexData;
  23593. /**
  23594. * Creates the VertexData for a torus
  23595. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23596. * * diameter the diameter of the torus, optional default 1
  23597. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23598. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23599. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23600. * * 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)
  23601. * * 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)
  23602. * @returns the VertexData of the torus
  23603. */
  23604. static CreateTorus(options: {
  23605. diameter?: number;
  23606. thickness?: number;
  23607. tessellation?: number;
  23608. sideOrientation?: number;
  23609. frontUVs?: Vector4;
  23610. backUVs?: Vector4;
  23611. }): VertexData;
  23612. /**
  23613. * Creates the VertexData of the LineSystem
  23614. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23615. * - lines an array of lines, each line being an array of successive Vector3
  23616. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23617. * @returns the VertexData of the LineSystem
  23618. */
  23619. static CreateLineSystem(options: {
  23620. lines: Vector3[][];
  23621. colors?: Nullable<Color4[][]>;
  23622. }): VertexData;
  23623. /**
  23624. * Create the VertexData for a DashedLines
  23625. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23626. * - points an array successive Vector3
  23627. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23628. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23629. * - dashNb the intended total number of dashes, optional, default 200
  23630. * @returns the VertexData for the DashedLines
  23631. */
  23632. static CreateDashedLines(options: {
  23633. points: Vector3[];
  23634. dashSize?: number;
  23635. gapSize?: number;
  23636. dashNb?: number;
  23637. }): VertexData;
  23638. /**
  23639. * Creates the VertexData for a Ground
  23640. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23641. * - width the width (x direction) of the ground, optional, default 1
  23642. * - height the height (z direction) of the ground, optional, default 1
  23643. * - subdivisions the number of subdivisions per side, optional, default 1
  23644. * @returns the VertexData of the Ground
  23645. */
  23646. static CreateGround(options: {
  23647. width?: number;
  23648. height?: number;
  23649. subdivisions?: number;
  23650. subdivisionsX?: number;
  23651. subdivisionsY?: number;
  23652. }): VertexData;
  23653. /**
  23654. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23655. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23656. * * xmin the ground minimum X coordinate, optional, default -1
  23657. * * zmin the ground minimum Z coordinate, optional, default -1
  23658. * * xmax the ground maximum X coordinate, optional, default 1
  23659. * * zmax the ground maximum Z coordinate, optional, default 1
  23660. * * 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}
  23661. * * 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}
  23662. * @returns the VertexData of the TiledGround
  23663. */
  23664. static CreateTiledGround(options: {
  23665. xmin: number;
  23666. zmin: number;
  23667. xmax: number;
  23668. zmax: number;
  23669. subdivisions?: {
  23670. w: number;
  23671. h: number;
  23672. };
  23673. precision?: {
  23674. w: number;
  23675. h: number;
  23676. };
  23677. }): VertexData;
  23678. /**
  23679. * Creates the VertexData of the Ground designed from a heightmap
  23680. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23681. * * width the width (x direction) of the ground
  23682. * * height the height (z direction) of the ground
  23683. * * subdivisions the number of subdivisions per side
  23684. * * minHeight the minimum altitude on the ground, optional, default 0
  23685. * * maxHeight the maximum altitude on the ground, optional default 1
  23686. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23687. * * buffer the array holding the image color data
  23688. * * bufferWidth the width of image
  23689. * * bufferHeight the height of image
  23690. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23691. * @returns the VertexData of the Ground designed from a heightmap
  23692. */
  23693. static CreateGroundFromHeightMap(options: {
  23694. width: number;
  23695. height: number;
  23696. subdivisions: number;
  23697. minHeight: number;
  23698. maxHeight: number;
  23699. colorFilter: Color3;
  23700. buffer: Uint8Array;
  23701. bufferWidth: number;
  23702. bufferHeight: number;
  23703. alphaFilter: number;
  23704. }): VertexData;
  23705. /**
  23706. * Creates the VertexData for a Plane
  23707. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23708. * * size sets the width and height of the plane to the value of size, optional default 1
  23709. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23710. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23711. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23712. * * 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)
  23713. * * 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)
  23714. * @returns the VertexData of the box
  23715. */
  23716. static CreatePlane(options: {
  23717. size?: number;
  23718. width?: number;
  23719. height?: number;
  23720. sideOrientation?: number;
  23721. frontUVs?: Vector4;
  23722. backUVs?: Vector4;
  23723. }): VertexData;
  23724. /**
  23725. * Creates the VertexData of the Disc or regular Polygon
  23726. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23727. * * radius the radius of the disc, optional default 0.5
  23728. * * tessellation the number of polygon sides, optional, default 64
  23729. * * 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
  23730. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23731. * * 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)
  23732. * * 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)
  23733. * @returns the VertexData of the box
  23734. */
  23735. static CreateDisc(options: {
  23736. radius?: number;
  23737. tessellation?: number;
  23738. arc?: number;
  23739. sideOrientation?: number;
  23740. frontUVs?: Vector4;
  23741. backUVs?: Vector4;
  23742. }): VertexData;
  23743. /**
  23744. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23745. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23746. * @param polygon a mesh built from polygonTriangulation.build()
  23747. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23748. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23749. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23750. * @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)
  23751. * @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)
  23752. * @returns the VertexData of the Polygon
  23753. */
  23754. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23755. /**
  23756. * Creates the VertexData of the IcoSphere
  23757. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23758. * * radius the radius of the IcoSphere, optional default 1
  23759. * * radiusX allows stretching in the x direction, optional, default radius
  23760. * * radiusY allows stretching in the y direction, optional, default radius
  23761. * * radiusZ allows stretching in the z direction, optional, default radius
  23762. * * flat when true creates a flat shaded mesh, optional, default true
  23763. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23764. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23765. * * 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)
  23766. * * 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)
  23767. * @returns the VertexData of the IcoSphere
  23768. */
  23769. static CreateIcoSphere(options: {
  23770. radius?: number;
  23771. radiusX?: number;
  23772. radiusY?: number;
  23773. radiusZ?: number;
  23774. flat?: boolean;
  23775. subdivisions?: number;
  23776. sideOrientation?: number;
  23777. frontUVs?: Vector4;
  23778. backUVs?: Vector4;
  23779. }): VertexData;
  23780. /**
  23781. * Creates the VertexData for a Polyhedron
  23782. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23783. * * type provided types are:
  23784. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23785. * * 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)
  23786. * * size the size of the IcoSphere, optional default 1
  23787. * * sizeX allows stretching in the x direction, optional, default size
  23788. * * sizeY allows stretching in the y direction, optional, default size
  23789. * * sizeZ allows stretching in the z direction, optional, default size
  23790. * * 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
  23791. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23792. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23793. * * flat when true creates a flat shaded mesh, optional, default true
  23794. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23795. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23796. * * 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)
  23797. * * 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)
  23798. * @returns the VertexData of the Polyhedron
  23799. */
  23800. static CreatePolyhedron(options: {
  23801. type?: number;
  23802. size?: number;
  23803. sizeX?: number;
  23804. sizeY?: number;
  23805. sizeZ?: number;
  23806. custom?: any;
  23807. faceUV?: Vector4[];
  23808. faceColors?: Color4[];
  23809. flat?: boolean;
  23810. sideOrientation?: number;
  23811. frontUVs?: Vector4;
  23812. backUVs?: Vector4;
  23813. }): VertexData;
  23814. /**
  23815. * Creates the VertexData for a TorusKnot
  23816. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23817. * * radius the radius of the torus knot, optional, default 2
  23818. * * tube the thickness of the tube, optional, default 0.5
  23819. * * radialSegments the number of sides on each tube segments, optional, default 32
  23820. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23821. * * p the number of windings around the z axis, optional, default 2
  23822. * * q the number of windings around the x axis, optional, default 3
  23823. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23824. * * 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)
  23825. * * 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)
  23826. * @returns the VertexData of the Torus Knot
  23827. */
  23828. static CreateTorusKnot(options: {
  23829. radius?: number;
  23830. tube?: number;
  23831. radialSegments?: number;
  23832. tubularSegments?: number;
  23833. p?: number;
  23834. q?: number;
  23835. sideOrientation?: number;
  23836. frontUVs?: Vector4;
  23837. backUVs?: Vector4;
  23838. }): VertexData;
  23839. /**
  23840. * Compute normals for given positions and indices
  23841. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23842. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23843. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23844. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23845. * * facetNormals : optional array of facet normals (vector3)
  23846. * * facetPositions : optional array of facet positions (vector3)
  23847. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23848. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23849. * * bInfo : optional bounding info, required for facetPartitioning computation
  23850. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23851. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23852. * * useRightHandedSystem: optional boolean to for right handed system computation
  23853. * * depthSort : optional boolean to enable the facet depth sort computation
  23854. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23855. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23856. */
  23857. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23858. facetNormals?: any;
  23859. facetPositions?: any;
  23860. facetPartitioning?: any;
  23861. ratio?: number;
  23862. bInfo?: any;
  23863. bbSize?: Vector3;
  23864. subDiv?: any;
  23865. useRightHandedSystem?: boolean;
  23866. depthSort?: boolean;
  23867. distanceTo?: Vector3;
  23868. depthSortedFacets?: any;
  23869. }): void;
  23870. /** @hidden */
  23871. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23872. /**
  23873. * Applies VertexData created from the imported parameters to the geometry
  23874. * @param parsedVertexData the parsed data from an imported file
  23875. * @param geometry the geometry to apply the VertexData to
  23876. */
  23877. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23878. }
  23879. }
  23880. declare module BABYLON {
  23881. /**
  23882. * Class containing static functions to help procedurally build meshes
  23883. */
  23884. export class DiscBuilder {
  23885. /**
  23886. * Creates a plane polygonal mesh. By default, this is a disc
  23887. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23888. * * 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
  23889. * * 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
  23890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23891. * * 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
  23892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23893. * @param name defines the name of the mesh
  23894. * @param options defines the options used to create the mesh
  23895. * @param scene defines the hosting scene
  23896. * @returns the plane polygonal mesh
  23897. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23898. */
  23899. static CreateDisc(name: string, options: {
  23900. radius?: number;
  23901. tessellation?: number;
  23902. arc?: number;
  23903. updatable?: boolean;
  23904. sideOrientation?: number;
  23905. frontUVs?: Vector4;
  23906. backUVs?: Vector4;
  23907. }, scene?: Nullable<Scene>): Mesh;
  23908. }
  23909. }
  23910. declare module BABYLON {
  23911. /**
  23912. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23913. *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.
  23914. * The SPS is also a particle system. It provides some methods to manage the particles.
  23915. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23916. *
  23917. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23918. */
  23919. export class SolidParticleSystem implements IDisposable {
  23920. /**
  23921. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23922. * Example : var p = SPS.particles[i];
  23923. */
  23924. particles: SolidParticle[];
  23925. /**
  23926. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23927. */
  23928. nbParticles: number;
  23929. /**
  23930. * If the particles must ever face the camera (default false). Useful for planar particles.
  23931. */
  23932. billboard: boolean;
  23933. /**
  23934. * Recompute normals when adding a shape
  23935. */
  23936. recomputeNormals: boolean;
  23937. /**
  23938. * This a counter ofr your own usage. It's not set by any SPS functions.
  23939. */
  23940. counter: number;
  23941. /**
  23942. * The SPS name. This name is also given to the underlying mesh.
  23943. */
  23944. name: string;
  23945. /**
  23946. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23947. */
  23948. mesh: Mesh;
  23949. /**
  23950. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23951. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23952. */
  23953. vars: any;
  23954. /**
  23955. * This array is populated when the SPS is set as 'pickable'.
  23956. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23957. * Each element of this array is an object `{idx: int, faceId: int}`.
  23958. * `idx` is the picked particle index in the `SPS.particles` array
  23959. * `faceId` is the picked face index counted within this particle.
  23960. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23961. */
  23962. pickedParticles: {
  23963. idx: number;
  23964. faceId: number;
  23965. }[];
  23966. /**
  23967. * This array is populated when `enableDepthSort` is set to true.
  23968. * Each element of this array is an instance of the class DepthSortedParticle.
  23969. */
  23970. depthSortedParticles: DepthSortedParticle[];
  23971. /**
  23972. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23973. * @hidden
  23974. */
  23975. _bSphereOnly: boolean;
  23976. /**
  23977. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23978. * @hidden
  23979. */
  23980. _bSphereRadiusFactor: number;
  23981. private _scene;
  23982. private _positions;
  23983. private _indices;
  23984. private _normals;
  23985. private _colors;
  23986. private _uvs;
  23987. private _indices32;
  23988. private _positions32;
  23989. private _normals32;
  23990. private _fixedNormal32;
  23991. private _colors32;
  23992. private _uvs32;
  23993. private _index;
  23994. private _updatable;
  23995. private _pickable;
  23996. private _isVisibilityBoxLocked;
  23997. private _alwaysVisible;
  23998. private _depthSort;
  23999. private _shapeCounter;
  24000. private _copy;
  24001. private _color;
  24002. private _computeParticleColor;
  24003. private _computeParticleTexture;
  24004. private _computeParticleRotation;
  24005. private _computeParticleVertex;
  24006. private _computeBoundingBox;
  24007. private _depthSortParticles;
  24008. private _camera;
  24009. private _mustUnrotateFixedNormals;
  24010. private _particlesIntersect;
  24011. private _needs32Bits;
  24012. /**
  24013. * Creates a SPS (Solid Particle System) object.
  24014. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24015. * @param scene (Scene) is the scene in which the SPS is added.
  24016. * @param options defines the options of the sps e.g.
  24017. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24018. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24019. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24020. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24021. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24022. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24023. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24024. */
  24025. constructor(name: string, scene: Scene, options?: {
  24026. updatable?: boolean;
  24027. isPickable?: boolean;
  24028. enableDepthSort?: boolean;
  24029. particleIntersection?: boolean;
  24030. boundingSphereOnly?: boolean;
  24031. bSphereRadiusFactor?: number;
  24032. });
  24033. /**
  24034. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24035. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24036. * @returns the created mesh
  24037. */
  24038. buildMesh(): Mesh;
  24039. /**
  24040. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24041. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24042. * Thus the particles generated from `digest()` have their property `position` set yet.
  24043. * @param mesh ( Mesh ) is the mesh to be digested
  24044. * @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
  24045. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24046. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24047. * @returns the current SPS
  24048. */
  24049. digest(mesh: Mesh, options?: {
  24050. facetNb?: number;
  24051. number?: number;
  24052. delta?: number;
  24053. }): SolidParticleSystem;
  24054. private _unrotateFixedNormals;
  24055. private _resetCopy;
  24056. private _meshBuilder;
  24057. private _posToShape;
  24058. private _uvsToShapeUV;
  24059. private _addParticle;
  24060. /**
  24061. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24062. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24063. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24064. * @param nb (positive integer) the number of particles to be created from this model
  24065. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24066. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24067. * @returns the number of shapes in the system
  24068. */
  24069. addShape(mesh: Mesh, nb: number, options?: {
  24070. positionFunction?: any;
  24071. vertexFunction?: any;
  24072. }): number;
  24073. private _rebuildParticle;
  24074. /**
  24075. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24076. * @returns the SPS.
  24077. */
  24078. rebuildMesh(): SolidParticleSystem;
  24079. /**
  24080. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24081. * This method calls `updateParticle()` for each particle of the SPS.
  24082. * For an animated SPS, it is usually called within the render loop.
  24083. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24084. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24085. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24086. * @returns the SPS.
  24087. */
  24088. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24089. /**
  24090. * Disposes the SPS.
  24091. */
  24092. dispose(): void;
  24093. /**
  24094. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24095. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24096. * @returns the SPS.
  24097. */
  24098. refreshVisibleSize(): SolidParticleSystem;
  24099. /**
  24100. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24101. * @param size the size (float) of the visibility box
  24102. * note : this doesn't lock the SPS mesh bounding box.
  24103. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24104. */
  24105. setVisibilityBox(size: number): void;
  24106. /**
  24107. * Gets whether the SPS as always visible or not
  24108. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24109. */
  24110. /**
  24111. * Sets the SPS as always visible or not
  24112. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24113. */
  24114. isAlwaysVisible: boolean;
  24115. /**
  24116. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24117. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24118. */
  24119. /**
  24120. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24121. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24122. */
  24123. isVisibilityBoxLocked: boolean;
  24124. /**
  24125. * Tells to `setParticles()` to compute the particle rotations or not.
  24126. * Default value : true. The SPS is faster when it's set to false.
  24127. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24128. */
  24129. /**
  24130. * Gets if `setParticles()` computes the particle rotations or not.
  24131. * Default value : true. The SPS is faster when it's set to false.
  24132. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24133. */
  24134. computeParticleRotation: boolean;
  24135. /**
  24136. * Tells to `setParticles()` to compute the particle colors or not.
  24137. * Default value : true. The SPS is faster when it's set to false.
  24138. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24139. */
  24140. /**
  24141. * Gets if `setParticles()` computes the particle colors or not.
  24142. * Default value : true. The SPS is faster when it's set to false.
  24143. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24144. */
  24145. computeParticleColor: boolean;
  24146. /**
  24147. * Gets if `setParticles()` computes the particle textures or not.
  24148. * Default value : true. The SPS is faster when it's set to false.
  24149. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24150. */
  24151. computeParticleTexture: boolean;
  24152. /**
  24153. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24154. * Default value : false. The SPS is faster when it's set to false.
  24155. * Note : the particle custom vertex positions aren't stored values.
  24156. */
  24157. /**
  24158. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24159. * Default value : false. The SPS is faster when it's set to false.
  24160. * Note : the particle custom vertex positions aren't stored values.
  24161. */
  24162. computeParticleVertex: boolean;
  24163. /**
  24164. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24165. */
  24166. /**
  24167. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24168. */
  24169. computeBoundingBox: boolean;
  24170. /**
  24171. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24172. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24173. * Default : `true`
  24174. */
  24175. /**
  24176. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24177. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24178. * Default : `true`
  24179. */
  24180. depthSortParticles: boolean;
  24181. /**
  24182. * This function does nothing. It may be overwritten to set all the particle first values.
  24183. * The SPS doesn't call this function, you may have to call it by your own.
  24184. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24185. */
  24186. initParticles(): void;
  24187. /**
  24188. * This function does nothing. It may be overwritten to recycle a particle.
  24189. * The SPS doesn't call this function, you may have to call it by your own.
  24190. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24191. * @param particle The particle to recycle
  24192. * @returns the recycled particle
  24193. */
  24194. recycleParticle(particle: SolidParticle): SolidParticle;
  24195. /**
  24196. * Updates a particle : this function should be overwritten by the user.
  24197. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24198. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24199. * @example : just set a particle position or velocity and recycle conditions
  24200. * @param particle The particle to update
  24201. * @returns the updated particle
  24202. */
  24203. updateParticle(particle: SolidParticle): SolidParticle;
  24204. /**
  24205. * Updates a vertex of a particle : it can be overwritten by the user.
  24206. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24207. * @param particle the current particle
  24208. * @param vertex the current index of the current particle
  24209. * @param pt the index of the current vertex in the particle shape
  24210. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24211. * @example : just set a vertex particle position
  24212. * @returns the updated vertex
  24213. */
  24214. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24215. /**
  24216. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24217. * This does nothing and may be overwritten by the user.
  24218. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24219. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24220. * @param update the boolean update value actually passed to setParticles()
  24221. */
  24222. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24223. /**
  24224. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24225. * This will be passed three parameters.
  24226. * This does nothing and may be overwritten by the user.
  24227. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24228. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24229. * @param update the boolean update value actually passed to setParticles()
  24230. */
  24231. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24232. }
  24233. }
  24234. declare module BABYLON {
  24235. /**
  24236. * Represents one particle of a solid particle system.
  24237. */
  24238. export class SolidParticle {
  24239. /**
  24240. * particle global index
  24241. */
  24242. idx: number;
  24243. /**
  24244. * The color of the particle
  24245. */
  24246. color: Nullable<Color4>;
  24247. /**
  24248. * The world space position of the particle.
  24249. */
  24250. position: Vector3;
  24251. /**
  24252. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24253. */
  24254. rotation: Vector3;
  24255. /**
  24256. * The world space rotation quaternion of the particle.
  24257. */
  24258. rotationQuaternion: Nullable<Quaternion>;
  24259. /**
  24260. * The scaling of the particle.
  24261. */
  24262. scaling: Vector3;
  24263. /**
  24264. * The uvs of the particle.
  24265. */
  24266. uvs: Vector4;
  24267. /**
  24268. * The current speed of the particle.
  24269. */
  24270. velocity: Vector3;
  24271. /**
  24272. * The pivot point in the particle local space.
  24273. */
  24274. pivot: Vector3;
  24275. /**
  24276. * Must the particle be translated from its pivot point in its local space ?
  24277. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24278. * Default : false
  24279. */
  24280. translateFromPivot: boolean;
  24281. /**
  24282. * Is the particle active or not ?
  24283. */
  24284. alive: boolean;
  24285. /**
  24286. * Is the particle visible or not ?
  24287. */
  24288. isVisible: boolean;
  24289. /**
  24290. * Index of this particle in the global "positions" array (Internal use)
  24291. * @hidden
  24292. */
  24293. _pos: number;
  24294. /**
  24295. * @hidden Index of this particle in the global "indices" array (Internal use)
  24296. */
  24297. _ind: number;
  24298. /**
  24299. * @hidden ModelShape of this particle (Internal use)
  24300. */
  24301. _model: ModelShape;
  24302. /**
  24303. * ModelShape id of this particle
  24304. */
  24305. shapeId: number;
  24306. /**
  24307. * Index of the particle in its shape id (Internal use)
  24308. */
  24309. idxInShape: number;
  24310. /**
  24311. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24312. */
  24313. _modelBoundingInfo: BoundingInfo;
  24314. /**
  24315. * @hidden Particle BoundingInfo object (Internal use)
  24316. */
  24317. _boundingInfo: BoundingInfo;
  24318. /**
  24319. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24320. */
  24321. _sps: SolidParticleSystem;
  24322. /**
  24323. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24324. */
  24325. _stillInvisible: boolean;
  24326. /**
  24327. * @hidden Last computed particle rotation matrix
  24328. */
  24329. _rotationMatrix: number[];
  24330. /**
  24331. * Parent particle Id, if any.
  24332. * Default null.
  24333. */
  24334. parentId: Nullable<number>;
  24335. /**
  24336. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24337. * The possible values are :
  24338. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24339. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24340. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24341. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24342. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24343. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24344. * */
  24345. cullingStrategy: number;
  24346. /**
  24347. * @hidden Internal global position in the SPS.
  24348. */
  24349. _globalPosition: Vector3;
  24350. /**
  24351. * Creates a Solid Particle object.
  24352. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24353. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24354. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24355. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24356. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24357. * @param shapeId (integer) is the model shape identifier in the SPS.
  24358. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24359. * @param sps defines the sps it is associated to
  24360. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24361. */
  24362. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24363. /**
  24364. * Legacy support, changed scale to scaling
  24365. */
  24366. /**
  24367. * Legacy support, changed scale to scaling
  24368. */
  24369. scale: Vector3;
  24370. /**
  24371. * Legacy support, changed quaternion to rotationQuaternion
  24372. */
  24373. /**
  24374. * Legacy support, changed quaternion to rotationQuaternion
  24375. */
  24376. quaternion: Nullable<Quaternion>;
  24377. /**
  24378. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24379. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24380. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24381. * @returns true if it intersects
  24382. */
  24383. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24384. /**
  24385. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24386. * A particle is in the frustum if its bounding box intersects the frustum
  24387. * @param frustumPlanes defines the frustum to test
  24388. * @returns true if the particle is in the frustum planes
  24389. */
  24390. isInFrustum(frustumPlanes: Plane[]): boolean;
  24391. /**
  24392. * get the rotation matrix of the particle
  24393. * @hidden
  24394. */
  24395. getRotationMatrix(m: Matrix): void;
  24396. }
  24397. /**
  24398. * Represents the shape of the model used by one particle of a solid particle system.
  24399. * SPS internal tool, don't use it manually.
  24400. */
  24401. export class ModelShape {
  24402. /**
  24403. * The shape id
  24404. * @hidden
  24405. */
  24406. shapeID: number;
  24407. /**
  24408. * flat array of model positions (internal use)
  24409. * @hidden
  24410. */
  24411. _shape: Vector3[];
  24412. /**
  24413. * flat array of model UVs (internal use)
  24414. * @hidden
  24415. */
  24416. _shapeUV: number[];
  24417. /**
  24418. * length of the shape in the model indices array (internal use)
  24419. * @hidden
  24420. */
  24421. _indicesLength: number;
  24422. /**
  24423. * Custom position function (internal use)
  24424. * @hidden
  24425. */
  24426. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24427. /**
  24428. * Custom vertex function (internal use)
  24429. * @hidden
  24430. */
  24431. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24432. /**
  24433. * 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.
  24434. * SPS internal tool, don't use it manually.
  24435. * @hidden
  24436. */
  24437. 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>);
  24438. }
  24439. /**
  24440. * Represents a Depth Sorted Particle in the solid particle system.
  24441. */
  24442. export class DepthSortedParticle {
  24443. /**
  24444. * Index of the particle in the "indices" array
  24445. */
  24446. ind: number;
  24447. /**
  24448. * Length of the particle shape in the "indices" array
  24449. */
  24450. indicesLength: number;
  24451. /**
  24452. * Squared distance from the particle to the camera
  24453. */
  24454. sqDistance: number;
  24455. }
  24456. }
  24457. declare module BABYLON {
  24458. /**
  24459. * @hidden
  24460. */
  24461. export class _MeshCollisionData {
  24462. _checkCollisions: boolean;
  24463. _collisionMask: number;
  24464. _collisionGroup: number;
  24465. _collider: Nullable<Collider>;
  24466. _oldPositionForCollisions: Vector3;
  24467. _diffPositionForCollisions: Vector3;
  24468. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  24469. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  24470. }
  24471. }
  24472. declare module BABYLON {
  24473. /** @hidden */
  24474. class _FacetDataStorage {
  24475. facetPositions: Vector3[];
  24476. facetNormals: Vector3[];
  24477. facetPartitioning: number[][];
  24478. facetNb: number;
  24479. partitioningSubdivisions: number;
  24480. partitioningBBoxRatio: number;
  24481. facetDataEnabled: boolean;
  24482. facetParameters: any;
  24483. bbSize: Vector3;
  24484. subDiv: {
  24485. max: number;
  24486. X: number;
  24487. Y: number;
  24488. Z: number;
  24489. };
  24490. facetDepthSort: boolean;
  24491. facetDepthSortEnabled: boolean;
  24492. depthSortedIndices: IndicesArray;
  24493. depthSortedFacets: {
  24494. ind: number;
  24495. sqDistance: number;
  24496. }[];
  24497. facetDepthSortFunction: (f1: {
  24498. ind: number;
  24499. sqDistance: number;
  24500. }, f2: {
  24501. ind: number;
  24502. sqDistance: number;
  24503. }) => number;
  24504. facetDepthSortFrom: Vector3;
  24505. facetDepthSortOrigin: Vector3;
  24506. invertedMatrix: Matrix;
  24507. }
  24508. /**
  24509. * @hidden
  24510. **/
  24511. class _InternalAbstractMeshDataInfo {
  24512. _hasVertexAlpha: boolean;
  24513. _useVertexColors: boolean;
  24514. _numBoneInfluencers: number;
  24515. _applyFog: boolean;
  24516. _receiveShadows: boolean;
  24517. _facetData: _FacetDataStorage;
  24518. _visibility: number;
  24519. _skeleton: Nullable<Skeleton>;
  24520. _layerMask: number;
  24521. _computeBonesUsingShaders: boolean;
  24522. _isActive: boolean;
  24523. _onlyForInstances: boolean;
  24524. _isActiveIntermediate: boolean;
  24525. _onlyForInstancesIntermediate: boolean;
  24526. }
  24527. /**
  24528. * Class used to store all common mesh properties
  24529. */
  24530. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24531. /** No occlusion */
  24532. static OCCLUSION_TYPE_NONE: number;
  24533. /** Occlusion set to optimisitic */
  24534. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24535. /** Occlusion set to strict */
  24536. static OCCLUSION_TYPE_STRICT: number;
  24537. /** Use an accurante occlusion algorithm */
  24538. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24539. /** Use a conservative occlusion algorithm */
  24540. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24541. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24542. * Test order :
  24543. * Is the bounding sphere outside the frustum ?
  24544. * If not, are the bounding box vertices outside the frustum ?
  24545. * It not, then the cullable object is in the frustum.
  24546. */
  24547. static readonly CULLINGSTRATEGY_STANDARD: number;
  24548. /** Culling strategy : Bounding Sphere Only.
  24549. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24550. * It's also less accurate than the standard because some not visible objects can still be selected.
  24551. * Test : is the bounding sphere outside the frustum ?
  24552. * If not, then the cullable object is in the frustum.
  24553. */
  24554. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24555. /** Culling strategy : Optimistic Inclusion.
  24556. * This in an inclusion test first, then the standard exclusion test.
  24557. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24558. * 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.
  24559. * Anyway, it's as accurate as the standard strategy.
  24560. * Test :
  24561. * Is the cullable object bounding sphere center in the frustum ?
  24562. * If not, apply the default culling strategy.
  24563. */
  24564. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24565. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24566. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24567. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24568. * 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.
  24569. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24570. * Test :
  24571. * Is the cullable object bounding sphere center in the frustum ?
  24572. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24573. */
  24574. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24575. /**
  24576. * No billboard
  24577. */
  24578. static readonly BILLBOARDMODE_NONE: number;
  24579. /** Billboard on X axis */
  24580. static readonly BILLBOARDMODE_X: number;
  24581. /** Billboard on Y axis */
  24582. static readonly BILLBOARDMODE_Y: number;
  24583. /** Billboard on Z axis */
  24584. static readonly BILLBOARDMODE_Z: number;
  24585. /** Billboard on all axes */
  24586. static readonly BILLBOARDMODE_ALL: number;
  24587. /** @hidden */
  24588. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  24589. /**
  24590. * The culling strategy to use to check whether the mesh must be rendered or not.
  24591. * This value can be changed at any time and will be used on the next render mesh selection.
  24592. * The possible values are :
  24593. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24594. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24595. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24596. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24597. * Please read each static variable documentation to get details about the culling process.
  24598. * */
  24599. cullingStrategy: number;
  24600. /**
  24601. * Gets the number of facets in the mesh
  24602. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24603. */
  24604. readonly facetNb: number;
  24605. /**
  24606. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24607. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24608. */
  24609. partitioningSubdivisions: number;
  24610. /**
  24611. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24612. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24613. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24614. */
  24615. partitioningBBoxRatio: number;
  24616. /**
  24617. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24618. * Works only for updatable meshes.
  24619. * Doesn't work with multi-materials
  24620. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24621. */
  24622. mustDepthSortFacets: boolean;
  24623. /**
  24624. * The location (Vector3) where the facet depth sort must be computed from.
  24625. * By default, the active camera position.
  24626. * Used only when facet depth sort is enabled
  24627. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24628. */
  24629. facetDepthSortFrom: Vector3;
  24630. /**
  24631. * gets a boolean indicating if facetData is enabled
  24632. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24633. */
  24634. readonly isFacetDataEnabled: boolean;
  24635. /** @hidden */
  24636. _updateNonUniformScalingState(value: boolean): boolean;
  24637. /**
  24638. * An event triggered when this mesh collides with another one
  24639. */
  24640. onCollideObservable: Observable<AbstractMesh>;
  24641. /** Set a function to call when this mesh collides with another one */
  24642. onCollide: () => void;
  24643. /**
  24644. * An event triggered when the collision's position changes
  24645. */
  24646. onCollisionPositionChangeObservable: Observable<Vector3>;
  24647. /** Set a function to call when the collision's position changes */
  24648. onCollisionPositionChange: () => void;
  24649. /**
  24650. * An event triggered when material is changed
  24651. */
  24652. onMaterialChangedObservable: Observable<AbstractMesh>;
  24653. /**
  24654. * Gets or sets the orientation for POV movement & rotation
  24655. */
  24656. definedFacingForward: boolean;
  24657. /** @hidden */
  24658. _occlusionQuery: Nullable<WebGLQuery>;
  24659. /** @hidden */
  24660. _renderingGroup: Nullable<RenderingGroup>;
  24661. /**
  24662. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24663. */
  24664. /**
  24665. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24666. */
  24667. visibility: number;
  24668. /** Gets or sets the alpha index used to sort transparent meshes
  24669. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24670. */
  24671. alphaIndex: number;
  24672. /**
  24673. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24674. */
  24675. isVisible: boolean;
  24676. /**
  24677. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24678. */
  24679. isPickable: boolean;
  24680. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24681. showSubMeshesBoundingBox: boolean;
  24682. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24683. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24684. */
  24685. isBlocker: boolean;
  24686. /**
  24687. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24688. */
  24689. enablePointerMoveEvents: boolean;
  24690. /**
  24691. * Specifies the rendering group id for this mesh (0 by default)
  24692. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24693. */
  24694. renderingGroupId: number;
  24695. private _material;
  24696. /** Gets or sets current material */
  24697. material: Nullable<Material>;
  24698. /**
  24699. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24700. * @see http://doc.babylonjs.com/babylon101/shadows
  24701. */
  24702. receiveShadows: boolean;
  24703. /** Defines color to use when rendering outline */
  24704. outlineColor: Color3;
  24705. /** Define width to use when rendering outline */
  24706. outlineWidth: number;
  24707. /** Defines color to use when rendering overlay */
  24708. overlayColor: Color3;
  24709. /** Defines alpha to use when rendering overlay */
  24710. overlayAlpha: number;
  24711. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24712. hasVertexAlpha: boolean;
  24713. /** 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) */
  24714. useVertexColors: boolean;
  24715. /**
  24716. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24717. */
  24718. computeBonesUsingShaders: boolean;
  24719. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24720. numBoneInfluencers: number;
  24721. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24722. applyFog: boolean;
  24723. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24724. useOctreeForRenderingSelection: boolean;
  24725. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24726. useOctreeForPicking: boolean;
  24727. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24728. useOctreeForCollisions: boolean;
  24729. /**
  24730. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24731. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24732. */
  24733. layerMask: number;
  24734. /**
  24735. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24736. */
  24737. alwaysSelectAsActiveMesh: boolean;
  24738. /**
  24739. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24740. */
  24741. doNotSyncBoundingInfo: boolean;
  24742. /**
  24743. * Gets or sets the current action manager
  24744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24745. */
  24746. actionManager: Nullable<AbstractActionManager>;
  24747. private _meshCollisionData;
  24748. /**
  24749. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24750. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24751. */
  24752. ellipsoid: Vector3;
  24753. /**
  24754. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24755. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24756. */
  24757. ellipsoidOffset: Vector3;
  24758. /**
  24759. * Gets or sets a collision mask used to mask collisions (default is -1).
  24760. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24761. */
  24762. collisionMask: number;
  24763. /**
  24764. * Gets or sets the current collision group mask (-1 by default).
  24765. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24766. */
  24767. collisionGroup: number;
  24768. /**
  24769. * Defines edge width used when edgesRenderer is enabled
  24770. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24771. */
  24772. edgesWidth: number;
  24773. /**
  24774. * Defines edge color used when edgesRenderer is enabled
  24775. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24776. */
  24777. edgesColor: Color4;
  24778. /** @hidden */
  24779. _edgesRenderer: Nullable<IEdgesRenderer>;
  24780. /** @hidden */
  24781. _masterMesh: Nullable<AbstractMesh>;
  24782. /** @hidden */
  24783. _boundingInfo: Nullable<BoundingInfo>;
  24784. /** @hidden */
  24785. _renderId: number;
  24786. /**
  24787. * Gets or sets the list of subMeshes
  24788. * @see http://doc.babylonjs.com/how_to/multi_materials
  24789. */
  24790. subMeshes: SubMesh[];
  24791. /** @hidden */
  24792. _intersectionsInProgress: AbstractMesh[];
  24793. /** @hidden */
  24794. _unIndexed: boolean;
  24795. /** @hidden */
  24796. _lightSources: Light[];
  24797. /** Gets the list of lights affecting that mesh */
  24798. readonly lightSources: Light[];
  24799. /** @hidden */
  24800. readonly _positions: Nullable<Vector3[]>;
  24801. /** @hidden */
  24802. _waitingData: {
  24803. lods: Nullable<any>;
  24804. actions: Nullable<any>;
  24805. freezeWorldMatrix: Nullable<boolean>;
  24806. };
  24807. /** @hidden */
  24808. _bonesTransformMatrices: Nullable<Float32Array>;
  24809. /** @hidden */
  24810. _transformMatrixTexture: Nullable<RawTexture>;
  24811. /**
  24812. * Gets or sets a skeleton to apply skining transformations
  24813. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24814. */
  24815. skeleton: Nullable<Skeleton>;
  24816. /**
  24817. * An event triggered when the mesh is rebuilt.
  24818. */
  24819. onRebuildObservable: Observable<AbstractMesh>;
  24820. /**
  24821. * Creates a new AbstractMesh
  24822. * @param name defines the name of the mesh
  24823. * @param scene defines the hosting scene
  24824. */
  24825. constructor(name: string, scene?: Nullable<Scene>);
  24826. /**
  24827. * Returns the string "AbstractMesh"
  24828. * @returns "AbstractMesh"
  24829. */
  24830. getClassName(): string;
  24831. /**
  24832. * Gets a string representation of the current mesh
  24833. * @param fullDetails defines a boolean indicating if full details must be included
  24834. * @returns a string representation of the current mesh
  24835. */
  24836. toString(fullDetails?: boolean): string;
  24837. /**
  24838. * @hidden
  24839. */
  24840. protected _getEffectiveParent(): Nullable<Node>;
  24841. /** @hidden */
  24842. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24843. /** @hidden */
  24844. _rebuild(): void;
  24845. /** @hidden */
  24846. _resyncLightSources(): void;
  24847. /** @hidden */
  24848. _resyncLighSource(light: Light): void;
  24849. /** @hidden */
  24850. _unBindEffect(): void;
  24851. /** @hidden */
  24852. _removeLightSource(light: Light): void;
  24853. private _markSubMeshesAsDirty;
  24854. /** @hidden */
  24855. _markSubMeshesAsLightDirty(): void;
  24856. /** @hidden */
  24857. _markSubMeshesAsAttributesDirty(): void;
  24858. /** @hidden */
  24859. _markSubMeshesAsMiscDirty(): void;
  24860. /**
  24861. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24862. */
  24863. scaling: Vector3;
  24864. /**
  24865. * Returns true if the mesh is blocked. Implemented by child classes
  24866. */
  24867. readonly isBlocked: boolean;
  24868. /**
  24869. * Returns the mesh itself by default. Implemented by child classes
  24870. * @param camera defines the camera to use to pick the right LOD level
  24871. * @returns the currentAbstractMesh
  24872. */
  24873. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24874. /**
  24875. * Returns 0 by default. Implemented by child classes
  24876. * @returns an integer
  24877. */
  24878. getTotalVertices(): number;
  24879. /**
  24880. * Returns a positive integer : the total number of indices in this mesh geometry.
  24881. * @returns the numner of indices or zero if the mesh has no geometry.
  24882. */
  24883. getTotalIndices(): number;
  24884. /**
  24885. * Returns null by default. Implemented by child classes
  24886. * @returns null
  24887. */
  24888. getIndices(): Nullable<IndicesArray>;
  24889. /**
  24890. * Returns the array of the requested vertex data kind. Implemented by child classes
  24891. * @param kind defines the vertex data kind to use
  24892. * @returns null
  24893. */
  24894. getVerticesData(kind: string): Nullable<FloatArray>;
  24895. /**
  24896. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24897. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24898. * Note that a new underlying VertexBuffer object is created each call.
  24899. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24900. * @param kind defines vertex data kind:
  24901. * * VertexBuffer.PositionKind
  24902. * * VertexBuffer.UVKind
  24903. * * VertexBuffer.UV2Kind
  24904. * * VertexBuffer.UV3Kind
  24905. * * VertexBuffer.UV4Kind
  24906. * * VertexBuffer.UV5Kind
  24907. * * VertexBuffer.UV6Kind
  24908. * * VertexBuffer.ColorKind
  24909. * * VertexBuffer.MatricesIndicesKind
  24910. * * VertexBuffer.MatricesIndicesExtraKind
  24911. * * VertexBuffer.MatricesWeightsKind
  24912. * * VertexBuffer.MatricesWeightsExtraKind
  24913. * @param data defines the data source
  24914. * @param updatable defines if the data must be flagged as updatable (or static)
  24915. * @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
  24916. * @returns the current mesh
  24917. */
  24918. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24919. /**
  24920. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24921. * If the mesh has no geometry, it is simply returned as it is.
  24922. * @param kind defines vertex data kind:
  24923. * * VertexBuffer.PositionKind
  24924. * * VertexBuffer.UVKind
  24925. * * VertexBuffer.UV2Kind
  24926. * * VertexBuffer.UV3Kind
  24927. * * VertexBuffer.UV4Kind
  24928. * * VertexBuffer.UV5Kind
  24929. * * VertexBuffer.UV6Kind
  24930. * * VertexBuffer.ColorKind
  24931. * * VertexBuffer.MatricesIndicesKind
  24932. * * VertexBuffer.MatricesIndicesExtraKind
  24933. * * VertexBuffer.MatricesWeightsKind
  24934. * * VertexBuffer.MatricesWeightsExtraKind
  24935. * @param data defines the data source
  24936. * @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
  24937. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24938. * @returns the current mesh
  24939. */
  24940. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24941. /**
  24942. * Sets the mesh indices,
  24943. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24944. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24945. * @param totalVertices Defines the total number of vertices
  24946. * @returns the current mesh
  24947. */
  24948. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24949. /**
  24950. * Gets a boolean indicating if specific vertex data is present
  24951. * @param kind defines the vertex data kind to use
  24952. * @returns true is data kind is present
  24953. */
  24954. isVerticesDataPresent(kind: string): boolean;
  24955. /**
  24956. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  24957. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  24958. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  24959. * @returns a BoundingInfo
  24960. */
  24961. getBoundingInfo(): BoundingInfo;
  24962. /**
  24963. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24964. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24965. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24966. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  24967. * @returns the current mesh
  24968. */
  24969. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  24970. /**
  24971. * Overwrite the current bounding info
  24972. * @param boundingInfo defines the new bounding info
  24973. * @returns the current mesh
  24974. */
  24975. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24976. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24977. readonly useBones: boolean;
  24978. /** @hidden */
  24979. _preActivate(): void;
  24980. /** @hidden */
  24981. _preActivateForIntermediateRendering(renderId: number): void;
  24982. /** @hidden */
  24983. _activate(renderId: number, intermediateRendering: boolean): boolean;
  24984. /** @hidden */
  24985. _postActivate(): void;
  24986. /** @hidden */
  24987. _freeze(): void;
  24988. /** @hidden */
  24989. _unFreeze(): void;
  24990. /**
  24991. * Gets the current world matrix
  24992. * @returns a Matrix
  24993. */
  24994. getWorldMatrix(): Matrix;
  24995. /** @hidden */
  24996. _getWorldMatrixDeterminant(): number;
  24997. /**
  24998. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  24999. */
  25000. readonly isAnInstance: boolean;
  25001. /**
  25002. * Perform relative position change from the point of view of behind the front of the mesh.
  25003. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25004. * Supports definition of mesh facing forward or backward
  25005. * @param amountRight defines the distance on the right axis
  25006. * @param amountUp defines the distance on the up axis
  25007. * @param amountForward defines the distance on the forward axis
  25008. * @returns the current mesh
  25009. */
  25010. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25011. /**
  25012. * Calculate relative position change from the point of view of behind the front of the mesh.
  25013. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25014. * Supports definition of mesh facing forward or backward
  25015. * @param amountRight defines the distance on the right axis
  25016. * @param amountUp defines the distance on the up axis
  25017. * @param amountForward defines the distance on the forward axis
  25018. * @returns the new displacement vector
  25019. */
  25020. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25021. /**
  25022. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25023. * Supports definition of mesh facing forward or backward
  25024. * @param flipBack defines the flip
  25025. * @param twirlClockwise defines the twirl
  25026. * @param tiltRight defines the tilt
  25027. * @returns the current mesh
  25028. */
  25029. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25030. /**
  25031. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25032. * Supports definition of mesh facing forward or backward.
  25033. * @param flipBack defines the flip
  25034. * @param twirlClockwise defines the twirl
  25035. * @param tiltRight defines the tilt
  25036. * @returns the new rotation vector
  25037. */
  25038. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25039. /**
  25040. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25041. * This means the mesh underlying bounding box and sphere are recomputed.
  25042. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25043. * @returns the current mesh
  25044. */
  25045. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25046. /** @hidden */
  25047. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25048. /** @hidden */
  25049. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25050. /** @hidden */
  25051. _updateBoundingInfo(): AbstractMesh;
  25052. /** @hidden */
  25053. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25054. /** @hidden */
  25055. protected _afterComputeWorldMatrix(): void;
  25056. /** @hidden */
  25057. readonly _effectiveMesh: AbstractMesh;
  25058. /**
  25059. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25060. * A mesh is in the frustum if its bounding box intersects the frustum
  25061. * @param frustumPlanes defines the frustum to test
  25062. * @returns true if the mesh is in the frustum planes
  25063. */
  25064. isInFrustum(frustumPlanes: Plane[]): boolean;
  25065. /**
  25066. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25067. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25068. * @param frustumPlanes defines the frustum to test
  25069. * @returns true if the mesh is completely in the frustum planes
  25070. */
  25071. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25072. /**
  25073. * True if the mesh intersects another mesh or a SolidParticle object
  25074. * @param mesh defines a target mesh or SolidParticle to test
  25075. * @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)
  25076. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25077. * @returns true if there is an intersection
  25078. */
  25079. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25080. /**
  25081. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25082. * @param point defines the point to test
  25083. * @returns true if there is an intersection
  25084. */
  25085. intersectsPoint(point: Vector3): boolean;
  25086. /**
  25087. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25088. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25089. */
  25090. checkCollisions: boolean;
  25091. /**
  25092. * Gets Collider object used to compute collisions (not physics)
  25093. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25094. */
  25095. readonly collider: Nullable<Collider>;
  25096. /**
  25097. * Move the mesh using collision engine
  25098. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25099. * @param displacement defines the requested displacement vector
  25100. * @returns the current mesh
  25101. */
  25102. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25103. private _onCollisionPositionChange;
  25104. /** @hidden */
  25105. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25106. /** @hidden */
  25107. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25108. /** @hidden */
  25109. _checkCollision(collider: Collider): AbstractMesh;
  25110. /** @hidden */
  25111. _generatePointsArray(): boolean;
  25112. /**
  25113. * Checks if the passed Ray intersects with the mesh
  25114. * @param ray defines the ray to use
  25115. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25116. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25117. * @returns the picking info
  25118. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25119. */
  25120. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25121. /**
  25122. * Clones the current mesh
  25123. * @param name defines the mesh name
  25124. * @param newParent defines the new mesh parent
  25125. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25126. * @returns the new mesh
  25127. */
  25128. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25129. /**
  25130. * Disposes all the submeshes of the current meshnp
  25131. * @returns the current mesh
  25132. */
  25133. releaseSubMeshes(): AbstractMesh;
  25134. /**
  25135. * Releases resources associated with this abstract mesh.
  25136. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25137. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25138. */
  25139. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25140. /**
  25141. * Adds the passed mesh as a child to the current mesh
  25142. * @param mesh defines the child mesh
  25143. * @returns the current mesh
  25144. */
  25145. addChild(mesh: AbstractMesh): AbstractMesh;
  25146. /**
  25147. * Removes the passed mesh from the current mesh children list
  25148. * @param mesh defines the child mesh
  25149. * @returns the current mesh
  25150. */
  25151. removeChild(mesh: AbstractMesh): AbstractMesh;
  25152. /** @hidden */
  25153. private _initFacetData;
  25154. /**
  25155. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25156. * This method can be called within the render loop.
  25157. * 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
  25158. * @returns the current mesh
  25159. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25160. */
  25161. updateFacetData(): AbstractMesh;
  25162. /**
  25163. * Returns the facetLocalNormals array.
  25164. * The normals are expressed in the mesh local spac
  25165. * @returns an array of Vector3
  25166. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25167. */
  25168. getFacetLocalNormals(): Vector3[];
  25169. /**
  25170. * Returns the facetLocalPositions array.
  25171. * The facet positions are expressed in the mesh local space
  25172. * @returns an array of Vector3
  25173. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25174. */
  25175. getFacetLocalPositions(): Vector3[];
  25176. /**
  25177. * Returns the facetLocalPartioning array
  25178. * @returns an array of array of numbers
  25179. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25180. */
  25181. getFacetLocalPartitioning(): number[][];
  25182. /**
  25183. * Returns the i-th facet position in the world system.
  25184. * This method allocates a new Vector3 per call
  25185. * @param i defines the facet index
  25186. * @returns a new Vector3
  25187. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25188. */
  25189. getFacetPosition(i: number): Vector3;
  25190. /**
  25191. * Sets the reference Vector3 with the i-th facet position in the world system
  25192. * @param i defines the facet index
  25193. * @param ref defines the target vector
  25194. * @returns the current mesh
  25195. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25196. */
  25197. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25198. /**
  25199. * Returns the i-th facet normal in the world system.
  25200. * This method allocates a new Vector3 per call
  25201. * @param i defines the facet index
  25202. * @returns a new Vector3
  25203. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25204. */
  25205. getFacetNormal(i: number): Vector3;
  25206. /**
  25207. * Sets the reference Vector3 with the i-th facet normal in the world system
  25208. * @param i defines the facet index
  25209. * @param ref defines the target vector
  25210. * @returns the current mesh
  25211. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25212. */
  25213. getFacetNormalToRef(i: number, ref: Vector3): this;
  25214. /**
  25215. * 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)
  25216. * @param x defines x coordinate
  25217. * @param y defines y coordinate
  25218. * @param z defines z coordinate
  25219. * @returns the array of facet indexes
  25220. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25221. */
  25222. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25223. /**
  25224. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25225. * @param projected sets as the (x,y,z) world projection on the facet
  25226. * @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
  25227. * @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
  25228. * @param x defines x coordinate
  25229. * @param y defines y coordinate
  25230. * @param z defines z coordinate
  25231. * @returns the face index if found (or null instead)
  25232. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25233. */
  25234. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25235. /**
  25236. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25237. * @param projected sets as the (x,y,z) local projection on the facet
  25238. * @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
  25239. * @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
  25240. * @param x defines x coordinate
  25241. * @param y defines y coordinate
  25242. * @param z defines z coordinate
  25243. * @returns the face index if found (or null instead)
  25244. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25245. */
  25246. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25247. /**
  25248. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25249. * @returns the parameters
  25250. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25251. */
  25252. getFacetDataParameters(): any;
  25253. /**
  25254. * Disables the feature FacetData and frees the related memory
  25255. * @returns the current mesh
  25256. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25257. */
  25258. disableFacetData(): AbstractMesh;
  25259. /**
  25260. * Updates the AbstractMesh indices array
  25261. * @param indices defines the data source
  25262. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25263. * @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)
  25264. * @returns the current mesh
  25265. */
  25266. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25267. /**
  25268. * Creates new normals data for the mesh
  25269. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25270. * @returns the current mesh
  25271. */
  25272. createNormals(updatable: boolean): AbstractMesh;
  25273. /**
  25274. * Align the mesh with a normal
  25275. * @param normal defines the normal to use
  25276. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25277. * @returns the current mesh
  25278. */
  25279. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25280. /** @hidden */
  25281. _checkOcclusionQuery(): boolean;
  25282. /**
  25283. * Disables the mesh edge rendering mode
  25284. * @returns the currentAbstractMesh
  25285. */
  25286. disableEdgesRendering(): AbstractMesh;
  25287. /**
  25288. * Enables the edge rendering mode on the mesh.
  25289. * This mode makes the mesh edges visible
  25290. * @param epsilon defines the maximal distance between two angles to detect a face
  25291. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25292. * @returns the currentAbstractMesh
  25293. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25294. */
  25295. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25296. }
  25297. }
  25298. declare module BABYLON {
  25299. /**
  25300. * Interface used to define ActionEvent
  25301. */
  25302. export interface IActionEvent {
  25303. /** The mesh or sprite that triggered the action */
  25304. source: any;
  25305. /** The X mouse cursor position at the time of the event */
  25306. pointerX: number;
  25307. /** The Y mouse cursor position at the time of the event */
  25308. pointerY: number;
  25309. /** The mesh that is currently pointed at (can be null) */
  25310. meshUnderPointer: Nullable<AbstractMesh>;
  25311. /** the original (browser) event that triggered the ActionEvent */
  25312. sourceEvent?: any;
  25313. /** additional data for the event */
  25314. additionalData?: any;
  25315. }
  25316. /**
  25317. * ActionEvent is the event being sent when an action is triggered.
  25318. */
  25319. export class ActionEvent implements IActionEvent {
  25320. /** The mesh or sprite that triggered the action */
  25321. source: any;
  25322. /** The X mouse cursor position at the time of the event */
  25323. pointerX: number;
  25324. /** The Y mouse cursor position at the time of the event */
  25325. pointerY: number;
  25326. /** The mesh that is currently pointed at (can be null) */
  25327. meshUnderPointer: Nullable<AbstractMesh>;
  25328. /** the original (browser) event that triggered the ActionEvent */
  25329. sourceEvent?: any;
  25330. /** additional data for the event */
  25331. additionalData?: any;
  25332. /**
  25333. * Creates a new ActionEvent
  25334. * @param source The mesh or sprite that triggered the action
  25335. * @param pointerX The X mouse cursor position at the time of the event
  25336. * @param pointerY The Y mouse cursor position at the time of the event
  25337. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25338. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25339. * @param additionalData additional data for the event
  25340. */
  25341. constructor(
  25342. /** The mesh or sprite that triggered the action */
  25343. source: any,
  25344. /** The X mouse cursor position at the time of the event */
  25345. pointerX: number,
  25346. /** The Y mouse cursor position at the time of the event */
  25347. pointerY: number,
  25348. /** The mesh that is currently pointed at (can be null) */
  25349. meshUnderPointer: Nullable<AbstractMesh>,
  25350. /** the original (browser) event that triggered the ActionEvent */
  25351. sourceEvent?: any,
  25352. /** additional data for the event */
  25353. additionalData?: any);
  25354. /**
  25355. * Helper function to auto-create an ActionEvent from a source mesh.
  25356. * @param source The source mesh that triggered the event
  25357. * @param evt The original (browser) event
  25358. * @param additionalData additional data for the event
  25359. * @returns the new ActionEvent
  25360. */
  25361. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25362. /**
  25363. * Helper function to auto-create an ActionEvent from a source sprite
  25364. * @param source The source sprite that triggered the event
  25365. * @param scene Scene associated with the sprite
  25366. * @param evt The original (browser) event
  25367. * @param additionalData additional data for the event
  25368. * @returns the new ActionEvent
  25369. */
  25370. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25371. /**
  25372. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25373. * @param scene the scene where the event occurred
  25374. * @param evt The original (browser) event
  25375. * @returns the new ActionEvent
  25376. */
  25377. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25378. /**
  25379. * Helper function to auto-create an ActionEvent from a primitive
  25380. * @param prim defines the target primitive
  25381. * @param pointerPos defines the pointer position
  25382. * @param evt The original (browser) event
  25383. * @param additionalData additional data for the event
  25384. * @returns the new ActionEvent
  25385. */
  25386. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25387. }
  25388. }
  25389. declare module BABYLON {
  25390. /**
  25391. * Abstract class used to decouple action Manager from scene and meshes.
  25392. * Do not instantiate.
  25393. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25394. */
  25395. export abstract class AbstractActionManager implements IDisposable {
  25396. /** Gets the list of active triggers */
  25397. static Triggers: {
  25398. [key: string]: number;
  25399. };
  25400. /** Gets the cursor to use when hovering items */
  25401. hoverCursor: string;
  25402. /** Gets the list of actions */
  25403. actions: IAction[];
  25404. /**
  25405. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25406. */
  25407. isRecursive: boolean;
  25408. /**
  25409. * Releases all associated resources
  25410. */
  25411. abstract dispose(): void;
  25412. /**
  25413. * Does this action manager has pointer triggers
  25414. */
  25415. abstract readonly hasPointerTriggers: boolean;
  25416. /**
  25417. * Does this action manager has pick triggers
  25418. */
  25419. abstract readonly hasPickTriggers: boolean;
  25420. /**
  25421. * Process a specific trigger
  25422. * @param trigger defines the trigger to process
  25423. * @param evt defines the event details to be processed
  25424. */
  25425. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25426. /**
  25427. * Does this action manager handles actions of any of the given triggers
  25428. * @param triggers defines the triggers to be tested
  25429. * @return a boolean indicating whether one (or more) of the triggers is handled
  25430. */
  25431. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25432. /**
  25433. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25434. * speed.
  25435. * @param triggerA defines the trigger to be tested
  25436. * @param triggerB defines the trigger to be tested
  25437. * @return a boolean indicating whether one (or more) of the triggers is handled
  25438. */
  25439. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25440. /**
  25441. * Does this action manager handles actions of a given trigger
  25442. * @param trigger defines the trigger to be tested
  25443. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25444. * @return whether the trigger is handled
  25445. */
  25446. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25447. /**
  25448. * Serialize this manager to a JSON object
  25449. * @param name defines the property name to store this manager
  25450. * @returns a JSON representation of this manager
  25451. */
  25452. abstract serialize(name: string): any;
  25453. /**
  25454. * Registers an action to this action manager
  25455. * @param action defines the action to be registered
  25456. * @return the action amended (prepared) after registration
  25457. */
  25458. abstract registerAction(action: IAction): Nullable<IAction>;
  25459. /**
  25460. * Unregisters an action to this action manager
  25461. * @param action defines the action to be unregistered
  25462. * @return a boolean indicating whether the action has been unregistered
  25463. */
  25464. abstract unregisterAction(action: IAction): Boolean;
  25465. /**
  25466. * Does exist one action manager with at least one trigger
  25467. **/
  25468. static readonly HasTriggers: boolean;
  25469. /**
  25470. * Does exist one action manager with at least one pick trigger
  25471. **/
  25472. static readonly HasPickTriggers: boolean;
  25473. /**
  25474. * Does exist one action manager that handles actions of a given trigger
  25475. * @param trigger defines the trigger to be tested
  25476. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25477. **/
  25478. static HasSpecificTrigger(trigger: number): boolean;
  25479. }
  25480. }
  25481. declare module BABYLON {
  25482. /**
  25483. * Defines how a node can be built from a string name.
  25484. */
  25485. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25486. /**
  25487. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25488. */
  25489. export class Node implements IBehaviorAware<Node> {
  25490. /** @hidden */
  25491. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  25492. private static _NodeConstructors;
  25493. /**
  25494. * Add a new node constructor
  25495. * @param type defines the type name of the node to construct
  25496. * @param constructorFunc defines the constructor function
  25497. */
  25498. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25499. /**
  25500. * Returns a node constructor based on type name
  25501. * @param type defines the type name
  25502. * @param name defines the new node name
  25503. * @param scene defines the hosting scene
  25504. * @param options defines optional options to transmit to constructors
  25505. * @returns the new constructor or null
  25506. */
  25507. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25508. /**
  25509. * Gets or sets the name of the node
  25510. */
  25511. name: string;
  25512. /**
  25513. * Gets or sets the id of the node
  25514. */
  25515. id: string;
  25516. /**
  25517. * Gets or sets the unique id of the node
  25518. */
  25519. uniqueId: number;
  25520. /**
  25521. * Gets or sets a string used to store user defined state for the node
  25522. */
  25523. state: string;
  25524. /**
  25525. * Gets or sets an object used to store user defined information for the node
  25526. */
  25527. metadata: any;
  25528. /**
  25529. * For internal use only. Please do not use.
  25530. */
  25531. reservedDataStore: any;
  25532. /**
  25533. * List of inspectable custom properties (used by the Inspector)
  25534. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25535. */
  25536. inspectableCustomProperties: IInspectable[];
  25537. /**
  25538. * Gets or sets a boolean used to define if the node must be serialized
  25539. */
  25540. doNotSerialize: boolean;
  25541. /** @hidden */
  25542. _isDisposed: boolean;
  25543. /**
  25544. * Gets a list of Animations associated with the node
  25545. */
  25546. animations: Animation[];
  25547. protected _ranges: {
  25548. [name: string]: Nullable<AnimationRange>;
  25549. };
  25550. /**
  25551. * Callback raised when the node is ready to be used
  25552. */
  25553. onReady: Nullable<(node: Node) => void>;
  25554. private _isEnabled;
  25555. private _isParentEnabled;
  25556. private _isReady;
  25557. /** @hidden */
  25558. _currentRenderId: number;
  25559. private _parentUpdateId;
  25560. /** @hidden */
  25561. _childUpdateId: number;
  25562. /** @hidden */
  25563. _waitingParentId: Nullable<string>;
  25564. /** @hidden */
  25565. _scene: Scene;
  25566. /** @hidden */
  25567. _cache: any;
  25568. private _parentNode;
  25569. private _children;
  25570. /** @hidden */
  25571. _worldMatrix: Matrix;
  25572. /** @hidden */
  25573. _worldMatrixDeterminant: number;
  25574. /** @hidden */
  25575. _worldMatrixDeterminantIsDirty: boolean;
  25576. /** @hidden */
  25577. private _sceneRootNodesIndex;
  25578. /**
  25579. * Gets a boolean indicating if the node has been disposed
  25580. * @returns true if the node was disposed
  25581. */
  25582. isDisposed(): boolean;
  25583. /**
  25584. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25585. * @see https://doc.babylonjs.com/how_to/parenting
  25586. */
  25587. parent: Nullable<Node>;
  25588. private addToSceneRootNodes;
  25589. private removeFromSceneRootNodes;
  25590. private _animationPropertiesOverride;
  25591. /**
  25592. * Gets or sets the animation properties override
  25593. */
  25594. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25595. /**
  25596. * Gets a string idenfifying the name of the class
  25597. * @returns "Node" string
  25598. */
  25599. getClassName(): string;
  25600. /** @hidden */
  25601. readonly _isNode: boolean;
  25602. /**
  25603. * An event triggered when the mesh is disposed
  25604. */
  25605. onDisposeObservable: Observable<Node>;
  25606. private _onDisposeObserver;
  25607. /**
  25608. * Sets a callback that will be raised when the node will be disposed
  25609. */
  25610. onDispose: () => void;
  25611. /**
  25612. * Creates a new Node
  25613. * @param name the name and id to be given to this node
  25614. * @param scene the scene this node will be added to
  25615. * @param addToRootNodes the node will be added to scene.rootNodes
  25616. */
  25617. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25618. /**
  25619. * Gets the scene of the node
  25620. * @returns a scene
  25621. */
  25622. getScene(): Scene;
  25623. /**
  25624. * Gets the engine of the node
  25625. * @returns a Engine
  25626. */
  25627. getEngine(): Engine;
  25628. private _behaviors;
  25629. /**
  25630. * Attach a behavior to the node
  25631. * @see http://doc.babylonjs.com/features/behaviour
  25632. * @param behavior defines the behavior to attach
  25633. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25634. * @returns the current Node
  25635. */
  25636. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25637. /**
  25638. * Remove an attached behavior
  25639. * @see http://doc.babylonjs.com/features/behaviour
  25640. * @param behavior defines the behavior to attach
  25641. * @returns the current Node
  25642. */
  25643. removeBehavior(behavior: Behavior<Node>): Node;
  25644. /**
  25645. * Gets the list of attached behaviors
  25646. * @see http://doc.babylonjs.com/features/behaviour
  25647. */
  25648. readonly behaviors: Behavior<Node>[];
  25649. /**
  25650. * Gets an attached behavior by name
  25651. * @param name defines the name of the behavior to look for
  25652. * @see http://doc.babylonjs.com/features/behaviour
  25653. * @returns null if behavior was not found else the requested behavior
  25654. */
  25655. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25656. /**
  25657. * Returns the latest update of the World matrix
  25658. * @returns a Matrix
  25659. */
  25660. getWorldMatrix(): Matrix;
  25661. /** @hidden */
  25662. _getWorldMatrixDeterminant(): number;
  25663. /**
  25664. * Returns directly the latest state of the mesh World matrix.
  25665. * A Matrix is returned.
  25666. */
  25667. readonly worldMatrixFromCache: Matrix;
  25668. /** @hidden */
  25669. _initCache(): void;
  25670. /** @hidden */
  25671. updateCache(force?: boolean): void;
  25672. /** @hidden */
  25673. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25674. /** @hidden */
  25675. _updateCache(ignoreParentClass?: boolean): void;
  25676. /** @hidden */
  25677. _isSynchronized(): boolean;
  25678. /** @hidden */
  25679. _markSyncedWithParent(): void;
  25680. /** @hidden */
  25681. isSynchronizedWithParent(): boolean;
  25682. /** @hidden */
  25683. isSynchronized(): boolean;
  25684. /**
  25685. * Is this node ready to be used/rendered
  25686. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25687. * @return true if the node is ready
  25688. */
  25689. isReady(completeCheck?: boolean): boolean;
  25690. /**
  25691. * Is this node enabled?
  25692. * 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
  25693. * @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
  25694. * @return whether this node (and its parent) is enabled
  25695. */
  25696. isEnabled(checkAncestors?: boolean): boolean;
  25697. /** @hidden */
  25698. protected _syncParentEnabledState(): void;
  25699. /**
  25700. * Set the enabled state of this node
  25701. * @param value defines the new enabled state
  25702. */
  25703. setEnabled(value: boolean): void;
  25704. /**
  25705. * Is this node a descendant of the given node?
  25706. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25707. * @param ancestor defines the parent node to inspect
  25708. * @returns a boolean indicating if this node is a descendant of the given node
  25709. */
  25710. isDescendantOf(ancestor: Node): boolean;
  25711. /** @hidden */
  25712. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25713. /**
  25714. * Will return all nodes that have this node as ascendant
  25715. * @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
  25716. * @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
  25717. * @return all children nodes of all types
  25718. */
  25719. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25720. /**
  25721. * Get all child-meshes of this node
  25722. * @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)
  25723. * @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
  25724. * @returns an array of AbstractMesh
  25725. */
  25726. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25727. /**
  25728. * Get all direct children of this node
  25729. * @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
  25730. * @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)
  25731. * @returns an array of Node
  25732. */
  25733. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25734. /** @hidden */
  25735. _setReady(state: boolean): void;
  25736. /**
  25737. * Get an animation by name
  25738. * @param name defines the name of the animation to look for
  25739. * @returns null if not found else the requested animation
  25740. */
  25741. getAnimationByName(name: string): Nullable<Animation>;
  25742. /**
  25743. * Creates an animation range for this node
  25744. * @param name defines the name of the range
  25745. * @param from defines the starting key
  25746. * @param to defines the end key
  25747. */
  25748. createAnimationRange(name: string, from: number, to: number): void;
  25749. /**
  25750. * Delete a specific animation range
  25751. * @param name defines the name of the range to delete
  25752. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25753. */
  25754. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25755. /**
  25756. * Get an animation range by name
  25757. * @param name defines the name of the animation range to look for
  25758. * @returns null if not found else the requested animation range
  25759. */
  25760. getAnimationRange(name: string): Nullable<AnimationRange>;
  25761. /**
  25762. * Gets the list of all animation ranges defined on this node
  25763. * @returns an array
  25764. */
  25765. getAnimationRanges(): Nullable<AnimationRange>[];
  25766. /**
  25767. * Will start the animation sequence
  25768. * @param name defines the range frames for animation sequence
  25769. * @param loop defines if the animation should loop (false by default)
  25770. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25771. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25772. * @returns the object created for this animation. If range does not exist, it will return null
  25773. */
  25774. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25775. /**
  25776. * Serialize animation ranges into a JSON compatible object
  25777. * @returns serialization object
  25778. */
  25779. serializeAnimationRanges(): any;
  25780. /**
  25781. * Computes the world matrix of the node
  25782. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25783. * @returns the world matrix
  25784. */
  25785. computeWorldMatrix(force?: boolean): Matrix;
  25786. /**
  25787. * Releases resources associated with this node.
  25788. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25789. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25790. */
  25791. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25792. /**
  25793. * Parse animation range data from a serialization object and store them into a given node
  25794. * @param node defines where to store the animation ranges
  25795. * @param parsedNode defines the serialization object to read data from
  25796. * @param scene defines the hosting scene
  25797. */
  25798. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25799. /**
  25800. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25801. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25802. * @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
  25803. * @returns the new bounding vectors
  25804. */
  25805. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25806. min: Vector3;
  25807. max: Vector3;
  25808. };
  25809. }
  25810. }
  25811. declare module BABYLON {
  25812. /**
  25813. * @hidden
  25814. */
  25815. export class _IAnimationState {
  25816. key: number;
  25817. repeatCount: number;
  25818. workValue?: any;
  25819. loopMode?: number;
  25820. offsetValue?: any;
  25821. highLimitValue?: any;
  25822. }
  25823. /**
  25824. * Class used to store any kind of animation
  25825. */
  25826. export class Animation {
  25827. /**Name of the animation */
  25828. name: string;
  25829. /**Property to animate */
  25830. targetProperty: string;
  25831. /**The frames per second of the animation */
  25832. framePerSecond: number;
  25833. /**The data type of the animation */
  25834. dataType: number;
  25835. /**The loop mode of the animation */
  25836. loopMode?: number | undefined;
  25837. /**Specifies if blending should be enabled */
  25838. enableBlending?: boolean | undefined;
  25839. /**
  25840. * Use matrix interpolation instead of using direct key value when animating matrices
  25841. */
  25842. static AllowMatricesInterpolation: boolean;
  25843. /**
  25844. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25845. */
  25846. static AllowMatrixDecomposeForInterpolation: boolean;
  25847. /**
  25848. * Stores the key frames of the animation
  25849. */
  25850. private _keys;
  25851. /**
  25852. * Stores the easing function of the animation
  25853. */
  25854. private _easingFunction;
  25855. /**
  25856. * @hidden Internal use only
  25857. */
  25858. _runtimeAnimations: RuntimeAnimation[];
  25859. /**
  25860. * The set of event that will be linked to this animation
  25861. */
  25862. private _events;
  25863. /**
  25864. * Stores an array of target property paths
  25865. */
  25866. targetPropertyPath: string[];
  25867. /**
  25868. * Stores the blending speed of the animation
  25869. */
  25870. blendingSpeed: number;
  25871. /**
  25872. * Stores the animation ranges for the animation
  25873. */
  25874. private _ranges;
  25875. /**
  25876. * @hidden Internal use
  25877. */
  25878. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25879. /**
  25880. * Sets up an animation
  25881. * @param property The property to animate
  25882. * @param animationType The animation type to apply
  25883. * @param framePerSecond The frames per second of the animation
  25884. * @param easingFunction The easing function used in the animation
  25885. * @returns The created animation
  25886. */
  25887. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25888. /**
  25889. * Create and start an animation on a node
  25890. * @param name defines the name of the global animation that will be run on all nodes
  25891. * @param node defines the root node where the animation will take place
  25892. * @param targetProperty defines property to animate
  25893. * @param framePerSecond defines the number of frame per second yo use
  25894. * @param totalFrame defines the number of frames in total
  25895. * @param from defines the initial value
  25896. * @param to defines the final value
  25897. * @param loopMode defines which loop mode you want to use (off by default)
  25898. * @param easingFunction defines the easing function to use (linear by default)
  25899. * @param onAnimationEnd defines the callback to call when animation end
  25900. * @returns the animatable created for this animation
  25901. */
  25902. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25903. /**
  25904. * Create and start an animation on a node and its descendants
  25905. * @param name defines the name of the global animation that will be run on all nodes
  25906. * @param node defines the root node where the animation will take place
  25907. * @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
  25908. * @param targetProperty defines property to animate
  25909. * @param framePerSecond defines the number of frame per second to use
  25910. * @param totalFrame defines the number of frames in total
  25911. * @param from defines the initial value
  25912. * @param to defines the final value
  25913. * @param loopMode defines which loop mode you want to use (off by default)
  25914. * @param easingFunction defines the easing function to use (linear by default)
  25915. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25916. * @returns the list of animatables created for all nodes
  25917. * @example https://www.babylonjs-playground.com/#MH0VLI
  25918. */
  25919. 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[]>;
  25920. /**
  25921. * Creates a new animation, merges it with the existing animations and starts it
  25922. * @param name Name of the animation
  25923. * @param node Node which contains the scene that begins the animations
  25924. * @param targetProperty Specifies which property to animate
  25925. * @param framePerSecond The frames per second of the animation
  25926. * @param totalFrame The total number of frames
  25927. * @param from The frame at the beginning of the animation
  25928. * @param to The frame at the end of the animation
  25929. * @param loopMode Specifies the loop mode of the animation
  25930. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25931. * @param onAnimationEnd Callback to run once the animation is complete
  25932. * @returns Nullable animation
  25933. */
  25934. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25935. /**
  25936. * Transition property of an host to the target Value
  25937. * @param property The property to transition
  25938. * @param targetValue The target Value of the property
  25939. * @param host The object where the property to animate belongs
  25940. * @param scene Scene used to run the animation
  25941. * @param frameRate Framerate (in frame/s) to use
  25942. * @param transition The transition type we want to use
  25943. * @param duration The duration of the animation, in milliseconds
  25944. * @param onAnimationEnd Callback trigger at the end of the animation
  25945. * @returns Nullable animation
  25946. */
  25947. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25948. /**
  25949. * Return the array of runtime animations currently using this animation
  25950. */
  25951. readonly runtimeAnimations: RuntimeAnimation[];
  25952. /**
  25953. * Specifies if any of the runtime animations are currently running
  25954. */
  25955. readonly hasRunningRuntimeAnimations: boolean;
  25956. /**
  25957. * Initializes the animation
  25958. * @param name Name of the animation
  25959. * @param targetProperty Property to animate
  25960. * @param framePerSecond The frames per second of the animation
  25961. * @param dataType The data type of the animation
  25962. * @param loopMode The loop mode of the animation
  25963. * @param enableBlending Specifies if blending should be enabled
  25964. */
  25965. constructor(
  25966. /**Name of the animation */
  25967. name: string,
  25968. /**Property to animate */
  25969. targetProperty: string,
  25970. /**The frames per second of the animation */
  25971. framePerSecond: number,
  25972. /**The data type of the animation */
  25973. dataType: number,
  25974. /**The loop mode of the animation */
  25975. loopMode?: number | undefined,
  25976. /**Specifies if blending should be enabled */
  25977. enableBlending?: boolean | undefined);
  25978. /**
  25979. * Converts the animation to a string
  25980. * @param fullDetails support for multiple levels of logging within scene loading
  25981. * @returns String form of the animation
  25982. */
  25983. toString(fullDetails?: boolean): string;
  25984. /**
  25985. * Add an event to this animation
  25986. * @param event Event to add
  25987. */
  25988. addEvent(event: AnimationEvent): void;
  25989. /**
  25990. * Remove all events found at the given frame
  25991. * @param frame The frame to remove events from
  25992. */
  25993. removeEvents(frame: number): void;
  25994. /**
  25995. * Retrieves all the events from the animation
  25996. * @returns Events from the animation
  25997. */
  25998. getEvents(): AnimationEvent[];
  25999. /**
  26000. * Creates an animation range
  26001. * @param name Name of the animation range
  26002. * @param from Starting frame of the animation range
  26003. * @param to Ending frame of the animation
  26004. */
  26005. createRange(name: string, from: number, to: number): void;
  26006. /**
  26007. * Deletes an animation range by name
  26008. * @param name Name of the animation range to delete
  26009. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26010. */
  26011. deleteRange(name: string, deleteFrames?: boolean): void;
  26012. /**
  26013. * Gets the animation range by name, or null if not defined
  26014. * @param name Name of the animation range
  26015. * @returns Nullable animation range
  26016. */
  26017. getRange(name: string): Nullable<AnimationRange>;
  26018. /**
  26019. * Gets the key frames from the animation
  26020. * @returns The key frames of the animation
  26021. */
  26022. getKeys(): Array<IAnimationKey>;
  26023. /**
  26024. * Gets the highest frame rate of the animation
  26025. * @returns Highest frame rate of the animation
  26026. */
  26027. getHighestFrame(): number;
  26028. /**
  26029. * Gets the easing function of the animation
  26030. * @returns Easing function of the animation
  26031. */
  26032. getEasingFunction(): IEasingFunction;
  26033. /**
  26034. * Sets the easing function of the animation
  26035. * @param easingFunction A custom mathematical formula for animation
  26036. */
  26037. setEasingFunction(easingFunction: EasingFunction): void;
  26038. /**
  26039. * Interpolates a scalar linearly
  26040. * @param startValue Start value of the animation curve
  26041. * @param endValue End value of the animation curve
  26042. * @param gradient Scalar amount to interpolate
  26043. * @returns Interpolated scalar value
  26044. */
  26045. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26046. /**
  26047. * Interpolates a scalar cubically
  26048. * @param startValue Start value of the animation curve
  26049. * @param outTangent End tangent of the animation
  26050. * @param endValue End value of the animation curve
  26051. * @param inTangent Start tangent of the animation curve
  26052. * @param gradient Scalar amount to interpolate
  26053. * @returns Interpolated scalar value
  26054. */
  26055. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26056. /**
  26057. * Interpolates a quaternion using a spherical linear interpolation
  26058. * @param startValue Start value of the animation curve
  26059. * @param endValue End value of the animation curve
  26060. * @param gradient Scalar amount to interpolate
  26061. * @returns Interpolated quaternion value
  26062. */
  26063. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26064. /**
  26065. * Interpolates a quaternion cubically
  26066. * @param startValue Start value of the animation curve
  26067. * @param outTangent End tangent of the animation curve
  26068. * @param endValue End value of the animation curve
  26069. * @param inTangent Start tangent of the animation curve
  26070. * @param gradient Scalar amount to interpolate
  26071. * @returns Interpolated quaternion value
  26072. */
  26073. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26074. /**
  26075. * Interpolates a Vector3 linearl
  26076. * @param startValue Start value of the animation curve
  26077. * @param endValue End value of the animation curve
  26078. * @param gradient Scalar amount to interpolate
  26079. * @returns Interpolated scalar value
  26080. */
  26081. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26082. /**
  26083. * Interpolates a Vector3 cubically
  26084. * @param startValue Start value of the animation curve
  26085. * @param outTangent End tangent of the animation
  26086. * @param endValue End value of the animation curve
  26087. * @param inTangent Start tangent of the animation curve
  26088. * @param gradient Scalar amount to interpolate
  26089. * @returns InterpolatedVector3 value
  26090. */
  26091. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26092. /**
  26093. * Interpolates a Vector2 linearly
  26094. * @param startValue Start value of the animation curve
  26095. * @param endValue End value of the animation curve
  26096. * @param gradient Scalar amount to interpolate
  26097. * @returns Interpolated Vector2 value
  26098. */
  26099. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26100. /**
  26101. * Interpolates a Vector2 cubically
  26102. * @param startValue Start value of the animation curve
  26103. * @param outTangent End tangent of the animation
  26104. * @param endValue End value of the animation curve
  26105. * @param inTangent Start tangent of the animation curve
  26106. * @param gradient Scalar amount to interpolate
  26107. * @returns Interpolated Vector2 value
  26108. */
  26109. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26110. /**
  26111. * Interpolates a size linearly
  26112. * @param startValue Start value of the animation curve
  26113. * @param endValue End value of the animation curve
  26114. * @param gradient Scalar amount to interpolate
  26115. * @returns Interpolated Size value
  26116. */
  26117. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26118. /**
  26119. * Interpolates a Color3 linearly
  26120. * @param startValue Start value of the animation curve
  26121. * @param endValue End value of the animation curve
  26122. * @param gradient Scalar amount to interpolate
  26123. * @returns Interpolated Color3 value
  26124. */
  26125. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26126. /**
  26127. * @hidden Internal use only
  26128. */
  26129. _getKeyValue(value: any): any;
  26130. /**
  26131. * @hidden Internal use only
  26132. */
  26133. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26134. /**
  26135. * Defines the function to use to interpolate matrices
  26136. * @param startValue defines the start matrix
  26137. * @param endValue defines the end matrix
  26138. * @param gradient defines the gradient between both matrices
  26139. * @param result defines an optional target matrix where to store the interpolation
  26140. * @returns the interpolated matrix
  26141. */
  26142. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26143. /**
  26144. * Makes a copy of the animation
  26145. * @returns Cloned animation
  26146. */
  26147. clone(): Animation;
  26148. /**
  26149. * Sets the key frames of the animation
  26150. * @param values The animation key frames to set
  26151. */
  26152. setKeys(values: Array<IAnimationKey>): void;
  26153. /**
  26154. * Serializes the animation to an object
  26155. * @returns Serialized object
  26156. */
  26157. serialize(): any;
  26158. /**
  26159. * Float animation type
  26160. */
  26161. private static _ANIMATIONTYPE_FLOAT;
  26162. /**
  26163. * Vector3 animation type
  26164. */
  26165. private static _ANIMATIONTYPE_VECTOR3;
  26166. /**
  26167. * Quaternion animation type
  26168. */
  26169. private static _ANIMATIONTYPE_QUATERNION;
  26170. /**
  26171. * Matrix animation type
  26172. */
  26173. private static _ANIMATIONTYPE_MATRIX;
  26174. /**
  26175. * Color3 animation type
  26176. */
  26177. private static _ANIMATIONTYPE_COLOR3;
  26178. /**
  26179. * Vector2 animation type
  26180. */
  26181. private static _ANIMATIONTYPE_VECTOR2;
  26182. /**
  26183. * Size animation type
  26184. */
  26185. private static _ANIMATIONTYPE_SIZE;
  26186. /**
  26187. * Relative Loop Mode
  26188. */
  26189. private static _ANIMATIONLOOPMODE_RELATIVE;
  26190. /**
  26191. * Cycle Loop Mode
  26192. */
  26193. private static _ANIMATIONLOOPMODE_CYCLE;
  26194. /**
  26195. * Constant Loop Mode
  26196. */
  26197. private static _ANIMATIONLOOPMODE_CONSTANT;
  26198. /**
  26199. * Get the float animation type
  26200. */
  26201. static readonly ANIMATIONTYPE_FLOAT: number;
  26202. /**
  26203. * Get the Vector3 animation type
  26204. */
  26205. static readonly ANIMATIONTYPE_VECTOR3: number;
  26206. /**
  26207. * Get the Vector2 animation type
  26208. */
  26209. static readonly ANIMATIONTYPE_VECTOR2: number;
  26210. /**
  26211. * Get the Size animation type
  26212. */
  26213. static readonly ANIMATIONTYPE_SIZE: number;
  26214. /**
  26215. * Get the Quaternion animation type
  26216. */
  26217. static readonly ANIMATIONTYPE_QUATERNION: number;
  26218. /**
  26219. * Get the Matrix animation type
  26220. */
  26221. static readonly ANIMATIONTYPE_MATRIX: number;
  26222. /**
  26223. * Get the Color3 animation type
  26224. */
  26225. static readonly ANIMATIONTYPE_COLOR3: number;
  26226. /**
  26227. * Get the Relative Loop Mode
  26228. */
  26229. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26230. /**
  26231. * Get the Cycle Loop Mode
  26232. */
  26233. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26234. /**
  26235. * Get the Constant Loop Mode
  26236. */
  26237. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26238. /** @hidden */
  26239. static _UniversalLerp(left: any, right: any, amount: number): any;
  26240. /**
  26241. * Parses an animation object and creates an animation
  26242. * @param parsedAnimation Parsed animation object
  26243. * @returns Animation object
  26244. */
  26245. static Parse(parsedAnimation: any): Animation;
  26246. /**
  26247. * Appends the serialized animations from the source animations
  26248. * @param source Source containing the animations
  26249. * @param destination Target to store the animations
  26250. */
  26251. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26252. }
  26253. }
  26254. declare module BABYLON {
  26255. /**
  26256. * Base class of all the textures in babylon.
  26257. * It groups all the common properties the materials, post process, lights... might need
  26258. * in order to make a correct use of the texture.
  26259. */
  26260. export class BaseTexture implements IAnimatable {
  26261. /**
  26262. * Default anisotropic filtering level for the application.
  26263. * It is set to 4 as a good tradeoff between perf and quality.
  26264. */
  26265. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26266. /**
  26267. * Gets or sets the unique id of the texture
  26268. */
  26269. uniqueId: number;
  26270. /**
  26271. * Define the name of the texture.
  26272. */
  26273. name: string;
  26274. /**
  26275. * Gets or sets an object used to store user defined information.
  26276. */
  26277. metadata: any;
  26278. /**
  26279. * For internal use only. Please do not use.
  26280. */
  26281. reservedDataStore: any;
  26282. private _hasAlpha;
  26283. /**
  26284. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26285. */
  26286. hasAlpha: boolean;
  26287. /**
  26288. * Defines if the alpha value should be determined via the rgb values.
  26289. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26290. */
  26291. getAlphaFromRGB: boolean;
  26292. /**
  26293. * Intensity or strength of the texture.
  26294. * It is commonly used by materials to fine tune the intensity of the texture
  26295. */
  26296. level: number;
  26297. /**
  26298. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26299. * This is part of the texture as textures usually maps to one uv set.
  26300. */
  26301. coordinatesIndex: number;
  26302. private _coordinatesMode;
  26303. /**
  26304. * How a texture is mapped.
  26305. *
  26306. * | Value | Type | Description |
  26307. * | ----- | ----------------------------------- | ----------- |
  26308. * | 0 | EXPLICIT_MODE | |
  26309. * | 1 | SPHERICAL_MODE | |
  26310. * | 2 | PLANAR_MODE | |
  26311. * | 3 | CUBIC_MODE | |
  26312. * | 4 | PROJECTION_MODE | |
  26313. * | 5 | SKYBOX_MODE | |
  26314. * | 6 | INVCUBIC_MODE | |
  26315. * | 7 | EQUIRECTANGULAR_MODE | |
  26316. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26317. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26318. */
  26319. coordinatesMode: number;
  26320. /**
  26321. * | Value | Type | Description |
  26322. * | ----- | ------------------ | ----------- |
  26323. * | 0 | CLAMP_ADDRESSMODE | |
  26324. * | 1 | WRAP_ADDRESSMODE | |
  26325. * | 2 | MIRROR_ADDRESSMODE | |
  26326. */
  26327. wrapU: number;
  26328. /**
  26329. * | Value | Type | Description |
  26330. * | ----- | ------------------ | ----------- |
  26331. * | 0 | CLAMP_ADDRESSMODE | |
  26332. * | 1 | WRAP_ADDRESSMODE | |
  26333. * | 2 | MIRROR_ADDRESSMODE | |
  26334. */
  26335. wrapV: number;
  26336. /**
  26337. * | Value | Type | Description |
  26338. * | ----- | ------------------ | ----------- |
  26339. * | 0 | CLAMP_ADDRESSMODE | |
  26340. * | 1 | WRAP_ADDRESSMODE | |
  26341. * | 2 | MIRROR_ADDRESSMODE | |
  26342. */
  26343. wrapR: number;
  26344. /**
  26345. * With compliant hardware and browser (supporting anisotropic filtering)
  26346. * this defines the level of anisotropic filtering in the texture.
  26347. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26348. */
  26349. anisotropicFilteringLevel: number;
  26350. /**
  26351. * Define if the texture is a cube texture or if false a 2d texture.
  26352. */
  26353. isCube: boolean;
  26354. /**
  26355. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26356. */
  26357. is3D: boolean;
  26358. /**
  26359. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26360. * HDR texture are usually stored in linear space.
  26361. * This only impacts the PBR and Background materials
  26362. */
  26363. gammaSpace: boolean;
  26364. /**
  26365. * Gets whether or not the texture contains RGBD data.
  26366. */
  26367. readonly isRGBD: boolean;
  26368. /**
  26369. * Is Z inverted in the texture (useful in a cube texture).
  26370. */
  26371. invertZ: boolean;
  26372. /**
  26373. * Are mip maps generated for this texture or not.
  26374. */
  26375. readonly noMipmap: boolean;
  26376. /**
  26377. * @hidden
  26378. */
  26379. lodLevelInAlpha: boolean;
  26380. /**
  26381. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26382. */
  26383. lodGenerationOffset: number;
  26384. /**
  26385. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26386. */
  26387. lodGenerationScale: number;
  26388. /**
  26389. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  26390. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  26391. * average roughness values.
  26392. */
  26393. linearSpecularLOD: boolean;
  26394. /**
  26395. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  26396. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  26397. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  26398. */
  26399. irradianceTexture: Nullable<BaseTexture>;
  26400. /**
  26401. * Define if the texture is a render target.
  26402. */
  26403. isRenderTarget: boolean;
  26404. /**
  26405. * Define the unique id of the texture in the scene.
  26406. */
  26407. readonly uid: string;
  26408. /**
  26409. * Return a string representation of the texture.
  26410. * @returns the texture as a string
  26411. */
  26412. toString(): string;
  26413. /**
  26414. * Get the class name of the texture.
  26415. * @returns "BaseTexture"
  26416. */
  26417. getClassName(): string;
  26418. /**
  26419. * Define the list of animation attached to the texture.
  26420. */
  26421. animations: Animation[];
  26422. /**
  26423. * An event triggered when the texture is disposed.
  26424. */
  26425. onDisposeObservable: Observable<BaseTexture>;
  26426. private _onDisposeObserver;
  26427. /**
  26428. * Callback triggered when the texture has been disposed.
  26429. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26430. */
  26431. onDispose: () => void;
  26432. /**
  26433. * Define the current state of the loading sequence when in delayed load mode.
  26434. */
  26435. delayLoadState: number;
  26436. private _scene;
  26437. /** @hidden */
  26438. _texture: Nullable<InternalTexture>;
  26439. private _uid;
  26440. /**
  26441. * Define if the texture is preventinga material to render or not.
  26442. * If not and the texture is not ready, the engine will use a default black texture instead.
  26443. */
  26444. readonly isBlocking: boolean;
  26445. /**
  26446. * Instantiates a new BaseTexture.
  26447. * Base class of all the textures in babylon.
  26448. * It groups all the common properties the materials, post process, lights... might need
  26449. * in order to make a correct use of the texture.
  26450. * @param scene Define the scene the texture blongs to
  26451. */
  26452. constructor(scene: Nullable<Scene>);
  26453. /**
  26454. * Get the scene the texture belongs to.
  26455. * @returns the scene or null if undefined
  26456. */
  26457. getScene(): Nullable<Scene>;
  26458. /**
  26459. * Get the texture transform matrix used to offset tile the texture for istance.
  26460. * @returns the transformation matrix
  26461. */
  26462. getTextureMatrix(): Matrix;
  26463. /**
  26464. * Get the texture reflection matrix used to rotate/transform the reflection.
  26465. * @returns the reflection matrix
  26466. */
  26467. getReflectionTextureMatrix(): Matrix;
  26468. /**
  26469. * Get the underlying lower level texture from Babylon.
  26470. * @returns the insternal texture
  26471. */
  26472. getInternalTexture(): Nullable<InternalTexture>;
  26473. /**
  26474. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26475. * @returns true if ready or not blocking
  26476. */
  26477. isReadyOrNotBlocking(): boolean;
  26478. /**
  26479. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26480. * @returns true if fully ready
  26481. */
  26482. isReady(): boolean;
  26483. private _cachedSize;
  26484. /**
  26485. * Get the size of the texture.
  26486. * @returns the texture size.
  26487. */
  26488. getSize(): ISize;
  26489. /**
  26490. * Get the base size of the texture.
  26491. * It can be different from the size if the texture has been resized for POT for instance
  26492. * @returns the base size
  26493. */
  26494. getBaseSize(): ISize;
  26495. /**
  26496. * Update the sampling mode of the texture.
  26497. * Default is Trilinear mode.
  26498. *
  26499. * | Value | Type | Description |
  26500. * | ----- | ------------------ | ----------- |
  26501. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26502. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26503. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26504. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26505. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26506. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26507. * | 7 | NEAREST_LINEAR | |
  26508. * | 8 | NEAREST_NEAREST | |
  26509. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26510. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26511. * | 11 | LINEAR_LINEAR | |
  26512. * | 12 | LINEAR_NEAREST | |
  26513. *
  26514. * > _mag_: magnification filter (close to the viewer)
  26515. * > _min_: minification filter (far from the viewer)
  26516. * > _mip_: filter used between mip map levels
  26517. *@param samplingMode Define the new sampling mode of the texture
  26518. */
  26519. updateSamplingMode(samplingMode: number): void;
  26520. /**
  26521. * Scales the texture if is `canRescale()`
  26522. * @param ratio the resize factor we want to use to rescale
  26523. */
  26524. scale(ratio: number): void;
  26525. /**
  26526. * Get if the texture can rescale.
  26527. */
  26528. readonly canRescale: boolean;
  26529. /** @hidden */
  26530. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26531. /** @hidden */
  26532. _rebuild(): void;
  26533. /**
  26534. * Triggers the load sequence in delayed load mode.
  26535. */
  26536. delayLoad(): void;
  26537. /**
  26538. * Clones the texture.
  26539. * @returns the cloned texture
  26540. */
  26541. clone(): Nullable<BaseTexture>;
  26542. /**
  26543. * Get the texture underlying type (INT, FLOAT...)
  26544. */
  26545. readonly textureType: number;
  26546. /**
  26547. * Get the texture underlying format (RGB, RGBA...)
  26548. */
  26549. readonly textureFormat: number;
  26550. /**
  26551. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26552. * This will returns an RGBA array buffer containing either in values (0-255) or
  26553. * float values (0-1) depending of the underlying buffer type.
  26554. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26555. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26556. * @param buffer defines a user defined buffer to fill with data (can be null)
  26557. * @returns The Array buffer containing the pixels data.
  26558. */
  26559. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26560. /**
  26561. * Release and destroy the underlying lower level texture aka internalTexture.
  26562. */
  26563. releaseInternalTexture(): void;
  26564. /**
  26565. * Get the polynomial representation of the texture data.
  26566. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26567. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26568. */
  26569. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26570. /** @hidden */
  26571. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26572. /** @hidden */
  26573. readonly _lodTextureMid: Nullable<BaseTexture>;
  26574. /** @hidden */
  26575. readonly _lodTextureLow: Nullable<BaseTexture>;
  26576. /**
  26577. * Dispose the texture and release its associated resources.
  26578. */
  26579. dispose(): void;
  26580. /**
  26581. * Serialize the texture into a JSON representation that can be parsed later on.
  26582. * @returns the JSON representation of the texture
  26583. */
  26584. serialize(): any;
  26585. /**
  26586. * Helper function to be called back once a list of texture contains only ready textures.
  26587. * @param textures Define the list of textures to wait for
  26588. * @param callback Define the callback triggered once the entire list will be ready
  26589. */
  26590. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26591. }
  26592. }
  26593. declare module BABYLON {
  26594. /**
  26595. * Uniform buffer objects.
  26596. *
  26597. * Handles blocks of uniform on the GPU.
  26598. *
  26599. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26600. *
  26601. * For more information, please refer to :
  26602. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26603. */
  26604. export class UniformBuffer {
  26605. private _engine;
  26606. private _buffer;
  26607. private _data;
  26608. private _bufferData;
  26609. private _dynamic?;
  26610. private _uniformLocations;
  26611. private _uniformSizes;
  26612. private _uniformLocationPointer;
  26613. private _needSync;
  26614. private _noUBO;
  26615. private _currentEffect;
  26616. private static _MAX_UNIFORM_SIZE;
  26617. private static _tempBuffer;
  26618. /**
  26619. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26620. * This is dynamic to allow compat with webgl 1 and 2.
  26621. * You will need to pass the name of the uniform as well as the value.
  26622. */
  26623. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26624. /**
  26625. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26626. * This is dynamic to allow compat with webgl 1 and 2.
  26627. * You will need to pass the name of the uniform as well as the value.
  26628. */
  26629. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26630. /**
  26631. * Lambda to Update a single float in a uniform buffer.
  26632. * This is dynamic to allow compat with webgl 1 and 2.
  26633. * You will need to pass the name of the uniform as well as the value.
  26634. */
  26635. updateFloat: (name: string, x: number) => void;
  26636. /**
  26637. * Lambda to Update a vec2 of float in a uniform buffer.
  26638. * This is dynamic to allow compat with webgl 1 and 2.
  26639. * You will need to pass the name of the uniform as well as the value.
  26640. */
  26641. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26642. /**
  26643. * Lambda to Update a vec3 of float in a uniform buffer.
  26644. * This is dynamic to allow compat with webgl 1 and 2.
  26645. * You will need to pass the name of the uniform as well as the value.
  26646. */
  26647. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26648. /**
  26649. * Lambda to Update a vec4 of float in a uniform buffer.
  26650. * This is dynamic to allow compat with webgl 1 and 2.
  26651. * You will need to pass the name of the uniform as well as the value.
  26652. */
  26653. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26654. /**
  26655. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26656. * This is dynamic to allow compat with webgl 1 and 2.
  26657. * You will need to pass the name of the uniform as well as the value.
  26658. */
  26659. updateMatrix: (name: string, mat: Matrix) => void;
  26660. /**
  26661. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26662. * This is dynamic to allow compat with webgl 1 and 2.
  26663. * You will need to pass the name of the uniform as well as the value.
  26664. */
  26665. updateVector3: (name: string, vector: Vector3) => void;
  26666. /**
  26667. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26668. * This is dynamic to allow compat with webgl 1 and 2.
  26669. * You will need to pass the name of the uniform as well as the value.
  26670. */
  26671. updateVector4: (name: string, vector: Vector4) => void;
  26672. /**
  26673. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26674. * This is dynamic to allow compat with webgl 1 and 2.
  26675. * You will need to pass the name of the uniform as well as the value.
  26676. */
  26677. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26678. /**
  26679. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26680. * This is dynamic to allow compat with webgl 1 and 2.
  26681. * You will need to pass the name of the uniform as well as the value.
  26682. */
  26683. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26684. /**
  26685. * Instantiates a new Uniform buffer objects.
  26686. *
  26687. * Handles blocks of uniform on the GPU.
  26688. *
  26689. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26690. *
  26691. * For more information, please refer to :
  26692. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26693. * @param engine Define the engine the buffer is associated with
  26694. * @param data Define the data contained in the buffer
  26695. * @param dynamic Define if the buffer is updatable
  26696. */
  26697. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26698. /**
  26699. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26700. * or just falling back on setUniformXXX calls.
  26701. */
  26702. readonly useUbo: boolean;
  26703. /**
  26704. * Indicates if the WebGL underlying uniform buffer is in sync
  26705. * with the javascript cache data.
  26706. */
  26707. readonly isSync: boolean;
  26708. /**
  26709. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26710. * Also, a dynamic UniformBuffer will disable cache verification and always
  26711. * update the underlying WebGL uniform buffer to the GPU.
  26712. * @returns if Dynamic, otherwise false
  26713. */
  26714. isDynamic(): boolean;
  26715. /**
  26716. * The data cache on JS side.
  26717. * @returns the underlying data as a float array
  26718. */
  26719. getData(): Float32Array;
  26720. /**
  26721. * The underlying WebGL Uniform buffer.
  26722. * @returns the webgl buffer
  26723. */
  26724. getBuffer(): Nullable<DataBuffer>;
  26725. /**
  26726. * std140 layout specifies how to align data within an UBO structure.
  26727. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26728. * for specs.
  26729. */
  26730. private _fillAlignment;
  26731. /**
  26732. * Adds an uniform in the buffer.
  26733. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26734. * for the layout to be correct !
  26735. * @param name Name of the uniform, as used in the uniform block in the shader.
  26736. * @param size Data size, or data directly.
  26737. */
  26738. addUniform(name: string, size: number | number[]): void;
  26739. /**
  26740. * Adds a Matrix 4x4 to the uniform buffer.
  26741. * @param name Name of the uniform, as used in the uniform block in the shader.
  26742. * @param mat A 4x4 matrix.
  26743. */
  26744. addMatrix(name: string, mat: Matrix): void;
  26745. /**
  26746. * Adds a vec2 to the uniform buffer.
  26747. * @param name Name of the uniform, as used in the uniform block in the shader.
  26748. * @param x Define the x component value of the vec2
  26749. * @param y Define the y component value of the vec2
  26750. */
  26751. addFloat2(name: string, x: number, y: number): void;
  26752. /**
  26753. * Adds a vec3 to the uniform buffer.
  26754. * @param name Name of the uniform, as used in the uniform block in the shader.
  26755. * @param x Define the x component value of the vec3
  26756. * @param y Define the y component value of the vec3
  26757. * @param z Define the z component value of the vec3
  26758. */
  26759. addFloat3(name: string, x: number, y: number, z: number): void;
  26760. /**
  26761. * Adds a vec3 to the uniform buffer.
  26762. * @param name Name of the uniform, as used in the uniform block in the shader.
  26763. * @param color Define the vec3 from a Color
  26764. */
  26765. addColor3(name: string, color: Color3): void;
  26766. /**
  26767. * Adds a vec4 to the uniform buffer.
  26768. * @param name Name of the uniform, as used in the uniform block in the shader.
  26769. * @param color Define the rgb components from a Color
  26770. * @param alpha Define the a component of the vec4
  26771. */
  26772. addColor4(name: string, color: Color3, alpha: number): void;
  26773. /**
  26774. * Adds a vec3 to the uniform buffer.
  26775. * @param name Name of the uniform, as used in the uniform block in the shader.
  26776. * @param vector Define the vec3 components from a Vector
  26777. */
  26778. addVector3(name: string, vector: Vector3): void;
  26779. /**
  26780. * Adds a Matrix 3x3 to the uniform buffer.
  26781. * @param name Name of the uniform, as used in the uniform block in the shader.
  26782. */
  26783. addMatrix3x3(name: string): void;
  26784. /**
  26785. * Adds a Matrix 2x2 to the uniform buffer.
  26786. * @param name Name of the uniform, as used in the uniform block in the shader.
  26787. */
  26788. addMatrix2x2(name: string): void;
  26789. /**
  26790. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26791. */
  26792. create(): void;
  26793. /** @hidden */
  26794. _rebuild(): void;
  26795. /**
  26796. * Updates the WebGL Uniform Buffer on the GPU.
  26797. * If the `dynamic` flag is set to true, no cache comparison is done.
  26798. * Otherwise, the buffer will be updated only if the cache differs.
  26799. */
  26800. update(): void;
  26801. /**
  26802. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26803. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26804. * @param data Define the flattened data
  26805. * @param size Define the size of the data.
  26806. */
  26807. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26808. private _updateMatrix3x3ForUniform;
  26809. private _updateMatrix3x3ForEffect;
  26810. private _updateMatrix2x2ForEffect;
  26811. private _updateMatrix2x2ForUniform;
  26812. private _updateFloatForEffect;
  26813. private _updateFloatForUniform;
  26814. private _updateFloat2ForEffect;
  26815. private _updateFloat2ForUniform;
  26816. private _updateFloat3ForEffect;
  26817. private _updateFloat3ForUniform;
  26818. private _updateFloat4ForEffect;
  26819. private _updateFloat4ForUniform;
  26820. private _updateMatrixForEffect;
  26821. private _updateMatrixForUniform;
  26822. private _updateVector3ForEffect;
  26823. private _updateVector3ForUniform;
  26824. private _updateVector4ForEffect;
  26825. private _updateVector4ForUniform;
  26826. private _updateColor3ForEffect;
  26827. private _updateColor3ForUniform;
  26828. private _updateColor4ForEffect;
  26829. private _updateColor4ForUniform;
  26830. /**
  26831. * Sets a sampler uniform on the effect.
  26832. * @param name Define the name of the sampler.
  26833. * @param texture Define the texture to set in the sampler
  26834. */
  26835. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26836. /**
  26837. * Directly updates the value of the uniform in the cache AND on the GPU.
  26838. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26839. * @param data Define the flattened data
  26840. */
  26841. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26842. /**
  26843. * Binds this uniform buffer to an effect.
  26844. * @param effect Define the effect to bind the buffer to
  26845. * @param name Name of the uniform block in the shader.
  26846. */
  26847. bindToEffect(effect: Effect, name: string): void;
  26848. /**
  26849. * Disposes the uniform buffer.
  26850. */
  26851. dispose(): void;
  26852. }
  26853. }
  26854. declare module BABYLON {
  26855. /**
  26856. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26857. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26858. */
  26859. export class Analyser {
  26860. /**
  26861. * Gets or sets the smoothing
  26862. * @ignorenaming
  26863. */
  26864. SMOOTHING: number;
  26865. /**
  26866. * Gets or sets the FFT table size
  26867. * @ignorenaming
  26868. */
  26869. FFT_SIZE: number;
  26870. /**
  26871. * Gets or sets the bar graph amplitude
  26872. * @ignorenaming
  26873. */
  26874. BARGRAPHAMPLITUDE: number;
  26875. /**
  26876. * Gets or sets the position of the debug canvas
  26877. * @ignorenaming
  26878. */
  26879. DEBUGCANVASPOS: {
  26880. x: number;
  26881. y: number;
  26882. };
  26883. /**
  26884. * Gets or sets the debug canvas size
  26885. * @ignorenaming
  26886. */
  26887. DEBUGCANVASSIZE: {
  26888. width: number;
  26889. height: number;
  26890. };
  26891. private _byteFreqs;
  26892. private _byteTime;
  26893. private _floatFreqs;
  26894. private _webAudioAnalyser;
  26895. private _debugCanvas;
  26896. private _debugCanvasContext;
  26897. private _scene;
  26898. private _registerFunc;
  26899. private _audioEngine;
  26900. /**
  26901. * Creates a new analyser
  26902. * @param scene defines hosting scene
  26903. */
  26904. constructor(scene: Scene);
  26905. /**
  26906. * Get the number of data values you will have to play with for the visualization
  26907. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26908. * @returns a number
  26909. */
  26910. getFrequencyBinCount(): number;
  26911. /**
  26912. * Gets the current frequency data as a byte array
  26913. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26914. * @returns a Uint8Array
  26915. */
  26916. getByteFrequencyData(): Uint8Array;
  26917. /**
  26918. * Gets the current waveform as a byte array
  26919. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26920. * @returns a Uint8Array
  26921. */
  26922. getByteTimeDomainData(): Uint8Array;
  26923. /**
  26924. * Gets the current frequency data as a float array
  26925. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26926. * @returns a Float32Array
  26927. */
  26928. getFloatFrequencyData(): Float32Array;
  26929. /**
  26930. * Renders the debug canvas
  26931. */
  26932. drawDebugCanvas(): void;
  26933. /**
  26934. * Stops rendering the debug canvas and removes it
  26935. */
  26936. stopDebugCanvas(): void;
  26937. /**
  26938. * Connects two audio nodes
  26939. * @param inputAudioNode defines first node to connect
  26940. * @param outputAudioNode defines second node to connect
  26941. */
  26942. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26943. /**
  26944. * Releases all associated resources
  26945. */
  26946. dispose(): void;
  26947. }
  26948. }
  26949. declare module BABYLON {
  26950. /**
  26951. * This represents an audio engine and it is responsible
  26952. * to play, synchronize and analyse sounds throughout the application.
  26953. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26954. */
  26955. export interface IAudioEngine extends IDisposable {
  26956. /**
  26957. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26958. */
  26959. readonly canUseWebAudio: boolean;
  26960. /**
  26961. * Gets the current AudioContext if available.
  26962. */
  26963. readonly audioContext: Nullable<AudioContext>;
  26964. /**
  26965. * The master gain node defines the global audio volume of your audio engine.
  26966. */
  26967. readonly masterGain: GainNode;
  26968. /**
  26969. * Gets whether or not mp3 are supported by your browser.
  26970. */
  26971. readonly isMP3supported: boolean;
  26972. /**
  26973. * Gets whether or not ogg are supported by your browser.
  26974. */
  26975. readonly isOGGsupported: boolean;
  26976. /**
  26977. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26978. * @ignoreNaming
  26979. */
  26980. WarnedWebAudioUnsupported: boolean;
  26981. /**
  26982. * Defines if the audio engine relies on a custom unlocked button.
  26983. * In this case, the embedded button will not be displayed.
  26984. */
  26985. useCustomUnlockedButton: boolean;
  26986. /**
  26987. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26988. */
  26989. readonly unlocked: boolean;
  26990. /**
  26991. * Event raised when audio has been unlocked on the browser.
  26992. */
  26993. onAudioUnlockedObservable: Observable<AudioEngine>;
  26994. /**
  26995. * Event raised when audio has been locked on the browser.
  26996. */
  26997. onAudioLockedObservable: Observable<AudioEngine>;
  26998. /**
  26999. * Flags the audio engine in Locked state.
  27000. * This happens due to new browser policies preventing audio to autoplay.
  27001. */
  27002. lock(): void;
  27003. /**
  27004. * Unlocks the audio engine once a user action has been done on the dom.
  27005. * This is helpful to resume play once browser policies have been satisfied.
  27006. */
  27007. unlock(): void;
  27008. }
  27009. /**
  27010. * This represents the default audio engine used in babylon.
  27011. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27012. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27013. */
  27014. export class AudioEngine implements IAudioEngine {
  27015. private _audioContext;
  27016. private _audioContextInitialized;
  27017. private _muteButton;
  27018. private _hostElement;
  27019. /**
  27020. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27021. */
  27022. canUseWebAudio: boolean;
  27023. /**
  27024. * The master gain node defines the global audio volume of your audio engine.
  27025. */
  27026. masterGain: GainNode;
  27027. /**
  27028. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27029. * @ignoreNaming
  27030. */
  27031. WarnedWebAudioUnsupported: boolean;
  27032. /**
  27033. * Gets whether or not mp3 are supported by your browser.
  27034. */
  27035. isMP3supported: boolean;
  27036. /**
  27037. * Gets whether or not ogg are supported by your browser.
  27038. */
  27039. isOGGsupported: boolean;
  27040. /**
  27041. * Gets whether audio has been unlocked on the device.
  27042. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27043. * a user interaction has happened.
  27044. */
  27045. unlocked: boolean;
  27046. /**
  27047. * Defines if the audio engine relies on a custom unlocked button.
  27048. * In this case, the embedded button will not be displayed.
  27049. */
  27050. useCustomUnlockedButton: boolean;
  27051. /**
  27052. * Event raised when audio has been unlocked on the browser.
  27053. */
  27054. onAudioUnlockedObservable: Observable<AudioEngine>;
  27055. /**
  27056. * Event raised when audio has been locked on the browser.
  27057. */
  27058. onAudioLockedObservable: Observable<AudioEngine>;
  27059. /**
  27060. * Gets the current AudioContext if available.
  27061. */
  27062. readonly audioContext: Nullable<AudioContext>;
  27063. private _connectedAnalyser;
  27064. /**
  27065. * Instantiates a new audio engine.
  27066. *
  27067. * There should be only one per page as some browsers restrict the number
  27068. * of audio contexts you can create.
  27069. * @param hostElement defines the host element where to display the mute icon if necessary
  27070. */
  27071. constructor(hostElement?: Nullable<HTMLElement>);
  27072. /**
  27073. * Flags the audio engine in Locked state.
  27074. * This happens due to new browser policies preventing audio to autoplay.
  27075. */
  27076. lock(): void;
  27077. /**
  27078. * Unlocks the audio engine once a user action has been done on the dom.
  27079. * This is helpful to resume play once browser policies have been satisfied.
  27080. */
  27081. unlock(): void;
  27082. private _resumeAudioContext;
  27083. private _initializeAudioContext;
  27084. private _tryToRun;
  27085. private _triggerRunningState;
  27086. private _triggerSuspendedState;
  27087. private _displayMuteButton;
  27088. private _moveButtonToTopLeft;
  27089. private _onResize;
  27090. private _hideMuteButton;
  27091. /**
  27092. * Destroy and release the resources associated with the audio ccontext.
  27093. */
  27094. dispose(): void;
  27095. /**
  27096. * Gets the global volume sets on the master gain.
  27097. * @returns the global volume if set or -1 otherwise
  27098. */
  27099. getGlobalVolume(): number;
  27100. /**
  27101. * Sets the global volume of your experience (sets on the master gain).
  27102. * @param newVolume Defines the new global volume of the application
  27103. */
  27104. setGlobalVolume(newVolume: number): void;
  27105. /**
  27106. * Connect the audio engine to an audio analyser allowing some amazing
  27107. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27108. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27109. * @param analyser The analyser to connect to the engine
  27110. */
  27111. connectToAnalyser(analyser: Analyser): void;
  27112. }
  27113. }
  27114. declare module BABYLON {
  27115. /**
  27116. * Interface used to present a loading screen while loading a scene
  27117. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27118. */
  27119. export interface ILoadingScreen {
  27120. /**
  27121. * Function called to display the loading screen
  27122. */
  27123. displayLoadingUI: () => void;
  27124. /**
  27125. * Function called to hide the loading screen
  27126. */
  27127. hideLoadingUI: () => void;
  27128. /**
  27129. * Gets or sets the color to use for the background
  27130. */
  27131. loadingUIBackgroundColor: string;
  27132. /**
  27133. * Gets or sets the text to display while loading
  27134. */
  27135. loadingUIText: string;
  27136. }
  27137. /**
  27138. * Class used for the default loading screen
  27139. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27140. */
  27141. export class DefaultLoadingScreen implements ILoadingScreen {
  27142. private _renderingCanvas;
  27143. private _loadingText;
  27144. private _loadingDivBackgroundColor;
  27145. private _loadingDiv;
  27146. private _loadingTextDiv;
  27147. /** Gets or sets the logo url to use for the default loading screen */
  27148. static DefaultLogoUrl: string;
  27149. /** Gets or sets the spinner url to use for the default loading screen */
  27150. static DefaultSpinnerUrl: string;
  27151. /**
  27152. * Creates a new default loading screen
  27153. * @param _renderingCanvas defines the canvas used to render the scene
  27154. * @param _loadingText defines the default text to display
  27155. * @param _loadingDivBackgroundColor defines the default background color
  27156. */
  27157. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27158. /**
  27159. * Function called to display the loading screen
  27160. */
  27161. displayLoadingUI(): void;
  27162. /**
  27163. * Function called to hide the loading screen
  27164. */
  27165. hideLoadingUI(): void;
  27166. /**
  27167. * Gets or sets the text to display while loading
  27168. */
  27169. loadingUIText: string;
  27170. /**
  27171. * Gets or sets the color to use for the background
  27172. */
  27173. loadingUIBackgroundColor: string;
  27174. private _resizeLoadingUI;
  27175. }
  27176. }
  27177. declare module BABYLON {
  27178. /** @hidden */
  27179. export class WebGLPipelineContext implements IPipelineContext {
  27180. engine: Engine;
  27181. program: Nullable<WebGLProgram>;
  27182. context?: WebGLRenderingContext;
  27183. vertexShader?: WebGLShader;
  27184. fragmentShader?: WebGLShader;
  27185. isParallelCompiled: boolean;
  27186. onCompiled?: () => void;
  27187. transformFeedback?: WebGLTransformFeedback | null;
  27188. readonly isAsync: boolean;
  27189. readonly isReady: boolean;
  27190. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27191. }
  27192. }
  27193. declare module BABYLON {
  27194. /** @hidden */
  27195. export class WebGLDataBuffer extends DataBuffer {
  27196. private _buffer;
  27197. constructor(resource: WebGLBuffer);
  27198. readonly underlyingResource: any;
  27199. }
  27200. }
  27201. declare module BABYLON {
  27202. /** @hidden */
  27203. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27204. attributeProcessor(attribute: string): string;
  27205. varyingProcessor(varying: string, isFragment: boolean): string;
  27206. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27207. }
  27208. }
  27209. declare module BABYLON {
  27210. /**
  27211. * Settings for finer control over video usage
  27212. */
  27213. export interface VideoTextureSettings {
  27214. /**
  27215. * Applies `autoplay` to video, if specified
  27216. */
  27217. autoPlay?: boolean;
  27218. /**
  27219. * Applies `loop` to video, if specified
  27220. */
  27221. loop?: boolean;
  27222. /**
  27223. * Automatically updates internal texture from video at every frame in the render loop
  27224. */
  27225. autoUpdateTexture: boolean;
  27226. /**
  27227. * Image src displayed during the video loading or until the user interacts with the video.
  27228. */
  27229. poster?: string;
  27230. }
  27231. /**
  27232. * If you want to display a video in your scene, this is the special texture for that.
  27233. * This special texture works similar to other textures, with the exception of a few parameters.
  27234. * @see https://doc.babylonjs.com/how_to/video_texture
  27235. */
  27236. export class VideoTexture extends Texture {
  27237. /**
  27238. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27239. */
  27240. readonly autoUpdateTexture: boolean;
  27241. /**
  27242. * The video instance used by the texture internally
  27243. */
  27244. readonly video: HTMLVideoElement;
  27245. private _onUserActionRequestedObservable;
  27246. /**
  27247. * Event triggerd when a dom action is required by the user to play the video.
  27248. * This happens due to recent changes in browser policies preventing video to auto start.
  27249. */
  27250. readonly onUserActionRequestedObservable: Observable<Texture>;
  27251. private _generateMipMaps;
  27252. private _engine;
  27253. private _stillImageCaptured;
  27254. private _displayingPosterTexture;
  27255. private _settings;
  27256. private _createInternalTextureOnEvent;
  27257. /**
  27258. * Creates a video texture.
  27259. * If you want to display a video in your scene, this is the special texture for that.
  27260. * This special texture works similar to other textures, with the exception of a few parameters.
  27261. * @see https://doc.babylonjs.com/how_to/video_texture
  27262. * @param name optional name, will detect from video source, if not defined
  27263. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27264. * @param scene is obviously the current scene.
  27265. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27266. * @param invertY is false by default but can be used to invert video on Y axis
  27267. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27268. * @param settings allows finer control over video usage
  27269. */
  27270. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27271. private _getName;
  27272. private _getVideo;
  27273. private _createInternalTexture;
  27274. private reset;
  27275. /**
  27276. * @hidden Internal method to initiate `update`.
  27277. */
  27278. _rebuild(): void;
  27279. /**
  27280. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27281. */
  27282. update(): void;
  27283. /**
  27284. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27285. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27286. */
  27287. updateTexture(isVisible: boolean): void;
  27288. protected _updateInternalTexture: () => void;
  27289. /**
  27290. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27291. * @param url New url.
  27292. */
  27293. updateURL(url: string): void;
  27294. /**
  27295. * Dispose the texture and release its associated resources.
  27296. */
  27297. dispose(): void;
  27298. /**
  27299. * Creates a video texture straight from a stream.
  27300. * @param scene Define the scene the texture should be created in
  27301. * @param stream Define the stream the texture should be created from
  27302. * @returns The created video texture as a promise
  27303. */
  27304. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27305. /**
  27306. * Creates a video texture straight from your WebCam video feed.
  27307. * @param scene Define the scene the texture should be created in
  27308. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27309. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27310. * @returns The created video texture as a promise
  27311. */
  27312. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27313. minWidth: number;
  27314. maxWidth: number;
  27315. minHeight: number;
  27316. maxHeight: number;
  27317. deviceId: string;
  27318. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27319. /**
  27320. * Creates a video texture straight from your WebCam video feed.
  27321. * @param scene Define the scene the texture should be created in
  27322. * @param onReady Define a callback to triggered once the texture will be ready
  27323. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27324. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27325. */
  27326. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27327. minWidth: number;
  27328. maxWidth: number;
  27329. minHeight: number;
  27330. maxHeight: number;
  27331. deviceId: string;
  27332. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27333. }
  27334. }
  27335. declare module BABYLON {
  27336. /**
  27337. * Interface for attribute information associated with buffer instanciation
  27338. */
  27339. export class InstancingAttributeInfo {
  27340. /**
  27341. * Index/offset of the attribute in the vertex shader
  27342. */
  27343. index: number;
  27344. /**
  27345. * size of the attribute, 1, 2, 3 or 4
  27346. */
  27347. attributeSize: number;
  27348. /**
  27349. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27350. * default is FLOAT
  27351. */
  27352. attribyteType: number;
  27353. /**
  27354. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27355. */
  27356. normalized: boolean;
  27357. /**
  27358. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27359. */
  27360. offset: number;
  27361. /**
  27362. * Name of the GLSL attribute, for debugging purpose only
  27363. */
  27364. attributeName: string;
  27365. }
  27366. /**
  27367. * Define options used to create a depth texture
  27368. */
  27369. export class DepthTextureCreationOptions {
  27370. /** Specifies whether or not a stencil should be allocated in the texture */
  27371. generateStencil?: boolean;
  27372. /** Specifies whether or not bilinear filtering is enable on the texture */
  27373. bilinearFiltering?: boolean;
  27374. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27375. comparisonFunction?: number;
  27376. /** Specifies if the created texture is a cube texture */
  27377. isCube?: boolean;
  27378. }
  27379. /**
  27380. * Class used to describe the capabilities of the engine relatively to the current browser
  27381. */
  27382. export class EngineCapabilities {
  27383. /** Maximum textures units per fragment shader */
  27384. maxTexturesImageUnits: number;
  27385. /** Maximum texture units per vertex shader */
  27386. maxVertexTextureImageUnits: number;
  27387. /** Maximum textures units in the entire pipeline */
  27388. maxCombinedTexturesImageUnits: number;
  27389. /** Maximum texture size */
  27390. maxTextureSize: number;
  27391. /** Maximum cube texture size */
  27392. maxCubemapTextureSize: number;
  27393. /** Maximum render texture size */
  27394. maxRenderTextureSize: number;
  27395. /** Maximum number of vertex attributes */
  27396. maxVertexAttribs: number;
  27397. /** Maximum number of varyings */
  27398. maxVaryingVectors: number;
  27399. /** Maximum number of uniforms per vertex shader */
  27400. maxVertexUniformVectors: number;
  27401. /** Maximum number of uniforms per fragment shader */
  27402. maxFragmentUniformVectors: number;
  27403. /** Defines if standard derivates (dx/dy) are supported */
  27404. standardDerivatives: boolean;
  27405. /** Defines if s3tc texture compression is supported */
  27406. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27407. /** Defines if pvrtc texture compression is supported */
  27408. pvrtc: any;
  27409. /** Defines if etc1 texture compression is supported */
  27410. etc1: any;
  27411. /** Defines if etc2 texture compression is supported */
  27412. etc2: any;
  27413. /** Defines if astc texture compression is supported */
  27414. astc: any;
  27415. /** Defines if float textures are supported */
  27416. textureFloat: boolean;
  27417. /** Defines if vertex array objects are supported */
  27418. vertexArrayObject: boolean;
  27419. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27420. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27421. /** Gets the maximum level of anisotropy supported */
  27422. maxAnisotropy: number;
  27423. /** Defines if instancing is supported */
  27424. instancedArrays: boolean;
  27425. /** Defines if 32 bits indices are supported */
  27426. uintIndices: boolean;
  27427. /** Defines if high precision shaders are supported */
  27428. highPrecisionShaderSupported: boolean;
  27429. /** Defines if depth reading in the fragment shader is supported */
  27430. fragmentDepthSupported: boolean;
  27431. /** Defines if float texture linear filtering is supported*/
  27432. textureFloatLinearFiltering: boolean;
  27433. /** Defines if rendering to float textures is supported */
  27434. textureFloatRender: boolean;
  27435. /** Defines if half float textures are supported*/
  27436. textureHalfFloat: boolean;
  27437. /** Defines if half float texture linear filtering is supported*/
  27438. textureHalfFloatLinearFiltering: boolean;
  27439. /** Defines if rendering to half float textures is supported */
  27440. textureHalfFloatRender: boolean;
  27441. /** Defines if textureLOD shader command is supported */
  27442. textureLOD: boolean;
  27443. /** Defines if draw buffers extension is supported */
  27444. drawBuffersExtension: boolean;
  27445. /** Defines if depth textures are supported */
  27446. depthTextureExtension: boolean;
  27447. /** Defines if float color buffer are supported */
  27448. colorBufferFloat: boolean;
  27449. /** Gets disjoint timer query extension (null if not supported) */
  27450. timerQuery: EXT_disjoint_timer_query;
  27451. /** Defines if timestamp can be used with timer query */
  27452. canUseTimestampForTimerQuery: boolean;
  27453. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27454. multiview: any;
  27455. /** Function used to let the system compiles shaders in background */
  27456. parallelShaderCompile: {
  27457. COMPLETION_STATUS_KHR: number;
  27458. };
  27459. }
  27460. /** Interface defining initialization parameters for Engine class */
  27461. export interface EngineOptions extends WebGLContextAttributes {
  27462. /**
  27463. * Defines if the engine should no exceed a specified device ratio
  27464. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27465. */
  27466. limitDeviceRatio?: number;
  27467. /**
  27468. * Defines if webvr should be enabled automatically
  27469. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27470. */
  27471. autoEnableWebVR?: boolean;
  27472. /**
  27473. * Defines if webgl2 should be turned off even if supported
  27474. * @see http://doc.babylonjs.com/features/webgl2
  27475. */
  27476. disableWebGL2Support?: boolean;
  27477. /**
  27478. * Defines if webaudio should be initialized as well
  27479. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27480. */
  27481. audioEngine?: boolean;
  27482. /**
  27483. * Defines if animations should run using a deterministic lock step
  27484. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27485. */
  27486. deterministicLockstep?: boolean;
  27487. /** Defines the maximum steps to use with deterministic lock step mode */
  27488. lockstepMaxSteps?: number;
  27489. /**
  27490. * Defines that engine should ignore context lost events
  27491. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27492. */
  27493. doNotHandleContextLost?: boolean;
  27494. /**
  27495. * Defines that engine should ignore modifying touch action attribute and style
  27496. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27497. */
  27498. doNotHandleTouchAction?: boolean;
  27499. /**
  27500. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27501. */
  27502. useHighPrecisionFloats?: boolean;
  27503. }
  27504. /**
  27505. * Defines the interface used by display changed events
  27506. */
  27507. export interface IDisplayChangedEventArgs {
  27508. /** Gets the vrDisplay object (if any) */
  27509. vrDisplay: Nullable<any>;
  27510. /** Gets a boolean indicating if webVR is supported */
  27511. vrSupported: boolean;
  27512. }
  27513. /**
  27514. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27515. */
  27516. export class Engine {
  27517. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27518. static ExceptionList: ({
  27519. key: string;
  27520. capture: string;
  27521. captureConstraint: number;
  27522. targets: string[];
  27523. } | {
  27524. key: string;
  27525. capture: null;
  27526. captureConstraint: null;
  27527. targets: string[];
  27528. })[];
  27529. /** Gets the list of created engines */
  27530. static readonly Instances: Engine[];
  27531. /**
  27532. * Gets the latest created engine
  27533. */
  27534. static readonly LastCreatedEngine: Nullable<Engine>;
  27535. /**
  27536. * Gets the latest created scene
  27537. */
  27538. static readonly LastCreatedScene: Nullable<Scene>;
  27539. /**
  27540. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27541. * @param flag defines which part of the materials must be marked as dirty
  27542. * @param predicate defines a predicate used to filter which materials should be affected
  27543. */
  27544. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27545. /** @hidden */
  27546. static _TextureLoaders: IInternalTextureLoader[];
  27547. /** Defines that alpha blending is disabled */
  27548. static readonly ALPHA_DISABLE: number;
  27549. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27550. static readonly ALPHA_ADD: number;
  27551. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27552. static readonly ALPHA_COMBINE: number;
  27553. /** Defines that alpha blending to DEST - SRC * DEST */
  27554. static readonly ALPHA_SUBTRACT: number;
  27555. /** Defines that alpha blending to SRC * DEST */
  27556. static readonly ALPHA_MULTIPLY: number;
  27557. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27558. static readonly ALPHA_MAXIMIZED: number;
  27559. /** Defines that alpha blending to SRC + DEST */
  27560. static readonly ALPHA_ONEONE: number;
  27561. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27562. static readonly ALPHA_PREMULTIPLIED: number;
  27563. /**
  27564. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27565. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27566. */
  27567. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27568. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27569. static readonly ALPHA_INTERPOLATE: number;
  27570. /**
  27571. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27572. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27573. */
  27574. static readonly ALPHA_SCREENMODE: number;
  27575. /** Defines that the ressource is not delayed*/
  27576. static readonly DELAYLOADSTATE_NONE: number;
  27577. /** Defines that the ressource was successfully delay loaded */
  27578. static readonly DELAYLOADSTATE_LOADED: number;
  27579. /** Defines that the ressource is currently delay loading */
  27580. static readonly DELAYLOADSTATE_LOADING: number;
  27581. /** Defines that the ressource is delayed and has not started loading */
  27582. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27583. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27584. static readonly NEVER: number;
  27585. /** 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 */
  27586. static readonly ALWAYS: number;
  27587. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27588. static readonly LESS: number;
  27589. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27590. static readonly EQUAL: number;
  27591. /** 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 */
  27592. static readonly LEQUAL: number;
  27593. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27594. static readonly GREATER: number;
  27595. /** 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 */
  27596. static readonly GEQUAL: number;
  27597. /** 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 */
  27598. static readonly NOTEQUAL: number;
  27599. /** Passed to stencilOperation to specify that stencil value must be kept */
  27600. static readonly KEEP: number;
  27601. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27602. static readonly REPLACE: number;
  27603. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27604. static readonly INCR: number;
  27605. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27606. static readonly DECR: number;
  27607. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27608. static readonly INVERT: number;
  27609. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27610. static readonly INCR_WRAP: number;
  27611. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27612. static readonly DECR_WRAP: number;
  27613. /** Texture is not repeating outside of 0..1 UVs */
  27614. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27615. /** Texture is repeating outside of 0..1 UVs */
  27616. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27617. /** Texture is repeating and mirrored */
  27618. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27619. /** ALPHA */
  27620. static readonly TEXTUREFORMAT_ALPHA: number;
  27621. /** LUMINANCE */
  27622. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27623. /** LUMINANCE_ALPHA */
  27624. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27625. /** RGB */
  27626. static readonly TEXTUREFORMAT_RGB: number;
  27627. /** RGBA */
  27628. static readonly TEXTUREFORMAT_RGBA: number;
  27629. /** RED */
  27630. static readonly TEXTUREFORMAT_RED: number;
  27631. /** RED (2nd reference) */
  27632. static readonly TEXTUREFORMAT_R: number;
  27633. /** RG */
  27634. static readonly TEXTUREFORMAT_RG: number;
  27635. /** RED_INTEGER */
  27636. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27637. /** RED_INTEGER (2nd reference) */
  27638. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27639. /** RG_INTEGER */
  27640. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27641. /** RGB_INTEGER */
  27642. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27643. /** RGBA_INTEGER */
  27644. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27645. /** UNSIGNED_BYTE */
  27646. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27647. /** UNSIGNED_BYTE (2nd reference) */
  27648. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27649. /** FLOAT */
  27650. static readonly TEXTURETYPE_FLOAT: number;
  27651. /** HALF_FLOAT */
  27652. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27653. /** BYTE */
  27654. static readonly TEXTURETYPE_BYTE: number;
  27655. /** SHORT */
  27656. static readonly TEXTURETYPE_SHORT: number;
  27657. /** UNSIGNED_SHORT */
  27658. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27659. /** INT */
  27660. static readonly TEXTURETYPE_INT: number;
  27661. /** UNSIGNED_INT */
  27662. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27663. /** UNSIGNED_SHORT_4_4_4_4 */
  27664. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27665. /** UNSIGNED_SHORT_5_5_5_1 */
  27666. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27667. /** UNSIGNED_SHORT_5_6_5 */
  27668. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27669. /** UNSIGNED_INT_2_10_10_10_REV */
  27670. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27671. /** UNSIGNED_INT_24_8 */
  27672. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27673. /** UNSIGNED_INT_10F_11F_11F_REV */
  27674. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27675. /** UNSIGNED_INT_5_9_9_9_REV */
  27676. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27677. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27678. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27679. /** nearest is mag = nearest and min = nearest and mip = linear */
  27680. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27681. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27682. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27683. /** Trilinear is mag = linear and min = linear and mip = linear */
  27684. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27685. /** nearest is mag = nearest and min = nearest and mip = linear */
  27686. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27687. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27688. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27689. /** Trilinear is mag = linear and min = linear and mip = linear */
  27690. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27691. /** mag = nearest and min = nearest and mip = nearest */
  27692. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27693. /** mag = nearest and min = linear and mip = nearest */
  27694. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27695. /** mag = nearest and min = linear and mip = linear */
  27696. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27697. /** mag = nearest and min = linear and mip = none */
  27698. static readonly TEXTURE_NEAREST_LINEAR: number;
  27699. /** mag = nearest and min = nearest and mip = none */
  27700. static readonly TEXTURE_NEAREST_NEAREST: number;
  27701. /** mag = linear and min = nearest and mip = nearest */
  27702. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27703. /** mag = linear and min = nearest and mip = linear */
  27704. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27705. /** mag = linear and min = linear and mip = none */
  27706. static readonly TEXTURE_LINEAR_LINEAR: number;
  27707. /** mag = linear and min = nearest and mip = none */
  27708. static readonly TEXTURE_LINEAR_NEAREST: number;
  27709. /** Explicit coordinates mode */
  27710. static readonly TEXTURE_EXPLICIT_MODE: number;
  27711. /** Spherical coordinates mode */
  27712. static readonly TEXTURE_SPHERICAL_MODE: number;
  27713. /** Planar coordinates mode */
  27714. static readonly TEXTURE_PLANAR_MODE: number;
  27715. /** Cubic coordinates mode */
  27716. static readonly TEXTURE_CUBIC_MODE: number;
  27717. /** Projection coordinates mode */
  27718. static readonly TEXTURE_PROJECTION_MODE: number;
  27719. /** Skybox coordinates mode */
  27720. static readonly TEXTURE_SKYBOX_MODE: number;
  27721. /** Inverse Cubic coordinates mode */
  27722. static readonly TEXTURE_INVCUBIC_MODE: number;
  27723. /** Equirectangular coordinates mode */
  27724. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27725. /** Equirectangular Fixed coordinates mode */
  27726. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27727. /** Equirectangular Fixed Mirrored coordinates mode */
  27728. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27729. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27730. static readonly SCALEMODE_FLOOR: number;
  27731. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27732. static readonly SCALEMODE_NEAREST: number;
  27733. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27734. static readonly SCALEMODE_CEILING: number;
  27735. /**
  27736. * Returns the current npm package of the sdk
  27737. */
  27738. static readonly NpmPackage: string;
  27739. /**
  27740. * Returns the current version of the framework
  27741. */
  27742. static readonly Version: string;
  27743. /**
  27744. * Returns a string describing the current engine
  27745. */
  27746. readonly description: string;
  27747. /**
  27748. * Gets or sets the epsilon value used by collision engine
  27749. */
  27750. static CollisionsEpsilon: number;
  27751. /**
  27752. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27753. */
  27754. static ShadersRepository: string;
  27755. /**
  27756. * Method called to create the default loading screen.
  27757. * This can be overriden in your own app.
  27758. * @param canvas The rendering canvas element
  27759. * @returns The loading screen
  27760. */
  27761. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27762. /**
  27763. * Method called to create the default rescale post process on each engine.
  27764. */
  27765. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27766. /** @hidden */
  27767. _shaderProcessor: IShaderProcessor;
  27768. /**
  27769. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27770. */
  27771. forcePOTTextures: boolean;
  27772. /**
  27773. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27774. */
  27775. isFullscreen: boolean;
  27776. /**
  27777. * Gets a boolean indicating if the pointer is currently locked
  27778. */
  27779. isPointerLock: boolean;
  27780. /**
  27781. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27782. */
  27783. cullBackFaces: boolean;
  27784. /**
  27785. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27786. */
  27787. renderEvenInBackground: boolean;
  27788. /**
  27789. * Gets or sets a boolean indicating that cache can be kept between frames
  27790. */
  27791. preventCacheWipeBetweenFrames: boolean;
  27792. /**
  27793. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27794. **/
  27795. enableOfflineSupport: boolean;
  27796. /**
  27797. * 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)
  27798. **/
  27799. disableManifestCheck: boolean;
  27800. /**
  27801. * Gets the list of created scenes
  27802. */
  27803. scenes: Scene[];
  27804. /**
  27805. * Event raised when a new scene is created
  27806. */
  27807. onNewSceneAddedObservable: Observable<Scene>;
  27808. /**
  27809. * Gets the list of created postprocesses
  27810. */
  27811. postProcesses: PostProcess[];
  27812. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27813. validateShaderPrograms: boolean;
  27814. /**
  27815. * Observable event triggered each time the rendering canvas is resized
  27816. */
  27817. onResizeObservable: Observable<Engine>;
  27818. /**
  27819. * Observable event triggered each time the canvas loses focus
  27820. */
  27821. onCanvasBlurObservable: Observable<Engine>;
  27822. /**
  27823. * Observable event triggered each time the canvas gains focus
  27824. */
  27825. onCanvasFocusObservable: Observable<Engine>;
  27826. /**
  27827. * Observable event triggered each time the canvas receives pointerout event
  27828. */
  27829. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27830. /**
  27831. * Observable event triggered before each texture is initialized
  27832. */
  27833. onBeforeTextureInitObservable: Observable<Texture>;
  27834. /**
  27835. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27836. */
  27837. disableUniformBuffers: boolean;
  27838. /** @hidden */
  27839. _uniformBuffers: UniformBuffer[];
  27840. /**
  27841. * Gets a boolean indicating that the engine supports uniform buffers
  27842. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27843. */
  27844. readonly supportsUniformBuffers: boolean;
  27845. /**
  27846. * Observable raised when the engine begins a new frame
  27847. */
  27848. onBeginFrameObservable: Observable<Engine>;
  27849. /**
  27850. * If set, will be used to request the next animation frame for the render loop
  27851. */
  27852. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27853. /**
  27854. * Observable raised when the engine ends the current frame
  27855. */
  27856. onEndFrameObservable: Observable<Engine>;
  27857. /**
  27858. * Observable raised when the engine is about to compile a shader
  27859. */
  27860. onBeforeShaderCompilationObservable: Observable<Engine>;
  27861. /**
  27862. * Observable raised when the engine has jsut compiled a shader
  27863. */
  27864. onAfterShaderCompilationObservable: Observable<Engine>;
  27865. /** @hidden */
  27866. _gl: WebGLRenderingContext;
  27867. private _renderingCanvas;
  27868. private _windowIsBackground;
  27869. private _webGLVersion;
  27870. protected _highPrecisionShadersAllowed: boolean;
  27871. /** @hidden */
  27872. readonly _shouldUseHighPrecisionShader: boolean;
  27873. /**
  27874. * Gets a boolean indicating that only power of 2 textures are supported
  27875. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27876. */
  27877. readonly needPOTTextures: boolean;
  27878. /** @hidden */
  27879. _badOS: boolean;
  27880. /** @hidden */
  27881. _badDesktopOS: boolean;
  27882. /**
  27883. * Gets the audio engine
  27884. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27885. * @ignorenaming
  27886. */
  27887. static audioEngine: IAudioEngine;
  27888. /**
  27889. * Default AudioEngine factory responsible of creating the Audio Engine.
  27890. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27891. */
  27892. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27893. /**
  27894. * Default offline support factory responsible of creating a tool used to store data locally.
  27895. * By default, this will create a Database object if the workload has been embedded.
  27896. */
  27897. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27898. private _onFocus;
  27899. private _onBlur;
  27900. private _onCanvasPointerOut;
  27901. private _onCanvasBlur;
  27902. private _onCanvasFocus;
  27903. private _onFullscreenChange;
  27904. private _onPointerLockChange;
  27905. private _hardwareScalingLevel;
  27906. /** @hidden */
  27907. _caps: EngineCapabilities;
  27908. private _pointerLockRequested;
  27909. private _isStencilEnable;
  27910. private _colorWrite;
  27911. private _loadingScreen;
  27912. /** @hidden */
  27913. _drawCalls: PerfCounter;
  27914. private _glVersion;
  27915. private _glRenderer;
  27916. private _glVendor;
  27917. private _videoTextureSupported;
  27918. private _renderingQueueLaunched;
  27919. private _activeRenderLoops;
  27920. private _deterministicLockstep;
  27921. private _lockstepMaxSteps;
  27922. /**
  27923. * Observable signaled when a context lost event is raised
  27924. */
  27925. onContextLostObservable: Observable<Engine>;
  27926. /**
  27927. * Observable signaled when a context restored event is raised
  27928. */
  27929. onContextRestoredObservable: Observable<Engine>;
  27930. private _onContextLost;
  27931. private _onContextRestored;
  27932. private _contextWasLost;
  27933. /** @hidden */
  27934. _doNotHandleContextLost: boolean;
  27935. /**
  27936. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27937. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27938. */
  27939. doNotHandleContextLost: boolean;
  27940. private _performanceMonitor;
  27941. private _fps;
  27942. private _deltaTime;
  27943. /**
  27944. * Turn this value on if you want to pause FPS computation when in background
  27945. */
  27946. disablePerformanceMonitorInBackground: boolean;
  27947. /**
  27948. * Gets the performance monitor attached to this engine
  27949. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27950. */
  27951. readonly performanceMonitor: PerformanceMonitor;
  27952. /**
  27953. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27954. */
  27955. disableVertexArrayObjects: boolean;
  27956. /** @hidden */
  27957. protected _depthCullingState: _DepthCullingState;
  27958. /** @hidden */
  27959. protected _stencilState: _StencilState;
  27960. /** @hidden */
  27961. protected _alphaState: _AlphaState;
  27962. /** @hidden */
  27963. protected _alphaMode: number;
  27964. /** @hidden */
  27965. _internalTexturesCache: InternalTexture[];
  27966. /** @hidden */
  27967. protected _activeChannel: number;
  27968. private _currentTextureChannel;
  27969. /** @hidden */
  27970. protected _boundTexturesCache: {
  27971. [key: string]: Nullable<InternalTexture>;
  27972. };
  27973. /** @hidden */
  27974. protected _currentEffect: Nullable<Effect>;
  27975. /** @hidden */
  27976. protected _currentProgram: Nullable<WebGLProgram>;
  27977. private _compiledEffects;
  27978. private _vertexAttribArraysEnabled;
  27979. /** @hidden */
  27980. protected _cachedViewport: Nullable<Viewport>;
  27981. private _cachedVertexArrayObject;
  27982. /** @hidden */
  27983. protected _cachedVertexBuffers: any;
  27984. /** @hidden */
  27985. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27986. /** @hidden */
  27987. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27988. /** @hidden */
  27989. _currentRenderTarget: Nullable<InternalTexture>;
  27990. private _uintIndicesCurrentlySet;
  27991. private _currentBoundBuffer;
  27992. /** @hidden */
  27993. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27994. private _currentBufferPointers;
  27995. private _currentInstanceLocations;
  27996. private _currentInstanceBuffers;
  27997. private _textureUnits;
  27998. /** @hidden */
  27999. _workingCanvas: Nullable<HTMLCanvasElement>;
  28000. /** @hidden */
  28001. _workingContext: Nullable<CanvasRenderingContext2D>;
  28002. private _rescalePostProcess;
  28003. private _dummyFramebuffer;
  28004. private _externalData;
  28005. /** @hidden */
  28006. _bindedRenderFunction: any;
  28007. private _vaoRecordInProgress;
  28008. private _mustWipeVertexAttributes;
  28009. private _emptyTexture;
  28010. private _emptyCubeTexture;
  28011. private _emptyTexture3D;
  28012. /** @hidden */
  28013. _frameHandler: number;
  28014. private _nextFreeTextureSlots;
  28015. private _maxSimultaneousTextures;
  28016. private _activeRequests;
  28017. private _texturesSupported;
  28018. /** @hidden */
  28019. _textureFormatInUse: Nullable<string>;
  28020. /**
  28021. * Gets the list of texture formats supported
  28022. */
  28023. readonly texturesSupported: Array<string>;
  28024. /**
  28025. * Gets the list of texture formats in use
  28026. */
  28027. readonly textureFormatInUse: Nullable<string>;
  28028. /**
  28029. * Gets the current viewport
  28030. */
  28031. readonly currentViewport: Nullable<Viewport>;
  28032. /**
  28033. * Gets the default empty texture
  28034. */
  28035. readonly emptyTexture: InternalTexture;
  28036. /**
  28037. * Gets the default empty 3D texture
  28038. */
  28039. readonly emptyTexture3D: InternalTexture;
  28040. /**
  28041. * Gets the default empty cube texture
  28042. */
  28043. readonly emptyCubeTexture: InternalTexture;
  28044. /**
  28045. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28046. */
  28047. readonly premultipliedAlpha: boolean;
  28048. /**
  28049. * Creates a new engine
  28050. * @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
  28051. * @param antialias defines enable antialiasing (default: false)
  28052. * @param options defines further options to be sent to the getContext() function
  28053. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28054. */
  28055. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28056. /**
  28057. * Initializes a webVR display and starts listening to display change events
  28058. * The onVRDisplayChangedObservable will be notified upon these changes
  28059. * @returns The onVRDisplayChangedObservable
  28060. */
  28061. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28062. /** @hidden */
  28063. _prepareVRComponent(): void;
  28064. /** @hidden */
  28065. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28066. /** @hidden */
  28067. _submitVRFrame(): void;
  28068. /**
  28069. * Call this function to leave webVR mode
  28070. * Will do nothing if webVR is not supported or if there is no webVR device
  28071. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28072. */
  28073. disableVR(): void;
  28074. /**
  28075. * Gets a boolean indicating that the system is in VR mode and is presenting
  28076. * @returns true if VR mode is engaged
  28077. */
  28078. isVRPresenting(): boolean;
  28079. /** @hidden */
  28080. _requestVRFrame(): void;
  28081. private _disableTouchAction;
  28082. private _rebuildInternalTextures;
  28083. private _rebuildEffects;
  28084. /**
  28085. * Gets a boolean indicating if all created effects are ready
  28086. * @returns true if all effects are ready
  28087. */
  28088. areAllEffectsReady(): boolean;
  28089. private _rebuildBuffers;
  28090. private _initGLContext;
  28091. /**
  28092. * Gets version of the current webGL context
  28093. */
  28094. readonly webGLVersion: number;
  28095. /**
  28096. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28097. */
  28098. readonly isStencilEnable: boolean;
  28099. /** @hidden */
  28100. _prepareWorkingCanvas(): void;
  28101. /**
  28102. * Reset the texture cache to empty state
  28103. */
  28104. resetTextureCache(): void;
  28105. /**
  28106. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28107. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28108. * @returns true if engine is in deterministic lock step mode
  28109. */
  28110. isDeterministicLockStep(): boolean;
  28111. /**
  28112. * Gets the max steps when engine is running in deterministic lock step
  28113. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28114. * @returns the max steps
  28115. */
  28116. getLockstepMaxSteps(): number;
  28117. /**
  28118. * Gets an object containing information about the current webGL context
  28119. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28120. */
  28121. getGlInfo(): {
  28122. vendor: string;
  28123. renderer: string;
  28124. version: string;
  28125. };
  28126. /**
  28127. * Gets current aspect ratio
  28128. * @param camera defines the camera to use to get the aspect ratio
  28129. * @param useScreen defines if screen size must be used (or the current render target if any)
  28130. * @returns a number defining the aspect ratio
  28131. */
  28132. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28133. /**
  28134. * Gets current screen aspect ratio
  28135. * @returns a number defining the aspect ratio
  28136. */
  28137. getScreenAspectRatio(): number;
  28138. /**
  28139. * Gets the current render width
  28140. * @param useScreen defines if screen size must be used (or the current render target if any)
  28141. * @returns a number defining the current render width
  28142. */
  28143. getRenderWidth(useScreen?: boolean): number;
  28144. /**
  28145. * Gets the current render height
  28146. * @param useScreen defines if screen size must be used (or the current render target if any)
  28147. * @returns a number defining the current render height
  28148. */
  28149. getRenderHeight(useScreen?: boolean): number;
  28150. /**
  28151. * Gets the HTML canvas attached with the current webGL context
  28152. * @returns a HTML canvas
  28153. */
  28154. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28155. /**
  28156. * Gets the client rect of the HTML canvas attached with the current webGL context
  28157. * @returns a client rectanglee
  28158. */
  28159. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28160. /**
  28161. * Defines the hardware scaling level.
  28162. * By default the hardware scaling level is computed from the window device ratio.
  28163. * 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.
  28164. * @param level defines the level to use
  28165. */
  28166. setHardwareScalingLevel(level: number): void;
  28167. /**
  28168. * Gets the current hardware scaling level.
  28169. * By default the hardware scaling level is computed from the window device ratio.
  28170. * 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.
  28171. * @returns a number indicating the current hardware scaling level
  28172. */
  28173. getHardwareScalingLevel(): number;
  28174. /**
  28175. * Gets the list of loaded textures
  28176. * @returns an array containing all loaded textures
  28177. */
  28178. getLoadedTexturesCache(): InternalTexture[];
  28179. /**
  28180. * Gets the object containing all engine capabilities
  28181. * @returns the EngineCapabilities object
  28182. */
  28183. getCaps(): EngineCapabilities;
  28184. /**
  28185. * Gets the current depth function
  28186. * @returns a number defining the depth function
  28187. */
  28188. getDepthFunction(): Nullable<number>;
  28189. /**
  28190. * Sets the current depth function
  28191. * @param depthFunc defines the function to use
  28192. */
  28193. setDepthFunction(depthFunc: number): void;
  28194. /**
  28195. * Sets the current depth function to GREATER
  28196. */
  28197. setDepthFunctionToGreater(): void;
  28198. /**
  28199. * Sets the current depth function to GEQUAL
  28200. */
  28201. setDepthFunctionToGreaterOrEqual(): void;
  28202. /**
  28203. * Sets the current depth function to LESS
  28204. */
  28205. setDepthFunctionToLess(): void;
  28206. private _cachedStencilBuffer;
  28207. private _cachedStencilFunction;
  28208. private _cachedStencilMask;
  28209. private _cachedStencilOperationPass;
  28210. private _cachedStencilOperationFail;
  28211. private _cachedStencilOperationDepthFail;
  28212. private _cachedStencilReference;
  28213. /**
  28214. * Caches the the state of the stencil buffer
  28215. */
  28216. cacheStencilState(): void;
  28217. /**
  28218. * Restores the state of the stencil buffer
  28219. */
  28220. restoreStencilState(): void;
  28221. /**
  28222. * Sets the current depth function to LEQUAL
  28223. */
  28224. setDepthFunctionToLessOrEqual(): void;
  28225. /**
  28226. * Gets a boolean indicating if stencil buffer is enabled
  28227. * @returns the current stencil buffer state
  28228. */
  28229. getStencilBuffer(): boolean;
  28230. /**
  28231. * Enable or disable the stencil buffer
  28232. * @param enable defines if the stencil buffer must be enabled or disabled
  28233. */
  28234. setStencilBuffer(enable: boolean): void;
  28235. /**
  28236. * Gets the current stencil mask
  28237. * @returns a number defining the new stencil mask to use
  28238. */
  28239. getStencilMask(): number;
  28240. /**
  28241. * Sets the current stencil mask
  28242. * @param mask defines the new stencil mask to use
  28243. */
  28244. setStencilMask(mask: number): void;
  28245. /**
  28246. * Gets the current stencil function
  28247. * @returns a number defining the stencil function to use
  28248. */
  28249. getStencilFunction(): number;
  28250. /**
  28251. * Gets the current stencil reference value
  28252. * @returns a number defining the stencil reference value to use
  28253. */
  28254. getStencilFunctionReference(): number;
  28255. /**
  28256. * Gets the current stencil mask
  28257. * @returns a number defining the stencil mask to use
  28258. */
  28259. getStencilFunctionMask(): number;
  28260. /**
  28261. * Sets the current stencil function
  28262. * @param stencilFunc defines the new stencil function to use
  28263. */
  28264. setStencilFunction(stencilFunc: number): void;
  28265. /**
  28266. * Sets the current stencil reference
  28267. * @param reference defines the new stencil reference to use
  28268. */
  28269. setStencilFunctionReference(reference: number): void;
  28270. /**
  28271. * Sets the current stencil mask
  28272. * @param mask defines the new stencil mask to use
  28273. */
  28274. setStencilFunctionMask(mask: number): void;
  28275. /**
  28276. * Gets the current stencil operation when stencil fails
  28277. * @returns a number defining stencil operation to use when stencil fails
  28278. */
  28279. getStencilOperationFail(): number;
  28280. /**
  28281. * Gets the current stencil operation when depth fails
  28282. * @returns a number defining stencil operation to use when depth fails
  28283. */
  28284. getStencilOperationDepthFail(): number;
  28285. /**
  28286. * Gets the current stencil operation when stencil passes
  28287. * @returns a number defining stencil operation to use when stencil passes
  28288. */
  28289. getStencilOperationPass(): number;
  28290. /**
  28291. * Sets the stencil operation to use when stencil fails
  28292. * @param operation defines the stencil operation to use when stencil fails
  28293. */
  28294. setStencilOperationFail(operation: number): void;
  28295. /**
  28296. * Sets the stencil operation to use when depth fails
  28297. * @param operation defines the stencil operation to use when depth fails
  28298. */
  28299. setStencilOperationDepthFail(operation: number): void;
  28300. /**
  28301. * Sets the stencil operation to use when stencil passes
  28302. * @param operation defines the stencil operation to use when stencil passes
  28303. */
  28304. setStencilOperationPass(operation: number): void;
  28305. /**
  28306. * Sets a boolean indicating if the dithering state is enabled or disabled
  28307. * @param value defines the dithering state
  28308. */
  28309. setDitheringState(value: boolean): void;
  28310. /**
  28311. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28312. * @param value defines the rasterizer state
  28313. */
  28314. setRasterizerState(value: boolean): void;
  28315. /**
  28316. * stop executing a render loop function and remove it from the execution array
  28317. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28318. */
  28319. stopRenderLoop(renderFunction?: () => void): void;
  28320. /** @hidden */
  28321. _renderLoop(): void;
  28322. /**
  28323. * Register and execute a render loop. The engine can have more than one render function
  28324. * @param renderFunction defines the function to continuously execute
  28325. */
  28326. runRenderLoop(renderFunction: () => void): void;
  28327. /**
  28328. * Toggle full screen mode
  28329. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28330. */
  28331. switchFullscreen(requestPointerLock: boolean): void;
  28332. /**
  28333. * Enters full screen mode
  28334. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28335. */
  28336. enterFullscreen(requestPointerLock: boolean): void;
  28337. /**
  28338. * Exits full screen mode
  28339. */
  28340. exitFullscreen(): void;
  28341. /**
  28342. * Enters Pointerlock mode
  28343. */
  28344. enterPointerlock(): void;
  28345. /**
  28346. * Exits Pointerlock mode
  28347. */
  28348. exitPointerlock(): void;
  28349. /**
  28350. * Clear the current render buffer or the current render target (if any is set up)
  28351. * @param color defines the color to use
  28352. * @param backBuffer defines if the back buffer must be cleared
  28353. * @param depth defines if the depth buffer must be cleared
  28354. * @param stencil defines if the stencil buffer must be cleared
  28355. */
  28356. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28357. /**
  28358. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28359. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28360. * @param y defines the y-coordinate of the corner of the clear rectangle
  28361. * @param width defines the width of the clear rectangle
  28362. * @param height defines the height of the clear rectangle
  28363. * @param clearColor defines the clear color
  28364. */
  28365. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28366. /**
  28367. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28368. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28369. * @param y defines the y-coordinate of the corner of the clear rectangle
  28370. * @param width defines the width of the clear rectangle
  28371. * @param height defines the height of the clear rectangle
  28372. */
  28373. enableScissor(x: number, y: number, width: number, height: number): void;
  28374. /**
  28375. * Disable previously set scissor test rectangle
  28376. */
  28377. disableScissor(): void;
  28378. private _viewportCached;
  28379. /** @hidden */
  28380. _viewport(x: number, y: number, width: number, height: number): void;
  28381. /**
  28382. * Set the WebGL's viewport
  28383. * @param viewport defines the viewport element to be used
  28384. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28385. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28386. */
  28387. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28388. /**
  28389. * Directly set the WebGL Viewport
  28390. * @param x defines the x coordinate of the viewport (in screen space)
  28391. * @param y defines the y coordinate of the viewport (in screen space)
  28392. * @param width defines the width of the viewport (in screen space)
  28393. * @param height defines the height of the viewport (in screen space)
  28394. * @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
  28395. */
  28396. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28397. /**
  28398. * Begin a new frame
  28399. */
  28400. beginFrame(): void;
  28401. /**
  28402. * Enf the current frame
  28403. */
  28404. endFrame(): void;
  28405. /**
  28406. * Resize the view according to the canvas' size
  28407. */
  28408. resize(): void;
  28409. /**
  28410. * Force a specific size of the canvas
  28411. * @param width defines the new canvas' width
  28412. * @param height defines the new canvas' height
  28413. */
  28414. setSize(width: number, height: number): void;
  28415. /**
  28416. * Binds the frame buffer to the specified texture.
  28417. * @param texture The texture to render to or null for the default canvas
  28418. * @param faceIndex The face of the texture to render to in case of cube texture
  28419. * @param requiredWidth The width of the target to render to
  28420. * @param requiredHeight The height of the target to render to
  28421. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28422. * @param depthStencilTexture The depth stencil texture to use to render
  28423. * @param lodLevel defines le lod level to bind to the frame buffer
  28424. */
  28425. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28426. /** @hidden */
  28427. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28428. /**
  28429. * Unbind the current render target texture from the webGL context
  28430. * @param texture defines the render target texture to unbind
  28431. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28432. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28433. */
  28434. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28435. /**
  28436. * Force the mipmap generation for the given render target texture
  28437. * @param texture defines the render target texture to use
  28438. */
  28439. generateMipMapsForCubemap(texture: InternalTexture): void;
  28440. /**
  28441. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28442. */
  28443. flushFramebuffer(): void;
  28444. /**
  28445. * Unbind the current render target and bind the default framebuffer
  28446. */
  28447. restoreDefaultFramebuffer(): void;
  28448. /**
  28449. * Create an uniform buffer
  28450. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28451. * @param elements defines the content of the uniform buffer
  28452. * @returns the webGL uniform buffer
  28453. */
  28454. createUniformBuffer(elements: FloatArray): DataBuffer;
  28455. /**
  28456. * Create a dynamic uniform buffer
  28457. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28458. * @param elements defines the content of the uniform buffer
  28459. * @returns the webGL uniform buffer
  28460. */
  28461. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28462. /**
  28463. * Update an existing uniform buffer
  28464. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28465. * @param uniformBuffer defines the target uniform buffer
  28466. * @param elements defines the content to update
  28467. * @param offset defines the offset in the uniform buffer where update should start
  28468. * @param count defines the size of the data to update
  28469. */
  28470. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28471. private _resetVertexBufferBinding;
  28472. /**
  28473. * Creates a vertex buffer
  28474. * @param data the data for the vertex buffer
  28475. * @returns the new WebGL static buffer
  28476. */
  28477. createVertexBuffer(data: DataArray): DataBuffer;
  28478. /**
  28479. * Creates a dynamic vertex buffer
  28480. * @param data the data for the dynamic vertex buffer
  28481. * @returns the new WebGL dynamic buffer
  28482. */
  28483. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28484. /**
  28485. * Update a dynamic index buffer
  28486. * @param indexBuffer defines the target index buffer
  28487. * @param indices defines the data to update
  28488. * @param offset defines the offset in the target index buffer where update should start
  28489. */
  28490. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28491. /**
  28492. * Updates a dynamic vertex buffer.
  28493. * @param vertexBuffer the vertex buffer to update
  28494. * @param data the data used to update the vertex buffer
  28495. * @param byteOffset the byte offset of the data
  28496. * @param byteLength the byte length of the data
  28497. */
  28498. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28499. private _resetIndexBufferBinding;
  28500. /**
  28501. * Creates a new index buffer
  28502. * @param indices defines the content of the index buffer
  28503. * @param updatable defines if the index buffer must be updatable
  28504. * @returns a new webGL buffer
  28505. */
  28506. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28507. /**
  28508. * Bind a webGL buffer to the webGL context
  28509. * @param buffer defines the buffer to bind
  28510. */
  28511. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28512. /**
  28513. * Bind an uniform buffer to the current webGL context
  28514. * @param buffer defines the buffer to bind
  28515. */
  28516. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28517. /**
  28518. * Bind a buffer to the current webGL context at a given location
  28519. * @param buffer defines the buffer to bind
  28520. * @param location defines the index where to bind the buffer
  28521. */
  28522. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28523. /**
  28524. * Bind a specific block at a given index in a specific shader program
  28525. * @param pipelineContext defines the pipeline context to use
  28526. * @param blockName defines the block name
  28527. * @param index defines the index where to bind the block
  28528. */
  28529. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28530. private bindIndexBuffer;
  28531. private bindBuffer;
  28532. /**
  28533. * update the bound buffer with the given data
  28534. * @param data defines the data to update
  28535. */
  28536. updateArrayBuffer(data: Float32Array): void;
  28537. private _vertexAttribPointer;
  28538. private _bindIndexBufferWithCache;
  28539. private _bindVertexBuffersAttributes;
  28540. /**
  28541. * Records a vertex array object
  28542. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28543. * @param vertexBuffers defines the list of vertex buffers to store
  28544. * @param indexBuffer defines the index buffer to store
  28545. * @param effect defines the effect to store
  28546. * @returns the new vertex array object
  28547. */
  28548. recordVertexArrayObject(vertexBuffers: {
  28549. [key: string]: VertexBuffer;
  28550. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28551. /**
  28552. * Bind a specific vertex array object
  28553. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28554. * @param vertexArrayObject defines the vertex array object to bind
  28555. * @param indexBuffer defines the index buffer to bind
  28556. */
  28557. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28558. /**
  28559. * Bind webGl buffers directly to the webGL context
  28560. * @param vertexBuffer defines the vertex buffer to bind
  28561. * @param indexBuffer defines the index buffer to bind
  28562. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28563. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28564. * @param effect defines the effect associated with the vertex buffer
  28565. */
  28566. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28567. private _unbindVertexArrayObject;
  28568. /**
  28569. * Bind a list of vertex buffers to the webGL context
  28570. * @param vertexBuffers defines the list of vertex buffers to bind
  28571. * @param indexBuffer defines the index buffer to bind
  28572. * @param effect defines the effect associated with the vertex buffers
  28573. */
  28574. bindBuffers(vertexBuffers: {
  28575. [key: string]: Nullable<VertexBuffer>;
  28576. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28577. /**
  28578. * Unbind all instance attributes
  28579. */
  28580. unbindInstanceAttributes(): void;
  28581. /**
  28582. * Release and free the memory of a vertex array object
  28583. * @param vao defines the vertex array object to delete
  28584. */
  28585. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28586. /** @hidden */
  28587. _releaseBuffer(buffer: DataBuffer): boolean;
  28588. /**
  28589. * Creates a webGL buffer to use with instanciation
  28590. * @param capacity defines the size of the buffer
  28591. * @returns the webGL buffer
  28592. */
  28593. createInstancesBuffer(capacity: number): DataBuffer;
  28594. /**
  28595. * Delete a webGL buffer used with instanciation
  28596. * @param buffer defines the webGL buffer to delete
  28597. */
  28598. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28599. /**
  28600. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28601. * @param instancesBuffer defines the webGL buffer to update and bind
  28602. * @param data defines the data to store in the buffer
  28603. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28604. */
  28605. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28606. /**
  28607. * Apply all cached states (depth, culling, stencil and alpha)
  28608. */
  28609. applyStates(): void;
  28610. /**
  28611. * Send a draw order
  28612. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28613. * @param indexStart defines the starting index
  28614. * @param indexCount defines the number of index to draw
  28615. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28616. */
  28617. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28618. /**
  28619. * Draw a list of points
  28620. * @param verticesStart defines the index of first vertex to draw
  28621. * @param verticesCount defines the count of vertices to draw
  28622. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28623. */
  28624. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28625. /**
  28626. * Draw a list of unindexed primitives
  28627. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28628. * @param verticesStart defines the index of first vertex to draw
  28629. * @param verticesCount defines the count of vertices to draw
  28630. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28631. */
  28632. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28633. /**
  28634. * Draw a list of indexed primitives
  28635. * @param fillMode defines the primitive to use
  28636. * @param indexStart defines the starting index
  28637. * @param indexCount defines the number of index to draw
  28638. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28639. */
  28640. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28641. /**
  28642. * Draw a list of unindexed primitives
  28643. * @param fillMode defines the primitive to use
  28644. * @param verticesStart defines the index of first vertex to draw
  28645. * @param verticesCount defines the count of vertices to draw
  28646. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28647. */
  28648. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28649. private _drawMode;
  28650. /** @hidden */
  28651. _releaseEffect(effect: Effect): void;
  28652. /** @hidden */
  28653. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  28654. /**
  28655. * Create a new effect (used to store vertex/fragment shaders)
  28656. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28657. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28658. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28659. * @param samplers defines an array of string used to represent textures
  28660. * @param defines defines the string containing the defines to use to compile the shaders
  28661. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28662. * @param onCompiled defines a function to call when the effect creation is successful
  28663. * @param onError defines a function to call when the effect creation has failed
  28664. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28665. * @returns the new Effect
  28666. */
  28667. 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;
  28668. private _compileShader;
  28669. private _compileRawShader;
  28670. /**
  28671. * Directly creates a webGL program
  28672. * @param pipelineContext defines the pipeline context to attach to
  28673. * @param vertexCode defines the vertex shader code to use
  28674. * @param fragmentCode defines the fragment shader code to use
  28675. * @param context defines the webGL context to use (if not set, the current one will be used)
  28676. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28677. * @returns the new webGL program
  28678. */
  28679. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28680. /**
  28681. * Creates a webGL program
  28682. * @param pipelineContext defines the pipeline context to attach to
  28683. * @param vertexCode defines the vertex shader code to use
  28684. * @param fragmentCode defines the fragment shader code to use
  28685. * @param defines defines the string containing the defines to use to compile the shaders
  28686. * @param context defines the webGL context to use (if not set, the current one will be used)
  28687. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28688. * @returns the new webGL program
  28689. */
  28690. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28691. /**
  28692. * Creates a new pipeline context
  28693. * @returns the new pipeline
  28694. */
  28695. createPipelineContext(): WebGLPipelineContext;
  28696. private _createShaderProgram;
  28697. private _finalizePipelineContext;
  28698. /** @hidden */
  28699. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  28700. /** @hidden */
  28701. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  28702. /** @hidden */
  28703. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  28704. /**
  28705. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28706. * @param pipelineContext defines the pipeline context to use
  28707. * @param uniformsNames defines the list of uniform names
  28708. * @returns an array of webGL uniform locations
  28709. */
  28710. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28711. /**
  28712. * Gets the lsit of active attributes for a given webGL program
  28713. * @param pipelineContext defines the pipeline context to use
  28714. * @param attributesNames defines the list of attribute names to get
  28715. * @returns an array of indices indicating the offset of each attribute
  28716. */
  28717. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  28718. /**
  28719. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28720. * @param effect defines the effect to activate
  28721. */
  28722. enableEffect(effect: Nullable<Effect>): void;
  28723. /**
  28724. * Set the value of an uniform to an array of int32
  28725. * @param uniform defines the webGL uniform location where to store the value
  28726. * @param array defines the array of int32 to store
  28727. */
  28728. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28729. /**
  28730. * Set the value of an uniform to an array of int32 (stored as vec2)
  28731. * @param uniform defines the webGL uniform location where to store the value
  28732. * @param array defines the array of int32 to store
  28733. */
  28734. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28735. /**
  28736. * Set the value of an uniform to an array of int32 (stored as vec3)
  28737. * @param uniform defines the webGL uniform location where to store the value
  28738. * @param array defines the array of int32 to store
  28739. */
  28740. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28741. /**
  28742. * Set the value of an uniform to an array of int32 (stored as vec4)
  28743. * @param uniform defines the webGL uniform location where to store the value
  28744. * @param array defines the array of int32 to store
  28745. */
  28746. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28747. /**
  28748. * Set the value of an uniform to an array of float32
  28749. * @param uniform defines the webGL uniform location where to store the value
  28750. * @param array defines the array of float32 to store
  28751. */
  28752. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28753. /**
  28754. * Set the value of an uniform to an array of float32 (stored as vec2)
  28755. * @param uniform defines the webGL uniform location where to store the value
  28756. * @param array defines the array of float32 to store
  28757. */
  28758. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28759. /**
  28760. * Set the value of an uniform to an array of float32 (stored as vec3)
  28761. * @param uniform defines the webGL uniform location where to store the value
  28762. * @param array defines the array of float32 to store
  28763. */
  28764. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28765. /**
  28766. * Set the value of an uniform to an array of float32 (stored as vec4)
  28767. * @param uniform defines the webGL uniform location where to store the value
  28768. * @param array defines the array of float32 to store
  28769. */
  28770. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28771. /**
  28772. * Set the value of an uniform to an array of number
  28773. * @param uniform defines the webGL uniform location where to store the value
  28774. * @param array defines the array of number to store
  28775. */
  28776. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28777. /**
  28778. * Set the value of an uniform to an array of number (stored as vec2)
  28779. * @param uniform defines the webGL uniform location where to store the value
  28780. * @param array defines the array of number to store
  28781. */
  28782. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28783. /**
  28784. * Set the value of an uniform to an array of number (stored as vec3)
  28785. * @param uniform defines the webGL uniform location where to store the value
  28786. * @param array defines the array of number to store
  28787. */
  28788. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28789. /**
  28790. * Set the value of an uniform to an array of number (stored as vec4)
  28791. * @param uniform defines the webGL uniform location where to store the value
  28792. * @param array defines the array of number to store
  28793. */
  28794. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28795. /**
  28796. * Set the value of an uniform to an array of float32 (stored as matrices)
  28797. * @param uniform defines the webGL uniform location where to store the value
  28798. * @param matrices defines the array of float32 to store
  28799. */
  28800. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28801. /**
  28802. * Set the value of an uniform to a matrix
  28803. * @param uniform defines the webGL uniform location where to store the value
  28804. * @param matrix defines the matrix to store
  28805. */
  28806. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28807. /**
  28808. * Set the value of an uniform to a matrix (3x3)
  28809. * @param uniform defines the webGL uniform location where to store the value
  28810. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28811. */
  28812. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28813. /**
  28814. * Set the value of an uniform to a matrix (2x2)
  28815. * @param uniform defines the webGL uniform location where to store the value
  28816. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28817. */
  28818. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28819. /**
  28820. * Set the value of an uniform to a number (int)
  28821. * @param uniform defines the webGL uniform location where to store the value
  28822. * @param value defines the int number to store
  28823. */
  28824. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28825. /**
  28826. * Set the value of an uniform to a number (float)
  28827. * @param uniform defines the webGL uniform location where to store the value
  28828. * @param value defines the float number to store
  28829. */
  28830. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28831. /**
  28832. * Set the value of an uniform to a vec2
  28833. * @param uniform defines the webGL uniform location where to store the value
  28834. * @param x defines the 1st component of the value
  28835. * @param y defines the 2nd component of the value
  28836. */
  28837. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28838. /**
  28839. * Set the value of an uniform to a vec3
  28840. * @param uniform defines the webGL uniform location where to store the value
  28841. * @param x defines the 1st component of the value
  28842. * @param y defines the 2nd component of the value
  28843. * @param z defines the 3rd component of the value
  28844. */
  28845. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28846. /**
  28847. * Set the value of an uniform to a boolean
  28848. * @param uniform defines the webGL uniform location where to store the value
  28849. * @param bool defines the boolean to store
  28850. */
  28851. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28852. /**
  28853. * Set the value of an uniform to a vec4
  28854. * @param uniform defines the webGL uniform location where to store the value
  28855. * @param x defines the 1st component of the value
  28856. * @param y defines the 2nd component of the value
  28857. * @param z defines the 3rd component of the value
  28858. * @param w defines the 4th component of the value
  28859. */
  28860. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28861. /**
  28862. * Set the value of an uniform to a Color3
  28863. * @param uniform defines the webGL uniform location where to store the value
  28864. * @param color3 defines the color to store
  28865. */
  28866. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28867. /**
  28868. * Set the value of an uniform to a Color3 and an alpha value
  28869. * @param uniform defines the webGL uniform location where to store the value
  28870. * @param color3 defines the color to store
  28871. * @param alpha defines the alpha component to store
  28872. */
  28873. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28874. /**
  28875. * Sets a Color4 on a uniform variable
  28876. * @param uniform defines the uniform location
  28877. * @param color4 defines the value to be set
  28878. */
  28879. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28880. /**
  28881. * Set various states to the webGL context
  28882. * @param culling defines backface culling state
  28883. * @param zOffset defines the value to apply to zOffset (0 by default)
  28884. * @param force defines if states must be applied even if cache is up to date
  28885. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28886. */
  28887. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28888. /**
  28889. * Set the z offset to apply to current rendering
  28890. * @param value defines the offset to apply
  28891. */
  28892. setZOffset(value: number): void;
  28893. /**
  28894. * Gets the current value of the zOffset
  28895. * @returns the current zOffset state
  28896. */
  28897. getZOffset(): number;
  28898. /**
  28899. * Enable or disable depth buffering
  28900. * @param enable defines the state to set
  28901. */
  28902. setDepthBuffer(enable: boolean): void;
  28903. /**
  28904. * Gets a boolean indicating if depth writing is enabled
  28905. * @returns the current depth writing state
  28906. */
  28907. getDepthWrite(): boolean;
  28908. /**
  28909. * Enable or disable depth writing
  28910. * @param enable defines the state to set
  28911. */
  28912. setDepthWrite(enable: boolean): void;
  28913. /**
  28914. * Enable or disable color writing
  28915. * @param enable defines the state to set
  28916. */
  28917. setColorWrite(enable: boolean): void;
  28918. /**
  28919. * Gets a boolean indicating if color writing is enabled
  28920. * @returns the current color writing state
  28921. */
  28922. getColorWrite(): boolean;
  28923. /**
  28924. * Sets alpha constants used by some alpha blending modes
  28925. * @param r defines the red component
  28926. * @param g defines the green component
  28927. * @param b defines the blue component
  28928. * @param a defines the alpha component
  28929. */
  28930. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28931. /**
  28932. * Sets the current alpha mode
  28933. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28934. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28935. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28936. */
  28937. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28938. /**
  28939. * Gets the current alpha mode
  28940. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28941. * @returns the current alpha mode
  28942. */
  28943. getAlphaMode(): number;
  28944. /**
  28945. * Clears the list of texture accessible through engine.
  28946. * This can help preventing texture load conflict due to name collision.
  28947. */
  28948. clearInternalTexturesCache(): void;
  28949. /**
  28950. * Force the entire cache to be cleared
  28951. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28952. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28953. */
  28954. wipeCaches(bruteForce?: boolean): void;
  28955. /**
  28956. * Set the compressed texture format to use, based on the formats you have, and the formats
  28957. * supported by the hardware / browser.
  28958. *
  28959. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28960. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28961. * to API arguments needed to compressed textures. This puts the burden on the container
  28962. * generator to house the arcane code for determining these for current & future formats.
  28963. *
  28964. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28965. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28966. *
  28967. * Note: The result of this call is not taken into account when a texture is base64.
  28968. *
  28969. * @param formatsAvailable defines the list of those format families you have created
  28970. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28971. *
  28972. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28973. * @returns The extension selected.
  28974. */
  28975. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28976. /** @hidden */
  28977. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28978. min: number;
  28979. mag: number;
  28980. };
  28981. /** @hidden */
  28982. _createTexture(): WebGLTexture;
  28983. /**
  28984. * Usually called from Texture.ts.
  28985. * Passed information to create a WebGLTexture
  28986. * @param urlArg defines a value which contains one of the following:
  28987. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28988. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28989. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28990. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28991. * @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)
  28992. * @param scene needed for loading to the correct scene
  28993. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28994. * @param onLoad optional callback to be called upon successful completion
  28995. * @param onError optional callback to be called upon failure
  28996. * @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
  28997. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28998. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28999. * @param forcedExtension defines the extension to use to pick the right loader
  29000. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29001. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29002. */
  29003. 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;
  29004. /**
  29005. * @hidden
  29006. * Rescales a texture
  29007. * @param source input texutre
  29008. * @param destination destination texture
  29009. * @param scene scene to use to render the resize
  29010. * @param internalFormat format to use when resizing
  29011. * @param onComplete callback to be called when resize has completed
  29012. */
  29013. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  29014. private _unpackFlipYCached;
  29015. /**
  29016. * In case you are sharing the context with other applications, it might
  29017. * be interested to not cache the unpack flip y state to ensure a consistent
  29018. * value would be set.
  29019. */
  29020. enableUnpackFlipYCached: boolean;
  29021. /** @hidden */
  29022. _unpackFlipY(value: boolean): void;
  29023. /** @hidden */
  29024. _getUnpackAlignement(): number;
  29025. /**
  29026. * Creates a dynamic texture
  29027. * @param width defines the width of the texture
  29028. * @param height defines the height of the texture
  29029. * @param generateMipMaps defines if the engine should generate the mip levels
  29030. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29031. * @returns the dynamic texture inside an InternalTexture
  29032. */
  29033. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29034. /**
  29035. * Update the sampling mode of a given texture
  29036. * @param samplingMode defines the required sampling mode
  29037. * @param texture defines the texture to update
  29038. */
  29039. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29040. /**
  29041. * Update the content of a dynamic texture
  29042. * @param texture defines the texture to update
  29043. * @param canvas defines the canvas containing the source
  29044. * @param invertY defines if data must be stored with Y axis inverted
  29045. * @param premulAlpha defines if alpha is stored as premultiplied
  29046. * @param format defines the format of the data
  29047. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29048. */
  29049. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29050. /**
  29051. * Update a video texture
  29052. * @param texture defines the texture to update
  29053. * @param video defines the video element to use
  29054. * @param invertY defines if data must be stored with Y axis inverted
  29055. */
  29056. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29057. /**
  29058. * Updates a depth texture Comparison Mode and Function.
  29059. * If the comparison Function is equal to 0, the mode will be set to none.
  29060. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29061. * @param texture The texture to set the comparison function for
  29062. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29063. */
  29064. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29065. /** @hidden */
  29066. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29067. width: number;
  29068. height: number;
  29069. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29070. /**
  29071. * Creates a depth stencil texture.
  29072. * This is only available in WebGL 2 or with the depth texture extension available.
  29073. * @param size The size of face edge in the texture.
  29074. * @param options The options defining the texture.
  29075. * @returns The texture
  29076. */
  29077. createDepthStencilTexture(size: number | {
  29078. width: number;
  29079. height: number;
  29080. }, options: DepthTextureCreationOptions): InternalTexture;
  29081. /**
  29082. * Creates a depth stencil texture.
  29083. * This is only available in WebGL 2 or with the depth texture extension available.
  29084. * @param size The size of face edge in the texture.
  29085. * @param options The options defining the texture.
  29086. * @returns The texture
  29087. */
  29088. private _createDepthStencilTexture;
  29089. /**
  29090. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29091. * @param renderTarget The render target to set the frame buffer for
  29092. */
  29093. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29094. /**
  29095. * Creates a new render target texture
  29096. * @param size defines the size of the texture
  29097. * @param options defines the options used to create the texture
  29098. * @returns a new render target texture stored in an InternalTexture
  29099. */
  29100. createRenderTargetTexture(size: number | {
  29101. width: number;
  29102. height: number;
  29103. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29104. /** @hidden */
  29105. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29106. /**
  29107. * Updates the sample count of a render target texture
  29108. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29109. * @param texture defines the texture to update
  29110. * @param samples defines the sample count to set
  29111. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29112. */
  29113. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29114. /** @hidden */
  29115. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29116. /** @hidden */
  29117. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29118. /** @hidden */
  29119. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29120. /** @hidden */
  29121. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29122. /**
  29123. * @hidden
  29124. */
  29125. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29126. private _prepareWebGLTextureContinuation;
  29127. private _prepareWebGLTexture;
  29128. /** @hidden */
  29129. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29130. /** @hidden */
  29131. _releaseFramebufferObjects(texture: InternalTexture): void;
  29132. /** @hidden */
  29133. _releaseTexture(texture: InternalTexture): void;
  29134. private setProgram;
  29135. private _boundUniforms;
  29136. /**
  29137. * Binds an effect to the webGL context
  29138. * @param effect defines the effect to bind
  29139. */
  29140. bindSamplers(effect: Effect): void;
  29141. private _activateCurrentTexture;
  29142. /** @hidden */
  29143. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29144. /** @hidden */
  29145. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29146. /**
  29147. * Sets a texture to the webGL context from a postprocess
  29148. * @param channel defines the channel to use
  29149. * @param postProcess defines the source postprocess
  29150. */
  29151. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29152. /**
  29153. * Binds the output of the passed in post process to the texture channel specified
  29154. * @param channel The channel the texture should be bound to
  29155. * @param postProcess The post process which's output should be bound
  29156. */
  29157. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29158. /**
  29159. * Unbind all textures from the webGL context
  29160. */
  29161. unbindAllTextures(): void;
  29162. /**
  29163. * Sets a texture to the according uniform.
  29164. * @param channel The texture channel
  29165. * @param uniform The uniform to set
  29166. * @param texture The texture to apply
  29167. */
  29168. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29169. /**
  29170. * Sets a depth stencil texture from a render target to the according uniform.
  29171. * @param channel The texture channel
  29172. * @param uniform The uniform to set
  29173. * @param texture The render target texture containing the depth stencil texture to apply
  29174. */
  29175. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29176. private _bindSamplerUniformToChannel;
  29177. private _getTextureWrapMode;
  29178. private _setTexture;
  29179. /**
  29180. * Sets an array of texture to the webGL context
  29181. * @param channel defines the channel where the texture array must be set
  29182. * @param uniform defines the associated uniform location
  29183. * @param textures defines the array of textures to bind
  29184. */
  29185. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29186. /** @hidden */
  29187. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29188. private _setTextureParameterFloat;
  29189. private _setTextureParameterInteger;
  29190. /**
  29191. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29192. * @param x defines the x coordinate of the rectangle where pixels must be read
  29193. * @param y defines the y coordinate of the rectangle where pixels must be read
  29194. * @param width defines the width of the rectangle where pixels must be read
  29195. * @param height defines the height of the rectangle where pixels must be read
  29196. * @returns a Uint8Array containing RGBA colors
  29197. */
  29198. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29199. /**
  29200. * Add an externaly attached data from its key.
  29201. * This method call will fail and return false, if such key already exists.
  29202. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29203. * @param key the unique key that identifies the data
  29204. * @param data the data object to associate to the key for this Engine instance
  29205. * @return true if no such key were already present and the data was added successfully, false otherwise
  29206. */
  29207. addExternalData<T>(key: string, data: T): boolean;
  29208. /**
  29209. * Get an externaly attached data from its key
  29210. * @param key the unique key that identifies the data
  29211. * @return the associated data, if present (can be null), or undefined if not present
  29212. */
  29213. getExternalData<T>(key: string): T;
  29214. /**
  29215. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29216. * @param key the unique key that identifies the data
  29217. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29218. * @return the associated data, can be null if the factory returned null.
  29219. */
  29220. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29221. /**
  29222. * Remove an externaly attached data from the Engine instance
  29223. * @param key the unique key that identifies the data
  29224. * @return true if the data was successfully removed, false if it doesn't exist
  29225. */
  29226. removeExternalData(key: string): boolean;
  29227. /**
  29228. * Unbind all vertex attributes from the webGL context
  29229. */
  29230. unbindAllAttributes(): void;
  29231. /**
  29232. * 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
  29233. */
  29234. releaseEffects(): void;
  29235. /**
  29236. * Dispose and release all associated resources
  29237. */
  29238. dispose(): void;
  29239. /**
  29240. * Display the loading screen
  29241. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29242. */
  29243. displayLoadingUI(): void;
  29244. /**
  29245. * Hide the loading screen
  29246. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29247. */
  29248. hideLoadingUI(): void;
  29249. /**
  29250. * Gets the current loading screen object
  29251. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29252. */
  29253. /**
  29254. * Sets the current loading screen object
  29255. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29256. */
  29257. loadingScreen: ILoadingScreen;
  29258. /**
  29259. * Sets the current loading screen text
  29260. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29261. */
  29262. loadingUIText: string;
  29263. /**
  29264. * Sets the current loading screen background color
  29265. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29266. */
  29267. loadingUIBackgroundColor: string;
  29268. /**
  29269. * Attach a new callback raised when context lost event is fired
  29270. * @param callback defines the callback to call
  29271. */
  29272. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29273. /**
  29274. * Attach a new callback raised when context restored event is fired
  29275. * @param callback defines the callback to call
  29276. */
  29277. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29278. /**
  29279. * Gets the source code of the vertex shader associated with a specific webGL program
  29280. * @param program defines the program to use
  29281. * @returns a string containing the source code of the vertex shader associated with the program
  29282. */
  29283. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29284. /**
  29285. * Gets the source code of the fragment shader associated with a specific webGL program
  29286. * @param program defines the program to use
  29287. * @returns a string containing the source code of the fragment shader associated with the program
  29288. */
  29289. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29290. /**
  29291. * Get the current error code of the webGL context
  29292. * @returns the error code
  29293. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29294. */
  29295. getError(): number;
  29296. /**
  29297. * Gets the current framerate
  29298. * @returns a number representing the framerate
  29299. */
  29300. getFps(): number;
  29301. /**
  29302. * Gets the time spent between current and previous frame
  29303. * @returns a number representing the delta time in ms
  29304. */
  29305. getDeltaTime(): number;
  29306. private _measureFps;
  29307. /** @hidden */
  29308. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29309. private _canRenderToFloatFramebuffer;
  29310. private _canRenderToHalfFloatFramebuffer;
  29311. private _canRenderToFramebuffer;
  29312. /** @hidden */
  29313. _getWebGLTextureType(type: number): number;
  29314. /** @hidden */
  29315. _getInternalFormat(format: number): number;
  29316. /** @hidden */
  29317. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29318. /** @hidden */
  29319. _getRGBAMultiSampleBufferFormat(type: number): number;
  29320. /** @hidden */
  29321. _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;
  29322. /** @hidden */
  29323. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29324. /**
  29325. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29326. * @returns true if the engine can be created
  29327. * @ignorenaming
  29328. */
  29329. static isSupported(): boolean;
  29330. }
  29331. }
  29332. declare module BABYLON {
  29333. /**
  29334. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29335. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29336. */
  29337. export class EffectFallbacks {
  29338. private _defines;
  29339. private _currentRank;
  29340. private _maxRank;
  29341. private _mesh;
  29342. /**
  29343. * Removes the fallback from the bound mesh.
  29344. */
  29345. unBindMesh(): void;
  29346. /**
  29347. * Adds a fallback on the specified property.
  29348. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29349. * @param define The name of the define in the shader
  29350. */
  29351. addFallback(rank: number, define: string): void;
  29352. /**
  29353. * Sets the mesh to use CPU skinning when needing to fallback.
  29354. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29355. * @param mesh The mesh to use the fallbacks.
  29356. */
  29357. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29358. /**
  29359. * Checks to see if more fallbacks are still availible.
  29360. */
  29361. readonly isMoreFallbacks: boolean;
  29362. /**
  29363. * Removes the defines that should be removed when falling back.
  29364. * @param currentDefines defines the current define statements for the shader.
  29365. * @param effect defines the current effect we try to compile
  29366. * @returns The resulting defines with defines of the current rank removed.
  29367. */
  29368. reduce(currentDefines: string, effect: Effect): string;
  29369. }
  29370. /**
  29371. * Options to be used when creating an effect.
  29372. */
  29373. export class EffectCreationOptions {
  29374. /**
  29375. * Atrributes that will be used in the shader.
  29376. */
  29377. attributes: string[];
  29378. /**
  29379. * Uniform varible names that will be set in the shader.
  29380. */
  29381. uniformsNames: string[];
  29382. /**
  29383. * Uniform buffer varible names that will be set in the shader.
  29384. */
  29385. uniformBuffersNames: string[];
  29386. /**
  29387. * Sampler texture variable names that will be set in the shader.
  29388. */
  29389. samplers: string[];
  29390. /**
  29391. * Define statements that will be set in the shader.
  29392. */
  29393. defines: any;
  29394. /**
  29395. * Possible fallbacks for this effect to improve performance when needed.
  29396. */
  29397. fallbacks: Nullable<EffectFallbacks>;
  29398. /**
  29399. * Callback that will be called when the shader is compiled.
  29400. */
  29401. onCompiled: Nullable<(effect: Effect) => void>;
  29402. /**
  29403. * Callback that will be called if an error occurs during shader compilation.
  29404. */
  29405. onError: Nullable<(effect: Effect, errors: string) => void>;
  29406. /**
  29407. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29408. */
  29409. indexParameters: any;
  29410. /**
  29411. * Max number of lights that can be used in the shader.
  29412. */
  29413. maxSimultaneousLights: number;
  29414. /**
  29415. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29416. */
  29417. transformFeedbackVaryings: Nullable<string[]>;
  29418. }
  29419. /**
  29420. * Effect containing vertex and fragment shader that can be executed on an object.
  29421. */
  29422. export class Effect implements IDisposable {
  29423. /**
  29424. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29425. */
  29426. static ShadersRepository: string;
  29427. /**
  29428. * Name of the effect.
  29429. */
  29430. name: any;
  29431. /**
  29432. * String container all the define statements that should be set on the shader.
  29433. */
  29434. defines: string;
  29435. /**
  29436. * Callback that will be called when the shader is compiled.
  29437. */
  29438. onCompiled: Nullable<(effect: Effect) => void>;
  29439. /**
  29440. * Callback that will be called if an error occurs during shader compilation.
  29441. */
  29442. onError: Nullable<(effect: Effect, errors: string) => void>;
  29443. /**
  29444. * Callback that will be called when effect is bound.
  29445. */
  29446. onBind: Nullable<(effect: Effect) => void>;
  29447. /**
  29448. * Unique ID of the effect.
  29449. */
  29450. uniqueId: number;
  29451. /**
  29452. * Observable that will be called when the shader is compiled.
  29453. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29454. */
  29455. onCompileObservable: Observable<Effect>;
  29456. /**
  29457. * Observable that will be called if an error occurs during shader compilation.
  29458. */
  29459. onErrorObservable: Observable<Effect>;
  29460. /** @hidden */
  29461. _onBindObservable: Nullable<Observable<Effect>>;
  29462. /**
  29463. * Observable that will be called when effect is bound.
  29464. */
  29465. readonly onBindObservable: Observable<Effect>;
  29466. /** @hidden */
  29467. _bonesComputationForcedToCPU: boolean;
  29468. private static _uniqueIdSeed;
  29469. private _engine;
  29470. private _uniformBuffersNames;
  29471. private _uniformsNames;
  29472. private _samplerList;
  29473. private _samplers;
  29474. private _isReady;
  29475. private _compilationError;
  29476. private _attributesNames;
  29477. private _attributes;
  29478. private _uniforms;
  29479. /**
  29480. * Key for the effect.
  29481. * @hidden
  29482. */
  29483. _key: string;
  29484. private _indexParameters;
  29485. private _fallbacks;
  29486. private _vertexSourceCode;
  29487. private _fragmentSourceCode;
  29488. private _vertexSourceCodeOverride;
  29489. private _fragmentSourceCodeOverride;
  29490. private _transformFeedbackVaryings;
  29491. /**
  29492. * Compiled shader to webGL program.
  29493. * @hidden
  29494. */
  29495. _pipelineContext: Nullable<IPipelineContext>;
  29496. private _valueCache;
  29497. private static _baseCache;
  29498. /**
  29499. * Instantiates an effect.
  29500. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29501. * @param baseName Name of the effect.
  29502. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29503. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29504. * @param samplers List of sampler variables that will be passed to the shader.
  29505. * @param engine Engine to be used to render the effect
  29506. * @param defines Define statements to be added to the shader.
  29507. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29508. * @param onCompiled Callback that will be called when the shader is compiled.
  29509. * @param onError Callback that will be called if an error occurs during shader compilation.
  29510. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29511. */
  29512. 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);
  29513. private _useFinalCode;
  29514. /**
  29515. * Unique key for this effect
  29516. */
  29517. readonly key: string;
  29518. /**
  29519. * If the effect has been compiled and prepared.
  29520. * @returns if the effect is compiled and prepared.
  29521. */
  29522. isReady(): boolean;
  29523. /**
  29524. * The engine the effect was initialized with.
  29525. * @returns the engine.
  29526. */
  29527. getEngine(): Engine;
  29528. /**
  29529. * The pipeline context for this effect
  29530. * @returns the associated pipeline context
  29531. */
  29532. getPipelineContext(): Nullable<IPipelineContext>;
  29533. /**
  29534. * The set of names of attribute variables for the shader.
  29535. * @returns An array of attribute names.
  29536. */
  29537. getAttributesNames(): string[];
  29538. /**
  29539. * Returns the attribute at the given index.
  29540. * @param index The index of the attribute.
  29541. * @returns The location of the attribute.
  29542. */
  29543. getAttributeLocation(index: number): number;
  29544. /**
  29545. * Returns the attribute based on the name of the variable.
  29546. * @param name of the attribute to look up.
  29547. * @returns the attribute location.
  29548. */
  29549. getAttributeLocationByName(name: string): number;
  29550. /**
  29551. * The number of attributes.
  29552. * @returns the numnber of attributes.
  29553. */
  29554. getAttributesCount(): number;
  29555. /**
  29556. * Gets the index of a uniform variable.
  29557. * @param uniformName of the uniform to look up.
  29558. * @returns the index.
  29559. */
  29560. getUniformIndex(uniformName: string): number;
  29561. /**
  29562. * Returns the attribute based on the name of the variable.
  29563. * @param uniformName of the uniform to look up.
  29564. * @returns the location of the uniform.
  29565. */
  29566. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29567. /**
  29568. * Returns an array of sampler variable names
  29569. * @returns The array of sampler variable neames.
  29570. */
  29571. getSamplers(): string[];
  29572. /**
  29573. * The error from the last compilation.
  29574. * @returns the error string.
  29575. */
  29576. getCompilationError(): string;
  29577. /**
  29578. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29579. * @param func The callback to be used.
  29580. */
  29581. executeWhenCompiled(func: (effect: Effect) => void): void;
  29582. private _checkIsReady;
  29583. /** @hidden */
  29584. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29585. /** @hidden */
  29586. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29587. /** @hidden */
  29588. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29589. /**
  29590. * Recompiles the webGL program
  29591. * @param vertexSourceCode The source code for the vertex shader.
  29592. * @param fragmentSourceCode The source code for the fragment shader.
  29593. * @param onCompiled Callback called when completed.
  29594. * @param onError Callback called on error.
  29595. * @hidden
  29596. */
  29597. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29598. /**
  29599. * Prepares the effect
  29600. * @hidden
  29601. */
  29602. _prepareEffect(): void;
  29603. /**
  29604. * Checks if the effect is supported. (Must be called after compilation)
  29605. */
  29606. readonly isSupported: boolean;
  29607. /**
  29608. * Binds a texture to the engine to be used as output of the shader.
  29609. * @param channel Name of the output variable.
  29610. * @param texture Texture to bind.
  29611. * @hidden
  29612. */
  29613. _bindTexture(channel: string, texture: InternalTexture): void;
  29614. /**
  29615. * Sets a texture on the engine to be used in the shader.
  29616. * @param channel Name of the sampler variable.
  29617. * @param texture Texture to set.
  29618. */
  29619. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29620. /**
  29621. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29622. * @param channel Name of the sampler variable.
  29623. * @param texture Texture to set.
  29624. */
  29625. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29626. /**
  29627. * Sets an array of textures on the engine to be used in the shader.
  29628. * @param channel Name of the variable.
  29629. * @param textures Textures to set.
  29630. */
  29631. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29632. /**
  29633. * 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)
  29634. * @param channel Name of the sampler variable.
  29635. * @param postProcess Post process to get the input texture from.
  29636. */
  29637. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29638. /**
  29639. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29640. * 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)
  29641. * @param channel Name of the sampler variable.
  29642. * @param postProcess Post process to get the output texture from.
  29643. */
  29644. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29645. /** @hidden */
  29646. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29647. /** @hidden */
  29648. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29649. /** @hidden */
  29650. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29651. /** @hidden */
  29652. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29653. /**
  29654. * Binds a buffer to a uniform.
  29655. * @param buffer Buffer to bind.
  29656. * @param name Name of the uniform variable to bind to.
  29657. */
  29658. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29659. /**
  29660. * Binds block to a uniform.
  29661. * @param blockName Name of the block to bind.
  29662. * @param index Index to bind.
  29663. */
  29664. bindUniformBlock(blockName: string, index: number): void;
  29665. /**
  29666. * Sets an interger value on a uniform variable.
  29667. * @param uniformName Name of the variable.
  29668. * @param value Value to be set.
  29669. * @returns this effect.
  29670. */
  29671. setInt(uniformName: string, value: number): Effect;
  29672. /**
  29673. * Sets an int array on a uniform variable.
  29674. * @param uniformName Name of the variable.
  29675. * @param array array to be set.
  29676. * @returns this effect.
  29677. */
  29678. setIntArray(uniformName: string, array: Int32Array): Effect;
  29679. /**
  29680. * 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)
  29681. * @param uniformName Name of the variable.
  29682. * @param array array to be set.
  29683. * @returns this effect.
  29684. */
  29685. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29686. /**
  29687. * 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)
  29688. * @param uniformName Name of the variable.
  29689. * @param array array to be set.
  29690. * @returns this effect.
  29691. */
  29692. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29693. /**
  29694. * 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)
  29695. * @param uniformName Name of the variable.
  29696. * @param array array to be set.
  29697. * @returns this effect.
  29698. */
  29699. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29700. /**
  29701. * Sets an float array on a uniform variable.
  29702. * @param uniformName Name of the variable.
  29703. * @param array array to be set.
  29704. * @returns this effect.
  29705. */
  29706. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29707. /**
  29708. * 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)
  29709. * @param uniformName Name of the variable.
  29710. * @param array array to be set.
  29711. * @returns this effect.
  29712. */
  29713. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29714. /**
  29715. * 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)
  29716. * @param uniformName Name of the variable.
  29717. * @param array array to be set.
  29718. * @returns this effect.
  29719. */
  29720. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29721. /**
  29722. * 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)
  29723. * @param uniformName Name of the variable.
  29724. * @param array array to be set.
  29725. * @returns this effect.
  29726. */
  29727. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29728. /**
  29729. * Sets an array on a uniform variable.
  29730. * @param uniformName Name of the variable.
  29731. * @param array array to be set.
  29732. * @returns this effect.
  29733. */
  29734. setArray(uniformName: string, array: number[]): Effect;
  29735. /**
  29736. * 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)
  29737. * @param uniformName Name of the variable.
  29738. * @param array array to be set.
  29739. * @returns this effect.
  29740. */
  29741. setArray2(uniformName: string, array: number[]): Effect;
  29742. /**
  29743. * 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)
  29744. * @param uniformName Name of the variable.
  29745. * @param array array to be set.
  29746. * @returns this effect.
  29747. */
  29748. setArray3(uniformName: string, array: number[]): Effect;
  29749. /**
  29750. * 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)
  29751. * @param uniformName Name of the variable.
  29752. * @param array array to be set.
  29753. * @returns this effect.
  29754. */
  29755. setArray4(uniformName: string, array: number[]): Effect;
  29756. /**
  29757. * Sets matrices on a uniform variable.
  29758. * @param uniformName Name of the variable.
  29759. * @param matrices matrices to be set.
  29760. * @returns this effect.
  29761. */
  29762. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29763. /**
  29764. * Sets matrix on a uniform variable.
  29765. * @param uniformName Name of the variable.
  29766. * @param matrix matrix to be set.
  29767. * @returns this effect.
  29768. */
  29769. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29770. /**
  29771. * 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)
  29772. * @param uniformName Name of the variable.
  29773. * @param matrix matrix to be set.
  29774. * @returns this effect.
  29775. */
  29776. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29777. /**
  29778. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29779. * @param uniformName Name of the variable.
  29780. * @param matrix matrix to be set.
  29781. * @returns this effect.
  29782. */
  29783. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29784. /**
  29785. * Sets a float on a uniform variable.
  29786. * @param uniformName Name of the variable.
  29787. * @param value value to be set.
  29788. * @returns this effect.
  29789. */
  29790. setFloat(uniformName: string, value: number): Effect;
  29791. /**
  29792. * Sets a boolean on a uniform variable.
  29793. * @param uniformName Name of the variable.
  29794. * @param bool value to be set.
  29795. * @returns this effect.
  29796. */
  29797. setBool(uniformName: string, bool: boolean): Effect;
  29798. /**
  29799. * Sets a Vector2 on a uniform variable.
  29800. * @param uniformName Name of the variable.
  29801. * @param vector2 vector2 to be set.
  29802. * @returns this effect.
  29803. */
  29804. setVector2(uniformName: string, vector2: Vector2): Effect;
  29805. /**
  29806. * Sets a float2 on a uniform variable.
  29807. * @param uniformName Name of the variable.
  29808. * @param x First float in float2.
  29809. * @param y Second float in float2.
  29810. * @returns this effect.
  29811. */
  29812. setFloat2(uniformName: string, x: number, y: number): Effect;
  29813. /**
  29814. * Sets a Vector3 on a uniform variable.
  29815. * @param uniformName Name of the variable.
  29816. * @param vector3 Value to be set.
  29817. * @returns this effect.
  29818. */
  29819. setVector3(uniformName: string, vector3: Vector3): Effect;
  29820. /**
  29821. * Sets a float3 on a uniform variable.
  29822. * @param uniformName Name of the variable.
  29823. * @param x First float in float3.
  29824. * @param y Second float in float3.
  29825. * @param z Third float in float3.
  29826. * @returns this effect.
  29827. */
  29828. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29829. /**
  29830. * Sets a Vector4 on a uniform variable.
  29831. * @param uniformName Name of the variable.
  29832. * @param vector4 Value to be set.
  29833. * @returns this effect.
  29834. */
  29835. setVector4(uniformName: string, vector4: Vector4): Effect;
  29836. /**
  29837. * Sets a float4 on a uniform variable.
  29838. * @param uniformName Name of the variable.
  29839. * @param x First float in float4.
  29840. * @param y Second float in float4.
  29841. * @param z Third float in float4.
  29842. * @param w Fourth float in float4.
  29843. * @returns this effect.
  29844. */
  29845. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29846. /**
  29847. * Sets a Color3 on a uniform variable.
  29848. * @param uniformName Name of the variable.
  29849. * @param color3 Value to be set.
  29850. * @returns this effect.
  29851. */
  29852. setColor3(uniformName: string, color3: Color3): Effect;
  29853. /**
  29854. * Sets a Color4 on a uniform variable.
  29855. * @param uniformName Name of the variable.
  29856. * @param color3 Value to be set.
  29857. * @param alpha Alpha value to be set.
  29858. * @returns this effect.
  29859. */
  29860. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29861. /**
  29862. * Sets a Color4 on a uniform variable
  29863. * @param uniformName defines the name of the variable
  29864. * @param color4 defines the value to be set
  29865. * @returns this effect.
  29866. */
  29867. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29868. /** Release all associated resources */
  29869. dispose(): void;
  29870. /**
  29871. * This function will add a new shader to the shader store
  29872. * @param name the name of the shader
  29873. * @param pixelShader optional pixel shader content
  29874. * @param vertexShader optional vertex shader content
  29875. */
  29876. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29877. /**
  29878. * Store of each shader (The can be looked up using effect.key)
  29879. */
  29880. static ShadersStore: {
  29881. [key: string]: string;
  29882. };
  29883. /**
  29884. * Store of each included file for a shader (The can be looked up using effect.key)
  29885. */
  29886. static IncludesShadersStore: {
  29887. [key: string]: string;
  29888. };
  29889. /**
  29890. * Resets the cache of effects.
  29891. */
  29892. static ResetCache(): void;
  29893. }
  29894. }
  29895. declare module BABYLON {
  29896. /**
  29897. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29898. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29899. * 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;
  29900. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29901. */
  29902. export class ColorCurves {
  29903. private _dirty;
  29904. private _tempColor;
  29905. private _globalCurve;
  29906. private _highlightsCurve;
  29907. private _midtonesCurve;
  29908. private _shadowsCurve;
  29909. private _positiveCurve;
  29910. private _negativeCurve;
  29911. private _globalHue;
  29912. private _globalDensity;
  29913. private _globalSaturation;
  29914. private _globalExposure;
  29915. /**
  29916. * Gets the global Hue value.
  29917. * 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).
  29918. */
  29919. /**
  29920. * Sets the global Hue value.
  29921. * 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).
  29922. */
  29923. globalHue: number;
  29924. /**
  29925. * Gets the global Density value.
  29926. * 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.
  29927. * Values less than zero provide a filter of opposite hue.
  29928. */
  29929. /**
  29930. * Sets the global Density value.
  29931. * 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.
  29932. * Values less than zero provide a filter of opposite hue.
  29933. */
  29934. globalDensity: number;
  29935. /**
  29936. * Gets the global Saturation value.
  29937. * 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.
  29938. */
  29939. /**
  29940. * Sets the global Saturation value.
  29941. * 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.
  29942. */
  29943. globalSaturation: number;
  29944. /**
  29945. * Gets the global Exposure value.
  29946. * 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.
  29947. */
  29948. /**
  29949. * Sets the global Exposure value.
  29950. * 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.
  29951. */
  29952. globalExposure: number;
  29953. private _highlightsHue;
  29954. private _highlightsDensity;
  29955. private _highlightsSaturation;
  29956. private _highlightsExposure;
  29957. /**
  29958. * Gets the highlights Hue value.
  29959. * 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).
  29960. */
  29961. /**
  29962. * Sets the highlights Hue value.
  29963. * 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).
  29964. */
  29965. highlightsHue: number;
  29966. /**
  29967. * Gets the highlights Density value.
  29968. * 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.
  29969. * Values less than zero provide a filter of opposite hue.
  29970. */
  29971. /**
  29972. * Sets the highlights Density value.
  29973. * 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.
  29974. * Values less than zero provide a filter of opposite hue.
  29975. */
  29976. highlightsDensity: number;
  29977. /**
  29978. * Gets the highlights Saturation value.
  29979. * 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.
  29980. */
  29981. /**
  29982. * Sets the highlights Saturation value.
  29983. * 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.
  29984. */
  29985. highlightsSaturation: number;
  29986. /**
  29987. * Gets the highlights Exposure value.
  29988. * 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.
  29989. */
  29990. /**
  29991. * Sets the highlights Exposure value.
  29992. * 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.
  29993. */
  29994. highlightsExposure: number;
  29995. private _midtonesHue;
  29996. private _midtonesDensity;
  29997. private _midtonesSaturation;
  29998. private _midtonesExposure;
  29999. /**
  30000. * Gets the midtones Hue value.
  30001. * 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).
  30002. */
  30003. /**
  30004. * Sets the midtones Hue value.
  30005. * 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).
  30006. */
  30007. midtonesHue: number;
  30008. /**
  30009. * Gets the midtones Density value.
  30010. * 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.
  30011. * Values less than zero provide a filter of opposite hue.
  30012. */
  30013. /**
  30014. * Sets the midtones Density value.
  30015. * 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.
  30016. * Values less than zero provide a filter of opposite hue.
  30017. */
  30018. midtonesDensity: number;
  30019. /**
  30020. * Gets the midtones Saturation value.
  30021. * 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.
  30022. */
  30023. /**
  30024. * Sets the midtones Saturation value.
  30025. * 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.
  30026. */
  30027. midtonesSaturation: number;
  30028. /**
  30029. * Gets the midtones Exposure value.
  30030. * 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.
  30031. */
  30032. /**
  30033. * Sets the midtones Exposure value.
  30034. * 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.
  30035. */
  30036. midtonesExposure: number;
  30037. private _shadowsHue;
  30038. private _shadowsDensity;
  30039. private _shadowsSaturation;
  30040. private _shadowsExposure;
  30041. /**
  30042. * Gets the shadows Hue value.
  30043. * 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).
  30044. */
  30045. /**
  30046. * Sets the shadows Hue value.
  30047. * 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).
  30048. */
  30049. shadowsHue: number;
  30050. /**
  30051. * Gets the shadows Density value.
  30052. * 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.
  30053. * Values less than zero provide a filter of opposite hue.
  30054. */
  30055. /**
  30056. * Sets the shadows Density value.
  30057. * 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.
  30058. * Values less than zero provide a filter of opposite hue.
  30059. */
  30060. shadowsDensity: number;
  30061. /**
  30062. * Gets the shadows Saturation value.
  30063. * 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.
  30064. */
  30065. /**
  30066. * Sets the shadows Saturation value.
  30067. * 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.
  30068. */
  30069. shadowsSaturation: number;
  30070. /**
  30071. * Gets the shadows Exposure value.
  30072. * 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.
  30073. */
  30074. /**
  30075. * Sets the shadows Exposure value.
  30076. * 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.
  30077. */
  30078. shadowsExposure: number;
  30079. /**
  30080. * Returns the class name
  30081. * @returns The class name
  30082. */
  30083. getClassName(): string;
  30084. /**
  30085. * Binds the color curves to the shader.
  30086. * @param colorCurves The color curve to bind
  30087. * @param effect The effect to bind to
  30088. * @param positiveUniform The positive uniform shader parameter
  30089. * @param neutralUniform The neutral uniform shader parameter
  30090. * @param negativeUniform The negative uniform shader parameter
  30091. */
  30092. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30093. /**
  30094. * Prepare the list of uniforms associated with the ColorCurves effects.
  30095. * @param uniformsList The list of uniforms used in the effect
  30096. */
  30097. static PrepareUniforms(uniformsList: string[]): void;
  30098. /**
  30099. * Returns color grading data based on a hue, density, saturation and exposure value.
  30100. * @param filterHue The hue of the color filter.
  30101. * @param filterDensity The density of the color filter.
  30102. * @param saturation The saturation.
  30103. * @param exposure The exposure.
  30104. * @param result The result data container.
  30105. */
  30106. private getColorGradingDataToRef;
  30107. /**
  30108. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30109. * @param value The input slider value in range [-100,100].
  30110. * @returns Adjusted value.
  30111. */
  30112. private static applyColorGradingSliderNonlinear;
  30113. /**
  30114. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30115. * @param hue The hue (H) input.
  30116. * @param saturation The saturation (S) input.
  30117. * @param brightness The brightness (B) input.
  30118. * @result An RGBA color represented as Vector4.
  30119. */
  30120. private static fromHSBToRef;
  30121. /**
  30122. * Returns a value clamped between min and max
  30123. * @param value The value to clamp
  30124. * @param min The minimum of value
  30125. * @param max The maximum of value
  30126. * @returns The clamped value.
  30127. */
  30128. private static clamp;
  30129. /**
  30130. * Clones the current color curve instance.
  30131. * @return The cloned curves
  30132. */
  30133. clone(): ColorCurves;
  30134. /**
  30135. * Serializes the current color curve instance to a json representation.
  30136. * @return a JSON representation
  30137. */
  30138. serialize(): any;
  30139. /**
  30140. * Parses the color curve from a json representation.
  30141. * @param source the JSON source to parse
  30142. * @return The parsed curves
  30143. */
  30144. static Parse(source: any): ColorCurves;
  30145. }
  30146. }
  30147. declare module BABYLON {
  30148. /**
  30149. * Interface to follow in your material defines to integrate easily the
  30150. * Image proccessing functions.
  30151. * @hidden
  30152. */
  30153. export interface IImageProcessingConfigurationDefines {
  30154. IMAGEPROCESSING: boolean;
  30155. VIGNETTE: boolean;
  30156. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30157. VIGNETTEBLENDMODEOPAQUE: boolean;
  30158. TONEMAPPING: boolean;
  30159. TONEMAPPING_ACES: boolean;
  30160. CONTRAST: boolean;
  30161. EXPOSURE: boolean;
  30162. COLORCURVES: boolean;
  30163. COLORGRADING: boolean;
  30164. COLORGRADING3D: boolean;
  30165. SAMPLER3DGREENDEPTH: boolean;
  30166. SAMPLER3DBGRMAP: boolean;
  30167. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30168. }
  30169. /**
  30170. * @hidden
  30171. */
  30172. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30173. IMAGEPROCESSING: boolean;
  30174. VIGNETTE: boolean;
  30175. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30176. VIGNETTEBLENDMODEOPAQUE: boolean;
  30177. TONEMAPPING: boolean;
  30178. TONEMAPPING_ACES: boolean;
  30179. CONTRAST: boolean;
  30180. COLORCURVES: boolean;
  30181. COLORGRADING: boolean;
  30182. COLORGRADING3D: boolean;
  30183. SAMPLER3DGREENDEPTH: boolean;
  30184. SAMPLER3DBGRMAP: boolean;
  30185. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30186. EXPOSURE: boolean;
  30187. constructor();
  30188. }
  30189. /**
  30190. * This groups together the common properties used for image processing either in direct forward pass
  30191. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30192. * or not.
  30193. */
  30194. export class ImageProcessingConfiguration {
  30195. /**
  30196. * Default tone mapping applied in BabylonJS.
  30197. */
  30198. static readonly TONEMAPPING_STANDARD: number;
  30199. /**
  30200. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30201. * to other engines rendering to increase portability.
  30202. */
  30203. static readonly TONEMAPPING_ACES: number;
  30204. /**
  30205. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30206. */
  30207. colorCurves: Nullable<ColorCurves>;
  30208. private _colorCurvesEnabled;
  30209. /**
  30210. * Gets wether the color curves effect is enabled.
  30211. */
  30212. /**
  30213. * Sets wether the color curves effect is enabled.
  30214. */
  30215. colorCurvesEnabled: boolean;
  30216. private _colorGradingTexture;
  30217. /**
  30218. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30219. */
  30220. /**
  30221. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30222. */
  30223. colorGradingTexture: Nullable<BaseTexture>;
  30224. private _colorGradingEnabled;
  30225. /**
  30226. * Gets wether the color grading effect is enabled.
  30227. */
  30228. /**
  30229. * Sets wether the color grading effect is enabled.
  30230. */
  30231. colorGradingEnabled: boolean;
  30232. private _colorGradingWithGreenDepth;
  30233. /**
  30234. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30235. */
  30236. /**
  30237. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30238. */
  30239. colorGradingWithGreenDepth: boolean;
  30240. private _colorGradingBGR;
  30241. /**
  30242. * Gets wether the color grading texture contains BGR values.
  30243. */
  30244. /**
  30245. * Sets wether the color grading texture contains BGR values.
  30246. */
  30247. colorGradingBGR: boolean;
  30248. /** @hidden */
  30249. _exposure: number;
  30250. /**
  30251. * Gets the Exposure used in the effect.
  30252. */
  30253. /**
  30254. * Sets the Exposure used in the effect.
  30255. */
  30256. exposure: number;
  30257. private _toneMappingEnabled;
  30258. /**
  30259. * Gets wether the tone mapping effect is enabled.
  30260. */
  30261. /**
  30262. * Sets wether the tone mapping effect is enabled.
  30263. */
  30264. toneMappingEnabled: boolean;
  30265. private _toneMappingType;
  30266. /**
  30267. * Gets the type of tone mapping effect.
  30268. */
  30269. /**
  30270. * Sets the type of tone mapping effect used in BabylonJS.
  30271. */
  30272. toneMappingType: number;
  30273. protected _contrast: number;
  30274. /**
  30275. * Gets the contrast used in the effect.
  30276. */
  30277. /**
  30278. * Sets the contrast used in the effect.
  30279. */
  30280. contrast: number;
  30281. /**
  30282. * Vignette stretch size.
  30283. */
  30284. vignetteStretch: number;
  30285. /**
  30286. * Vignette centre X Offset.
  30287. */
  30288. vignetteCentreX: number;
  30289. /**
  30290. * Vignette centre Y Offset.
  30291. */
  30292. vignetteCentreY: number;
  30293. /**
  30294. * Vignette weight or intensity of the vignette effect.
  30295. */
  30296. vignetteWeight: number;
  30297. /**
  30298. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30299. * if vignetteEnabled is set to true.
  30300. */
  30301. vignetteColor: Color4;
  30302. /**
  30303. * Camera field of view used by the Vignette effect.
  30304. */
  30305. vignetteCameraFov: number;
  30306. private _vignetteBlendMode;
  30307. /**
  30308. * Gets the vignette blend mode allowing different kind of effect.
  30309. */
  30310. /**
  30311. * Sets the vignette blend mode allowing different kind of effect.
  30312. */
  30313. vignetteBlendMode: number;
  30314. private _vignetteEnabled;
  30315. /**
  30316. * Gets wether the vignette effect is enabled.
  30317. */
  30318. /**
  30319. * Sets wether the vignette effect is enabled.
  30320. */
  30321. vignetteEnabled: boolean;
  30322. private _applyByPostProcess;
  30323. /**
  30324. * Gets wether the image processing is applied through a post process or not.
  30325. */
  30326. /**
  30327. * Sets wether the image processing is applied through a post process or not.
  30328. */
  30329. applyByPostProcess: boolean;
  30330. private _isEnabled;
  30331. /**
  30332. * Gets wether the image processing is enabled or not.
  30333. */
  30334. /**
  30335. * Sets wether the image processing is enabled or not.
  30336. */
  30337. isEnabled: boolean;
  30338. /**
  30339. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30340. */
  30341. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30342. /**
  30343. * Method called each time the image processing information changes requires to recompile the effect.
  30344. */
  30345. protected _updateParameters(): void;
  30346. /**
  30347. * Gets the current class name.
  30348. * @return "ImageProcessingConfiguration"
  30349. */
  30350. getClassName(): string;
  30351. /**
  30352. * Prepare the list of uniforms associated with the Image Processing effects.
  30353. * @param uniforms The list of uniforms used in the effect
  30354. * @param defines the list of defines currently in use
  30355. */
  30356. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30357. /**
  30358. * Prepare the list of samplers associated with the Image Processing effects.
  30359. * @param samplersList The list of uniforms used in the effect
  30360. * @param defines the list of defines currently in use
  30361. */
  30362. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30363. /**
  30364. * Prepare the list of defines associated to the shader.
  30365. * @param defines the list of defines to complete
  30366. * @param forPostProcess Define if we are currently in post process mode or not
  30367. */
  30368. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30369. /**
  30370. * Returns true if all the image processing information are ready.
  30371. * @returns True if ready, otherwise, false
  30372. */
  30373. isReady(): boolean;
  30374. /**
  30375. * Binds the image processing to the shader.
  30376. * @param effect The effect to bind to
  30377. * @param aspectRatio Define the current aspect ratio of the effect
  30378. */
  30379. bind(effect: Effect, aspectRatio?: number): void;
  30380. /**
  30381. * Clones the current image processing instance.
  30382. * @return The cloned image processing
  30383. */
  30384. clone(): ImageProcessingConfiguration;
  30385. /**
  30386. * Serializes the current image processing instance to a json representation.
  30387. * @return a JSON representation
  30388. */
  30389. serialize(): any;
  30390. /**
  30391. * Parses the image processing from a json representation.
  30392. * @param source the JSON source to parse
  30393. * @return The parsed image processing
  30394. */
  30395. static Parse(source: any): ImageProcessingConfiguration;
  30396. private static _VIGNETTEMODE_MULTIPLY;
  30397. private static _VIGNETTEMODE_OPAQUE;
  30398. /**
  30399. * Used to apply the vignette as a mix with the pixel color.
  30400. */
  30401. static readonly VIGNETTEMODE_MULTIPLY: number;
  30402. /**
  30403. * Used to apply the vignette as a replacement of the pixel color.
  30404. */
  30405. static readonly VIGNETTEMODE_OPAQUE: number;
  30406. }
  30407. }
  30408. declare module BABYLON {
  30409. /**
  30410. * This represents all the required information to add a fresnel effect on a material:
  30411. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30412. */
  30413. export class FresnelParameters {
  30414. private _isEnabled;
  30415. /**
  30416. * Define if the fresnel effect is enable or not.
  30417. */
  30418. isEnabled: boolean;
  30419. /**
  30420. * Define the color used on edges (grazing angle)
  30421. */
  30422. leftColor: Color3;
  30423. /**
  30424. * Define the color used on center
  30425. */
  30426. rightColor: Color3;
  30427. /**
  30428. * Define bias applied to computed fresnel term
  30429. */
  30430. bias: number;
  30431. /**
  30432. * Defined the power exponent applied to fresnel term
  30433. */
  30434. power: number;
  30435. /**
  30436. * Clones the current fresnel and its valuues
  30437. * @returns a clone fresnel configuration
  30438. */
  30439. clone(): FresnelParameters;
  30440. /**
  30441. * Serializes the current fresnel parameters to a JSON representation.
  30442. * @return the JSON serialization
  30443. */
  30444. serialize(): any;
  30445. /**
  30446. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30447. * @param parsedFresnelParameters Define the JSON representation
  30448. * @returns the parsed parameters
  30449. */
  30450. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30451. }
  30452. }
  30453. declare module BABYLON {
  30454. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30455. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30456. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30457. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30458. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30459. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30460. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30461. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30462. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30463. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30464. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30465. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30466. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30467. /**
  30468. * Decorator used to define property that can be serialized as reference to a camera
  30469. * @param sourceName defines the name of the property to decorate
  30470. */
  30471. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30472. /**
  30473. * Class used to help serialization objects
  30474. */
  30475. export class SerializationHelper {
  30476. /** @hidden */
  30477. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30478. /** @hidden */
  30479. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30480. /** @hidden */
  30481. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30482. /** @hidden */
  30483. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30484. /**
  30485. * Appends the serialized animations from the source animations
  30486. * @param source Source containing the animations
  30487. * @param destination Target to store the animations
  30488. */
  30489. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30490. /**
  30491. * Static function used to serialized a specific entity
  30492. * @param entity defines the entity to serialize
  30493. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30494. * @returns a JSON compatible object representing the serialization of the entity
  30495. */
  30496. static Serialize<T>(entity: T, serializationObject?: any): any;
  30497. /**
  30498. * Creates a new entity from a serialization data object
  30499. * @param creationFunction defines a function used to instanciated the new entity
  30500. * @param source defines the source serialization data
  30501. * @param scene defines the hosting scene
  30502. * @param rootUrl defines the root url for resources
  30503. * @returns a new entity
  30504. */
  30505. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30506. /**
  30507. * Clones an object
  30508. * @param creationFunction defines the function used to instanciate the new object
  30509. * @param source defines the source object
  30510. * @returns the cloned object
  30511. */
  30512. static Clone<T>(creationFunction: () => T, source: T): T;
  30513. /**
  30514. * Instanciates a new object based on a source one (some data will be shared between both object)
  30515. * @param creationFunction defines the function used to instanciate the new object
  30516. * @param source defines the source object
  30517. * @returns the new object
  30518. */
  30519. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30520. }
  30521. }
  30522. declare module BABYLON {
  30523. /**
  30524. * This is the base class of all the camera used in the application.
  30525. * @see http://doc.babylonjs.com/features/cameras
  30526. */
  30527. export class Camera extends Node {
  30528. /** @hidden */
  30529. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30530. /**
  30531. * This is the default projection mode used by the cameras.
  30532. * It helps recreating a feeling of perspective and better appreciate depth.
  30533. * This is the best way to simulate real life cameras.
  30534. */
  30535. static readonly PERSPECTIVE_CAMERA: number;
  30536. /**
  30537. * This helps creating camera with an orthographic mode.
  30538. * 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.
  30539. */
  30540. static readonly ORTHOGRAPHIC_CAMERA: number;
  30541. /**
  30542. * This is the default FOV mode for perspective cameras.
  30543. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30544. */
  30545. static readonly FOVMODE_VERTICAL_FIXED: number;
  30546. /**
  30547. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30548. */
  30549. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30550. /**
  30551. * This specifies ther is no need for a camera rig.
  30552. * Basically only one eye is rendered corresponding to the camera.
  30553. */
  30554. static readonly RIG_MODE_NONE: number;
  30555. /**
  30556. * Simulates a camera Rig with one blue eye and one red eye.
  30557. * This can be use with 3d blue and red glasses.
  30558. */
  30559. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30560. /**
  30561. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30562. */
  30563. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30564. /**
  30565. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30566. */
  30567. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30568. /**
  30569. * Defines that both eyes of the camera will be rendered over under each other.
  30570. */
  30571. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30572. /**
  30573. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30574. */
  30575. static readonly RIG_MODE_VR: number;
  30576. /**
  30577. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30578. */
  30579. static readonly RIG_MODE_WEBVR: number;
  30580. /**
  30581. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30582. */
  30583. static readonly RIG_MODE_CUSTOM: number;
  30584. /**
  30585. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30586. */
  30587. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30588. /**
  30589. * Define the input manager associated with the camera.
  30590. */
  30591. inputs: CameraInputsManager<Camera>;
  30592. /** @hidden */
  30593. _position: Vector3;
  30594. /**
  30595. * Define the current local position of the camera in the scene
  30596. */
  30597. position: Vector3;
  30598. /**
  30599. * The vector the camera should consider as up.
  30600. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30601. */
  30602. upVector: Vector3;
  30603. /**
  30604. * Define the current limit on the left side for an orthographic camera
  30605. * In scene unit
  30606. */
  30607. orthoLeft: Nullable<number>;
  30608. /**
  30609. * Define the current limit on the right side for an orthographic camera
  30610. * In scene unit
  30611. */
  30612. orthoRight: Nullable<number>;
  30613. /**
  30614. * Define the current limit on the bottom side for an orthographic camera
  30615. * In scene unit
  30616. */
  30617. orthoBottom: Nullable<number>;
  30618. /**
  30619. * Define the current limit on the top side for an orthographic camera
  30620. * In scene unit
  30621. */
  30622. orthoTop: Nullable<number>;
  30623. /**
  30624. * Field Of View is set in Radians. (default is 0.8)
  30625. */
  30626. fov: number;
  30627. /**
  30628. * Define the minimum distance the camera can see from.
  30629. * This is important to note that the depth buffer are not infinite and the closer it starts
  30630. * the more your scene might encounter depth fighting issue.
  30631. */
  30632. minZ: number;
  30633. /**
  30634. * Define the maximum distance the camera can see to.
  30635. * This is important to note that the depth buffer are not infinite and the further it end
  30636. * the more your scene might encounter depth fighting issue.
  30637. */
  30638. maxZ: number;
  30639. /**
  30640. * Define the default inertia of the camera.
  30641. * This helps giving a smooth feeling to the camera movement.
  30642. */
  30643. inertia: number;
  30644. /**
  30645. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30646. */
  30647. mode: number;
  30648. /**
  30649. * Define wether the camera is intermediate.
  30650. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30651. */
  30652. isIntermediate: boolean;
  30653. /**
  30654. * Define the viewport of the camera.
  30655. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30656. */
  30657. viewport: Viewport;
  30658. /**
  30659. * Restricts the camera to viewing objects with the same layerMask.
  30660. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30661. */
  30662. layerMask: number;
  30663. /**
  30664. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30665. */
  30666. fovMode: number;
  30667. /**
  30668. * Rig mode of the camera.
  30669. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30670. * This is normally controlled byt the camera themselves as internal use.
  30671. */
  30672. cameraRigMode: number;
  30673. /**
  30674. * Defines the distance between both "eyes" in case of a RIG
  30675. */
  30676. interaxialDistance: number;
  30677. /**
  30678. * Defines if stereoscopic rendering is done side by side or over under.
  30679. */
  30680. isStereoscopicSideBySide: boolean;
  30681. /**
  30682. * 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
  30683. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30684. * else in the scene.
  30685. */
  30686. customRenderTargets: RenderTargetTexture[];
  30687. /**
  30688. * When set, the camera will render to this render target instead of the default canvas
  30689. */
  30690. outputRenderTarget: Nullable<RenderTargetTexture>;
  30691. /**
  30692. * Observable triggered when the camera view matrix has changed.
  30693. */
  30694. onViewMatrixChangedObservable: Observable<Camera>;
  30695. /**
  30696. * Observable triggered when the camera Projection matrix has changed.
  30697. */
  30698. onProjectionMatrixChangedObservable: Observable<Camera>;
  30699. /**
  30700. * Observable triggered when the inputs have been processed.
  30701. */
  30702. onAfterCheckInputsObservable: Observable<Camera>;
  30703. /**
  30704. * Observable triggered when reset has been called and applied to the camera.
  30705. */
  30706. onRestoreStateObservable: Observable<Camera>;
  30707. /** @hidden */
  30708. _cameraRigParams: any;
  30709. /** @hidden */
  30710. _rigCameras: Camera[];
  30711. /** @hidden */
  30712. _rigPostProcess: Nullable<PostProcess>;
  30713. protected _webvrViewMatrix: Matrix;
  30714. /** @hidden */
  30715. _skipRendering: boolean;
  30716. /** @hidden */
  30717. _projectionMatrix: Matrix;
  30718. /** @hidden */
  30719. _postProcesses: Nullable<PostProcess>[];
  30720. /** @hidden */
  30721. _activeMeshes: SmartArray<AbstractMesh>;
  30722. protected _globalPosition: Vector3;
  30723. /** @hidden */
  30724. _computedViewMatrix: Matrix;
  30725. private _doNotComputeProjectionMatrix;
  30726. private _transformMatrix;
  30727. private _frustumPlanes;
  30728. private _refreshFrustumPlanes;
  30729. private _storedFov;
  30730. private _stateStored;
  30731. /**
  30732. * Instantiates a new camera object.
  30733. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30734. * @see http://doc.babylonjs.com/features/cameras
  30735. * @param name Defines the name of the camera in the scene
  30736. * @param position Defines the position of the camera
  30737. * @param scene Defines the scene the camera belongs too
  30738. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30739. */
  30740. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30741. /**
  30742. * Store current camera state (fov, position, etc..)
  30743. * @returns the camera
  30744. */
  30745. storeState(): Camera;
  30746. /**
  30747. * Restores the camera state values if it has been stored. You must call storeState() first
  30748. */
  30749. protected _restoreStateValues(): boolean;
  30750. /**
  30751. * Restored camera state. You must call storeState() first.
  30752. * @returns true if restored and false otherwise
  30753. */
  30754. restoreState(): boolean;
  30755. /**
  30756. * Gets the class name of the camera.
  30757. * @returns the class name
  30758. */
  30759. getClassName(): string;
  30760. /** @hidden */
  30761. readonly _isCamera: boolean;
  30762. /**
  30763. * Gets a string representation of the camera useful for debug purpose.
  30764. * @param fullDetails Defines that a more verboe level of logging is required
  30765. * @returns the string representation
  30766. */
  30767. toString(fullDetails?: boolean): string;
  30768. /**
  30769. * Gets the current world space position of the camera.
  30770. */
  30771. readonly globalPosition: Vector3;
  30772. /**
  30773. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30774. * @returns the active meshe list
  30775. */
  30776. getActiveMeshes(): SmartArray<AbstractMesh>;
  30777. /**
  30778. * Check wether a mesh is part of the current active mesh list of the camera
  30779. * @param mesh Defines the mesh to check
  30780. * @returns true if active, false otherwise
  30781. */
  30782. isActiveMesh(mesh: Mesh): boolean;
  30783. /**
  30784. * Is this camera ready to be used/rendered
  30785. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30786. * @return true if the camera is ready
  30787. */
  30788. isReady(completeCheck?: boolean): boolean;
  30789. /** @hidden */
  30790. _initCache(): void;
  30791. /** @hidden */
  30792. _updateCache(ignoreParentClass?: boolean): void;
  30793. /** @hidden */
  30794. _isSynchronized(): boolean;
  30795. /** @hidden */
  30796. _isSynchronizedViewMatrix(): boolean;
  30797. /** @hidden */
  30798. _isSynchronizedProjectionMatrix(): boolean;
  30799. /**
  30800. * Attach the input controls to a specific dom element to get the input from.
  30801. * @param element Defines the element the controls should be listened from
  30802. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30803. */
  30804. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30805. /**
  30806. * Detach the current controls from the specified dom element.
  30807. * @param element Defines the element to stop listening the inputs from
  30808. */
  30809. detachControl(element: HTMLElement): void;
  30810. /**
  30811. * Update the camera state according to the different inputs gathered during the frame.
  30812. */
  30813. update(): void;
  30814. /** @hidden */
  30815. _checkInputs(): void;
  30816. /** @hidden */
  30817. readonly rigCameras: Camera[];
  30818. /**
  30819. * Gets the post process used by the rig cameras
  30820. */
  30821. readonly rigPostProcess: Nullable<PostProcess>;
  30822. /**
  30823. * Internal, gets the first post proces.
  30824. * @returns the first post process to be run on this camera.
  30825. */
  30826. _getFirstPostProcess(): Nullable<PostProcess>;
  30827. private _cascadePostProcessesToRigCams;
  30828. /**
  30829. * Attach a post process to the camera.
  30830. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30831. * @param postProcess The post process to attach to the camera
  30832. * @param insertAt The position of the post process in case several of them are in use in the scene
  30833. * @returns the position the post process has been inserted at
  30834. */
  30835. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30836. /**
  30837. * Detach a post process to the camera.
  30838. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30839. * @param postProcess The post process to detach from the camera
  30840. */
  30841. detachPostProcess(postProcess: PostProcess): void;
  30842. /**
  30843. * Gets the current world matrix of the camera
  30844. */
  30845. getWorldMatrix(): Matrix;
  30846. /** @hidden */
  30847. _getViewMatrix(): Matrix;
  30848. /**
  30849. * Gets the current view matrix of the camera.
  30850. * @param force forces the camera to recompute the matrix without looking at the cached state
  30851. * @returns the view matrix
  30852. */
  30853. getViewMatrix(force?: boolean): Matrix;
  30854. /**
  30855. * Freeze the projection matrix.
  30856. * It will prevent the cache check of the camera projection compute and can speed up perf
  30857. * if no parameter of the camera are meant to change
  30858. * @param projection Defines manually a projection if necessary
  30859. */
  30860. freezeProjectionMatrix(projection?: Matrix): void;
  30861. /**
  30862. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30863. */
  30864. unfreezeProjectionMatrix(): void;
  30865. /**
  30866. * Gets the current projection matrix of the camera.
  30867. * @param force forces the camera to recompute the matrix without looking at the cached state
  30868. * @returns the projection matrix
  30869. */
  30870. getProjectionMatrix(force?: boolean): Matrix;
  30871. /**
  30872. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30873. * @returns a Matrix
  30874. */
  30875. getTransformationMatrix(): Matrix;
  30876. private _updateFrustumPlanes;
  30877. /**
  30878. * Checks if a cullable object (mesh...) is in the camera frustum
  30879. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30880. * @param target The object to check
  30881. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30882. * @returns true if the object is in frustum otherwise false
  30883. */
  30884. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30885. /**
  30886. * Checks if a cullable object (mesh...) is in the camera frustum
  30887. * Unlike isInFrustum this cheks the full bounding box
  30888. * @param target The object to check
  30889. * @returns true if the object is in frustum otherwise false
  30890. */
  30891. isCompletelyInFrustum(target: ICullable): boolean;
  30892. /**
  30893. * Gets a ray in the forward direction from the camera.
  30894. * @param length Defines the length of the ray to create
  30895. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30896. * @param origin Defines the start point of the ray which defaults to the camera position
  30897. * @returns the forward ray
  30898. */
  30899. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30900. /**
  30901. * Releases resources associated with this node.
  30902. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30903. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30904. */
  30905. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30906. /** @hidden */
  30907. _isLeftCamera: boolean;
  30908. /**
  30909. * Gets the left camera of a rig setup in case of Rigged Camera
  30910. */
  30911. readonly isLeftCamera: boolean;
  30912. /** @hidden */
  30913. _isRightCamera: boolean;
  30914. /**
  30915. * Gets the right camera of a rig setup in case of Rigged Camera
  30916. */
  30917. readonly isRightCamera: boolean;
  30918. /**
  30919. * Gets the left camera of a rig setup in case of Rigged Camera
  30920. */
  30921. readonly leftCamera: Nullable<FreeCamera>;
  30922. /**
  30923. * Gets the right camera of a rig setup in case of Rigged Camera
  30924. */
  30925. readonly rightCamera: Nullable<FreeCamera>;
  30926. /**
  30927. * Gets the left camera target of a rig setup in case of Rigged Camera
  30928. * @returns the target position
  30929. */
  30930. getLeftTarget(): Nullable<Vector3>;
  30931. /**
  30932. * Gets the right camera target of a rig setup in case of Rigged Camera
  30933. * @returns the target position
  30934. */
  30935. getRightTarget(): Nullable<Vector3>;
  30936. /**
  30937. * @hidden
  30938. */
  30939. setCameraRigMode(mode: number, rigParams: any): void;
  30940. /** @hidden */
  30941. static _setStereoscopicRigMode(camera: Camera): void;
  30942. /** @hidden */
  30943. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30944. /** @hidden */
  30945. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30946. /** @hidden */
  30947. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30948. /** @hidden */
  30949. _getVRProjectionMatrix(): Matrix;
  30950. protected _updateCameraRotationMatrix(): void;
  30951. protected _updateWebVRCameraRotationMatrix(): void;
  30952. /**
  30953. * This function MUST be overwritten by the different WebVR cameras available.
  30954. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30955. * @hidden
  30956. */
  30957. _getWebVRProjectionMatrix(): Matrix;
  30958. /**
  30959. * This function MUST be overwritten by the different WebVR cameras available.
  30960. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30961. * @hidden
  30962. */
  30963. _getWebVRViewMatrix(): Matrix;
  30964. /** @hidden */
  30965. setCameraRigParameter(name: string, value: any): void;
  30966. /**
  30967. * needs to be overridden by children so sub has required properties to be copied
  30968. * @hidden
  30969. */
  30970. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30971. /**
  30972. * May need to be overridden by children
  30973. * @hidden
  30974. */
  30975. _updateRigCameras(): void;
  30976. /** @hidden */
  30977. _setupInputs(): void;
  30978. /**
  30979. * Serialiaze the camera setup to a json represention
  30980. * @returns the JSON representation
  30981. */
  30982. serialize(): any;
  30983. /**
  30984. * Clones the current camera.
  30985. * @param name The cloned camera name
  30986. * @returns the cloned camera
  30987. */
  30988. clone(name: string): Camera;
  30989. /**
  30990. * Gets the direction of the camera relative to a given local axis.
  30991. * @param localAxis Defines the reference axis to provide a relative direction.
  30992. * @return the direction
  30993. */
  30994. getDirection(localAxis: Vector3): Vector3;
  30995. /**
  30996. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30997. * @param localAxis Defines the reference axis to provide a relative direction.
  30998. * @param result Defines the vector to store the result in
  30999. */
  31000. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31001. /**
  31002. * Gets a camera constructor for a given camera type
  31003. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31004. * @param name The name of the camera the result will be able to instantiate
  31005. * @param scene The scene the result will construct the camera in
  31006. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31007. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31008. * @returns a factory method to construc the camera
  31009. */
  31010. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31011. /**
  31012. * Compute the world matrix of the camera.
  31013. * @returns the camera workd matrix
  31014. */
  31015. computeWorldMatrix(): Matrix;
  31016. /**
  31017. * Parse a JSON and creates the camera from the parsed information
  31018. * @param parsedCamera The JSON to parse
  31019. * @param scene The scene to instantiate the camera in
  31020. * @returns the newly constructed camera
  31021. */
  31022. static Parse(parsedCamera: any, scene: Scene): Camera;
  31023. }
  31024. }
  31025. declare module BABYLON {
  31026. /**
  31027. * Interface for any object that can request an animation frame
  31028. */
  31029. export interface ICustomAnimationFrameRequester {
  31030. /**
  31031. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31032. */
  31033. renderFunction?: Function;
  31034. /**
  31035. * Called to request the next frame to render to
  31036. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31037. */
  31038. requestAnimationFrame: Function;
  31039. /**
  31040. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31041. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31042. */
  31043. requestID?: number;
  31044. }
  31045. /**
  31046. * Interface containing an array of animations
  31047. */
  31048. export interface IAnimatable {
  31049. /**
  31050. * Array of animations
  31051. */
  31052. animations: Nullable<Array<Animation>>;
  31053. }
  31054. /** Interface used by value gradients (color, factor, ...) */
  31055. export interface IValueGradient {
  31056. /**
  31057. * Gets or sets the gradient value (between 0 and 1)
  31058. */
  31059. gradient: number;
  31060. }
  31061. /** Class used to store color4 gradient */
  31062. export class ColorGradient implements IValueGradient {
  31063. /**
  31064. * Gets or sets the gradient value (between 0 and 1)
  31065. */
  31066. gradient: number;
  31067. /**
  31068. * Gets or sets first associated color
  31069. */
  31070. color1: Color4;
  31071. /**
  31072. * Gets or sets second associated color
  31073. */
  31074. color2?: Color4;
  31075. /**
  31076. * Will get a color picked randomly between color1 and color2.
  31077. * If color2 is undefined then color1 will be used
  31078. * @param result defines the target Color4 to store the result in
  31079. */
  31080. getColorToRef(result: Color4): void;
  31081. }
  31082. /** Class used to store color 3 gradient */
  31083. export class Color3Gradient implements IValueGradient {
  31084. /**
  31085. * Gets or sets the gradient value (between 0 and 1)
  31086. */
  31087. gradient: number;
  31088. /**
  31089. * Gets or sets the associated color
  31090. */
  31091. color: Color3;
  31092. }
  31093. /** Class used to store factor gradient */
  31094. export class FactorGradient implements IValueGradient {
  31095. /**
  31096. * Gets or sets the gradient value (between 0 and 1)
  31097. */
  31098. gradient: number;
  31099. /**
  31100. * Gets or sets first associated factor
  31101. */
  31102. factor1: number;
  31103. /**
  31104. * Gets or sets second associated factor
  31105. */
  31106. factor2?: number;
  31107. /**
  31108. * Will get a number picked randomly between factor1 and factor2.
  31109. * If factor2 is undefined then factor1 will be used
  31110. * @returns the picked number
  31111. */
  31112. getFactor(): number;
  31113. }
  31114. /**
  31115. * @ignore
  31116. * Application error to support additional information when loading a file
  31117. */
  31118. export class LoadFileError extends Error {
  31119. /** defines the optional web request */
  31120. request?: WebRequest | undefined;
  31121. private static _setPrototypeOf;
  31122. /**
  31123. * Creates a new LoadFileError
  31124. * @param message defines the message of the error
  31125. * @param request defines the optional web request
  31126. */
  31127. constructor(message: string,
  31128. /** defines the optional web request */
  31129. request?: WebRequest | undefined);
  31130. }
  31131. /**
  31132. * Class used to define a retry strategy when error happens while loading assets
  31133. */
  31134. export class RetryStrategy {
  31135. /**
  31136. * Function used to defines an exponential back off strategy
  31137. * @param maxRetries defines the maximum number of retries (3 by default)
  31138. * @param baseInterval defines the interval between retries
  31139. * @returns the strategy function to use
  31140. */
  31141. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31142. }
  31143. /**
  31144. * File request interface
  31145. */
  31146. export interface IFileRequest {
  31147. /**
  31148. * Raised when the request is complete (success or error).
  31149. */
  31150. onCompleteObservable: Observable<IFileRequest>;
  31151. /**
  31152. * Aborts the request for a file.
  31153. */
  31154. abort: () => void;
  31155. }
  31156. /**
  31157. * Class containing a set of static utilities functions
  31158. */
  31159. export class Tools {
  31160. /**
  31161. * Gets or sets the base URL to use to load assets
  31162. */
  31163. static BaseUrl: string;
  31164. /**
  31165. * Enable/Disable Custom HTTP Request Headers globally.
  31166. * default = false
  31167. * @see CustomRequestHeaders
  31168. */
  31169. static UseCustomRequestHeaders: boolean;
  31170. /**
  31171. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31172. * i.e. when loading files, where the server/service expects an Authorization header
  31173. */
  31174. static CustomRequestHeaders: {
  31175. [key: string]: string;
  31176. };
  31177. /**
  31178. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31179. */
  31180. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31181. /**
  31182. * Default behaviour for cors in the application.
  31183. * It can be a string if the expected behavior is identical in the entire app.
  31184. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31185. */
  31186. static CorsBehavior: string | ((url: string | string[]) => string);
  31187. /**
  31188. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31189. * @ignorenaming
  31190. */
  31191. static UseFallbackTexture: boolean;
  31192. /**
  31193. * Use this object to register external classes like custom textures or material
  31194. * to allow the laoders to instantiate them
  31195. */
  31196. static RegisteredExternalClasses: {
  31197. [key: string]: Object;
  31198. };
  31199. /**
  31200. * Texture content used if a texture cannot loaded
  31201. * @ignorenaming
  31202. */
  31203. static fallbackTexture: string;
  31204. /**
  31205. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31206. * @param u defines the coordinate on X axis
  31207. * @param v defines the coordinate on Y axis
  31208. * @param width defines the width of the source data
  31209. * @param height defines the height of the source data
  31210. * @param pixels defines the source byte array
  31211. * @param color defines the output color
  31212. */
  31213. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31214. /**
  31215. * Interpolates between a and b via alpha
  31216. * @param a The lower value (returned when alpha = 0)
  31217. * @param b The upper value (returned when alpha = 1)
  31218. * @param alpha The interpolation-factor
  31219. * @return The mixed value
  31220. */
  31221. static Mix(a: number, b: number, alpha: number): number;
  31222. /**
  31223. * Tries to instantiate a new object from a given class name
  31224. * @param className defines the class name to instantiate
  31225. * @returns the new object or null if the system was not able to do the instantiation
  31226. */
  31227. static Instantiate(className: string): any;
  31228. /**
  31229. * Provides a slice function that will work even on IE
  31230. * @param data defines the array to slice
  31231. * @param start defines the start of the data (optional)
  31232. * @param end defines the end of the data (optional)
  31233. * @returns the new sliced array
  31234. */
  31235. static Slice<T>(data: T, start?: number, end?: number): T;
  31236. /**
  31237. * Polyfill for setImmediate
  31238. * @param action defines the action to execute after the current execution block
  31239. */
  31240. static SetImmediate(action: () => void): void;
  31241. /**
  31242. * Function indicating if a number is an exponent of 2
  31243. * @param value defines the value to test
  31244. * @returns true if the value is an exponent of 2
  31245. */
  31246. static IsExponentOfTwo(value: number): boolean;
  31247. private static _tmpFloatArray;
  31248. /**
  31249. * Returns the nearest 32-bit single precision float representation of a Number
  31250. * @param value A Number. If the parameter is of a different type, it will get converted
  31251. * to a number or to NaN if it cannot be converted
  31252. * @returns number
  31253. */
  31254. static FloatRound(value: number): number;
  31255. /**
  31256. * Find the next highest power of two.
  31257. * @param x Number to start search from.
  31258. * @return Next highest power of two.
  31259. */
  31260. static CeilingPOT(x: number): number;
  31261. /**
  31262. * Find the next lowest power of two.
  31263. * @param x Number to start search from.
  31264. * @return Next lowest power of two.
  31265. */
  31266. static FloorPOT(x: number): number;
  31267. /**
  31268. * Find the nearest power of two.
  31269. * @param x Number to start search from.
  31270. * @return Next nearest power of two.
  31271. */
  31272. static NearestPOT(x: number): number;
  31273. /**
  31274. * Get the closest exponent of two
  31275. * @param value defines the value to approximate
  31276. * @param max defines the maximum value to return
  31277. * @param mode defines how to define the closest value
  31278. * @returns closest exponent of two of the given value
  31279. */
  31280. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31281. /**
  31282. * Extracts the filename from a path
  31283. * @param path defines the path to use
  31284. * @returns the filename
  31285. */
  31286. static GetFilename(path: string): string;
  31287. /**
  31288. * Extracts the "folder" part of a path (everything before the filename).
  31289. * @param uri The URI to extract the info from
  31290. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31291. * @returns The "folder" part of the path
  31292. */
  31293. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31294. /**
  31295. * Extracts text content from a DOM element hierarchy
  31296. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31297. */
  31298. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31299. /**
  31300. * Convert an angle in radians to degrees
  31301. * @param angle defines the angle to convert
  31302. * @returns the angle in degrees
  31303. */
  31304. static ToDegrees(angle: number): number;
  31305. /**
  31306. * Convert an angle in degrees to radians
  31307. * @param angle defines the angle to convert
  31308. * @returns the angle in radians
  31309. */
  31310. static ToRadians(angle: number): number;
  31311. /**
  31312. * Encode a buffer to a base64 string
  31313. * @param buffer defines the buffer to encode
  31314. * @returns the encoded string
  31315. */
  31316. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31317. /**
  31318. * Extracts minimum and maximum values from a list of indexed positions
  31319. * @param positions defines the positions to use
  31320. * @param indices defines the indices to the positions
  31321. * @param indexStart defines the start index
  31322. * @param indexCount defines the end index
  31323. * @param bias defines bias value to add to the result
  31324. * @return minimum and maximum values
  31325. */
  31326. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31327. minimum: Vector3;
  31328. maximum: Vector3;
  31329. };
  31330. /**
  31331. * Extracts minimum and maximum values from a list of positions
  31332. * @param positions defines the positions to use
  31333. * @param start defines the start index in the positions array
  31334. * @param count defines the number of positions to handle
  31335. * @param bias defines bias value to add to the result
  31336. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31337. * @return minimum and maximum values
  31338. */
  31339. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31340. minimum: Vector3;
  31341. maximum: Vector3;
  31342. };
  31343. /**
  31344. * Returns an array if obj is not an array
  31345. * @param obj defines the object to evaluate as an array
  31346. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31347. * @returns either obj directly if obj is an array or a new array containing obj
  31348. */
  31349. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31350. /**
  31351. * Gets the pointer prefix to use
  31352. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31353. */
  31354. static GetPointerPrefix(): string;
  31355. /**
  31356. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31357. * @param func - the function to be called
  31358. * @param requester - the object that will request the next frame. Falls back to window.
  31359. * @returns frame number
  31360. */
  31361. static QueueNewFrame(func: () => void, requester?: any): number;
  31362. /**
  31363. * Ask the browser to promote the current element to fullscreen rendering mode
  31364. * @param element defines the DOM element to promote
  31365. */
  31366. static RequestFullscreen(element: HTMLElement): void;
  31367. /**
  31368. * Asks the browser to exit fullscreen mode
  31369. */
  31370. static ExitFullscreen(): void;
  31371. /**
  31372. * Ask the browser to promote the current element to pointerlock mode
  31373. * @param element defines the DOM element to promote
  31374. */
  31375. static RequestPointerlock(element: HTMLElement): void;
  31376. /**
  31377. * Asks the browser to exit pointerlock mode
  31378. */
  31379. static ExitPointerlock(): void;
  31380. /**
  31381. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31382. * @param url define the url we are trying
  31383. * @param element define the dom element where to configure the cors policy
  31384. */
  31385. static SetCorsBehavior(url: string | string[], element: {
  31386. crossOrigin: string | null;
  31387. }): void;
  31388. /**
  31389. * Removes unwanted characters from an url
  31390. * @param url defines the url to clean
  31391. * @returns the cleaned url
  31392. */
  31393. static CleanUrl(url: string): string;
  31394. /**
  31395. * Gets or sets a function used to pre-process url before using them to load assets
  31396. */
  31397. static PreprocessUrl: (url: string) => string;
  31398. /**
  31399. * Loads an image as an HTMLImageElement.
  31400. * @param input url string, ArrayBuffer, or Blob to load
  31401. * @param onLoad callback called when the image successfully loads
  31402. * @param onError callback called when the image fails to load
  31403. * @param offlineProvider offline provider for caching
  31404. * @returns the HTMLImageElement of the loaded image
  31405. */
  31406. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31407. /**
  31408. * Loads a file
  31409. * @param url url string, ArrayBuffer, or Blob to load
  31410. * @param onSuccess callback called when the file successfully loads
  31411. * @param onProgress callback called while file is loading (if the server supports this mode)
  31412. * @param offlineProvider defines the offline provider for caching
  31413. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31414. * @param onError callback called when the file fails to load
  31415. * @returns a file request object
  31416. */
  31417. 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;
  31418. /**
  31419. * Loads a file from a url
  31420. * @param url the file url to load
  31421. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31422. */
  31423. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31424. /**
  31425. * Load a script (identified by an url). When the url returns, the
  31426. * content of this file is added into a new script element, attached to the DOM (body element)
  31427. * @param scriptUrl defines the url of the script to laod
  31428. * @param onSuccess defines the callback called when the script is loaded
  31429. * @param onError defines the callback to call if an error occurs
  31430. * @param scriptId defines the id of the script element
  31431. */
  31432. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31433. /**
  31434. * Load an asynchronous script (identified by an url). When the url returns, the
  31435. * content of this file is added into a new script element, attached to the DOM (body element)
  31436. * @param scriptUrl defines the url of the script to laod
  31437. * @param scriptId defines the id of the script element
  31438. * @returns a promise request object
  31439. */
  31440. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31441. /**
  31442. * Loads a file from a blob
  31443. * @param fileToLoad defines the blob to use
  31444. * @param callback defines the callback to call when data is loaded
  31445. * @param progressCallback defines the callback to call during loading process
  31446. * @returns a file request object
  31447. */
  31448. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31449. /**
  31450. * Loads a file
  31451. * @param fileToLoad defines the file to load
  31452. * @param callback defines the callback to call when data is loaded
  31453. * @param progressCallBack defines the callback to call during loading process
  31454. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31455. * @returns a file request object
  31456. */
  31457. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31458. /**
  31459. * Creates a data url from a given string content
  31460. * @param content defines the content to convert
  31461. * @returns the new data url link
  31462. */
  31463. static FileAsURL(content: string): string;
  31464. /**
  31465. * Format the given number to a specific decimal format
  31466. * @param value defines the number to format
  31467. * @param decimals defines the number of decimals to use
  31468. * @returns the formatted string
  31469. */
  31470. static Format(value: number, decimals?: number): string;
  31471. /**
  31472. * Checks if a given vector is inside a specific range
  31473. * @param v defines the vector to test
  31474. * @param min defines the minimum range
  31475. * @param max defines the maximum range
  31476. */
  31477. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31478. /**
  31479. * Tries to copy an object by duplicating every property
  31480. * @param source defines the source object
  31481. * @param destination defines the target object
  31482. * @param doNotCopyList defines a list of properties to avoid
  31483. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31484. */
  31485. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31486. /**
  31487. * Gets a boolean indicating if the given object has no own property
  31488. * @param obj defines the object to test
  31489. * @returns true if object has no own property
  31490. */
  31491. static IsEmpty(obj: any): boolean;
  31492. /**
  31493. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31494. * @param str Source string
  31495. * @param suffix Suffix to search for in the source string
  31496. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31497. */
  31498. static EndsWith(str: string, suffix: string): boolean;
  31499. /**
  31500. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  31501. * @param str Source string
  31502. * @param suffix Suffix to search for in the source string
  31503. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31504. */
  31505. static StartsWith(str: string, suffix: string): boolean;
  31506. /**
  31507. * Function used to register events at window level
  31508. * @param events defines the events to register
  31509. */
  31510. static RegisterTopRootEvents(events: {
  31511. name: string;
  31512. handler: Nullable<(e: FocusEvent) => any>;
  31513. }[]): void;
  31514. /**
  31515. * Function used to unregister events from window level
  31516. * @param events defines the events to unregister
  31517. */
  31518. static UnregisterTopRootEvents(events: {
  31519. name: string;
  31520. handler: Nullable<(e: FocusEvent) => any>;
  31521. }[]): void;
  31522. /**
  31523. * @ignore
  31524. */
  31525. static _ScreenshotCanvas: HTMLCanvasElement;
  31526. /**
  31527. * Dumps the current bound framebuffer
  31528. * @param width defines the rendering width
  31529. * @param height defines the rendering height
  31530. * @param engine defines the hosting engine
  31531. * @param successCallback defines the callback triggered once the data are available
  31532. * @param mimeType defines the mime type of the result
  31533. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31534. */
  31535. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31536. /**
  31537. * Converts the canvas data to blob.
  31538. * This acts as a polyfill for browsers not supporting the to blob function.
  31539. * @param canvas Defines the canvas to extract the data from
  31540. * @param successCallback Defines the callback triggered once the data are available
  31541. * @param mimeType Defines the mime type of the result
  31542. */
  31543. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31544. /**
  31545. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31546. * @param successCallback defines the callback triggered once the data are available
  31547. * @param mimeType defines the mime type of the result
  31548. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31549. */
  31550. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31551. /**
  31552. * Downloads a blob in the browser
  31553. * @param blob defines the blob to download
  31554. * @param fileName defines the name of the downloaded file
  31555. */
  31556. static Download(blob: Blob, fileName: string): void;
  31557. /**
  31558. * Captures a screenshot of the current rendering
  31559. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31560. * @param engine defines the rendering engine
  31561. * @param camera defines the source camera
  31562. * @param size This parameter can be set to a single number or to an object with the
  31563. * following (optional) properties: precision, width, height. If a single number is passed,
  31564. * it will be used for both width and height. If an object is passed, the screenshot size
  31565. * will be derived from the parameters. The precision property is a multiplier allowing
  31566. * rendering at a higher or lower resolution
  31567. * @param successCallback defines the callback receives a single parameter which contains the
  31568. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31569. * src parameter of an <img> to display it
  31570. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31571. * Check your browser for supported MIME types
  31572. */
  31573. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31574. /**
  31575. * Generates an image screenshot from the specified camera.
  31576. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31577. * @param engine The engine to use for rendering
  31578. * @param camera The camera to use for rendering
  31579. * @param size This parameter can be set to a single number or to an object with the
  31580. * following (optional) properties: precision, width, height. If a single number is passed,
  31581. * it will be used for both width and height. If an object is passed, the screenshot size
  31582. * will be derived from the parameters. The precision property is a multiplier allowing
  31583. * rendering at a higher or lower resolution
  31584. * @param successCallback The callback receives a single parameter which contains the
  31585. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31586. * src parameter of an <img> to display it
  31587. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31588. * Check your browser for supported MIME types
  31589. * @param samples Texture samples (default: 1)
  31590. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31591. * @param fileName A name for for the downloaded file.
  31592. */
  31593. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31594. /**
  31595. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31596. * Be aware Math.random() could cause collisions, but:
  31597. * "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"
  31598. * @returns a pseudo random id
  31599. */
  31600. static RandomId(): string;
  31601. /**
  31602. * Test if the given uri is a base64 string
  31603. * @param uri The uri to test
  31604. * @return True if the uri is a base64 string or false otherwise
  31605. */
  31606. static IsBase64(uri: string): boolean;
  31607. /**
  31608. * Decode the given base64 uri.
  31609. * @param uri The uri to decode
  31610. * @return The decoded base64 data.
  31611. */
  31612. static DecodeBase64(uri: string): ArrayBuffer;
  31613. /**
  31614. * Gets the absolute url.
  31615. * @param url the input url
  31616. * @return the absolute url
  31617. */
  31618. static GetAbsoluteUrl(url: string): string;
  31619. /**
  31620. * No log
  31621. */
  31622. static readonly NoneLogLevel: number;
  31623. /**
  31624. * Only message logs
  31625. */
  31626. static readonly MessageLogLevel: number;
  31627. /**
  31628. * Only warning logs
  31629. */
  31630. static readonly WarningLogLevel: number;
  31631. /**
  31632. * Only error logs
  31633. */
  31634. static readonly ErrorLogLevel: number;
  31635. /**
  31636. * All logs
  31637. */
  31638. static readonly AllLogLevel: number;
  31639. /**
  31640. * Gets a value indicating the number of loading errors
  31641. * @ignorenaming
  31642. */
  31643. static readonly errorsCount: number;
  31644. /**
  31645. * Callback called when a new log is added
  31646. */
  31647. static OnNewCacheEntry: (entry: string) => void;
  31648. /**
  31649. * Log a message to the console
  31650. * @param message defines the message to log
  31651. */
  31652. static Log(message: string): void;
  31653. /**
  31654. * Write a warning message to the console
  31655. * @param message defines the message to log
  31656. */
  31657. static Warn(message: string): void;
  31658. /**
  31659. * Write an error message to the console
  31660. * @param message defines the message to log
  31661. */
  31662. static Error(message: string): void;
  31663. /**
  31664. * Gets current log cache (list of logs)
  31665. */
  31666. static readonly LogCache: string;
  31667. /**
  31668. * Clears the log cache
  31669. */
  31670. static ClearLogCache(): void;
  31671. /**
  31672. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31673. */
  31674. static LogLevels: number;
  31675. /**
  31676. * Checks if the loaded document was accessed via `file:`-Protocol.
  31677. * @returns boolean
  31678. */
  31679. static IsFileURL(): boolean;
  31680. /**
  31681. * Checks if the window object exists
  31682. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31683. */
  31684. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31685. /**
  31686. * No performance log
  31687. */
  31688. static readonly PerformanceNoneLogLevel: number;
  31689. /**
  31690. * Use user marks to log performance
  31691. */
  31692. static readonly PerformanceUserMarkLogLevel: number;
  31693. /**
  31694. * Log performance to the console
  31695. */
  31696. static readonly PerformanceConsoleLogLevel: number;
  31697. private static _performance;
  31698. /**
  31699. * Sets the current performance log level
  31700. */
  31701. static PerformanceLogLevel: number;
  31702. private static _StartPerformanceCounterDisabled;
  31703. private static _EndPerformanceCounterDisabled;
  31704. private static _StartUserMark;
  31705. private static _EndUserMark;
  31706. private static _StartPerformanceConsole;
  31707. private static _EndPerformanceConsole;
  31708. /**
  31709. * Starts a performance counter
  31710. */
  31711. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31712. /**
  31713. * Ends a specific performance coutner
  31714. */
  31715. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31716. /**
  31717. * Gets either window.performance.now() if supported or Date.now() else
  31718. */
  31719. static readonly Now: number;
  31720. /**
  31721. * This method will return the name of the class used to create the instance of the given object.
  31722. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31723. * @param object the object to get the class name from
  31724. * @param isType defines if the object is actually a type
  31725. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31726. */
  31727. static GetClassName(object: any, isType?: boolean): string;
  31728. /**
  31729. * Gets the first element of an array satisfying a given predicate
  31730. * @param array defines the array to browse
  31731. * @param predicate defines the predicate to use
  31732. * @returns null if not found or the element
  31733. */
  31734. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31735. /**
  31736. * This method will return the name of the full name of the class, including its owning module (if any).
  31737. * 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).
  31738. * @param object the object to get the class name from
  31739. * @param isType defines if the object is actually a type
  31740. * @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.
  31741. * @ignorenaming
  31742. */
  31743. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31744. /**
  31745. * Returns a promise that resolves after the given amount of time.
  31746. * @param delay Number of milliseconds to delay
  31747. * @returns Promise that resolves after the given amount of time
  31748. */
  31749. static DelayAsync(delay: number): Promise<void>;
  31750. /**
  31751. * Gets the current gradient from an array of IValueGradient
  31752. * @param ratio defines the current ratio to get
  31753. * @param gradients defines the array of IValueGradient
  31754. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31755. */
  31756. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31757. }
  31758. /**
  31759. * This class is used to track a performance counter which is number based.
  31760. * The user has access to many properties which give statistics of different nature.
  31761. *
  31762. * The implementer can track two kinds of Performance Counter: time and count.
  31763. * 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.
  31764. * 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.
  31765. */
  31766. export class PerfCounter {
  31767. /**
  31768. * Gets or sets a global boolean to turn on and off all the counters
  31769. */
  31770. static Enabled: boolean;
  31771. /**
  31772. * Returns the smallest value ever
  31773. */
  31774. readonly min: number;
  31775. /**
  31776. * Returns the biggest value ever
  31777. */
  31778. readonly max: number;
  31779. /**
  31780. * Returns the average value since the performance counter is running
  31781. */
  31782. readonly average: number;
  31783. /**
  31784. * Returns the average value of the last second the counter was monitored
  31785. */
  31786. readonly lastSecAverage: number;
  31787. /**
  31788. * Returns the current value
  31789. */
  31790. readonly current: number;
  31791. /**
  31792. * Gets the accumulated total
  31793. */
  31794. readonly total: number;
  31795. /**
  31796. * Gets the total value count
  31797. */
  31798. readonly count: number;
  31799. /**
  31800. * Creates a new counter
  31801. */
  31802. constructor();
  31803. /**
  31804. * Call this method to start monitoring a new frame.
  31805. * 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.
  31806. */
  31807. fetchNewFrame(): void;
  31808. /**
  31809. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31810. * @param newCount the count value to add to the monitored count
  31811. * @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.
  31812. */
  31813. addCount(newCount: number, fetchResult: boolean): void;
  31814. /**
  31815. * Start monitoring this performance counter
  31816. */
  31817. beginMonitoring(): void;
  31818. /**
  31819. * Compute the time lapsed since the previous beginMonitoring() call.
  31820. * @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
  31821. */
  31822. endMonitoring(newFrame?: boolean): void;
  31823. private _fetchResult;
  31824. private _startMonitoringTime;
  31825. private _min;
  31826. private _max;
  31827. private _average;
  31828. private _current;
  31829. private _totalValueCount;
  31830. private _totalAccumulated;
  31831. private _lastSecAverage;
  31832. private _lastSecAccumulated;
  31833. private _lastSecTime;
  31834. private _lastSecValueCount;
  31835. }
  31836. /**
  31837. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31838. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31839. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31840. * @param name The name of the class, case should be preserved
  31841. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31842. */
  31843. export function className(name: string, module?: string): (target: Object) => void;
  31844. /**
  31845. * An implementation of a loop for asynchronous functions.
  31846. */
  31847. export class AsyncLoop {
  31848. /**
  31849. * Defines the number of iterations for the loop
  31850. */
  31851. iterations: number;
  31852. /**
  31853. * Defines the current index of the loop.
  31854. */
  31855. index: number;
  31856. private _done;
  31857. private _fn;
  31858. private _successCallback;
  31859. /**
  31860. * Constructor.
  31861. * @param iterations the number of iterations.
  31862. * @param func the function to run each iteration
  31863. * @param successCallback the callback that will be called upon succesful execution
  31864. * @param offset starting offset.
  31865. */
  31866. constructor(
  31867. /**
  31868. * Defines the number of iterations for the loop
  31869. */
  31870. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31871. /**
  31872. * Execute the next iteration. Must be called after the last iteration was finished.
  31873. */
  31874. executeNext(): void;
  31875. /**
  31876. * Break the loop and run the success callback.
  31877. */
  31878. breakLoop(): void;
  31879. /**
  31880. * Create and run an async loop.
  31881. * @param iterations the number of iterations.
  31882. * @param fn the function to run each iteration
  31883. * @param successCallback the callback that will be called upon succesful execution
  31884. * @param offset starting offset.
  31885. * @returns the created async loop object
  31886. */
  31887. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31888. /**
  31889. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31890. * @param iterations total number of iterations
  31891. * @param syncedIterations number of synchronous iterations in each async iteration.
  31892. * @param fn the function to call each iteration.
  31893. * @param callback a success call back that will be called when iterating stops.
  31894. * @param breakFunction a break condition (optional)
  31895. * @param timeout timeout settings for the setTimeout function. default - 0.
  31896. * @returns the created async loop object
  31897. */
  31898. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31899. }
  31900. }
  31901. declare module BABYLON {
  31902. /** @hidden */
  31903. export interface ICollisionCoordinator {
  31904. createCollider(): Collider;
  31905. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31906. init(scene: Scene): void;
  31907. }
  31908. /** @hidden */
  31909. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31910. private _scene;
  31911. private _scaledPosition;
  31912. private _scaledVelocity;
  31913. private _finalPosition;
  31914. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31915. createCollider(): Collider;
  31916. init(scene: Scene): void;
  31917. private _collideWithWorld;
  31918. }
  31919. }
  31920. declare module BABYLON {
  31921. /**
  31922. * Class used to manage all inputs for the scene.
  31923. */
  31924. export class InputManager {
  31925. /** The distance in pixel that you have to move to prevent some events */
  31926. static DragMovementThreshold: number;
  31927. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31928. static LongPressDelay: number;
  31929. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31930. static DoubleClickDelay: number;
  31931. /** If you need to check double click without raising a single click at first click, enable this flag */
  31932. static ExclusiveDoubleClickMode: boolean;
  31933. private _wheelEventName;
  31934. private _onPointerMove;
  31935. private _onPointerDown;
  31936. private _onPointerUp;
  31937. private _initClickEvent;
  31938. private _initActionManager;
  31939. private _delayedSimpleClick;
  31940. private _delayedSimpleClickTimeout;
  31941. private _previousDelayedSimpleClickTimeout;
  31942. private _meshPickProceed;
  31943. private _previousButtonPressed;
  31944. private _currentPickResult;
  31945. private _previousPickResult;
  31946. private _totalPointersPressed;
  31947. private _doubleClickOccured;
  31948. private _pointerOverMesh;
  31949. private _pickedDownMesh;
  31950. private _pickedUpMesh;
  31951. private _pointerX;
  31952. private _pointerY;
  31953. private _unTranslatedPointerX;
  31954. private _unTranslatedPointerY;
  31955. private _startingPointerPosition;
  31956. private _previousStartingPointerPosition;
  31957. private _startingPointerTime;
  31958. private _previousStartingPointerTime;
  31959. private _pointerCaptures;
  31960. private _onKeyDown;
  31961. private _onKeyUp;
  31962. private _onCanvasFocusObserver;
  31963. private _onCanvasBlurObserver;
  31964. private _scene;
  31965. /**
  31966. * Creates a new InputManager
  31967. * @param scene defines the hosting scene
  31968. */
  31969. constructor(scene: Scene);
  31970. /**
  31971. * Gets the mesh that is currently under the pointer
  31972. */
  31973. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31974. /**
  31975. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31976. */
  31977. readonly unTranslatedPointer: Vector2;
  31978. /**
  31979. * Gets or sets the current on-screen X position of the pointer
  31980. */
  31981. pointerX: number;
  31982. /**
  31983. * Gets or sets the current on-screen Y position of the pointer
  31984. */
  31985. pointerY: number;
  31986. private _updatePointerPosition;
  31987. private _processPointerMove;
  31988. private _setRayOnPointerInfo;
  31989. private _checkPrePointerObservable;
  31990. /**
  31991. * Use this method to simulate a pointer move on a mesh
  31992. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31993. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31994. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31995. */
  31996. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31997. /**
  31998. * Use this method to simulate a pointer down on a mesh
  31999. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32000. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32001. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32002. */
  32003. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32004. private _processPointerDown;
  32005. /** @hidden */
  32006. _isPointerSwiping(): boolean;
  32007. /**
  32008. * Use this method to simulate a pointer up on a mesh
  32009. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32010. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32011. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32012. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32013. */
  32014. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32015. private _processPointerUp;
  32016. /**
  32017. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32018. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32019. * @returns true if the pointer was captured
  32020. */
  32021. isPointerCaptured(pointerId?: number): boolean;
  32022. /**
  32023. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32024. * @param attachUp defines if you want to attach events to pointerup
  32025. * @param attachDown defines if you want to attach events to pointerdown
  32026. * @param attachMove defines if you want to attach events to pointermove
  32027. */
  32028. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32029. /**
  32030. * Detaches all event handlers
  32031. */
  32032. detachControl(): void;
  32033. /**
  32034. * Force the value of meshUnderPointer
  32035. * @param mesh defines the mesh to use
  32036. */
  32037. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32038. /**
  32039. * Gets the mesh under the pointer
  32040. * @returns a Mesh or null if no mesh is under the pointer
  32041. */
  32042. getPointerOverMesh(): Nullable<AbstractMesh>;
  32043. }
  32044. }
  32045. declare module BABYLON {
  32046. /**
  32047. * This class defines the direct association between an animation and a target
  32048. */
  32049. export class TargetedAnimation {
  32050. /**
  32051. * Animation to perform
  32052. */
  32053. animation: Animation;
  32054. /**
  32055. * Target to animate
  32056. */
  32057. target: any;
  32058. /**
  32059. * Serialize the object
  32060. * @returns the JSON object representing the current entity
  32061. */
  32062. serialize(): any;
  32063. }
  32064. /**
  32065. * Use this class to create coordinated animations on multiple targets
  32066. */
  32067. export class AnimationGroup implements IDisposable {
  32068. /** The name of the animation group */
  32069. name: string;
  32070. private _scene;
  32071. private _targetedAnimations;
  32072. private _animatables;
  32073. private _from;
  32074. private _to;
  32075. private _isStarted;
  32076. private _isPaused;
  32077. private _speedRatio;
  32078. private _loopAnimation;
  32079. /**
  32080. * Gets or sets the unique id of the node
  32081. */
  32082. uniqueId: number;
  32083. /**
  32084. * This observable will notify when one animation have ended
  32085. */
  32086. onAnimationEndObservable: Observable<TargetedAnimation>;
  32087. /**
  32088. * Observer raised when one animation loops
  32089. */
  32090. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32091. /**
  32092. * This observable will notify when all animations have ended.
  32093. */
  32094. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32095. /**
  32096. * This observable will notify when all animations have paused.
  32097. */
  32098. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32099. /**
  32100. * This observable will notify when all animations are playing.
  32101. */
  32102. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32103. /**
  32104. * Gets the first frame
  32105. */
  32106. readonly from: number;
  32107. /**
  32108. * Gets the last frame
  32109. */
  32110. readonly to: number;
  32111. /**
  32112. * Define if the animations are started
  32113. */
  32114. readonly isStarted: boolean;
  32115. /**
  32116. * Gets a value indicating that the current group is playing
  32117. */
  32118. readonly isPlaying: boolean;
  32119. /**
  32120. * Gets or sets the speed ratio to use for all animations
  32121. */
  32122. /**
  32123. * Gets or sets the speed ratio to use for all animations
  32124. */
  32125. speedRatio: number;
  32126. /**
  32127. * Gets or sets if all animations should loop or not
  32128. */
  32129. loopAnimation: boolean;
  32130. /**
  32131. * Gets the targeted animations for this animation group
  32132. */
  32133. readonly targetedAnimations: Array<TargetedAnimation>;
  32134. /**
  32135. * returning the list of animatables controlled by this animation group.
  32136. */
  32137. readonly animatables: Array<Animatable>;
  32138. /**
  32139. * Instantiates a new Animation Group.
  32140. * This helps managing several animations at once.
  32141. * @see http://doc.babylonjs.com/how_to/group
  32142. * @param name Defines the name of the group
  32143. * @param scene Defines the scene the group belongs to
  32144. */
  32145. constructor(
  32146. /** The name of the animation group */
  32147. name: string, scene?: Nullable<Scene>);
  32148. /**
  32149. * Add an animation (with its target) in the group
  32150. * @param animation defines the animation we want to add
  32151. * @param target defines the target of the animation
  32152. * @returns the TargetedAnimation object
  32153. */
  32154. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32155. /**
  32156. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32157. * It can add constant keys at begin or end
  32158. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32159. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32160. * @returns the animation group
  32161. */
  32162. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32163. /**
  32164. * Start all animations on given targets
  32165. * @param loop defines if animations must loop
  32166. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32167. * @param from defines the from key (optional)
  32168. * @param to defines the to key (optional)
  32169. * @returns the current animation group
  32170. */
  32171. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32172. /**
  32173. * Pause all animations
  32174. * @returns the animation group
  32175. */
  32176. pause(): AnimationGroup;
  32177. /**
  32178. * Play all animations to initial state
  32179. * This function will start() the animations if they were not started or will restart() them if they were paused
  32180. * @param loop defines if animations must loop
  32181. * @returns the animation group
  32182. */
  32183. play(loop?: boolean): AnimationGroup;
  32184. /**
  32185. * Reset all animations to initial state
  32186. * @returns the animation group
  32187. */
  32188. reset(): AnimationGroup;
  32189. /**
  32190. * Restart animations from key 0
  32191. * @returns the animation group
  32192. */
  32193. restart(): AnimationGroup;
  32194. /**
  32195. * Stop all animations
  32196. * @returns the animation group
  32197. */
  32198. stop(): AnimationGroup;
  32199. /**
  32200. * Set animation weight for all animatables
  32201. * @param weight defines the weight to use
  32202. * @return the animationGroup
  32203. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32204. */
  32205. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32206. /**
  32207. * Synchronize and normalize all animatables with a source animatable
  32208. * @param root defines the root animatable to synchronize with
  32209. * @return the animationGroup
  32210. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32211. */
  32212. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32213. /**
  32214. * Goes to a specific frame in this animation group
  32215. * @param frame the frame number to go to
  32216. * @return the animationGroup
  32217. */
  32218. goToFrame(frame: number): AnimationGroup;
  32219. /**
  32220. * Dispose all associated resources
  32221. */
  32222. dispose(): void;
  32223. private _checkAnimationGroupEnded;
  32224. /**
  32225. * Clone the current animation group and returns a copy
  32226. * @param newName defines the name of the new group
  32227. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32228. * @returns the new aniamtion group
  32229. */
  32230. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32231. /**
  32232. * Serializes the animationGroup to an object
  32233. * @returns Serialized object
  32234. */
  32235. serialize(): any;
  32236. /**
  32237. * Returns a new AnimationGroup object parsed from the source provided.
  32238. * @param parsedAnimationGroup defines the source
  32239. * @param scene defines the scene that will receive the animationGroup
  32240. * @returns a new AnimationGroup
  32241. */
  32242. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32243. /**
  32244. * Returns the string "AnimationGroup"
  32245. * @returns "AnimationGroup"
  32246. */
  32247. getClassName(): string;
  32248. /**
  32249. * Creates a detailled string about the object
  32250. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32251. * @returns a string representing the object
  32252. */
  32253. toString(fullDetails?: boolean): string;
  32254. }
  32255. }
  32256. declare module BABYLON {
  32257. /**
  32258. * Define an interface for all classes that will hold resources
  32259. */
  32260. export interface IDisposable {
  32261. /**
  32262. * Releases all held resources
  32263. */
  32264. dispose(): void;
  32265. }
  32266. /** Interface defining initialization parameters for Scene class */
  32267. export interface SceneOptions {
  32268. /**
  32269. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32270. * It will improve performance when the number of geometries becomes important.
  32271. */
  32272. useGeometryUniqueIdsMap?: boolean;
  32273. /**
  32274. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32275. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32276. */
  32277. useMaterialMeshMap?: boolean;
  32278. /**
  32279. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32280. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32281. */
  32282. useClonedMeshhMap?: boolean;
  32283. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32284. virtual?: boolean;
  32285. }
  32286. /**
  32287. * Represents a scene to be rendered by the engine.
  32288. * @see http://doc.babylonjs.com/features/scene
  32289. */
  32290. export class Scene extends AbstractScene implements IAnimatable {
  32291. private static _uniqueIdCounter;
  32292. /** The fog is deactivated */
  32293. static readonly FOGMODE_NONE: number;
  32294. /** The fog density is following an exponential function */
  32295. static readonly FOGMODE_EXP: number;
  32296. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32297. static readonly FOGMODE_EXP2: number;
  32298. /** The fog density is following a linear function. */
  32299. static readonly FOGMODE_LINEAR: number;
  32300. /**
  32301. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32302. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32303. */
  32304. static MinDeltaTime: number;
  32305. /**
  32306. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32307. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32308. */
  32309. static MaxDeltaTime: number;
  32310. /**
  32311. * Factory used to create the default material.
  32312. * @param name The name of the material to create
  32313. * @param scene The scene to create the material for
  32314. * @returns The default material
  32315. */
  32316. static DefaultMaterialFactory(scene: Scene): Material;
  32317. /**
  32318. * Factory used to create the a collision coordinator.
  32319. * @returns The collision coordinator
  32320. */
  32321. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32322. /** @hidden */
  32323. _inputManager: InputManager;
  32324. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32325. cameraToUseForPointers: Nullable<Camera>;
  32326. /** @hidden */
  32327. readonly _isScene: boolean;
  32328. /**
  32329. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32330. */
  32331. autoClear: boolean;
  32332. /**
  32333. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32334. */
  32335. autoClearDepthAndStencil: boolean;
  32336. /**
  32337. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32338. */
  32339. clearColor: Color4;
  32340. /**
  32341. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32342. */
  32343. ambientColor: Color3;
  32344. /**
  32345. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32346. * It should only be one of the following (if not the default embedded one):
  32347. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32348. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32349. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32350. * The material properties need to be setup according to the type of texture in use.
  32351. */
  32352. environmentBRDFTexture: BaseTexture;
  32353. /** @hidden */
  32354. protected _environmentTexture: Nullable<BaseTexture>;
  32355. /**
  32356. * Texture used in all pbr material as the reflection texture.
  32357. * As in the majority of the scene they are the same (exception for multi room and so on),
  32358. * this is easier to reference from here than from all the materials.
  32359. */
  32360. /**
  32361. * Texture used in all pbr material as the reflection texture.
  32362. * As in the majority of the scene they are the same (exception for multi room and so on),
  32363. * this is easier to set here than in all the materials.
  32364. */
  32365. environmentTexture: Nullable<BaseTexture>;
  32366. /** @hidden */
  32367. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32368. /**
  32369. * Default image processing configuration used either in the rendering
  32370. * Forward main pass or through the imageProcessingPostProcess if present.
  32371. * As in the majority of the scene they are the same (exception for multi camera),
  32372. * this is easier to reference from here than from all the materials and post process.
  32373. *
  32374. * No setter as we it is a shared configuration, you can set the values instead.
  32375. */
  32376. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32377. private _forceWireframe;
  32378. /**
  32379. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32380. */
  32381. forceWireframe: boolean;
  32382. private _forcePointsCloud;
  32383. /**
  32384. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32385. */
  32386. forcePointsCloud: boolean;
  32387. /**
  32388. * Gets or sets the active clipplane 1
  32389. */
  32390. clipPlane: Nullable<Plane>;
  32391. /**
  32392. * Gets or sets the active clipplane 2
  32393. */
  32394. clipPlane2: Nullable<Plane>;
  32395. /**
  32396. * Gets or sets the active clipplane 3
  32397. */
  32398. clipPlane3: Nullable<Plane>;
  32399. /**
  32400. * Gets or sets the active clipplane 4
  32401. */
  32402. clipPlane4: Nullable<Plane>;
  32403. /**
  32404. * Gets or sets a boolean indicating if animations are enabled
  32405. */
  32406. animationsEnabled: boolean;
  32407. private _animationPropertiesOverride;
  32408. /**
  32409. * Gets or sets the animation properties override
  32410. */
  32411. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32412. /**
  32413. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32414. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32415. */
  32416. useConstantAnimationDeltaTime: boolean;
  32417. /**
  32418. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32419. * Please note that it requires to run a ray cast through the scene on every frame
  32420. */
  32421. constantlyUpdateMeshUnderPointer: boolean;
  32422. /**
  32423. * Defines the HTML cursor to use when hovering over interactive elements
  32424. */
  32425. hoverCursor: string;
  32426. /**
  32427. * Defines the HTML default cursor to use (empty by default)
  32428. */
  32429. defaultCursor: string;
  32430. /**
  32431. * This is used to call preventDefault() on pointer down
  32432. * in order to block unwanted artifacts like system double clicks
  32433. */
  32434. preventDefaultOnPointerDown: boolean;
  32435. /**
  32436. * This is used to call preventDefault() on pointer up
  32437. * in order to block unwanted artifacts like system double clicks
  32438. */
  32439. preventDefaultOnPointerUp: boolean;
  32440. /**
  32441. * Gets or sets user defined metadata
  32442. */
  32443. metadata: any;
  32444. /**
  32445. * For internal use only. Please do not use.
  32446. */
  32447. reservedDataStore: any;
  32448. /**
  32449. * Gets the name of the plugin used to load this scene (null by default)
  32450. */
  32451. loadingPluginName: string;
  32452. /**
  32453. * Use this array to add regular expressions used to disable offline support for specific urls
  32454. */
  32455. disableOfflineSupportExceptionRules: RegExp[];
  32456. /**
  32457. * An event triggered when the scene is disposed.
  32458. */
  32459. onDisposeObservable: Observable<Scene>;
  32460. private _onDisposeObserver;
  32461. /** Sets a function to be executed when this scene is disposed. */
  32462. onDispose: () => void;
  32463. /**
  32464. * An event triggered before rendering the scene (right after animations and physics)
  32465. */
  32466. onBeforeRenderObservable: Observable<Scene>;
  32467. private _onBeforeRenderObserver;
  32468. /** Sets a function to be executed before rendering this scene */
  32469. beforeRender: Nullable<() => void>;
  32470. /**
  32471. * An event triggered after rendering the scene
  32472. */
  32473. onAfterRenderObservable: Observable<Scene>;
  32474. /**
  32475. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32476. */
  32477. onAfterRenderCameraObservable: Observable<Camera>;
  32478. private _onAfterRenderObserver;
  32479. /** Sets a function to be executed after rendering this scene */
  32480. afterRender: Nullable<() => void>;
  32481. /**
  32482. * An event triggered before animating the scene
  32483. */
  32484. onBeforeAnimationsObservable: Observable<Scene>;
  32485. /**
  32486. * An event triggered after animations processing
  32487. */
  32488. onAfterAnimationsObservable: Observable<Scene>;
  32489. /**
  32490. * An event triggered before draw calls are ready to be sent
  32491. */
  32492. onBeforeDrawPhaseObservable: Observable<Scene>;
  32493. /**
  32494. * An event triggered after draw calls have been sent
  32495. */
  32496. onAfterDrawPhaseObservable: Observable<Scene>;
  32497. /**
  32498. * An event triggered when the scene is ready
  32499. */
  32500. onReadyObservable: Observable<Scene>;
  32501. /**
  32502. * An event triggered before rendering a camera
  32503. */
  32504. onBeforeCameraRenderObservable: Observable<Camera>;
  32505. private _onBeforeCameraRenderObserver;
  32506. /** Sets a function to be executed before rendering a camera*/
  32507. beforeCameraRender: () => void;
  32508. /**
  32509. * An event triggered after rendering a camera
  32510. */
  32511. onAfterCameraRenderObservable: Observable<Camera>;
  32512. private _onAfterCameraRenderObserver;
  32513. /** Sets a function to be executed after rendering a camera*/
  32514. afterCameraRender: () => void;
  32515. /**
  32516. * An event triggered when active meshes evaluation is about to start
  32517. */
  32518. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32519. /**
  32520. * An event triggered when active meshes evaluation is done
  32521. */
  32522. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32523. /**
  32524. * An event triggered when particles rendering is about to start
  32525. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32526. */
  32527. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32528. /**
  32529. * An event triggered when particles rendering is done
  32530. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32531. */
  32532. onAfterParticlesRenderingObservable: Observable<Scene>;
  32533. /**
  32534. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32535. */
  32536. onDataLoadedObservable: Observable<Scene>;
  32537. /**
  32538. * An event triggered when a camera is created
  32539. */
  32540. onNewCameraAddedObservable: Observable<Camera>;
  32541. /**
  32542. * An event triggered when a camera is removed
  32543. */
  32544. onCameraRemovedObservable: Observable<Camera>;
  32545. /**
  32546. * An event triggered when a light is created
  32547. */
  32548. onNewLightAddedObservable: Observable<Light>;
  32549. /**
  32550. * An event triggered when a light is removed
  32551. */
  32552. onLightRemovedObservable: Observable<Light>;
  32553. /**
  32554. * An event triggered when a geometry is created
  32555. */
  32556. onNewGeometryAddedObservable: Observable<Geometry>;
  32557. /**
  32558. * An event triggered when a geometry is removed
  32559. */
  32560. onGeometryRemovedObservable: Observable<Geometry>;
  32561. /**
  32562. * An event triggered when a transform node is created
  32563. */
  32564. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32565. /**
  32566. * An event triggered when a transform node is removed
  32567. */
  32568. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32569. /**
  32570. * An event triggered when a mesh is created
  32571. */
  32572. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32573. /**
  32574. * An event triggered when a mesh is removed
  32575. */
  32576. onMeshRemovedObservable: Observable<AbstractMesh>;
  32577. /**
  32578. * An event triggered when a skeleton is created
  32579. */
  32580. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32581. /**
  32582. * An event triggered when a skeleton is removed
  32583. */
  32584. onSkeletonRemovedObservable: Observable<Skeleton>;
  32585. /**
  32586. * An event triggered when a material is created
  32587. */
  32588. onNewMaterialAddedObservable: Observable<Material>;
  32589. /**
  32590. * An event triggered when a material is removed
  32591. */
  32592. onMaterialRemovedObservable: Observable<Material>;
  32593. /**
  32594. * An event triggered when a texture is created
  32595. */
  32596. onNewTextureAddedObservable: Observable<BaseTexture>;
  32597. /**
  32598. * An event triggered when a texture is removed
  32599. */
  32600. onTextureRemovedObservable: Observable<BaseTexture>;
  32601. /**
  32602. * An event triggered when render targets are about to be rendered
  32603. * Can happen multiple times per frame.
  32604. */
  32605. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32606. /**
  32607. * An event triggered when render targets were rendered.
  32608. * Can happen multiple times per frame.
  32609. */
  32610. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32611. /**
  32612. * An event triggered before calculating deterministic simulation step
  32613. */
  32614. onBeforeStepObservable: Observable<Scene>;
  32615. /**
  32616. * An event triggered after calculating deterministic simulation step
  32617. */
  32618. onAfterStepObservable: Observable<Scene>;
  32619. /**
  32620. * An event triggered when the activeCamera property is updated
  32621. */
  32622. onActiveCameraChanged: Observable<Scene>;
  32623. /**
  32624. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32625. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32626. * 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)
  32627. */
  32628. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32629. /**
  32630. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32631. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32632. * 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)
  32633. */
  32634. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32635. /**
  32636. * This Observable will when a mesh has been imported into the scene.
  32637. */
  32638. onMeshImportedObservable: Observable<AbstractMesh>;
  32639. /**
  32640. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32641. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32642. */
  32643. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32644. /** @hidden */
  32645. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32646. /**
  32647. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32648. */
  32649. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32650. /**
  32651. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32652. */
  32653. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32654. /**
  32655. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32656. */
  32657. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32658. /** Callback called when a pointer move is detected */
  32659. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32660. /** Callback called when a pointer down is detected */
  32661. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32662. /** Callback called when a pointer up is detected */
  32663. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32664. /** Callback called when a pointer pick is detected */
  32665. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32666. /**
  32667. * 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).
  32668. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32669. */
  32670. onPrePointerObservable: Observable<PointerInfoPre>;
  32671. /**
  32672. * Observable event triggered each time an input event is received from the rendering canvas
  32673. */
  32674. onPointerObservable: Observable<PointerInfo>;
  32675. /**
  32676. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32677. */
  32678. readonly unTranslatedPointer: Vector2;
  32679. /**
  32680. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32681. */
  32682. static DragMovementThreshold: number;
  32683. /**
  32684. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32685. */
  32686. static LongPressDelay: number;
  32687. /**
  32688. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32689. */
  32690. static DoubleClickDelay: number;
  32691. /** If you need to check double click without raising a single click at first click, enable this flag */
  32692. static ExclusiveDoubleClickMode: boolean;
  32693. /** @hidden */
  32694. _mirroredCameraPosition: Nullable<Vector3>;
  32695. /**
  32696. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32697. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32698. */
  32699. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32700. /**
  32701. * Observable event triggered each time an keyboard event is received from the hosting window
  32702. */
  32703. onKeyboardObservable: Observable<KeyboardInfo>;
  32704. private _useRightHandedSystem;
  32705. /**
  32706. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32707. */
  32708. useRightHandedSystem: boolean;
  32709. private _timeAccumulator;
  32710. private _currentStepId;
  32711. private _currentInternalStep;
  32712. /**
  32713. * Sets the step Id used by deterministic lock step
  32714. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32715. * @param newStepId defines the step Id
  32716. */
  32717. setStepId(newStepId: number): void;
  32718. /**
  32719. * Gets the step Id used by deterministic lock step
  32720. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32721. * @returns the step Id
  32722. */
  32723. getStepId(): number;
  32724. /**
  32725. * Gets the internal step used by deterministic lock step
  32726. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32727. * @returns the internal step
  32728. */
  32729. getInternalStep(): number;
  32730. private _fogEnabled;
  32731. /**
  32732. * Gets or sets a boolean indicating if fog is enabled on this scene
  32733. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32734. * (Default is true)
  32735. */
  32736. fogEnabled: boolean;
  32737. private _fogMode;
  32738. /**
  32739. * Gets or sets the fog mode to use
  32740. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32741. * | mode | value |
  32742. * | --- | --- |
  32743. * | FOGMODE_NONE | 0 |
  32744. * | FOGMODE_EXP | 1 |
  32745. * | FOGMODE_EXP2 | 2 |
  32746. * | FOGMODE_LINEAR | 3 |
  32747. */
  32748. fogMode: number;
  32749. /**
  32750. * Gets or sets the fog color to use
  32751. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32752. * (Default is Color3(0.2, 0.2, 0.3))
  32753. */
  32754. fogColor: Color3;
  32755. /**
  32756. * Gets or sets the fog density to use
  32757. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32758. * (Default is 0.1)
  32759. */
  32760. fogDensity: number;
  32761. /**
  32762. * Gets or sets the fog start distance to use
  32763. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32764. * (Default is 0)
  32765. */
  32766. fogStart: number;
  32767. /**
  32768. * Gets or sets the fog end distance to use
  32769. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32770. * (Default is 1000)
  32771. */
  32772. fogEnd: number;
  32773. private _shadowsEnabled;
  32774. /**
  32775. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32776. */
  32777. shadowsEnabled: boolean;
  32778. private _lightsEnabled;
  32779. /**
  32780. * Gets or sets a boolean indicating if lights are enabled on this scene
  32781. */
  32782. lightsEnabled: boolean;
  32783. /** All of the active cameras added to this scene. */
  32784. activeCameras: Camera[];
  32785. /** @hidden */
  32786. _activeCamera: Nullable<Camera>;
  32787. /** Gets or sets the current active camera */
  32788. activeCamera: Nullable<Camera>;
  32789. private _defaultMaterial;
  32790. /** The default material used on meshes when no material is affected */
  32791. /** The default material used on meshes when no material is affected */
  32792. defaultMaterial: Material;
  32793. private _texturesEnabled;
  32794. /**
  32795. * Gets or sets a boolean indicating if textures are enabled on this scene
  32796. */
  32797. texturesEnabled: boolean;
  32798. /**
  32799. * Gets or sets a boolean indicating if particles are enabled on this scene
  32800. */
  32801. particlesEnabled: boolean;
  32802. /**
  32803. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32804. */
  32805. spritesEnabled: boolean;
  32806. private _skeletonsEnabled;
  32807. /**
  32808. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32809. */
  32810. skeletonsEnabled: boolean;
  32811. /**
  32812. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32813. */
  32814. lensFlaresEnabled: boolean;
  32815. /**
  32816. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32817. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32818. */
  32819. collisionsEnabled: boolean;
  32820. private _collisionCoordinator;
  32821. /** @hidden */
  32822. readonly collisionCoordinator: ICollisionCoordinator;
  32823. /**
  32824. * Defines the gravity applied to this scene (used only for collisions)
  32825. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32826. */
  32827. gravity: Vector3;
  32828. /**
  32829. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32830. */
  32831. postProcessesEnabled: boolean;
  32832. /**
  32833. * The list of postprocesses added to the scene
  32834. */
  32835. postProcesses: PostProcess[];
  32836. /**
  32837. * Gets the current postprocess manager
  32838. */
  32839. postProcessManager: PostProcessManager;
  32840. /**
  32841. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32842. */
  32843. renderTargetsEnabled: boolean;
  32844. /**
  32845. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32846. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32847. */
  32848. dumpNextRenderTargets: boolean;
  32849. /**
  32850. * The list of user defined render targets added to the scene
  32851. */
  32852. customRenderTargets: RenderTargetTexture[];
  32853. /**
  32854. * Defines if texture loading must be delayed
  32855. * If true, textures will only be loaded when they need to be rendered
  32856. */
  32857. useDelayedTextureLoading: boolean;
  32858. /**
  32859. * Gets the list of meshes imported to the scene through SceneLoader
  32860. */
  32861. importedMeshesFiles: String[];
  32862. /**
  32863. * Gets or sets a boolean indicating if probes are enabled on this scene
  32864. */
  32865. probesEnabled: boolean;
  32866. /**
  32867. * Gets or sets the current offline provider to use to store scene data
  32868. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32869. */
  32870. offlineProvider: IOfflineProvider;
  32871. /**
  32872. * Gets or sets the action manager associated with the scene
  32873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32874. */
  32875. actionManager: AbstractActionManager;
  32876. private _meshesForIntersections;
  32877. /**
  32878. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32879. */
  32880. proceduralTexturesEnabled: boolean;
  32881. private _engine;
  32882. private _totalVertices;
  32883. /** @hidden */
  32884. _activeIndices: PerfCounter;
  32885. /** @hidden */
  32886. _activeParticles: PerfCounter;
  32887. /** @hidden */
  32888. _activeBones: PerfCounter;
  32889. private _animationRatio;
  32890. /** @hidden */
  32891. _animationTimeLast: number;
  32892. /** @hidden */
  32893. _animationTime: number;
  32894. /**
  32895. * Gets or sets a general scale for animation speed
  32896. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32897. */
  32898. animationTimeScale: number;
  32899. /** @hidden */
  32900. _cachedMaterial: Nullable<Material>;
  32901. /** @hidden */
  32902. _cachedEffect: Nullable<Effect>;
  32903. /** @hidden */
  32904. _cachedVisibility: Nullable<number>;
  32905. private _renderId;
  32906. private _frameId;
  32907. private _executeWhenReadyTimeoutId;
  32908. private _intermediateRendering;
  32909. private _viewUpdateFlag;
  32910. private _projectionUpdateFlag;
  32911. /** @hidden */
  32912. _toBeDisposed: Nullable<IDisposable>[];
  32913. private _activeRequests;
  32914. /** @hidden */
  32915. _pendingData: any[];
  32916. private _isDisposed;
  32917. /**
  32918. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32919. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32920. */
  32921. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32922. private _activeMeshes;
  32923. private _processedMaterials;
  32924. private _renderTargets;
  32925. /** @hidden */
  32926. _activeParticleSystems: SmartArray<IParticleSystem>;
  32927. private _activeSkeletons;
  32928. private _softwareSkinnedMeshes;
  32929. private _renderingManager;
  32930. /** @hidden */
  32931. _activeAnimatables: Animatable[];
  32932. private _transformMatrix;
  32933. private _sceneUbo;
  32934. /** @hidden */
  32935. _viewMatrix: Matrix;
  32936. private _projectionMatrix;
  32937. /** @hidden */
  32938. _forcedViewPosition: Nullable<Vector3>;
  32939. /** @hidden */
  32940. _frustumPlanes: Plane[];
  32941. /**
  32942. * Gets the list of frustum planes (built from the active camera)
  32943. */
  32944. readonly frustumPlanes: Plane[];
  32945. /**
  32946. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32947. * This is useful if there are more lights that the maximum simulteanous authorized
  32948. */
  32949. requireLightSorting: boolean;
  32950. /** @hidden */
  32951. readonly useMaterialMeshMap: boolean;
  32952. /** @hidden */
  32953. readonly useClonedMeshhMap: boolean;
  32954. private _externalData;
  32955. private _uid;
  32956. /**
  32957. * @hidden
  32958. * Backing store of defined scene components.
  32959. */
  32960. _components: ISceneComponent[];
  32961. /**
  32962. * @hidden
  32963. * Backing store of defined scene components.
  32964. */
  32965. _serializableComponents: ISceneSerializableComponent[];
  32966. /**
  32967. * List of components to register on the next registration step.
  32968. */
  32969. private _transientComponents;
  32970. /**
  32971. * Registers the transient components if needed.
  32972. */
  32973. private _registerTransientComponents;
  32974. /**
  32975. * @hidden
  32976. * Add a component to the scene.
  32977. * Note that the ccomponent could be registered on th next frame if this is called after
  32978. * the register component stage.
  32979. * @param component Defines the component to add to the scene
  32980. */
  32981. _addComponent(component: ISceneComponent): void;
  32982. /**
  32983. * @hidden
  32984. * Gets a component from the scene.
  32985. * @param name defines the name of the component to retrieve
  32986. * @returns the component or null if not present
  32987. */
  32988. _getComponent(name: string): Nullable<ISceneComponent>;
  32989. /**
  32990. * @hidden
  32991. * Defines the actions happening before camera updates.
  32992. */
  32993. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32994. /**
  32995. * @hidden
  32996. * Defines the actions happening before clear the canvas.
  32997. */
  32998. _beforeClearStage: Stage<SimpleStageAction>;
  32999. /**
  33000. * @hidden
  33001. * Defines the actions when collecting render targets for the frame.
  33002. */
  33003. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33004. /**
  33005. * @hidden
  33006. * Defines the actions happening for one camera in the frame.
  33007. */
  33008. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33009. /**
  33010. * @hidden
  33011. * Defines the actions happening during the per mesh ready checks.
  33012. */
  33013. _isReadyForMeshStage: Stage<MeshStageAction>;
  33014. /**
  33015. * @hidden
  33016. * Defines the actions happening before evaluate active mesh checks.
  33017. */
  33018. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33019. /**
  33020. * @hidden
  33021. * Defines the actions happening during the evaluate sub mesh checks.
  33022. */
  33023. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33024. /**
  33025. * @hidden
  33026. * Defines the actions happening during the active mesh stage.
  33027. */
  33028. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33029. /**
  33030. * @hidden
  33031. * Defines the actions happening during the per camera render target step.
  33032. */
  33033. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33034. /**
  33035. * @hidden
  33036. * Defines the actions happening just before the active camera is drawing.
  33037. */
  33038. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33039. /**
  33040. * @hidden
  33041. * Defines the actions happening just before a render target is drawing.
  33042. */
  33043. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33044. /**
  33045. * @hidden
  33046. * Defines the actions happening just before a rendering group is drawing.
  33047. */
  33048. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33049. /**
  33050. * @hidden
  33051. * Defines the actions happening just before a mesh is drawing.
  33052. */
  33053. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33054. /**
  33055. * @hidden
  33056. * Defines the actions happening just after a mesh has been drawn.
  33057. */
  33058. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33059. /**
  33060. * @hidden
  33061. * Defines the actions happening just after a rendering group has been drawn.
  33062. */
  33063. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33064. /**
  33065. * @hidden
  33066. * Defines the actions happening just after the active camera has been drawn.
  33067. */
  33068. _afterCameraDrawStage: Stage<CameraStageAction>;
  33069. /**
  33070. * @hidden
  33071. * Defines the actions happening just after a render target has been drawn.
  33072. */
  33073. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33074. /**
  33075. * @hidden
  33076. * Defines the actions happening just after rendering all cameras and computing intersections.
  33077. */
  33078. _afterRenderStage: Stage<SimpleStageAction>;
  33079. /**
  33080. * @hidden
  33081. * Defines the actions happening when a pointer move event happens.
  33082. */
  33083. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33084. /**
  33085. * @hidden
  33086. * Defines the actions happening when a pointer down event happens.
  33087. */
  33088. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33089. /**
  33090. * @hidden
  33091. * Defines the actions happening when a pointer up event happens.
  33092. */
  33093. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33094. /**
  33095. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33096. */
  33097. private geometriesByUniqueId;
  33098. /**
  33099. * Creates a new Scene
  33100. * @param engine defines the engine to use to render this scene
  33101. * @param options defines the scene options
  33102. */
  33103. constructor(engine: Engine, options?: SceneOptions);
  33104. /**
  33105. * Gets a string idenfifying the name of the class
  33106. * @returns "Scene" string
  33107. */
  33108. getClassName(): string;
  33109. private _defaultMeshCandidates;
  33110. /**
  33111. * @hidden
  33112. */
  33113. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33114. private _defaultSubMeshCandidates;
  33115. /**
  33116. * @hidden
  33117. */
  33118. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33119. /**
  33120. * Sets the default candidate providers for the scene.
  33121. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33122. * and getCollidingSubMeshCandidates to their default function
  33123. */
  33124. setDefaultCandidateProviders(): void;
  33125. /**
  33126. * Gets the mesh that is currently under the pointer
  33127. */
  33128. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33129. /**
  33130. * Gets or sets the current on-screen X position of the pointer
  33131. */
  33132. pointerX: number;
  33133. /**
  33134. * Gets or sets the current on-screen Y position of the pointer
  33135. */
  33136. pointerY: number;
  33137. /**
  33138. * Gets the cached material (ie. the latest rendered one)
  33139. * @returns the cached material
  33140. */
  33141. getCachedMaterial(): Nullable<Material>;
  33142. /**
  33143. * Gets the cached effect (ie. the latest rendered one)
  33144. * @returns the cached effect
  33145. */
  33146. getCachedEffect(): Nullable<Effect>;
  33147. /**
  33148. * Gets the cached visibility state (ie. the latest rendered one)
  33149. * @returns the cached visibility state
  33150. */
  33151. getCachedVisibility(): Nullable<number>;
  33152. /**
  33153. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33154. * @param material defines the current material
  33155. * @param effect defines the current effect
  33156. * @param visibility defines the current visibility state
  33157. * @returns true if one parameter is not cached
  33158. */
  33159. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33160. /**
  33161. * Gets the engine associated with the scene
  33162. * @returns an Engine
  33163. */
  33164. getEngine(): Engine;
  33165. /**
  33166. * Gets the total number of vertices rendered per frame
  33167. * @returns the total number of vertices rendered per frame
  33168. */
  33169. getTotalVertices(): number;
  33170. /**
  33171. * Gets the performance counter for total vertices
  33172. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33173. */
  33174. readonly totalVerticesPerfCounter: PerfCounter;
  33175. /**
  33176. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33177. * @returns the total number of active indices rendered per frame
  33178. */
  33179. getActiveIndices(): number;
  33180. /**
  33181. * Gets the performance counter for active indices
  33182. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33183. */
  33184. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33185. /**
  33186. * Gets the total number of active particles rendered per frame
  33187. * @returns the total number of active particles rendered per frame
  33188. */
  33189. getActiveParticles(): number;
  33190. /**
  33191. * Gets the performance counter for active particles
  33192. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33193. */
  33194. readonly activeParticlesPerfCounter: PerfCounter;
  33195. /**
  33196. * Gets the total number of active bones rendered per frame
  33197. * @returns the total number of active bones rendered per frame
  33198. */
  33199. getActiveBones(): number;
  33200. /**
  33201. * Gets the performance counter for active bones
  33202. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33203. */
  33204. readonly activeBonesPerfCounter: PerfCounter;
  33205. /**
  33206. * Gets the array of active meshes
  33207. * @returns an array of AbstractMesh
  33208. */
  33209. getActiveMeshes(): SmartArray<AbstractMesh>;
  33210. /**
  33211. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33212. * @returns a number
  33213. */
  33214. getAnimationRatio(): number;
  33215. /**
  33216. * Gets an unique Id for the current render phase
  33217. * @returns a number
  33218. */
  33219. getRenderId(): number;
  33220. /**
  33221. * Gets an unique Id for the current frame
  33222. * @returns a number
  33223. */
  33224. getFrameId(): number;
  33225. /** Call this function if you want to manually increment the render Id*/
  33226. incrementRenderId(): void;
  33227. private _createUbo;
  33228. /**
  33229. * Use this method to simulate a pointer move on a mesh
  33230. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33231. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33232. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33233. * @returns the current scene
  33234. */
  33235. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33236. /**
  33237. * Use this method to simulate a pointer down on a mesh
  33238. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33239. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33240. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33241. * @returns the current scene
  33242. */
  33243. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33244. /**
  33245. * Use this method to simulate a pointer up on a mesh
  33246. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33247. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33248. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33249. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33250. * @returns the current scene
  33251. */
  33252. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33253. /**
  33254. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33255. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33256. * @returns true if the pointer was captured
  33257. */
  33258. isPointerCaptured(pointerId?: number): boolean;
  33259. /**
  33260. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33261. * @param attachUp defines if you want to attach events to pointerup
  33262. * @param attachDown defines if you want to attach events to pointerdown
  33263. * @param attachMove defines if you want to attach events to pointermove
  33264. */
  33265. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33266. /** Detaches all event handlers*/
  33267. detachControl(): void;
  33268. /**
  33269. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33270. * Delay loaded resources are not taking in account
  33271. * @return true if all required resources are ready
  33272. */
  33273. isReady(): boolean;
  33274. /** Resets all cached information relative to material (including effect and visibility) */
  33275. resetCachedMaterial(): void;
  33276. /**
  33277. * Registers a function to be called before every frame render
  33278. * @param func defines the function to register
  33279. */
  33280. registerBeforeRender(func: () => void): void;
  33281. /**
  33282. * Unregisters a function called before every frame render
  33283. * @param func defines the function to unregister
  33284. */
  33285. unregisterBeforeRender(func: () => void): void;
  33286. /**
  33287. * Registers a function to be called after every frame render
  33288. * @param func defines the function to register
  33289. */
  33290. registerAfterRender(func: () => void): void;
  33291. /**
  33292. * Unregisters a function called after every frame render
  33293. * @param func defines the function to unregister
  33294. */
  33295. unregisterAfterRender(func: () => void): void;
  33296. private _executeOnceBeforeRender;
  33297. /**
  33298. * The provided function will run before render once and will be disposed afterwards.
  33299. * A timeout delay can be provided so that the function will be executed in N ms.
  33300. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33301. * @param func The function to be executed.
  33302. * @param timeout optional delay in ms
  33303. */
  33304. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33305. /** @hidden */
  33306. _addPendingData(data: any): void;
  33307. /** @hidden */
  33308. _removePendingData(data: any): void;
  33309. /**
  33310. * Returns the number of items waiting to be loaded
  33311. * @returns the number of items waiting to be loaded
  33312. */
  33313. getWaitingItemsCount(): number;
  33314. /**
  33315. * Returns a boolean indicating if the scene is still loading data
  33316. */
  33317. readonly isLoading: boolean;
  33318. /**
  33319. * Registers a function to be executed when the scene is ready
  33320. * @param {Function} func - the function to be executed
  33321. */
  33322. executeWhenReady(func: () => void): void;
  33323. /**
  33324. * Returns a promise that resolves when the scene is ready
  33325. * @returns A promise that resolves when the scene is ready
  33326. */
  33327. whenReadyAsync(): Promise<void>;
  33328. /** @hidden */
  33329. _checkIsReady(): void;
  33330. /**
  33331. * Gets all animatable attached to the scene
  33332. */
  33333. readonly animatables: Animatable[];
  33334. /**
  33335. * Resets the last animation time frame.
  33336. * Useful to override when animations start running when loading a scene for the first time.
  33337. */
  33338. resetLastAnimationTimeFrame(): void;
  33339. /**
  33340. * Gets the current view matrix
  33341. * @returns a Matrix
  33342. */
  33343. getViewMatrix(): Matrix;
  33344. /**
  33345. * Gets the current projection matrix
  33346. * @returns a Matrix
  33347. */
  33348. getProjectionMatrix(): Matrix;
  33349. /**
  33350. * Gets the current transform matrix
  33351. * @returns a Matrix made of View * Projection
  33352. */
  33353. getTransformMatrix(): Matrix;
  33354. /**
  33355. * Sets the current transform matrix
  33356. * @param viewL defines the View matrix to use
  33357. * @param projectionL defines the Projection matrix to use
  33358. * @param viewR defines the right View matrix to use (if provided)
  33359. * @param projectionR defines the right Projection matrix to use (if provided)
  33360. */
  33361. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33362. /**
  33363. * Gets the uniform buffer used to store scene data
  33364. * @returns a UniformBuffer
  33365. */
  33366. getSceneUniformBuffer(): UniformBuffer;
  33367. /**
  33368. * Gets an unique (relatively to the current scene) Id
  33369. * @returns an unique number for the scene
  33370. */
  33371. getUniqueId(): number;
  33372. /**
  33373. * Add a mesh to the list of scene's meshes
  33374. * @param newMesh defines the mesh to add
  33375. * @param recursive if all child meshes should also be added to the scene
  33376. */
  33377. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33378. /**
  33379. * Remove a mesh for the list of scene's meshes
  33380. * @param toRemove defines the mesh to remove
  33381. * @param recursive if all child meshes should also be removed from the scene
  33382. * @returns the index where the mesh was in the mesh list
  33383. */
  33384. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33385. /**
  33386. * Add a transform node to the list of scene's transform nodes
  33387. * @param newTransformNode defines the transform node to add
  33388. */
  33389. addTransformNode(newTransformNode: TransformNode): void;
  33390. /**
  33391. * Remove a transform node for the list of scene's transform nodes
  33392. * @param toRemove defines the transform node to remove
  33393. * @returns the index where the transform node was in the transform node list
  33394. */
  33395. removeTransformNode(toRemove: TransformNode): number;
  33396. /**
  33397. * Remove a skeleton for the list of scene's skeletons
  33398. * @param toRemove defines the skeleton to remove
  33399. * @returns the index where the skeleton was in the skeleton list
  33400. */
  33401. removeSkeleton(toRemove: Skeleton): number;
  33402. /**
  33403. * Remove a morph target for the list of scene's morph targets
  33404. * @param toRemove defines the morph target to remove
  33405. * @returns the index where the morph target was in the morph target list
  33406. */
  33407. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33408. /**
  33409. * Remove a light for the list of scene's lights
  33410. * @param toRemove defines the light to remove
  33411. * @returns the index where the light was in the light list
  33412. */
  33413. removeLight(toRemove: Light): number;
  33414. /**
  33415. * Remove a camera for the list of scene's cameras
  33416. * @param toRemove defines the camera to remove
  33417. * @returns the index where the camera was in the camera list
  33418. */
  33419. removeCamera(toRemove: Camera): number;
  33420. /**
  33421. * Remove a particle system for the list of scene's particle systems
  33422. * @param toRemove defines the particle system to remove
  33423. * @returns the index where the particle system was in the particle system list
  33424. */
  33425. removeParticleSystem(toRemove: IParticleSystem): number;
  33426. /**
  33427. * Remove a animation for the list of scene's animations
  33428. * @param toRemove defines the animation to remove
  33429. * @returns the index where the animation was in the animation list
  33430. */
  33431. removeAnimation(toRemove: Animation): number;
  33432. /**
  33433. * Will stop the animation of the given target
  33434. * @param target - the target
  33435. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33436. * @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)
  33437. */
  33438. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33439. /**
  33440. * Removes the given animation group from this scene.
  33441. * @param toRemove The animation group to remove
  33442. * @returns The index of the removed animation group
  33443. */
  33444. removeAnimationGroup(toRemove: AnimationGroup): number;
  33445. /**
  33446. * Removes the given multi-material from this scene.
  33447. * @param toRemove The multi-material to remove
  33448. * @returns The index of the removed multi-material
  33449. */
  33450. removeMultiMaterial(toRemove: MultiMaterial): number;
  33451. /**
  33452. * Removes the given material from this scene.
  33453. * @param toRemove The material to remove
  33454. * @returns The index of the removed material
  33455. */
  33456. removeMaterial(toRemove: Material): number;
  33457. /**
  33458. * Removes the given action manager from this scene.
  33459. * @param toRemove The action manager to remove
  33460. * @returns The index of the removed action manager
  33461. */
  33462. removeActionManager(toRemove: AbstractActionManager): number;
  33463. /**
  33464. * Removes the given texture from this scene.
  33465. * @param toRemove The texture to remove
  33466. * @returns The index of the removed texture
  33467. */
  33468. removeTexture(toRemove: BaseTexture): number;
  33469. /**
  33470. * Adds the given light to this scene
  33471. * @param newLight The light to add
  33472. */
  33473. addLight(newLight: Light): void;
  33474. /**
  33475. * Sorts the list list based on light priorities
  33476. */
  33477. sortLightsByPriority(): void;
  33478. /**
  33479. * Adds the given camera to this scene
  33480. * @param newCamera The camera to add
  33481. */
  33482. addCamera(newCamera: Camera): void;
  33483. /**
  33484. * Adds the given skeleton to this scene
  33485. * @param newSkeleton The skeleton to add
  33486. */
  33487. addSkeleton(newSkeleton: Skeleton): void;
  33488. /**
  33489. * Adds the given particle system to this scene
  33490. * @param newParticleSystem The particle system to add
  33491. */
  33492. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33493. /**
  33494. * Adds the given animation to this scene
  33495. * @param newAnimation The animation to add
  33496. */
  33497. addAnimation(newAnimation: Animation): void;
  33498. /**
  33499. * Adds the given animation group to this scene.
  33500. * @param newAnimationGroup The animation group to add
  33501. */
  33502. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33503. /**
  33504. * Adds the given multi-material to this scene
  33505. * @param newMultiMaterial The multi-material to add
  33506. */
  33507. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33508. /**
  33509. * Adds the given material to this scene
  33510. * @param newMaterial The material to add
  33511. */
  33512. addMaterial(newMaterial: Material): void;
  33513. /**
  33514. * Adds the given morph target to this scene
  33515. * @param newMorphTargetManager The morph target to add
  33516. */
  33517. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33518. /**
  33519. * Adds the given geometry to this scene
  33520. * @param newGeometry The geometry to add
  33521. */
  33522. addGeometry(newGeometry: Geometry): void;
  33523. /**
  33524. * Adds the given action manager to this scene
  33525. * @param newActionManager The action manager to add
  33526. */
  33527. addActionManager(newActionManager: AbstractActionManager): void;
  33528. /**
  33529. * Adds the given texture to this scene.
  33530. * @param newTexture The texture to add
  33531. */
  33532. addTexture(newTexture: BaseTexture): void;
  33533. /**
  33534. * Switch active camera
  33535. * @param newCamera defines the new active camera
  33536. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33537. */
  33538. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33539. /**
  33540. * sets the active camera of the scene using its ID
  33541. * @param id defines the camera's ID
  33542. * @return the new active camera or null if none found.
  33543. */
  33544. setActiveCameraByID(id: string): Nullable<Camera>;
  33545. /**
  33546. * sets the active camera of the scene using its name
  33547. * @param name defines the camera's name
  33548. * @returns the new active camera or null if none found.
  33549. */
  33550. setActiveCameraByName(name: string): Nullable<Camera>;
  33551. /**
  33552. * get an animation group using its name
  33553. * @param name defines the material's name
  33554. * @return the animation group or null if none found.
  33555. */
  33556. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33557. /**
  33558. * Get a material using its unique id
  33559. * @param uniqueId defines the material's unique id
  33560. * @return the material or null if none found.
  33561. */
  33562. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33563. /**
  33564. * get a material using its id
  33565. * @param id defines the material's ID
  33566. * @return the material or null if none found.
  33567. */
  33568. getMaterialByID(id: string): Nullable<Material>;
  33569. /**
  33570. * Gets a the last added material using a given id
  33571. * @param id defines the material's ID
  33572. * @return the last material with the given id or null if none found.
  33573. */
  33574. getLastMaterialByID(id: string): Nullable<Material>;
  33575. /**
  33576. * Gets a material using its name
  33577. * @param name defines the material's name
  33578. * @return the material or null if none found.
  33579. */
  33580. getMaterialByName(name: string): Nullable<Material>;
  33581. /**
  33582. * Gets a camera using its id
  33583. * @param id defines the id to look for
  33584. * @returns the camera or null if not found
  33585. */
  33586. getCameraByID(id: string): Nullable<Camera>;
  33587. /**
  33588. * Gets a camera using its unique id
  33589. * @param uniqueId defines the unique id to look for
  33590. * @returns the camera or null if not found
  33591. */
  33592. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33593. /**
  33594. * Gets a camera using its name
  33595. * @param name defines the camera's name
  33596. * @return the camera or null if none found.
  33597. */
  33598. getCameraByName(name: string): Nullable<Camera>;
  33599. /**
  33600. * Gets a bone using its id
  33601. * @param id defines the bone's id
  33602. * @return the bone or null if not found
  33603. */
  33604. getBoneByID(id: string): Nullable<Bone>;
  33605. /**
  33606. * Gets a bone using its id
  33607. * @param name defines the bone's name
  33608. * @return the bone or null if not found
  33609. */
  33610. getBoneByName(name: string): Nullable<Bone>;
  33611. /**
  33612. * Gets a light node using its name
  33613. * @param name defines the the light's name
  33614. * @return the light or null if none found.
  33615. */
  33616. getLightByName(name: string): Nullable<Light>;
  33617. /**
  33618. * Gets a light node using its id
  33619. * @param id defines the light's id
  33620. * @return the light or null if none found.
  33621. */
  33622. getLightByID(id: string): Nullable<Light>;
  33623. /**
  33624. * Gets a light node using its scene-generated unique ID
  33625. * @param uniqueId defines the light's unique id
  33626. * @return the light or null if none found.
  33627. */
  33628. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33629. /**
  33630. * Gets a particle system by id
  33631. * @param id defines the particle system id
  33632. * @return the corresponding system or null if none found
  33633. */
  33634. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33635. /**
  33636. * Gets a geometry using its ID
  33637. * @param id defines the geometry's id
  33638. * @return the geometry or null if none found.
  33639. */
  33640. getGeometryByID(id: string): Nullable<Geometry>;
  33641. private _getGeometryByUniqueID;
  33642. /**
  33643. * Add a new geometry to this scene
  33644. * @param geometry defines the geometry to be added to the scene.
  33645. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33646. * @return a boolean defining if the geometry was added or not
  33647. */
  33648. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33649. /**
  33650. * Removes an existing geometry
  33651. * @param geometry defines the geometry to be removed from the scene
  33652. * @return a boolean defining if the geometry was removed or not
  33653. */
  33654. removeGeometry(geometry: Geometry): boolean;
  33655. /**
  33656. * Gets the list of geometries attached to the scene
  33657. * @returns an array of Geometry
  33658. */
  33659. getGeometries(): Geometry[];
  33660. /**
  33661. * Gets the first added mesh found of a given ID
  33662. * @param id defines the id to search for
  33663. * @return the mesh found or null if not found at all
  33664. */
  33665. getMeshByID(id: string): Nullable<AbstractMesh>;
  33666. /**
  33667. * Gets a list of meshes using their id
  33668. * @param id defines the id to search for
  33669. * @returns a list of meshes
  33670. */
  33671. getMeshesByID(id: string): Array<AbstractMesh>;
  33672. /**
  33673. * Gets the first added transform node found of a given ID
  33674. * @param id defines the id to search for
  33675. * @return the found transform node or null if not found at all.
  33676. */
  33677. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33678. /**
  33679. * Gets a transform node with its auto-generated unique id
  33680. * @param uniqueId efines the unique id to search for
  33681. * @return the found transform node or null if not found at all.
  33682. */
  33683. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33684. /**
  33685. * Gets a list of transform nodes using their id
  33686. * @param id defines the id to search for
  33687. * @returns a list of transform nodes
  33688. */
  33689. getTransformNodesByID(id: string): Array<TransformNode>;
  33690. /**
  33691. * Gets a mesh with its auto-generated unique id
  33692. * @param uniqueId defines the unique id to search for
  33693. * @return the found mesh or null if not found at all.
  33694. */
  33695. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33696. /**
  33697. * Gets a the last added mesh using a given id
  33698. * @param id defines the id to search for
  33699. * @return the found mesh or null if not found at all.
  33700. */
  33701. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33702. /**
  33703. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33704. * @param id defines the id to search for
  33705. * @return the found node or null if not found at all
  33706. */
  33707. getLastEntryByID(id: string): Nullable<Node>;
  33708. /**
  33709. * Gets a node (Mesh, Camera, Light) using a given id
  33710. * @param id defines the id to search for
  33711. * @return the found node or null if not found at all
  33712. */
  33713. getNodeByID(id: string): Nullable<Node>;
  33714. /**
  33715. * Gets a node (Mesh, Camera, Light) using a given name
  33716. * @param name defines the name to search for
  33717. * @return the found node or null if not found at all.
  33718. */
  33719. getNodeByName(name: string): Nullable<Node>;
  33720. /**
  33721. * Gets a mesh using a given name
  33722. * @param name defines the name to search for
  33723. * @return the found mesh or null if not found at all.
  33724. */
  33725. getMeshByName(name: string): Nullable<AbstractMesh>;
  33726. /**
  33727. * Gets a transform node using a given name
  33728. * @param name defines the name to search for
  33729. * @return the found transform node or null if not found at all.
  33730. */
  33731. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33732. /**
  33733. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33734. * @param id defines the id to search for
  33735. * @return the found skeleton or null if not found at all.
  33736. */
  33737. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33738. /**
  33739. * Gets a skeleton using a given auto generated unique id
  33740. * @param uniqueId defines the unique id to search for
  33741. * @return the found skeleton or null if not found at all.
  33742. */
  33743. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33744. /**
  33745. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33746. * @param id defines the id to search for
  33747. * @return the found skeleton or null if not found at all.
  33748. */
  33749. getSkeletonById(id: string): Nullable<Skeleton>;
  33750. /**
  33751. * Gets a skeleton using a given name
  33752. * @param name defines the name to search for
  33753. * @return the found skeleton or null if not found at all.
  33754. */
  33755. getSkeletonByName(name: string): Nullable<Skeleton>;
  33756. /**
  33757. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33758. * @param id defines the id to search for
  33759. * @return the found morph target manager or null if not found at all.
  33760. */
  33761. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33762. /**
  33763. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33764. * @param id defines the id to search for
  33765. * @return the found morph target or null if not found at all.
  33766. */
  33767. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33768. /**
  33769. * Gets a boolean indicating if the given mesh is active
  33770. * @param mesh defines the mesh to look for
  33771. * @returns true if the mesh is in the active list
  33772. */
  33773. isActiveMesh(mesh: AbstractMesh): boolean;
  33774. /**
  33775. * Return a unique id as a string which can serve as an identifier for the scene
  33776. */
  33777. readonly uid: string;
  33778. /**
  33779. * Add an externaly attached data from its key.
  33780. * This method call will fail and return false, if such key already exists.
  33781. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33782. * @param key the unique key that identifies the data
  33783. * @param data the data object to associate to the key for this Engine instance
  33784. * @return true if no such key were already present and the data was added successfully, false otherwise
  33785. */
  33786. addExternalData<T>(key: string, data: T): boolean;
  33787. /**
  33788. * Get an externaly attached data from its key
  33789. * @param key the unique key that identifies the data
  33790. * @return the associated data, if present (can be null), or undefined if not present
  33791. */
  33792. getExternalData<T>(key: string): Nullable<T>;
  33793. /**
  33794. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33795. * @param key the unique key that identifies the data
  33796. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33797. * @return the associated data, can be null if the factory returned null.
  33798. */
  33799. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33800. /**
  33801. * Remove an externaly attached data from the Engine instance
  33802. * @param key the unique key that identifies the data
  33803. * @return true if the data was successfully removed, false if it doesn't exist
  33804. */
  33805. removeExternalData(key: string): boolean;
  33806. private _evaluateSubMesh;
  33807. /**
  33808. * Clear the processed materials smart array preventing retention point in material dispose.
  33809. */
  33810. freeProcessedMaterials(): void;
  33811. private _preventFreeActiveMeshesAndRenderingGroups;
  33812. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33813. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33814. * when disposing several meshes in a row or a hierarchy of meshes.
  33815. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33816. */
  33817. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33818. /**
  33819. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33820. */
  33821. freeActiveMeshes(): void;
  33822. /**
  33823. * Clear the info related to rendering groups preventing retention points during dispose.
  33824. */
  33825. freeRenderingGroups(): void;
  33826. /** @hidden */
  33827. _isInIntermediateRendering(): boolean;
  33828. /**
  33829. * Lambda returning the list of potentially active meshes.
  33830. */
  33831. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33832. /**
  33833. * Lambda returning the list of potentially active sub meshes.
  33834. */
  33835. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33836. /**
  33837. * Lambda returning the list of potentially intersecting sub meshes.
  33838. */
  33839. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33840. /**
  33841. * Lambda returning the list of potentially colliding sub meshes.
  33842. */
  33843. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33844. private _activeMeshesFrozen;
  33845. /**
  33846. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33847. * @returns the current scene
  33848. */
  33849. freezeActiveMeshes(): Scene;
  33850. /**
  33851. * Use this function to restart evaluating active meshes on every frame
  33852. * @returns the current scene
  33853. */
  33854. unfreezeActiveMeshes(): Scene;
  33855. private _evaluateActiveMeshes;
  33856. private _activeMesh;
  33857. /**
  33858. * Update the transform matrix to update from the current active camera
  33859. * @param force defines a boolean used to force the update even if cache is up to date
  33860. */
  33861. updateTransformMatrix(force?: boolean): void;
  33862. private _bindFrameBuffer;
  33863. /** @hidden */
  33864. _allowPostProcessClearColor: boolean;
  33865. /** @hidden */
  33866. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33867. private _processSubCameras;
  33868. private _checkIntersections;
  33869. /** @hidden */
  33870. _advancePhysicsEngineStep(step: number): void;
  33871. /**
  33872. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33873. */
  33874. getDeterministicFrameTime: () => number;
  33875. /** @hidden */
  33876. _animate(): void;
  33877. /** Execute all animations (for a frame) */
  33878. animate(): void;
  33879. /**
  33880. * Render the scene
  33881. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33882. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33883. */
  33884. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33885. /**
  33886. * Freeze all materials
  33887. * A frozen material will not be updatable but should be faster to render
  33888. */
  33889. freezeMaterials(): void;
  33890. /**
  33891. * Unfreeze all materials
  33892. * A frozen material will not be updatable but should be faster to render
  33893. */
  33894. unfreezeMaterials(): void;
  33895. /**
  33896. * Releases all held ressources
  33897. */
  33898. dispose(): void;
  33899. /**
  33900. * Gets if the scene is already disposed
  33901. */
  33902. readonly isDisposed: boolean;
  33903. /**
  33904. * Call this function to reduce memory footprint of the scene.
  33905. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33906. */
  33907. clearCachedVertexData(): void;
  33908. /**
  33909. * This function will remove the local cached buffer data from texture.
  33910. * It will save memory but will prevent the texture from being rebuilt
  33911. */
  33912. cleanCachedTextureBuffer(): void;
  33913. /**
  33914. * Get the world extend vectors with an optional filter
  33915. *
  33916. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33917. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33918. */
  33919. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33920. min: Vector3;
  33921. max: Vector3;
  33922. };
  33923. /**
  33924. * Creates a ray that can be used to pick in the scene
  33925. * @param x defines the x coordinate of the origin (on-screen)
  33926. * @param y defines the y coordinate of the origin (on-screen)
  33927. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33928. * @param camera defines the camera to use for the picking
  33929. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33930. * @returns a Ray
  33931. */
  33932. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): 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 world defines the world matrix to use if you want to pick in object space (instead of world space)
  33938. * @param result defines the ray where to store the picking ray
  33939. * @param camera defines the camera to use for the picking
  33940. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33941. * @returns the current scene
  33942. */
  33943. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33944. /**
  33945. * Creates a ray that can be used to pick in the scene
  33946. * @param x defines the x coordinate of the origin (on-screen)
  33947. * @param y defines the y coordinate of the origin (on-screen)
  33948. * @param camera defines the camera to use for the picking
  33949. * @returns a Ray
  33950. */
  33951. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33952. /**
  33953. * Creates a ray that can be used to pick in the scene
  33954. * @param x defines the x coordinate of the origin (on-screen)
  33955. * @param y defines the y coordinate of the origin (on-screen)
  33956. * @param result defines the ray where to store the picking ray
  33957. * @param camera defines the camera to use for the picking
  33958. * @returns the current scene
  33959. */
  33960. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33961. /** Launch a ray to try to pick a mesh in the scene
  33962. * @param x position on screen
  33963. * @param 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 fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33966. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33967. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33968. * @returns a PickingInfo
  33969. */
  33970. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33971. /** Use the given ray to pick a mesh in the scene
  33972. * @param ray The ray to use to pick meshes
  33973. * @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
  33974. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33975. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33976. * @returns a PickingInfo
  33977. */
  33978. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33979. /**
  33980. * Launch a ray to try to pick a mesh in the scene
  33981. * @param x X position on screen
  33982. * @param y Y position on screen
  33983. * @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
  33984. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33985. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33986. * @returns an array of PickingInfo
  33987. */
  33988. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33989. /**
  33990. * Launch a ray to try to pick a mesh in the scene
  33991. * @param ray Ray to use
  33992. * @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
  33993. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33994. * @returns an array of PickingInfo
  33995. */
  33996. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33997. /**
  33998. * Force the value of meshUnderPointer
  33999. * @param mesh defines the mesh to use
  34000. */
  34001. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34002. /**
  34003. * Gets the mesh under the pointer
  34004. * @returns a Mesh or null if no mesh is under the pointer
  34005. */
  34006. getPointerOverMesh(): Nullable<AbstractMesh>;
  34007. /** @hidden */
  34008. _rebuildGeometries(): void;
  34009. /** @hidden */
  34010. _rebuildTextures(): void;
  34011. private _getByTags;
  34012. /**
  34013. * Get a list of meshes by tags
  34014. * @param tagsQuery defines the tags query to use
  34015. * @param forEach defines a predicate used to filter results
  34016. * @returns an array of Mesh
  34017. */
  34018. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34019. /**
  34020. * Get a list of cameras by tags
  34021. * @param tagsQuery defines the tags query to use
  34022. * @param forEach defines a predicate used to filter results
  34023. * @returns an array of Camera
  34024. */
  34025. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34026. /**
  34027. * Get a list of lights by tags
  34028. * @param tagsQuery defines the tags query to use
  34029. * @param forEach defines a predicate used to filter results
  34030. * @returns an array of Light
  34031. */
  34032. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34033. /**
  34034. * Get a list of materials by tags
  34035. * @param tagsQuery defines the tags query to use
  34036. * @param forEach defines a predicate used to filter results
  34037. * @returns an array of Material
  34038. */
  34039. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34040. /**
  34041. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34042. * This allowed control for front to back rendering or reversly depending of the special needs.
  34043. *
  34044. * @param renderingGroupId The rendering group id corresponding to its index
  34045. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34046. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34047. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34048. */
  34049. 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;
  34050. /**
  34051. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34052. *
  34053. * @param renderingGroupId The rendering group id corresponding to its index
  34054. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34055. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34056. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34057. */
  34058. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34059. /**
  34060. * Gets the current auto clear configuration for one rendering group of the rendering
  34061. * manager.
  34062. * @param index the rendering group index to get the information for
  34063. * @returns The auto clear setup for the requested rendering group
  34064. */
  34065. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34066. private _blockMaterialDirtyMechanism;
  34067. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34068. blockMaterialDirtyMechanism: boolean;
  34069. /**
  34070. * Will flag all materials as dirty to trigger new shader compilation
  34071. * @param flag defines the flag used to specify which material part must be marked as dirty
  34072. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34073. */
  34074. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34075. /** @hidden */
  34076. _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;
  34077. /** @hidden */
  34078. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34079. }
  34080. }
  34081. declare module BABYLON {
  34082. /**
  34083. * Set of assets to keep when moving a scene into an asset container.
  34084. */
  34085. export class KeepAssets extends AbstractScene {
  34086. }
  34087. /**
  34088. * Container with a set of assets that can be added or removed from a scene.
  34089. */
  34090. export class AssetContainer extends AbstractScene {
  34091. /**
  34092. * The scene the AssetContainer belongs to.
  34093. */
  34094. scene: Scene;
  34095. /**
  34096. * Instantiates an AssetContainer.
  34097. * @param scene The scene the AssetContainer belongs to.
  34098. */
  34099. constructor(scene: Scene);
  34100. /**
  34101. * Adds all the assets from the container to the scene.
  34102. */
  34103. addAllToScene(): void;
  34104. /**
  34105. * Removes all the assets in the container from the scene
  34106. */
  34107. removeAllFromScene(): void;
  34108. /**
  34109. * Disposes all the assets in the container
  34110. */
  34111. dispose(): void;
  34112. private _moveAssets;
  34113. /**
  34114. * Removes all the assets contained in the scene and adds them to the container.
  34115. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34116. */
  34117. moveAllFromScene(keepAssets?: KeepAssets): void;
  34118. /**
  34119. * 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.
  34120. * @returns the root mesh
  34121. */
  34122. createRootMesh(): Mesh;
  34123. }
  34124. }
  34125. declare module BABYLON {
  34126. /**
  34127. * Defines how the parser contract is defined.
  34128. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34129. */
  34130. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34131. /**
  34132. * Defines how the individual parser contract is defined.
  34133. * These parser can parse an individual asset
  34134. */
  34135. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34136. /**
  34137. * Base class of the scene acting as a container for the different elements composing a scene.
  34138. * This class is dynamically extended by the different components of the scene increasing
  34139. * flexibility and reducing coupling
  34140. */
  34141. export abstract class AbstractScene {
  34142. /**
  34143. * Stores the list of available parsers in the application.
  34144. */
  34145. private static _BabylonFileParsers;
  34146. /**
  34147. * Stores the list of available individual parsers in the application.
  34148. */
  34149. private static _IndividualBabylonFileParsers;
  34150. /**
  34151. * Adds a parser in the list of available ones
  34152. * @param name Defines the name of the parser
  34153. * @param parser Defines the parser to add
  34154. */
  34155. static AddParser(name: string, parser: BabylonFileParser): void;
  34156. /**
  34157. * Gets a general parser from the list of avaialble ones
  34158. * @param name Defines the name of the parser
  34159. * @returns the requested parser or null
  34160. */
  34161. static GetParser(name: string): Nullable<BabylonFileParser>;
  34162. /**
  34163. * Adds n individual parser in the list of available ones
  34164. * @param name Defines the name of the parser
  34165. * @param parser Defines the parser to add
  34166. */
  34167. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34168. /**
  34169. * Gets an individual parser from the list of avaialble ones
  34170. * @param name Defines the name of the parser
  34171. * @returns the requested parser or null
  34172. */
  34173. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34174. /**
  34175. * Parser json data and populate both a scene and its associated container object
  34176. * @param jsonData Defines the data to parse
  34177. * @param scene Defines the scene to parse the data for
  34178. * @param container Defines the container attached to the parsing sequence
  34179. * @param rootUrl Defines the root url of the data
  34180. */
  34181. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34182. /**
  34183. * Gets the list of root nodes (ie. nodes with no parent)
  34184. */
  34185. rootNodes: Node[];
  34186. /** All of the cameras added to this scene
  34187. * @see http://doc.babylonjs.com/babylon101/cameras
  34188. */
  34189. cameras: Camera[];
  34190. /**
  34191. * All of the lights added to this scene
  34192. * @see http://doc.babylonjs.com/babylon101/lights
  34193. */
  34194. lights: Light[];
  34195. /**
  34196. * All of the (abstract) meshes added to this scene
  34197. */
  34198. meshes: AbstractMesh[];
  34199. /**
  34200. * The list of skeletons added to the scene
  34201. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34202. */
  34203. skeletons: Skeleton[];
  34204. /**
  34205. * All of the particle systems added to this scene
  34206. * @see http://doc.babylonjs.com/babylon101/particles
  34207. */
  34208. particleSystems: IParticleSystem[];
  34209. /**
  34210. * Gets a list of Animations associated with the scene
  34211. */
  34212. animations: Animation[];
  34213. /**
  34214. * All of the animation groups added to this scene
  34215. * @see http://doc.babylonjs.com/how_to/group
  34216. */
  34217. animationGroups: AnimationGroup[];
  34218. /**
  34219. * All of the multi-materials added to this scene
  34220. * @see http://doc.babylonjs.com/how_to/multi_materials
  34221. */
  34222. multiMaterials: MultiMaterial[];
  34223. /**
  34224. * All of the materials added to this scene
  34225. * In the context of a Scene, it is not supposed to be modified manually.
  34226. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34227. * Note also that the order of the Material wihin the array is not significant and might change.
  34228. * @see http://doc.babylonjs.com/babylon101/materials
  34229. */
  34230. materials: Material[];
  34231. /**
  34232. * The list of morph target managers added to the scene
  34233. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34234. */
  34235. morphTargetManagers: MorphTargetManager[];
  34236. /**
  34237. * The list of geometries used in the scene.
  34238. */
  34239. geometries: Geometry[];
  34240. /**
  34241. * All of the tranform nodes added to this scene
  34242. * In the context of a Scene, it is not supposed to be modified manually.
  34243. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34244. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34245. * @see http://doc.babylonjs.com/how_to/transformnode
  34246. */
  34247. transformNodes: TransformNode[];
  34248. /**
  34249. * ActionManagers available on the scene.
  34250. */
  34251. actionManagers: AbstractActionManager[];
  34252. /**
  34253. * Textures to keep.
  34254. */
  34255. textures: BaseTexture[];
  34256. /**
  34257. * Environment texture for the scene
  34258. */
  34259. environmentTexture: Nullable<BaseTexture>;
  34260. }
  34261. }
  34262. declare module BABYLON {
  34263. /**
  34264. * Interface used to define options for Sound class
  34265. */
  34266. export interface ISoundOptions {
  34267. /**
  34268. * Does the sound autoplay once loaded.
  34269. */
  34270. autoplay?: boolean;
  34271. /**
  34272. * Does the sound loop after it finishes playing once.
  34273. */
  34274. loop?: boolean;
  34275. /**
  34276. * Sound's volume
  34277. */
  34278. volume?: number;
  34279. /**
  34280. * Is it a spatial sound?
  34281. */
  34282. spatialSound?: boolean;
  34283. /**
  34284. * Maximum distance to hear that sound
  34285. */
  34286. maxDistance?: number;
  34287. /**
  34288. * Uses user defined attenuation function
  34289. */
  34290. useCustomAttenuation?: boolean;
  34291. /**
  34292. * Define the roll off factor of spatial sounds.
  34293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34294. */
  34295. rolloffFactor?: number;
  34296. /**
  34297. * Define the reference distance the sound should be heard perfectly.
  34298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34299. */
  34300. refDistance?: number;
  34301. /**
  34302. * Define the distance attenuation model the sound will follow.
  34303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34304. */
  34305. distanceModel?: string;
  34306. /**
  34307. * Defines the playback speed (1 by default)
  34308. */
  34309. playbackRate?: number;
  34310. /**
  34311. * Defines if the sound is from a streaming source
  34312. */
  34313. streaming?: boolean;
  34314. /**
  34315. * Defines an optional length (in seconds) inside the sound file
  34316. */
  34317. length?: number;
  34318. /**
  34319. * Defines an optional offset (in seconds) inside the sound file
  34320. */
  34321. offset?: number;
  34322. /**
  34323. * If true, URLs will not be required to state the audio file codec to use.
  34324. */
  34325. skipCodecCheck?: boolean;
  34326. }
  34327. /**
  34328. * Defines a sound that can be played in the application.
  34329. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34330. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34331. */
  34332. export class Sound {
  34333. /**
  34334. * The name of the sound in the scene.
  34335. */
  34336. name: string;
  34337. /**
  34338. * Does the sound autoplay once loaded.
  34339. */
  34340. autoplay: boolean;
  34341. /**
  34342. * Does the sound loop after it finishes playing once.
  34343. */
  34344. loop: boolean;
  34345. /**
  34346. * Does the sound use a custom attenuation curve to simulate the falloff
  34347. * happening when the source gets further away from the camera.
  34348. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34349. */
  34350. useCustomAttenuation: boolean;
  34351. /**
  34352. * The sound track id this sound belongs to.
  34353. */
  34354. soundTrackId: number;
  34355. /**
  34356. * Is this sound currently played.
  34357. */
  34358. isPlaying: boolean;
  34359. /**
  34360. * Is this sound currently paused.
  34361. */
  34362. isPaused: boolean;
  34363. /**
  34364. * Does this sound enables spatial sound.
  34365. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34366. */
  34367. spatialSound: boolean;
  34368. /**
  34369. * Define the reference distance the sound should be heard perfectly.
  34370. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34371. */
  34372. refDistance: number;
  34373. /**
  34374. * Define the roll off factor of spatial sounds.
  34375. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34376. */
  34377. rolloffFactor: number;
  34378. /**
  34379. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34380. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34381. */
  34382. maxDistance: number;
  34383. /**
  34384. * Define the distance attenuation model the sound will follow.
  34385. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34386. */
  34387. distanceModel: string;
  34388. /**
  34389. * @hidden
  34390. * Back Compat
  34391. **/
  34392. onended: () => any;
  34393. /**
  34394. * Observable event when the current playing sound finishes.
  34395. */
  34396. onEndedObservable: Observable<Sound>;
  34397. private _panningModel;
  34398. private _playbackRate;
  34399. private _streaming;
  34400. private _startTime;
  34401. private _startOffset;
  34402. private _position;
  34403. /** @hidden */
  34404. _positionInEmitterSpace: boolean;
  34405. private _localDirection;
  34406. private _volume;
  34407. private _isReadyToPlay;
  34408. private _isDirectional;
  34409. private _readyToPlayCallback;
  34410. private _audioBuffer;
  34411. private _soundSource;
  34412. private _streamingSource;
  34413. private _soundPanner;
  34414. private _soundGain;
  34415. private _inputAudioNode;
  34416. private _outputAudioNode;
  34417. private _coneInnerAngle;
  34418. private _coneOuterAngle;
  34419. private _coneOuterGain;
  34420. private _scene;
  34421. private _connectedTransformNode;
  34422. private _customAttenuationFunction;
  34423. private _registerFunc;
  34424. private _isOutputConnected;
  34425. private _htmlAudioElement;
  34426. private _urlType;
  34427. private _length?;
  34428. private _offset?;
  34429. /** @hidden */
  34430. static _SceneComponentInitialization: (scene: Scene) => void;
  34431. /**
  34432. * Create a sound and attach it to a scene
  34433. * @param name Name of your sound
  34434. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34435. * @param scene defines the scene the sound belongs to
  34436. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34437. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34438. */
  34439. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34440. /**
  34441. * Release the sound and its associated resources
  34442. */
  34443. dispose(): void;
  34444. /**
  34445. * Gets if the sounds is ready to be played or not.
  34446. * @returns true if ready, otherwise false
  34447. */
  34448. isReady(): boolean;
  34449. private _soundLoaded;
  34450. /**
  34451. * Sets the data of the sound from an audiobuffer
  34452. * @param audioBuffer The audioBuffer containing the data
  34453. */
  34454. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34455. /**
  34456. * Updates the current sounds options such as maxdistance, loop...
  34457. * @param options A JSON object containing values named as the object properties
  34458. */
  34459. updateOptions(options: ISoundOptions): void;
  34460. private _createSpatialParameters;
  34461. private _updateSpatialParameters;
  34462. /**
  34463. * Switch the panning model to HRTF:
  34464. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34465. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34466. */
  34467. switchPanningModelToHRTF(): void;
  34468. /**
  34469. * Switch the panning model to Equal Power:
  34470. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34472. */
  34473. switchPanningModelToEqualPower(): void;
  34474. private _switchPanningModel;
  34475. /**
  34476. * Connect this sound to a sound track audio node like gain...
  34477. * @param soundTrackAudioNode the sound track audio node to connect to
  34478. */
  34479. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34480. /**
  34481. * Transform this sound into a directional source
  34482. * @param coneInnerAngle Size of the inner cone in degree
  34483. * @param coneOuterAngle Size of the outer cone in degree
  34484. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34485. */
  34486. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34487. /**
  34488. * Gets or sets the inner angle for the directional cone.
  34489. */
  34490. /**
  34491. * Gets or sets the inner angle for the directional cone.
  34492. */
  34493. directionalConeInnerAngle: number;
  34494. /**
  34495. * Gets or sets the outer angle for the directional cone.
  34496. */
  34497. /**
  34498. * Gets or sets the outer angle for the directional cone.
  34499. */
  34500. directionalConeOuterAngle: number;
  34501. /**
  34502. * Sets the position of the emitter if spatial sound is enabled
  34503. * @param newPosition Defines the new posisiton
  34504. */
  34505. setPosition(newPosition: Vector3): void;
  34506. /**
  34507. * Sets the local direction of the emitter if spatial sound is enabled
  34508. * @param newLocalDirection Defines the new local direction
  34509. */
  34510. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34511. private _updateDirection;
  34512. /** @hidden */
  34513. updateDistanceFromListener(): void;
  34514. /**
  34515. * Sets a new custom attenuation function for the sound.
  34516. * @param callback Defines the function used for the attenuation
  34517. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34518. */
  34519. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34520. /**
  34521. * Play the sound
  34522. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34523. * @param offset (optional) Start the sound at a specific time in seconds
  34524. * @param length (optional) Sound duration (in seconds)
  34525. */
  34526. play(time?: number, offset?: number, length?: number): void;
  34527. private _onended;
  34528. /**
  34529. * Stop the sound
  34530. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34531. */
  34532. stop(time?: number): void;
  34533. /**
  34534. * Put the sound in pause
  34535. */
  34536. pause(): void;
  34537. /**
  34538. * Sets a dedicated volume for this sounds
  34539. * @param newVolume Define the new volume of the sound
  34540. * @param time Define time for gradual change to new volume
  34541. */
  34542. setVolume(newVolume: number, time?: number): void;
  34543. /**
  34544. * Set the sound play back rate
  34545. * @param newPlaybackRate Define the playback rate the sound should be played at
  34546. */
  34547. setPlaybackRate(newPlaybackRate: number): void;
  34548. /**
  34549. * Gets the volume of the sound.
  34550. * @returns the volume of the sound
  34551. */
  34552. getVolume(): number;
  34553. /**
  34554. * Attach the sound to a dedicated mesh
  34555. * @param transformNode The transform node to connect the sound with
  34556. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34557. */
  34558. attachToMesh(transformNode: TransformNode): void;
  34559. /**
  34560. * Detach the sound from the previously attached mesh
  34561. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34562. */
  34563. detachFromMesh(): void;
  34564. private _onRegisterAfterWorldMatrixUpdate;
  34565. /**
  34566. * Clone the current sound in the scene.
  34567. * @returns the new sound clone
  34568. */
  34569. clone(): Nullable<Sound>;
  34570. /**
  34571. * Gets the current underlying audio buffer containing the data
  34572. * @returns the audio buffer
  34573. */
  34574. getAudioBuffer(): Nullable<AudioBuffer>;
  34575. /**
  34576. * Serializes the Sound in a JSON representation
  34577. * @returns the JSON representation of the sound
  34578. */
  34579. serialize(): any;
  34580. /**
  34581. * Parse a JSON representation of a sound to innstantiate in a given scene
  34582. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34583. * @param scene Define the scene the new parsed sound should be created in
  34584. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34585. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34586. * @returns the newly parsed sound
  34587. */
  34588. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34589. }
  34590. }
  34591. declare module BABYLON {
  34592. /**
  34593. * This defines an action helpful to play a defined sound on a triggered action.
  34594. */
  34595. export class PlaySoundAction extends Action {
  34596. private _sound;
  34597. /**
  34598. * Instantiate the action
  34599. * @param triggerOptions defines the trigger options
  34600. * @param sound defines the sound to play
  34601. * @param condition defines the trigger related conditions
  34602. */
  34603. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34604. /** @hidden */
  34605. _prepare(): void;
  34606. /**
  34607. * Execute the action and play the sound.
  34608. */
  34609. execute(): void;
  34610. /**
  34611. * Serializes the actions and its related information.
  34612. * @param parent defines the object to serialize in
  34613. * @returns the serialized object
  34614. */
  34615. serialize(parent: any): any;
  34616. }
  34617. /**
  34618. * This defines an action helpful to stop a defined sound on a triggered action.
  34619. */
  34620. export class StopSoundAction extends Action {
  34621. private _sound;
  34622. /**
  34623. * Instantiate the action
  34624. * @param triggerOptions defines the trigger options
  34625. * @param sound defines the sound to stop
  34626. * @param condition defines the trigger related conditions
  34627. */
  34628. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34629. /** @hidden */
  34630. _prepare(): void;
  34631. /**
  34632. * Execute the action and stop the sound.
  34633. */
  34634. execute(): void;
  34635. /**
  34636. * Serializes the actions and its related information.
  34637. * @param parent defines the object to serialize in
  34638. * @returns the serialized object
  34639. */
  34640. serialize(parent: any): any;
  34641. }
  34642. }
  34643. declare module BABYLON {
  34644. /**
  34645. * This defines an action responsible to change the value of a property
  34646. * by interpolating between its current value and the newly set one once triggered.
  34647. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34648. */
  34649. export class InterpolateValueAction extends Action {
  34650. /**
  34651. * Defines the path of the property where the value should be interpolated
  34652. */
  34653. propertyPath: string;
  34654. /**
  34655. * Defines the target value at the end of the interpolation.
  34656. */
  34657. value: any;
  34658. /**
  34659. * Defines the time it will take for the property to interpolate to the value.
  34660. */
  34661. duration: number;
  34662. /**
  34663. * Defines if the other scene animations should be stopped when the action has been triggered
  34664. */
  34665. stopOtherAnimations?: boolean;
  34666. /**
  34667. * Defines a callback raised once the interpolation animation has been done.
  34668. */
  34669. onInterpolationDone?: () => void;
  34670. /**
  34671. * Observable triggered once the interpolation animation has been done.
  34672. */
  34673. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34674. private _target;
  34675. private _effectiveTarget;
  34676. private _property;
  34677. /**
  34678. * Instantiate the action
  34679. * @param triggerOptions defines the trigger options
  34680. * @param target defines the object containing the value to interpolate
  34681. * @param propertyPath defines the path to the property in the target object
  34682. * @param value defines the target value at the end of the interpolation
  34683. * @param duration deines the time it will take for the property to interpolate to the value.
  34684. * @param condition defines the trigger related conditions
  34685. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34686. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34687. */
  34688. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34689. /** @hidden */
  34690. _prepare(): void;
  34691. /**
  34692. * Execute the action starts the value interpolation.
  34693. */
  34694. execute(): void;
  34695. /**
  34696. * Serializes the actions and its related information.
  34697. * @param parent defines the object to serialize in
  34698. * @returns the serialized object
  34699. */
  34700. serialize(parent: any): any;
  34701. }
  34702. }
  34703. declare module BABYLON {
  34704. /**
  34705. * Options allowed during the creation of a sound track.
  34706. */
  34707. export interface ISoundTrackOptions {
  34708. /**
  34709. * The volume the sound track should take during creation
  34710. */
  34711. volume?: number;
  34712. /**
  34713. * Define if the sound track is the main sound track of the scene
  34714. */
  34715. mainTrack?: boolean;
  34716. }
  34717. /**
  34718. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34719. * It will be also used in a future release to apply effects on a specific track.
  34720. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34721. */
  34722. export class SoundTrack {
  34723. /**
  34724. * The unique identifier of the sound track in the scene.
  34725. */
  34726. id: number;
  34727. /**
  34728. * The list of sounds included in the sound track.
  34729. */
  34730. soundCollection: Array<Sound>;
  34731. private _outputAudioNode;
  34732. private _scene;
  34733. private _isMainTrack;
  34734. private _connectedAnalyser;
  34735. private _options;
  34736. private _isInitialized;
  34737. /**
  34738. * Creates a new sound track.
  34739. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34740. * @param scene Define the scene the sound track belongs to
  34741. * @param options
  34742. */
  34743. constructor(scene: Scene, options?: ISoundTrackOptions);
  34744. private _initializeSoundTrackAudioGraph;
  34745. /**
  34746. * Release the sound track and its associated resources
  34747. */
  34748. dispose(): void;
  34749. /**
  34750. * Adds a sound to this sound track
  34751. * @param sound define the cound to add
  34752. * @ignoreNaming
  34753. */
  34754. AddSound(sound: Sound): void;
  34755. /**
  34756. * Removes a sound to this sound track
  34757. * @param sound define the cound to remove
  34758. * @ignoreNaming
  34759. */
  34760. RemoveSound(sound: Sound): void;
  34761. /**
  34762. * Set a global volume for the full sound track.
  34763. * @param newVolume Define the new volume of the sound track
  34764. */
  34765. setVolume(newVolume: number): void;
  34766. /**
  34767. * Switch the panning model to HRTF:
  34768. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34769. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34770. */
  34771. switchPanningModelToHRTF(): void;
  34772. /**
  34773. * Switch the panning model to Equal Power:
  34774. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34775. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34776. */
  34777. switchPanningModelToEqualPower(): void;
  34778. /**
  34779. * Connect the sound track to an audio analyser allowing some amazing
  34780. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34782. * @param analyser The analyser to connect to the engine
  34783. */
  34784. connectToAnalyser(analyser: Analyser): void;
  34785. }
  34786. }
  34787. declare module BABYLON {
  34788. interface AbstractScene {
  34789. /**
  34790. * The list of sounds used in the scene.
  34791. */
  34792. sounds: Nullable<Array<Sound>>;
  34793. }
  34794. interface Scene {
  34795. /**
  34796. * @hidden
  34797. * Backing field
  34798. */
  34799. _mainSoundTrack: SoundTrack;
  34800. /**
  34801. * The main sound track played by the scene.
  34802. * It cotains your primary collection of sounds.
  34803. */
  34804. mainSoundTrack: SoundTrack;
  34805. /**
  34806. * The list of sound tracks added to the scene
  34807. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34808. */
  34809. soundTracks: Nullable<Array<SoundTrack>>;
  34810. /**
  34811. * Gets a sound using a given name
  34812. * @param name defines the name to search for
  34813. * @return the found sound or null if not found at all.
  34814. */
  34815. getSoundByName(name: string): Nullable<Sound>;
  34816. /**
  34817. * Gets or sets if audio support is enabled
  34818. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34819. */
  34820. audioEnabled: boolean;
  34821. /**
  34822. * Gets or sets if audio will be output to headphones
  34823. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34824. */
  34825. headphone: boolean;
  34826. }
  34827. /**
  34828. * Defines the sound scene component responsible to manage any sounds
  34829. * in a given scene.
  34830. */
  34831. export class AudioSceneComponent implements ISceneSerializableComponent {
  34832. /**
  34833. * The component name helpfull to identify the component in the list of scene components.
  34834. */
  34835. readonly name: string;
  34836. /**
  34837. * The scene the component belongs to.
  34838. */
  34839. scene: Scene;
  34840. private _audioEnabled;
  34841. /**
  34842. * Gets whether audio is enabled or not.
  34843. * Please use related enable/disable method to switch state.
  34844. */
  34845. readonly audioEnabled: boolean;
  34846. private _headphone;
  34847. /**
  34848. * Gets whether audio is outputing to headphone or not.
  34849. * Please use the according Switch methods to change output.
  34850. */
  34851. readonly headphone: boolean;
  34852. /**
  34853. * Creates a new instance of the component for the given scene
  34854. * @param scene Defines the scene to register the component in
  34855. */
  34856. constructor(scene: Scene);
  34857. /**
  34858. * Registers the component in a given scene
  34859. */
  34860. register(): void;
  34861. /**
  34862. * Rebuilds the elements related to this component in case of
  34863. * context lost for instance.
  34864. */
  34865. rebuild(): void;
  34866. /**
  34867. * Serializes the component data to the specified json object
  34868. * @param serializationObject The object to serialize to
  34869. */
  34870. serialize(serializationObject: any): void;
  34871. /**
  34872. * Adds all the elements from the container to the scene
  34873. * @param container the container holding the elements
  34874. */
  34875. addFromContainer(container: AbstractScene): void;
  34876. /**
  34877. * Removes all the elements in the container from the scene
  34878. * @param container contains the elements to remove
  34879. * @param dispose if the removed element should be disposed (default: false)
  34880. */
  34881. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34882. /**
  34883. * Disposes the component and the associated ressources.
  34884. */
  34885. dispose(): void;
  34886. /**
  34887. * Disables audio in the associated scene.
  34888. */
  34889. disableAudio(): void;
  34890. /**
  34891. * Enables audio in the associated scene.
  34892. */
  34893. enableAudio(): void;
  34894. /**
  34895. * Switch audio to headphone output.
  34896. */
  34897. switchAudioModeForHeadphones(): void;
  34898. /**
  34899. * Switch audio to normal speakers.
  34900. */
  34901. switchAudioModeForNormalSpeakers(): void;
  34902. private _afterRender;
  34903. }
  34904. }
  34905. declare module BABYLON {
  34906. /**
  34907. * Wraps one or more Sound objects and selects one with random weight for playback.
  34908. */
  34909. export class WeightedSound {
  34910. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34911. loop: boolean;
  34912. private _coneInnerAngle;
  34913. private _coneOuterAngle;
  34914. private _volume;
  34915. /** A Sound is currently playing. */
  34916. isPlaying: boolean;
  34917. /** A Sound is currently paused. */
  34918. isPaused: boolean;
  34919. private _sounds;
  34920. private _weights;
  34921. private _currentIndex?;
  34922. /**
  34923. * Creates a new WeightedSound from the list of sounds given.
  34924. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34925. * @param sounds Array of Sounds that will be selected from.
  34926. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34927. */
  34928. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34929. /**
  34930. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34931. */
  34932. /**
  34933. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34934. */
  34935. directionalConeInnerAngle: number;
  34936. /**
  34937. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34938. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34939. */
  34940. /**
  34941. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34942. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34943. */
  34944. directionalConeOuterAngle: number;
  34945. /**
  34946. * Playback volume.
  34947. */
  34948. /**
  34949. * Playback volume.
  34950. */
  34951. volume: number;
  34952. private _onended;
  34953. /**
  34954. * Suspend playback
  34955. */
  34956. pause(): void;
  34957. /**
  34958. * Stop playback
  34959. */
  34960. stop(): void;
  34961. /**
  34962. * Start playback.
  34963. * @param startOffset Position the clip head at a specific time in seconds.
  34964. */
  34965. play(startOffset?: number): void;
  34966. }
  34967. }
  34968. declare module BABYLON {
  34969. /**
  34970. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34971. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34972. */
  34973. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34974. /**
  34975. * Gets the name of the behavior.
  34976. */
  34977. readonly name: string;
  34978. /**
  34979. * The easing function used by animations
  34980. */
  34981. static EasingFunction: BackEase;
  34982. /**
  34983. * The easing mode used by animations
  34984. */
  34985. static EasingMode: number;
  34986. /**
  34987. * The duration of the animation, in milliseconds
  34988. */
  34989. transitionDuration: number;
  34990. /**
  34991. * Length of the distance animated by the transition when lower radius is reached
  34992. */
  34993. lowerRadiusTransitionRange: number;
  34994. /**
  34995. * Length of the distance animated by the transition when upper radius is reached
  34996. */
  34997. upperRadiusTransitionRange: number;
  34998. private _autoTransitionRange;
  34999. /**
  35000. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35001. */
  35002. /**
  35003. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35004. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35005. */
  35006. autoTransitionRange: boolean;
  35007. private _attachedCamera;
  35008. private _onAfterCheckInputsObserver;
  35009. private _onMeshTargetChangedObserver;
  35010. /**
  35011. * Initializes the behavior.
  35012. */
  35013. init(): void;
  35014. /**
  35015. * Attaches the behavior to its arc rotate camera.
  35016. * @param camera Defines the camera to attach the behavior to
  35017. */
  35018. attach(camera: ArcRotateCamera): void;
  35019. /**
  35020. * Detaches the behavior from its current arc rotate camera.
  35021. */
  35022. detach(): void;
  35023. private _radiusIsAnimating;
  35024. private _radiusBounceTransition;
  35025. private _animatables;
  35026. private _cachedWheelPrecision;
  35027. /**
  35028. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35029. * @param radiusLimit The limit to check against.
  35030. * @return Bool to indicate if at limit.
  35031. */
  35032. private _isRadiusAtLimit;
  35033. /**
  35034. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35035. * @param radiusDelta The delta by which to animate to. Can be negative.
  35036. */
  35037. private _applyBoundRadiusAnimation;
  35038. /**
  35039. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35040. */
  35041. protected _clearAnimationLocks(): void;
  35042. /**
  35043. * Stops and removes all animations that have been applied to the camera
  35044. */
  35045. stopAllAnimations(): void;
  35046. }
  35047. }
  35048. declare module BABYLON {
  35049. /**
  35050. * 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.
  35051. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35052. */
  35053. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35054. /**
  35055. * Gets the name of the behavior.
  35056. */
  35057. readonly name: string;
  35058. private _mode;
  35059. private _radiusScale;
  35060. private _positionScale;
  35061. private _defaultElevation;
  35062. private _elevationReturnTime;
  35063. private _elevationReturnWaitTime;
  35064. private _zoomStopsAnimation;
  35065. private _framingTime;
  35066. /**
  35067. * The easing function used by animations
  35068. */
  35069. static EasingFunction: ExponentialEase;
  35070. /**
  35071. * The easing mode used by animations
  35072. */
  35073. static EasingMode: number;
  35074. /**
  35075. * Sets the current mode used by the behavior
  35076. */
  35077. /**
  35078. * Gets current mode used by the behavior.
  35079. */
  35080. mode: number;
  35081. /**
  35082. * Sets the scale applied to the radius (1 by default)
  35083. */
  35084. /**
  35085. * Gets the scale applied to the radius
  35086. */
  35087. radiusScale: number;
  35088. /**
  35089. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35090. */
  35091. /**
  35092. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35093. */
  35094. positionScale: number;
  35095. /**
  35096. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35097. * behaviour is triggered, in radians.
  35098. */
  35099. /**
  35100. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35101. * behaviour is triggered, in radians.
  35102. */
  35103. defaultElevation: number;
  35104. /**
  35105. * Sets the time (in milliseconds) taken to return to the default beta position.
  35106. * Negative value indicates camera should not return to default.
  35107. */
  35108. /**
  35109. * Gets the time (in milliseconds) taken to return to the default beta position.
  35110. * Negative value indicates camera should not return to default.
  35111. */
  35112. elevationReturnTime: number;
  35113. /**
  35114. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35115. */
  35116. /**
  35117. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35118. */
  35119. elevationReturnWaitTime: number;
  35120. /**
  35121. * Sets the flag that indicates if user zooming should stop animation.
  35122. */
  35123. /**
  35124. * Gets the flag that indicates if user zooming should stop animation.
  35125. */
  35126. zoomStopsAnimation: boolean;
  35127. /**
  35128. * Sets the transition time when framing the mesh, in milliseconds
  35129. */
  35130. /**
  35131. * Gets the transition time when framing the mesh, in milliseconds
  35132. */
  35133. framingTime: number;
  35134. /**
  35135. * Define if the behavior should automatically change the configured
  35136. * camera limits and sensibilities.
  35137. */
  35138. autoCorrectCameraLimitsAndSensibility: boolean;
  35139. private _onPrePointerObservableObserver;
  35140. private _onAfterCheckInputsObserver;
  35141. private _onMeshTargetChangedObserver;
  35142. private _attachedCamera;
  35143. private _isPointerDown;
  35144. private _lastInteractionTime;
  35145. /**
  35146. * Initializes the behavior.
  35147. */
  35148. init(): void;
  35149. /**
  35150. * Attaches the behavior to its arc rotate camera.
  35151. * @param camera Defines the camera to attach the behavior to
  35152. */
  35153. attach(camera: ArcRotateCamera): void;
  35154. /**
  35155. * Detaches the behavior from its current arc rotate camera.
  35156. */
  35157. detach(): void;
  35158. private _animatables;
  35159. private _betaIsAnimating;
  35160. private _betaTransition;
  35161. private _radiusTransition;
  35162. private _vectorTransition;
  35163. /**
  35164. * Targets the given mesh and updates zoom level accordingly.
  35165. * @param mesh The mesh to target.
  35166. * @param radius Optional. If a cached radius position already exists, overrides default.
  35167. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35168. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35169. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35170. */
  35171. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35172. /**
  35173. * Targets the given mesh with its children and updates zoom level accordingly.
  35174. * @param mesh The mesh to target.
  35175. * @param radius Optional. If a cached radius position already exists, overrides default.
  35176. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35177. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35178. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35179. */
  35180. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35181. /**
  35182. * Targets the given meshes with their children and updates zoom level accordingly.
  35183. * @param meshes The mesh to target.
  35184. * @param radius Optional. If a cached radius position already exists, overrides default.
  35185. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35186. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35187. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35188. */
  35189. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35190. /**
  35191. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35192. * @param minimumWorld Determines the smaller position of the bounding box extend
  35193. * @param maximumWorld Determines the bigger position of the bounding box extend
  35194. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35195. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35196. */
  35197. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35198. /**
  35199. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35200. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35201. * frustum width.
  35202. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35203. * to fully enclose the mesh in the viewing frustum.
  35204. */
  35205. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35206. /**
  35207. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35208. * is automatically returned to its default position (expected to be above ground plane).
  35209. */
  35210. private _maintainCameraAboveGround;
  35211. /**
  35212. * Returns the frustum slope based on the canvas ratio and camera FOV
  35213. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35214. */
  35215. private _getFrustumSlope;
  35216. /**
  35217. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35218. */
  35219. private _clearAnimationLocks;
  35220. /**
  35221. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35222. */
  35223. private _applyUserInteraction;
  35224. /**
  35225. * Stops and removes all animations that have been applied to the camera
  35226. */
  35227. stopAllAnimations(): void;
  35228. /**
  35229. * Gets a value indicating if the user is moving the camera
  35230. */
  35231. readonly isUserIsMoving: boolean;
  35232. /**
  35233. * The camera can move all the way towards the mesh.
  35234. */
  35235. static IgnoreBoundsSizeMode: number;
  35236. /**
  35237. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35238. */
  35239. static FitFrustumSidesMode: number;
  35240. }
  35241. }
  35242. declare module BABYLON {
  35243. /**
  35244. * Base class for Camera Pointer Inputs.
  35245. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35246. * for example usage.
  35247. */
  35248. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35249. /**
  35250. * Defines the camera the input is attached to.
  35251. */
  35252. abstract camera: Camera;
  35253. /**
  35254. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35255. */
  35256. protected _altKey: boolean;
  35257. protected _ctrlKey: boolean;
  35258. protected _metaKey: boolean;
  35259. protected _shiftKey: boolean;
  35260. /**
  35261. * Which mouse buttons were pressed at time of last mouse event.
  35262. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35263. */
  35264. protected _buttonsPressed: number;
  35265. /**
  35266. * Defines the buttons associated with the input to handle camera move.
  35267. */
  35268. buttons: number[];
  35269. /**
  35270. * Attach the input controls to a specific dom element to get the input from.
  35271. * @param element Defines the element the controls should be listened from
  35272. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35273. */
  35274. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35275. /**
  35276. * Detach the current controls from the specified dom element.
  35277. * @param element Defines the element to stop listening the inputs from
  35278. */
  35279. detachControl(element: Nullable<HTMLElement>): void;
  35280. /**
  35281. * Gets the class name of the current input.
  35282. * @returns the class name
  35283. */
  35284. getClassName(): string;
  35285. /**
  35286. * Get the friendly name associated with the input class.
  35287. * @returns the input friendly name
  35288. */
  35289. getSimpleName(): string;
  35290. /**
  35291. * Called on pointer POINTERDOUBLETAP event.
  35292. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35293. */
  35294. protected onDoubleTap(type: string): void;
  35295. /**
  35296. * Called on pointer POINTERMOVE event if only a single touch is active.
  35297. * Override this method to provide functionality.
  35298. */
  35299. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35300. /**
  35301. * Called on pointer POINTERMOVE event if multiple touches are active.
  35302. * Override this method to provide functionality.
  35303. */
  35304. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35305. /**
  35306. * Called on JS contextmenu event.
  35307. * Override this method to provide functionality.
  35308. */
  35309. protected onContextMenu(evt: PointerEvent): void;
  35310. /**
  35311. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35312. * press.
  35313. * Override this method to provide functionality.
  35314. */
  35315. protected onButtonDown(evt: PointerEvent): void;
  35316. /**
  35317. * Called each time a new POINTERUP event occurs. Ie, for each button
  35318. * release.
  35319. * Override this method to provide functionality.
  35320. */
  35321. protected onButtonUp(evt: PointerEvent): void;
  35322. /**
  35323. * Called when window becomes inactive.
  35324. * Override this method to provide functionality.
  35325. */
  35326. protected onLostFocus(): void;
  35327. private _pointerInput;
  35328. private _observer;
  35329. private _onLostFocus;
  35330. private pointA;
  35331. private pointB;
  35332. }
  35333. }
  35334. declare module BABYLON {
  35335. /**
  35336. * Manage the pointers inputs to control an arc rotate camera.
  35337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35338. */
  35339. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35340. /**
  35341. * Defines the camera the input is attached to.
  35342. */
  35343. camera: ArcRotateCamera;
  35344. /**
  35345. * Gets the class name of the current input.
  35346. * @returns the class name
  35347. */
  35348. getClassName(): string;
  35349. /**
  35350. * Defines the buttons associated with the input to handle camera move.
  35351. */
  35352. buttons: number[];
  35353. /**
  35354. * Defines the pointer angular sensibility along the X axis or how fast is
  35355. * the camera rotating.
  35356. */
  35357. angularSensibilityX: number;
  35358. /**
  35359. * Defines the pointer angular sensibility along the Y axis or how fast is
  35360. * the camera rotating.
  35361. */
  35362. angularSensibilityY: number;
  35363. /**
  35364. * Defines the pointer pinch precision or how fast is the camera zooming.
  35365. */
  35366. pinchPrecision: number;
  35367. /**
  35368. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35369. * from 0.
  35370. * It defines the percentage of current camera.radius to use as delta when
  35371. * pinch zoom is used.
  35372. */
  35373. pinchDeltaPercentage: number;
  35374. /**
  35375. * Defines the pointer panning sensibility or how fast is the camera moving.
  35376. */
  35377. panningSensibility: number;
  35378. /**
  35379. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35380. */
  35381. multiTouchPanning: boolean;
  35382. /**
  35383. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35384. * zoom (pinch) through multitouch.
  35385. */
  35386. multiTouchPanAndZoom: boolean;
  35387. /**
  35388. * Revers pinch action direction.
  35389. */
  35390. pinchInwards: boolean;
  35391. private _isPanClick;
  35392. private _twoFingerActivityCount;
  35393. private _isPinching;
  35394. /**
  35395. * Called on pointer POINTERMOVE event if only a single touch is active.
  35396. */
  35397. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35398. /**
  35399. * Called on pointer POINTERDOUBLETAP event.
  35400. */
  35401. protected onDoubleTap(type: string): void;
  35402. /**
  35403. * Called on pointer POINTERMOVE event if multiple touches are active.
  35404. */
  35405. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35406. /**
  35407. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35408. * press.
  35409. */
  35410. protected onButtonDown(evt: PointerEvent): void;
  35411. /**
  35412. * Called each time a new POINTERUP event occurs. Ie, for each button
  35413. * release.
  35414. */
  35415. protected onButtonUp(evt: PointerEvent): void;
  35416. /**
  35417. * Called when window becomes inactive.
  35418. */
  35419. protected onLostFocus(): void;
  35420. }
  35421. }
  35422. declare module BABYLON {
  35423. /**
  35424. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35425. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35426. */
  35427. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35428. /**
  35429. * Defines the camera the input is attached to.
  35430. */
  35431. camera: ArcRotateCamera;
  35432. /**
  35433. * Defines the list of key codes associated with the up action (increase alpha)
  35434. */
  35435. keysUp: number[];
  35436. /**
  35437. * Defines the list of key codes associated with the down action (decrease alpha)
  35438. */
  35439. keysDown: number[];
  35440. /**
  35441. * Defines the list of key codes associated with the left action (increase beta)
  35442. */
  35443. keysLeft: number[];
  35444. /**
  35445. * Defines the list of key codes associated with the right action (decrease beta)
  35446. */
  35447. keysRight: number[];
  35448. /**
  35449. * Defines the list of key codes associated with the reset action.
  35450. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35451. */
  35452. keysReset: number[];
  35453. /**
  35454. * Defines the panning sensibility of the inputs.
  35455. * (How fast is the camera paning)
  35456. */
  35457. panningSensibility: number;
  35458. /**
  35459. * Defines the zooming sensibility of the inputs.
  35460. * (How fast is the camera zooming)
  35461. */
  35462. zoomingSensibility: number;
  35463. /**
  35464. * Defines wether maintaining the alt key down switch the movement mode from
  35465. * orientation to zoom.
  35466. */
  35467. useAltToZoom: boolean;
  35468. /**
  35469. * Rotation speed of the camera
  35470. */
  35471. angularSpeed: number;
  35472. private _keys;
  35473. private _ctrlPressed;
  35474. private _altPressed;
  35475. private _onCanvasBlurObserver;
  35476. private _onKeyboardObserver;
  35477. private _engine;
  35478. private _scene;
  35479. /**
  35480. * Attach the input controls to a specific dom element to get the input from.
  35481. * @param element Defines the element the controls should be listened from
  35482. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35483. */
  35484. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35485. /**
  35486. * Detach the current controls from the specified dom element.
  35487. * @param element Defines the element to stop listening the inputs from
  35488. */
  35489. detachControl(element: Nullable<HTMLElement>): void;
  35490. /**
  35491. * Update the current camera state depending on the inputs that have been used this frame.
  35492. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35493. */
  35494. checkInputs(): void;
  35495. /**
  35496. * Gets the class name of the current intput.
  35497. * @returns the class name
  35498. */
  35499. getClassName(): string;
  35500. /**
  35501. * Get the friendly name associated with the input class.
  35502. * @returns the input friendly name
  35503. */
  35504. getSimpleName(): string;
  35505. }
  35506. }
  35507. declare module BABYLON {
  35508. /**
  35509. * Manage the mouse wheel inputs to control an arc rotate camera.
  35510. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35511. */
  35512. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35513. /**
  35514. * Defines the camera the input is attached to.
  35515. */
  35516. camera: ArcRotateCamera;
  35517. /**
  35518. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35519. */
  35520. wheelPrecision: number;
  35521. /**
  35522. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35523. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35524. */
  35525. wheelDeltaPercentage: number;
  35526. private _wheel;
  35527. private _observer;
  35528. private computeDeltaFromMouseWheelLegacyEvent;
  35529. /**
  35530. * Attach the input controls to a specific dom element to get the input from.
  35531. * @param element Defines the element the controls should be listened from
  35532. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35533. */
  35534. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35535. /**
  35536. * Detach the current controls from the specified dom element.
  35537. * @param element Defines the element to stop listening the inputs from
  35538. */
  35539. detachControl(element: Nullable<HTMLElement>): void;
  35540. /**
  35541. * Gets the class name of the current intput.
  35542. * @returns the class name
  35543. */
  35544. getClassName(): string;
  35545. /**
  35546. * Get the friendly name associated with the input class.
  35547. * @returns the input friendly name
  35548. */
  35549. getSimpleName(): string;
  35550. }
  35551. }
  35552. declare module BABYLON {
  35553. /**
  35554. * Default Inputs manager for the ArcRotateCamera.
  35555. * It groups all the default supported inputs for ease of use.
  35556. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35557. */
  35558. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35559. /**
  35560. * Instantiates a new ArcRotateCameraInputsManager.
  35561. * @param camera Defines the camera the inputs belong to
  35562. */
  35563. constructor(camera: ArcRotateCamera);
  35564. /**
  35565. * Add mouse wheel input support to the input manager.
  35566. * @returns the current input manager
  35567. */
  35568. addMouseWheel(): ArcRotateCameraInputsManager;
  35569. /**
  35570. * Add pointers input support to the input manager.
  35571. * @returns the current input manager
  35572. */
  35573. addPointers(): ArcRotateCameraInputsManager;
  35574. /**
  35575. * Add keyboard input support to the input manager.
  35576. * @returns the current input manager
  35577. */
  35578. addKeyboard(): ArcRotateCameraInputsManager;
  35579. }
  35580. }
  35581. declare module BABYLON {
  35582. /**
  35583. * This represents an orbital type of camera.
  35584. *
  35585. * 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.
  35586. * 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.
  35587. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35588. */
  35589. export class ArcRotateCamera extends TargetCamera {
  35590. /**
  35591. * Defines the rotation angle of the camera along the longitudinal axis.
  35592. */
  35593. alpha: number;
  35594. /**
  35595. * Defines the rotation angle of the camera along the latitudinal axis.
  35596. */
  35597. beta: number;
  35598. /**
  35599. * Defines the radius of the camera from it s target point.
  35600. */
  35601. radius: number;
  35602. protected _target: Vector3;
  35603. protected _targetHost: Nullable<AbstractMesh>;
  35604. /**
  35605. * Defines the target point of the camera.
  35606. * The camera looks towards it form the radius distance.
  35607. */
  35608. target: Vector3;
  35609. /**
  35610. * Define the current local position of the camera in the scene
  35611. */
  35612. position: Vector3;
  35613. protected _upVector: Vector3;
  35614. protected _upToYMatrix: Matrix;
  35615. protected _YToUpMatrix: Matrix;
  35616. /**
  35617. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35618. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35619. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35620. */
  35621. upVector: Vector3;
  35622. /**
  35623. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35624. */
  35625. setMatUp(): void;
  35626. /**
  35627. * Current inertia value on the longitudinal axis.
  35628. * The bigger this number the longer it will take for the camera to stop.
  35629. */
  35630. inertialAlphaOffset: number;
  35631. /**
  35632. * Current inertia value on the latitudinal axis.
  35633. * The bigger this number the longer it will take for the camera to stop.
  35634. */
  35635. inertialBetaOffset: number;
  35636. /**
  35637. * Current inertia value on the radius axis.
  35638. * The bigger this number the longer it will take for the camera to stop.
  35639. */
  35640. inertialRadiusOffset: number;
  35641. /**
  35642. * Minimum allowed angle on the longitudinal axis.
  35643. * This can help limiting how the Camera is able to move in the scene.
  35644. */
  35645. lowerAlphaLimit: Nullable<number>;
  35646. /**
  35647. * Maximum allowed angle on the longitudinal axis.
  35648. * This can help limiting how the Camera is able to move in the scene.
  35649. */
  35650. upperAlphaLimit: Nullable<number>;
  35651. /**
  35652. * Minimum allowed angle on the latitudinal axis.
  35653. * This can help limiting how the Camera is able to move in the scene.
  35654. */
  35655. lowerBetaLimit: number;
  35656. /**
  35657. * Maximum allowed angle on the latitudinal axis.
  35658. * This can help limiting how the Camera is able to move in the scene.
  35659. */
  35660. upperBetaLimit: number;
  35661. /**
  35662. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35663. * This can help limiting how the Camera is able to move in the scene.
  35664. */
  35665. lowerRadiusLimit: Nullable<number>;
  35666. /**
  35667. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35668. * This can help limiting how the Camera is able to move in the scene.
  35669. */
  35670. upperRadiusLimit: Nullable<number>;
  35671. /**
  35672. * Defines the current inertia value used during panning of the camera along the X axis.
  35673. */
  35674. inertialPanningX: number;
  35675. /**
  35676. * Defines the current inertia value used during panning of the camera along the Y axis.
  35677. */
  35678. inertialPanningY: number;
  35679. /**
  35680. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35681. * Basically if your fingers moves away from more than this distance you will be considered
  35682. * in pinch mode.
  35683. */
  35684. pinchToPanMaxDistance: number;
  35685. /**
  35686. * Defines the maximum distance the camera can pan.
  35687. * This could help keeping the cammera always in your scene.
  35688. */
  35689. panningDistanceLimit: Nullable<number>;
  35690. /**
  35691. * Defines the target of the camera before paning.
  35692. */
  35693. panningOriginTarget: Vector3;
  35694. /**
  35695. * Defines the value of the inertia used during panning.
  35696. * 0 would mean stop inertia and one would mean no decelleration at all.
  35697. */
  35698. panningInertia: number;
  35699. /**
  35700. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35701. */
  35702. angularSensibilityX: number;
  35703. /**
  35704. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35705. */
  35706. angularSensibilityY: number;
  35707. /**
  35708. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35709. */
  35710. pinchPrecision: number;
  35711. /**
  35712. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35713. * It will be used instead of pinchDeltaPrecision if different from 0.
  35714. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35715. */
  35716. pinchDeltaPercentage: number;
  35717. /**
  35718. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35719. */
  35720. panningSensibility: number;
  35721. /**
  35722. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35723. */
  35724. keysUp: number[];
  35725. /**
  35726. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35727. */
  35728. keysDown: number[];
  35729. /**
  35730. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35731. */
  35732. keysLeft: number[];
  35733. /**
  35734. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35735. */
  35736. keysRight: number[];
  35737. /**
  35738. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35739. */
  35740. wheelPrecision: number;
  35741. /**
  35742. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35743. * It will be used instead of pinchDeltaPrecision if different from 0.
  35744. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35745. */
  35746. wheelDeltaPercentage: number;
  35747. /**
  35748. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35749. */
  35750. zoomOnFactor: number;
  35751. /**
  35752. * Defines a screen offset for the camera position.
  35753. */
  35754. targetScreenOffset: Vector2;
  35755. /**
  35756. * Allows the camera to be completely reversed.
  35757. * If false the camera can not arrive upside down.
  35758. */
  35759. allowUpsideDown: boolean;
  35760. /**
  35761. * Define if double tap/click is used to restore the previously saved state of the camera.
  35762. */
  35763. useInputToRestoreState: boolean;
  35764. /** @hidden */
  35765. _viewMatrix: Matrix;
  35766. /** @hidden */
  35767. _useCtrlForPanning: boolean;
  35768. /** @hidden */
  35769. _panningMouseButton: number;
  35770. /**
  35771. * Defines the input associated to the camera.
  35772. */
  35773. inputs: ArcRotateCameraInputsManager;
  35774. /** @hidden */
  35775. _reset: () => void;
  35776. /**
  35777. * Defines the allowed panning axis.
  35778. */
  35779. panningAxis: Vector3;
  35780. protected _localDirection: Vector3;
  35781. protected _transformedDirection: Vector3;
  35782. private _bouncingBehavior;
  35783. /**
  35784. * Gets the bouncing behavior of the camera if it has been enabled.
  35785. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35786. */
  35787. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35788. /**
  35789. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35790. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35791. */
  35792. useBouncingBehavior: boolean;
  35793. private _framingBehavior;
  35794. /**
  35795. * Gets the framing behavior of the camera if it has been enabled.
  35796. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35797. */
  35798. readonly framingBehavior: Nullable<FramingBehavior>;
  35799. /**
  35800. * Defines if the framing behavior of the camera is enabled on the camera.
  35801. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35802. */
  35803. useFramingBehavior: boolean;
  35804. private _autoRotationBehavior;
  35805. /**
  35806. * Gets the auto rotation behavior of the camera if it has been enabled.
  35807. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35808. */
  35809. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35810. /**
  35811. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35812. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35813. */
  35814. useAutoRotationBehavior: boolean;
  35815. /**
  35816. * Observable triggered when the mesh target has been changed on the camera.
  35817. */
  35818. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35819. /**
  35820. * Event raised when the camera is colliding with a mesh.
  35821. */
  35822. onCollide: (collidedMesh: AbstractMesh) => void;
  35823. /**
  35824. * Defines whether the camera should check collision with the objects oh the scene.
  35825. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35826. */
  35827. checkCollisions: boolean;
  35828. /**
  35829. * Defines the collision radius of the camera.
  35830. * This simulates a sphere around the camera.
  35831. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35832. */
  35833. collisionRadius: Vector3;
  35834. protected _collider: Collider;
  35835. protected _previousPosition: Vector3;
  35836. protected _collisionVelocity: Vector3;
  35837. protected _newPosition: Vector3;
  35838. protected _previousAlpha: number;
  35839. protected _previousBeta: number;
  35840. protected _previousRadius: number;
  35841. protected _collisionTriggered: boolean;
  35842. protected _targetBoundingCenter: Nullable<Vector3>;
  35843. private _computationVector;
  35844. /**
  35845. * Instantiates a new ArcRotateCamera in a given scene
  35846. * @param name Defines the name of the camera
  35847. * @param alpha Defines the camera rotation along the logitudinal axis
  35848. * @param beta Defines the camera rotation along the latitudinal axis
  35849. * @param radius Defines the camera distance from its target
  35850. * @param target Defines the camera target
  35851. * @param scene Defines the scene the camera belongs to
  35852. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35853. */
  35854. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35855. /** @hidden */
  35856. _initCache(): void;
  35857. /** @hidden */
  35858. _updateCache(ignoreParentClass?: boolean): void;
  35859. protected _getTargetPosition(): Vector3;
  35860. private _storedAlpha;
  35861. private _storedBeta;
  35862. private _storedRadius;
  35863. private _storedTarget;
  35864. /**
  35865. * Stores the current state of the camera (alpha, beta, radius and target)
  35866. * @returns the camera itself
  35867. */
  35868. storeState(): Camera;
  35869. /**
  35870. * @hidden
  35871. * Restored camera state. You must call storeState() first
  35872. */
  35873. _restoreStateValues(): boolean;
  35874. /** @hidden */
  35875. _isSynchronizedViewMatrix(): boolean;
  35876. /**
  35877. * Attached controls to the current camera.
  35878. * @param element Defines the element the controls should be listened from
  35879. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35880. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35881. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35882. */
  35883. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35884. /**
  35885. * Detach the current controls from the camera.
  35886. * The camera will stop reacting to inputs.
  35887. * @param element Defines the element to stop listening the inputs from
  35888. */
  35889. detachControl(element: HTMLElement): void;
  35890. /** @hidden */
  35891. _checkInputs(): void;
  35892. protected _checkLimits(): void;
  35893. /**
  35894. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35895. */
  35896. rebuildAnglesAndRadius(): void;
  35897. /**
  35898. * Use a position to define the current camera related information like aplha, beta and radius
  35899. * @param position Defines the position to set the camera at
  35900. */
  35901. setPosition(position: Vector3): void;
  35902. /**
  35903. * Defines the target the camera should look at.
  35904. * This will automatically adapt alpha beta and radius to fit within the new target.
  35905. * @param target Defines the new target as a Vector or a mesh
  35906. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35907. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35908. */
  35909. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35910. /** @hidden */
  35911. _getViewMatrix(): Matrix;
  35912. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35913. /**
  35914. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35915. * @param meshes Defines the mesh to zoom on
  35916. * @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)
  35917. */
  35918. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35919. /**
  35920. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35921. * The target will be changed but the radius
  35922. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35923. * @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)
  35924. */
  35925. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35926. min: Vector3;
  35927. max: Vector3;
  35928. distance: number;
  35929. }, doNotUpdateMaxZ?: boolean): void;
  35930. /**
  35931. * @override
  35932. * Override Camera.createRigCamera
  35933. */
  35934. createRigCamera(name: string, cameraIndex: number): Camera;
  35935. /**
  35936. * @hidden
  35937. * @override
  35938. * Override Camera._updateRigCameras
  35939. */
  35940. _updateRigCameras(): void;
  35941. /**
  35942. * Destroy the camera and release the current resources hold by it.
  35943. */
  35944. dispose(): void;
  35945. /**
  35946. * Gets the current object class name.
  35947. * @return the class name
  35948. */
  35949. getClassName(): string;
  35950. }
  35951. }
  35952. declare module BABYLON {
  35953. /**
  35954. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35955. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35956. */
  35957. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35958. /**
  35959. * Gets the name of the behavior.
  35960. */
  35961. readonly name: string;
  35962. private _zoomStopsAnimation;
  35963. private _idleRotationSpeed;
  35964. private _idleRotationWaitTime;
  35965. private _idleRotationSpinupTime;
  35966. /**
  35967. * Sets the flag that indicates if user zooming should stop animation.
  35968. */
  35969. /**
  35970. * Gets the flag that indicates if user zooming should stop animation.
  35971. */
  35972. zoomStopsAnimation: boolean;
  35973. /**
  35974. * Sets the default speed at which the camera rotates around the model.
  35975. */
  35976. /**
  35977. * Gets the default speed at which the camera rotates around the model.
  35978. */
  35979. idleRotationSpeed: number;
  35980. /**
  35981. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35982. */
  35983. /**
  35984. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35985. */
  35986. idleRotationWaitTime: number;
  35987. /**
  35988. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35989. */
  35990. /**
  35991. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35992. */
  35993. idleRotationSpinupTime: number;
  35994. /**
  35995. * Gets a value indicating if the camera is currently rotating because of this behavior
  35996. */
  35997. readonly rotationInProgress: boolean;
  35998. private _onPrePointerObservableObserver;
  35999. private _onAfterCheckInputsObserver;
  36000. private _attachedCamera;
  36001. private _isPointerDown;
  36002. private _lastFrameTime;
  36003. private _lastInteractionTime;
  36004. private _cameraRotationSpeed;
  36005. /**
  36006. * Initializes the behavior.
  36007. */
  36008. init(): void;
  36009. /**
  36010. * Attaches the behavior to its arc rotate camera.
  36011. * @param camera Defines the camera to attach the behavior to
  36012. */
  36013. attach(camera: ArcRotateCamera): void;
  36014. /**
  36015. * Detaches the behavior from its current arc rotate camera.
  36016. */
  36017. detach(): void;
  36018. /**
  36019. * Returns true if user is scrolling.
  36020. * @return true if user is scrolling.
  36021. */
  36022. private _userIsZooming;
  36023. private _lastFrameRadius;
  36024. private _shouldAnimationStopForInteraction;
  36025. /**
  36026. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36027. */
  36028. private _applyUserInteraction;
  36029. private _userIsMoving;
  36030. }
  36031. }
  36032. declare module BABYLON {
  36033. /**
  36034. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36035. */
  36036. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36037. private ui;
  36038. /**
  36039. * The name of the behavior
  36040. */
  36041. name: string;
  36042. /**
  36043. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36044. */
  36045. distanceAwayFromFace: number;
  36046. /**
  36047. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36048. */
  36049. distanceAwayFromBottomOfFace: number;
  36050. private _faceVectors;
  36051. private _target;
  36052. private _scene;
  36053. private _onRenderObserver;
  36054. private _tmpMatrix;
  36055. private _tmpVector;
  36056. /**
  36057. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36058. * @param ui The transform node that should be attched to the mesh
  36059. */
  36060. constructor(ui: TransformNode);
  36061. /**
  36062. * Initializes the behavior
  36063. */
  36064. init(): void;
  36065. private _closestFace;
  36066. private _zeroVector;
  36067. private _lookAtTmpMatrix;
  36068. private _lookAtToRef;
  36069. /**
  36070. * Attaches the AttachToBoxBehavior to the passed in mesh
  36071. * @param target The mesh that the specified node will be attached to
  36072. */
  36073. attach(target: Mesh): void;
  36074. /**
  36075. * Detaches the behavior from the mesh
  36076. */
  36077. detach(): void;
  36078. }
  36079. }
  36080. declare module BABYLON {
  36081. /**
  36082. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36083. */
  36084. export class FadeInOutBehavior implements Behavior<Mesh> {
  36085. /**
  36086. * Time in milliseconds to delay before fading in (Default: 0)
  36087. */
  36088. delay: number;
  36089. /**
  36090. * Time in milliseconds for the mesh to fade in (Default: 300)
  36091. */
  36092. fadeInTime: number;
  36093. private _millisecondsPerFrame;
  36094. private _hovered;
  36095. private _hoverValue;
  36096. private _ownerNode;
  36097. /**
  36098. * Instatiates the FadeInOutBehavior
  36099. */
  36100. constructor();
  36101. /**
  36102. * The name of the behavior
  36103. */
  36104. readonly name: string;
  36105. /**
  36106. * Initializes the behavior
  36107. */
  36108. init(): void;
  36109. /**
  36110. * Attaches the fade behavior on the passed in mesh
  36111. * @param ownerNode The mesh that will be faded in/out once attached
  36112. */
  36113. attach(ownerNode: Mesh): void;
  36114. /**
  36115. * Detaches the behavior from the mesh
  36116. */
  36117. detach(): void;
  36118. /**
  36119. * Triggers the mesh to begin fading in or out
  36120. * @param value if the object should fade in or out (true to fade in)
  36121. */
  36122. fadeIn(value: boolean): void;
  36123. private _update;
  36124. private _setAllVisibility;
  36125. }
  36126. }
  36127. declare module BABYLON {
  36128. /**
  36129. * Class containing a set of static utilities functions for managing Pivots
  36130. * @hidden
  36131. */
  36132. export class PivotTools {
  36133. private static _PivotCached;
  36134. private static _OldPivotPoint;
  36135. private static _PivotTranslation;
  36136. private static _PivotTmpVector;
  36137. /** @hidden */
  36138. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36139. /** @hidden */
  36140. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36141. }
  36142. }
  36143. declare module BABYLON {
  36144. /**
  36145. * Class containing static functions to help procedurally build meshes
  36146. */
  36147. export class PlaneBuilder {
  36148. /**
  36149. * Creates a plane mesh
  36150. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36151. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36152. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36154. * * 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
  36155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36156. * @param name defines the name of the mesh
  36157. * @param options defines the options used to create the mesh
  36158. * @param scene defines the hosting scene
  36159. * @returns the plane mesh
  36160. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36161. */
  36162. static CreatePlane(name: string, options: {
  36163. size?: number;
  36164. width?: number;
  36165. height?: number;
  36166. sideOrientation?: number;
  36167. frontUVs?: Vector4;
  36168. backUVs?: Vector4;
  36169. updatable?: boolean;
  36170. sourcePlane?: Plane;
  36171. }, scene?: Nullable<Scene>): Mesh;
  36172. }
  36173. }
  36174. declare module BABYLON {
  36175. /**
  36176. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36177. */
  36178. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36179. private static _AnyMouseID;
  36180. /**
  36181. * Abstract mesh the behavior is set on
  36182. */
  36183. attachedNode: AbstractMesh;
  36184. private _dragPlane;
  36185. private _scene;
  36186. private _pointerObserver;
  36187. private _beforeRenderObserver;
  36188. private static _planeScene;
  36189. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36190. /**
  36191. * 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)
  36192. */
  36193. maxDragAngle: number;
  36194. /**
  36195. * @hidden
  36196. */
  36197. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36198. /**
  36199. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36200. */
  36201. currentDraggingPointerID: number;
  36202. /**
  36203. * The last position where the pointer hit the drag plane in world space
  36204. */
  36205. lastDragPosition: Vector3;
  36206. /**
  36207. * If the behavior is currently in a dragging state
  36208. */
  36209. dragging: boolean;
  36210. /**
  36211. * 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)
  36212. */
  36213. dragDeltaRatio: number;
  36214. /**
  36215. * If the drag plane orientation should be updated during the dragging (Default: true)
  36216. */
  36217. updateDragPlane: boolean;
  36218. private _debugMode;
  36219. private _moving;
  36220. /**
  36221. * Fires each time the attached mesh is dragged with the pointer
  36222. * * delta between last drag position and current drag position in world space
  36223. * * dragDistance along the drag axis
  36224. * * dragPlaneNormal normal of the current drag plane used during the drag
  36225. * * dragPlanePoint in world space where the drag intersects the drag plane
  36226. */
  36227. onDragObservable: Observable<{
  36228. delta: Vector3;
  36229. dragPlanePoint: Vector3;
  36230. dragPlaneNormal: Vector3;
  36231. dragDistance: number;
  36232. pointerId: number;
  36233. }>;
  36234. /**
  36235. * Fires each time a drag begins (eg. mouse down on mesh)
  36236. */
  36237. onDragStartObservable: Observable<{
  36238. dragPlanePoint: Vector3;
  36239. pointerId: number;
  36240. }>;
  36241. /**
  36242. * Fires each time a drag ends (eg. mouse release after drag)
  36243. */
  36244. onDragEndObservable: Observable<{
  36245. dragPlanePoint: Vector3;
  36246. pointerId: number;
  36247. }>;
  36248. /**
  36249. * If the attached mesh should be moved when dragged
  36250. */
  36251. moveAttached: boolean;
  36252. /**
  36253. * If the drag behavior will react to drag events (Default: true)
  36254. */
  36255. enabled: boolean;
  36256. /**
  36257. * If pointer events should start and release the drag (Default: true)
  36258. */
  36259. startAndReleaseDragOnPointerEvents: boolean;
  36260. /**
  36261. * If camera controls should be detached during the drag
  36262. */
  36263. detachCameraControls: boolean;
  36264. /**
  36265. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36266. */
  36267. useObjectOrienationForDragging: boolean;
  36268. private _options;
  36269. /**
  36270. * Creates a pointer drag behavior that can be attached to a mesh
  36271. * @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)
  36272. */
  36273. constructor(options?: {
  36274. dragAxis?: Vector3;
  36275. dragPlaneNormal?: Vector3;
  36276. });
  36277. /**
  36278. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36279. */
  36280. validateDrag: (targetPosition: Vector3) => boolean;
  36281. /**
  36282. * The name of the behavior
  36283. */
  36284. readonly name: string;
  36285. /**
  36286. * Initializes the behavior
  36287. */
  36288. init(): void;
  36289. private _tmpVector;
  36290. private _alternatePickedPoint;
  36291. private _worldDragAxis;
  36292. private _targetPosition;
  36293. private _attachedElement;
  36294. /**
  36295. * Attaches the drag behavior the passed in mesh
  36296. * @param ownerNode The mesh that will be dragged around once attached
  36297. */
  36298. attach(ownerNode: AbstractMesh): void;
  36299. /**
  36300. * Force relase the drag action by code.
  36301. */
  36302. releaseDrag(): void;
  36303. private _startDragRay;
  36304. private _lastPointerRay;
  36305. /**
  36306. * Simulates the start of a pointer drag event on the behavior
  36307. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36308. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36309. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36310. */
  36311. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36312. private _startDrag;
  36313. private _dragDelta;
  36314. private _moveDrag;
  36315. private _pickWithRayOnDragPlane;
  36316. private _pointA;
  36317. private _pointB;
  36318. private _pointC;
  36319. private _lineA;
  36320. private _lineB;
  36321. private _localAxis;
  36322. private _lookAt;
  36323. private _updateDragPlanePosition;
  36324. /**
  36325. * Detaches the behavior from the mesh
  36326. */
  36327. detach(): void;
  36328. }
  36329. }
  36330. declare module BABYLON {
  36331. /**
  36332. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36333. */
  36334. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36335. private _dragBehaviorA;
  36336. private _dragBehaviorB;
  36337. private _startDistance;
  36338. private _initialScale;
  36339. private _targetScale;
  36340. private _ownerNode;
  36341. private _sceneRenderObserver;
  36342. /**
  36343. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36344. */
  36345. constructor();
  36346. /**
  36347. * The name of the behavior
  36348. */
  36349. readonly name: string;
  36350. /**
  36351. * Initializes the behavior
  36352. */
  36353. init(): void;
  36354. private _getCurrentDistance;
  36355. /**
  36356. * Attaches the scale behavior the passed in mesh
  36357. * @param ownerNode The mesh that will be scaled around once attached
  36358. */
  36359. attach(ownerNode: Mesh): void;
  36360. /**
  36361. * Detaches the behavior from the mesh
  36362. */
  36363. detach(): void;
  36364. }
  36365. }
  36366. declare module BABYLON {
  36367. /**
  36368. * 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
  36369. */
  36370. export class SixDofDragBehavior implements Behavior<Mesh> {
  36371. private static _virtualScene;
  36372. private _ownerNode;
  36373. private _sceneRenderObserver;
  36374. private _scene;
  36375. private _targetPosition;
  36376. private _virtualOriginMesh;
  36377. private _virtualDragMesh;
  36378. private _pointerObserver;
  36379. private _moving;
  36380. private _startingOrientation;
  36381. /**
  36382. * 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)
  36383. */
  36384. private zDragFactor;
  36385. /**
  36386. * If the object should rotate to face the drag origin
  36387. */
  36388. rotateDraggedObject: boolean;
  36389. /**
  36390. * If the behavior is currently in a dragging state
  36391. */
  36392. dragging: boolean;
  36393. /**
  36394. * 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)
  36395. */
  36396. dragDeltaRatio: number;
  36397. /**
  36398. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36399. */
  36400. currentDraggingPointerID: number;
  36401. /**
  36402. * If camera controls should be detached during the drag
  36403. */
  36404. detachCameraControls: boolean;
  36405. /**
  36406. * Fires each time a drag starts
  36407. */
  36408. onDragStartObservable: Observable<{}>;
  36409. /**
  36410. * Fires each time a drag ends (eg. mouse release after drag)
  36411. */
  36412. onDragEndObservable: Observable<{}>;
  36413. /**
  36414. * 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
  36415. */
  36416. constructor();
  36417. /**
  36418. * The name of the behavior
  36419. */
  36420. readonly name: string;
  36421. /**
  36422. * Initializes the behavior
  36423. */
  36424. init(): void;
  36425. /**
  36426. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36427. */
  36428. private readonly _pointerCamera;
  36429. /**
  36430. * Attaches the scale behavior the passed in mesh
  36431. * @param ownerNode The mesh that will be scaled around once attached
  36432. */
  36433. attach(ownerNode: Mesh): void;
  36434. /**
  36435. * Detaches the behavior from the mesh
  36436. */
  36437. detach(): void;
  36438. }
  36439. }
  36440. declare module BABYLON {
  36441. /**
  36442. * Class used to apply inverse kinematics to bones
  36443. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36444. */
  36445. export class BoneIKController {
  36446. private static _tmpVecs;
  36447. private static _tmpQuat;
  36448. private static _tmpMats;
  36449. /**
  36450. * Gets or sets the target mesh
  36451. */
  36452. targetMesh: AbstractMesh;
  36453. /** Gets or sets the mesh used as pole */
  36454. poleTargetMesh: AbstractMesh;
  36455. /**
  36456. * Gets or sets the bone used as pole
  36457. */
  36458. poleTargetBone: Nullable<Bone>;
  36459. /**
  36460. * Gets or sets the target position
  36461. */
  36462. targetPosition: Vector3;
  36463. /**
  36464. * Gets or sets the pole target position
  36465. */
  36466. poleTargetPosition: Vector3;
  36467. /**
  36468. * Gets or sets the pole target local offset
  36469. */
  36470. poleTargetLocalOffset: Vector3;
  36471. /**
  36472. * Gets or sets the pole angle
  36473. */
  36474. poleAngle: number;
  36475. /**
  36476. * Gets or sets the mesh associated with the controller
  36477. */
  36478. mesh: AbstractMesh;
  36479. /**
  36480. * 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)
  36481. */
  36482. slerpAmount: number;
  36483. private _bone1Quat;
  36484. private _bone1Mat;
  36485. private _bone2Ang;
  36486. private _bone1;
  36487. private _bone2;
  36488. private _bone1Length;
  36489. private _bone2Length;
  36490. private _maxAngle;
  36491. private _maxReach;
  36492. private _rightHandedSystem;
  36493. private _bendAxis;
  36494. private _slerping;
  36495. private _adjustRoll;
  36496. /**
  36497. * Gets or sets maximum allowed angle
  36498. */
  36499. maxAngle: number;
  36500. /**
  36501. * Creates a new BoneIKController
  36502. * @param mesh defines the mesh to control
  36503. * @param bone defines the bone to control
  36504. * @param options defines options to set up the controller
  36505. */
  36506. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36507. targetMesh?: AbstractMesh;
  36508. poleTargetMesh?: AbstractMesh;
  36509. poleTargetBone?: Bone;
  36510. poleTargetLocalOffset?: Vector3;
  36511. poleAngle?: number;
  36512. bendAxis?: Vector3;
  36513. maxAngle?: number;
  36514. slerpAmount?: number;
  36515. });
  36516. private _setMaxAngle;
  36517. /**
  36518. * Force the controller to update the bones
  36519. */
  36520. update(): void;
  36521. }
  36522. }
  36523. declare module BABYLON {
  36524. /**
  36525. * Class used to make a bone look toward a point in space
  36526. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36527. */
  36528. export class BoneLookController {
  36529. private static _tmpVecs;
  36530. private static _tmpQuat;
  36531. private static _tmpMats;
  36532. /**
  36533. * The target Vector3 that the bone will look at
  36534. */
  36535. target: Vector3;
  36536. /**
  36537. * The mesh that the bone is attached to
  36538. */
  36539. mesh: AbstractMesh;
  36540. /**
  36541. * The bone that will be looking to the target
  36542. */
  36543. bone: Bone;
  36544. /**
  36545. * The up axis of the coordinate system that is used when the bone is rotated
  36546. */
  36547. upAxis: Vector3;
  36548. /**
  36549. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36550. */
  36551. upAxisSpace: Space;
  36552. /**
  36553. * Used to make an adjustment to the yaw of the bone
  36554. */
  36555. adjustYaw: number;
  36556. /**
  36557. * Used to make an adjustment to the pitch of the bone
  36558. */
  36559. adjustPitch: number;
  36560. /**
  36561. * Used to make an adjustment to the roll of the bone
  36562. */
  36563. adjustRoll: number;
  36564. /**
  36565. * 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)
  36566. */
  36567. slerpAmount: number;
  36568. private _minYaw;
  36569. private _maxYaw;
  36570. private _minPitch;
  36571. private _maxPitch;
  36572. private _minYawSin;
  36573. private _minYawCos;
  36574. private _maxYawSin;
  36575. private _maxYawCos;
  36576. private _midYawConstraint;
  36577. private _minPitchTan;
  36578. private _maxPitchTan;
  36579. private _boneQuat;
  36580. private _slerping;
  36581. private _transformYawPitch;
  36582. private _transformYawPitchInv;
  36583. private _firstFrameSkipped;
  36584. private _yawRange;
  36585. private _fowardAxis;
  36586. /**
  36587. * Gets or sets the minimum yaw angle that the bone can look to
  36588. */
  36589. minYaw: number;
  36590. /**
  36591. * Gets or sets the maximum yaw angle that the bone can look to
  36592. */
  36593. maxYaw: number;
  36594. /**
  36595. * Gets or sets the minimum pitch angle that the bone can look to
  36596. */
  36597. minPitch: number;
  36598. /**
  36599. * Gets or sets the maximum pitch angle that the bone can look to
  36600. */
  36601. maxPitch: number;
  36602. /**
  36603. * Create a BoneLookController
  36604. * @param mesh the mesh that the bone belongs to
  36605. * @param bone the bone that will be looking to the target
  36606. * @param target the target Vector3 to look at
  36607. * @param options optional settings:
  36608. * * maxYaw: the maximum angle the bone will yaw to
  36609. * * minYaw: the minimum angle the bone will yaw to
  36610. * * maxPitch: the maximum angle the bone will pitch to
  36611. * * minPitch: the minimum angle the bone will yaw to
  36612. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36613. * * upAxis: the up axis of the coordinate system
  36614. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36615. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36616. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36617. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36618. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36619. * * adjustRoll: used to make an adjustment to the roll of the bone
  36620. **/
  36621. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36622. maxYaw?: number;
  36623. minYaw?: number;
  36624. maxPitch?: number;
  36625. minPitch?: number;
  36626. slerpAmount?: number;
  36627. upAxis?: Vector3;
  36628. upAxisSpace?: Space;
  36629. yawAxis?: Vector3;
  36630. pitchAxis?: Vector3;
  36631. adjustYaw?: number;
  36632. adjustPitch?: number;
  36633. adjustRoll?: number;
  36634. });
  36635. /**
  36636. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36637. */
  36638. update(): void;
  36639. private _getAngleDiff;
  36640. private _getAngleBetween;
  36641. private _isAngleBetween;
  36642. }
  36643. }
  36644. declare module BABYLON {
  36645. /**
  36646. * Manage the gamepad inputs to control an arc rotate camera.
  36647. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36648. */
  36649. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36650. /**
  36651. * Defines the camera the input is attached to.
  36652. */
  36653. camera: ArcRotateCamera;
  36654. /**
  36655. * Defines the gamepad the input is gathering event from.
  36656. */
  36657. gamepad: Nullable<Gamepad>;
  36658. /**
  36659. * Defines the gamepad rotation sensiblity.
  36660. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36661. */
  36662. gamepadRotationSensibility: number;
  36663. /**
  36664. * Defines the gamepad move sensiblity.
  36665. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36666. */
  36667. gamepadMoveSensibility: number;
  36668. private _onGamepadConnectedObserver;
  36669. private _onGamepadDisconnectedObserver;
  36670. /**
  36671. * Attach the input controls to a specific dom element to get the input from.
  36672. * @param element Defines the element the controls should be listened from
  36673. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36674. */
  36675. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36676. /**
  36677. * Detach the current controls from the specified dom element.
  36678. * @param element Defines the element to stop listening the inputs from
  36679. */
  36680. detachControl(element: Nullable<HTMLElement>): void;
  36681. /**
  36682. * Update the current camera state depending on the inputs that have been used this frame.
  36683. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36684. */
  36685. checkInputs(): void;
  36686. /**
  36687. * Gets the class name of the current intput.
  36688. * @returns the class name
  36689. */
  36690. getClassName(): string;
  36691. /**
  36692. * Get the friendly name associated with the input class.
  36693. * @returns the input friendly name
  36694. */
  36695. getSimpleName(): string;
  36696. }
  36697. }
  36698. declare module BABYLON {
  36699. interface ArcRotateCameraInputsManager {
  36700. /**
  36701. * Add orientation input support to the input manager.
  36702. * @returns the current input manager
  36703. */
  36704. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36705. }
  36706. /**
  36707. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36708. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36709. */
  36710. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36711. /**
  36712. * Defines the camera the input is attached to.
  36713. */
  36714. camera: ArcRotateCamera;
  36715. /**
  36716. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36717. */
  36718. alphaCorrection: number;
  36719. /**
  36720. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36721. */
  36722. gammaCorrection: number;
  36723. private _alpha;
  36724. private _gamma;
  36725. private _dirty;
  36726. private _deviceOrientationHandler;
  36727. /**
  36728. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36729. */
  36730. constructor();
  36731. /**
  36732. * Attach the input controls to a specific dom element to get the input from.
  36733. * @param element Defines the element the controls should be listened from
  36734. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36735. */
  36736. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36737. /** @hidden */
  36738. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36739. /**
  36740. * Update the current camera state depending on the inputs that have been used this frame.
  36741. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36742. */
  36743. checkInputs(): void;
  36744. /**
  36745. * Detach the current controls from the specified dom element.
  36746. * @param element Defines the element to stop listening the inputs from
  36747. */
  36748. detachControl(element: Nullable<HTMLElement>): void;
  36749. /**
  36750. * Gets the class name of the current intput.
  36751. * @returns the class name
  36752. */
  36753. getClassName(): string;
  36754. /**
  36755. * Get the friendly name associated with the input class.
  36756. * @returns the input friendly name
  36757. */
  36758. getSimpleName(): string;
  36759. }
  36760. }
  36761. declare module BABYLON {
  36762. /**
  36763. * Listen to mouse events to control the camera.
  36764. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36765. */
  36766. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36767. /**
  36768. * Defines the camera the input is attached to.
  36769. */
  36770. camera: FlyCamera;
  36771. /**
  36772. * Defines if touch is enabled. (Default is true.)
  36773. */
  36774. touchEnabled: boolean;
  36775. /**
  36776. * Defines the buttons associated with the input to handle camera rotation.
  36777. */
  36778. buttons: number[];
  36779. /**
  36780. * Assign buttons for Yaw control.
  36781. */
  36782. buttonsYaw: number[];
  36783. /**
  36784. * Assign buttons for Pitch control.
  36785. */
  36786. buttonsPitch: number[];
  36787. /**
  36788. * Assign buttons for Roll control.
  36789. */
  36790. buttonsRoll: number[];
  36791. /**
  36792. * Detect if any button is being pressed while mouse is moved.
  36793. * -1 = Mouse locked.
  36794. * 0 = Left button.
  36795. * 1 = Middle Button.
  36796. * 2 = Right Button.
  36797. */
  36798. activeButton: number;
  36799. /**
  36800. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36801. * Higher values reduce its sensitivity.
  36802. */
  36803. angularSensibility: number;
  36804. private _mousemoveCallback;
  36805. private _observer;
  36806. private _rollObserver;
  36807. private previousPosition;
  36808. private noPreventDefault;
  36809. private element;
  36810. /**
  36811. * Listen to mouse events to control the camera.
  36812. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36813. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36814. */
  36815. constructor(touchEnabled?: boolean);
  36816. /**
  36817. * Attach the mouse control to the HTML DOM element.
  36818. * @param element Defines the element that listens to the input events.
  36819. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36820. */
  36821. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36822. /**
  36823. * Detach the current controls from the specified dom element.
  36824. * @param element Defines the element to stop listening the inputs from
  36825. */
  36826. detachControl(element: Nullable<HTMLElement>): void;
  36827. /**
  36828. * Gets the class name of the current input.
  36829. * @returns the class name.
  36830. */
  36831. getClassName(): string;
  36832. /**
  36833. * Get the friendly name associated with the input class.
  36834. * @returns the input's friendly name.
  36835. */
  36836. getSimpleName(): string;
  36837. private _pointerInput;
  36838. private _onMouseMove;
  36839. /**
  36840. * Rotate camera by mouse offset.
  36841. */
  36842. private rotateCamera;
  36843. }
  36844. }
  36845. declare module BABYLON {
  36846. /**
  36847. * Default Inputs manager for the FlyCamera.
  36848. * It groups all the default supported inputs for ease of use.
  36849. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36850. */
  36851. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36852. /**
  36853. * Instantiates a new FlyCameraInputsManager.
  36854. * @param camera Defines the camera the inputs belong to.
  36855. */
  36856. constructor(camera: FlyCamera);
  36857. /**
  36858. * Add keyboard input support to the input manager.
  36859. * @returns the new FlyCameraKeyboardMoveInput().
  36860. */
  36861. addKeyboard(): FlyCameraInputsManager;
  36862. /**
  36863. * Add mouse input support to the input manager.
  36864. * @param touchEnabled Enable touch screen support.
  36865. * @returns the new FlyCameraMouseInput().
  36866. */
  36867. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36868. }
  36869. }
  36870. declare module BABYLON {
  36871. /**
  36872. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36873. * such as in a 3D Space Shooter or a Flight Simulator.
  36874. */
  36875. export class FlyCamera extends TargetCamera {
  36876. /**
  36877. * Define the collision ellipsoid of the camera.
  36878. * This is helpful for simulating a camera body, like a player's body.
  36879. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36880. */
  36881. ellipsoid: Vector3;
  36882. /**
  36883. * Define an offset for the position of the ellipsoid around the camera.
  36884. * This can be helpful if the camera is attached away from the player's body center,
  36885. * such as at its head.
  36886. */
  36887. ellipsoidOffset: Vector3;
  36888. /**
  36889. * Enable or disable collisions of the camera with the rest of the scene objects.
  36890. */
  36891. checkCollisions: boolean;
  36892. /**
  36893. * Enable or disable gravity on the camera.
  36894. */
  36895. applyGravity: boolean;
  36896. /**
  36897. * Define the current direction the camera is moving to.
  36898. */
  36899. cameraDirection: Vector3;
  36900. /**
  36901. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36902. * This overrides and empties cameraRotation.
  36903. */
  36904. rotationQuaternion: Quaternion;
  36905. /**
  36906. * Track Roll to maintain the wanted Rolling when looking around.
  36907. */
  36908. _trackRoll: number;
  36909. /**
  36910. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36911. */
  36912. rollCorrect: number;
  36913. /**
  36914. * Mimic a banked turn, Rolling the camera when Yawing.
  36915. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36916. */
  36917. bankedTurn: boolean;
  36918. /**
  36919. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36920. */
  36921. bankedTurnLimit: number;
  36922. /**
  36923. * Value of 0 disables the banked Roll.
  36924. * Value of 1 is equal to the Yaw angle in radians.
  36925. */
  36926. bankedTurnMultiplier: number;
  36927. /**
  36928. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36929. */
  36930. inputs: FlyCameraInputsManager;
  36931. /**
  36932. * Gets the input sensibility for mouse input.
  36933. * Higher values reduce sensitivity.
  36934. */
  36935. /**
  36936. * Sets the input sensibility for a mouse input.
  36937. * Higher values reduce sensitivity.
  36938. */
  36939. angularSensibility: number;
  36940. /**
  36941. * Get the keys for camera movement forward.
  36942. */
  36943. /**
  36944. * Set the keys for camera movement forward.
  36945. */
  36946. keysForward: number[];
  36947. /**
  36948. * Get the keys for camera movement backward.
  36949. */
  36950. keysBackward: number[];
  36951. /**
  36952. * Get the keys for camera movement up.
  36953. */
  36954. /**
  36955. * Set the keys for camera movement up.
  36956. */
  36957. keysUp: number[];
  36958. /**
  36959. * Get the keys for camera movement down.
  36960. */
  36961. /**
  36962. * Set the keys for camera movement down.
  36963. */
  36964. keysDown: number[];
  36965. /**
  36966. * Get the keys for camera movement left.
  36967. */
  36968. /**
  36969. * Set the keys for camera movement left.
  36970. */
  36971. keysLeft: number[];
  36972. /**
  36973. * Set the keys for camera movement right.
  36974. */
  36975. /**
  36976. * Set the keys for camera movement right.
  36977. */
  36978. keysRight: number[];
  36979. /**
  36980. * Event raised when the camera collides with a mesh in the scene.
  36981. */
  36982. onCollide: (collidedMesh: AbstractMesh) => void;
  36983. private _collider;
  36984. private _needMoveForGravity;
  36985. private _oldPosition;
  36986. private _diffPosition;
  36987. private _newPosition;
  36988. /** @hidden */
  36989. _localDirection: Vector3;
  36990. /** @hidden */
  36991. _transformedDirection: Vector3;
  36992. /**
  36993. * Instantiates a FlyCamera.
  36994. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36995. * such as in a 3D Space Shooter or a Flight Simulator.
  36996. * @param name Define the name of the camera in the scene.
  36997. * @param position Define the starting position of the camera in the scene.
  36998. * @param scene Define the scene the camera belongs to.
  36999. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37000. */
  37001. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37002. /**
  37003. * Attach a control to the HTML DOM element.
  37004. * @param element Defines the element that listens to the input events.
  37005. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37006. */
  37007. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37008. /**
  37009. * Detach a control from the HTML DOM element.
  37010. * The camera will stop reacting to that input.
  37011. * @param element Defines the element that listens to the input events.
  37012. */
  37013. detachControl(element: HTMLElement): void;
  37014. private _collisionMask;
  37015. /**
  37016. * Get the mask that the camera ignores in collision events.
  37017. */
  37018. /**
  37019. * Set the mask that the camera ignores in collision events.
  37020. */
  37021. collisionMask: number;
  37022. /** @hidden */
  37023. _collideWithWorld(displacement: Vector3): void;
  37024. /** @hidden */
  37025. private _onCollisionPositionChange;
  37026. /** @hidden */
  37027. _checkInputs(): void;
  37028. /** @hidden */
  37029. _decideIfNeedsToMove(): boolean;
  37030. /** @hidden */
  37031. _updatePosition(): void;
  37032. /**
  37033. * Restore the Roll to its target value at the rate specified.
  37034. * @param rate - Higher means slower restoring.
  37035. * @hidden
  37036. */
  37037. restoreRoll(rate: number): void;
  37038. /**
  37039. * Destroy the camera and release the current resources held by it.
  37040. */
  37041. dispose(): void;
  37042. /**
  37043. * Get the current object class name.
  37044. * @returns the class name.
  37045. */
  37046. getClassName(): string;
  37047. }
  37048. }
  37049. declare module BABYLON {
  37050. /**
  37051. * Listen to keyboard events to control the camera.
  37052. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37053. */
  37054. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37055. /**
  37056. * Defines the camera the input is attached to.
  37057. */
  37058. camera: FlyCamera;
  37059. /**
  37060. * The list of keyboard keys used to control the forward move of the camera.
  37061. */
  37062. keysForward: number[];
  37063. /**
  37064. * The list of keyboard keys used to control the backward move of the camera.
  37065. */
  37066. keysBackward: number[];
  37067. /**
  37068. * The list of keyboard keys used to control the forward move of the camera.
  37069. */
  37070. keysUp: number[];
  37071. /**
  37072. * The list of keyboard keys used to control the backward move of the camera.
  37073. */
  37074. keysDown: number[];
  37075. /**
  37076. * The list of keyboard keys used to control the right strafe move of the camera.
  37077. */
  37078. keysRight: number[];
  37079. /**
  37080. * The list of keyboard keys used to control the left strafe move of the camera.
  37081. */
  37082. keysLeft: number[];
  37083. private _keys;
  37084. private _onCanvasBlurObserver;
  37085. private _onKeyboardObserver;
  37086. private _engine;
  37087. private _scene;
  37088. /**
  37089. * Attach the input controls to a specific dom element to get the input from.
  37090. * @param element Defines the element the controls should be listened from
  37091. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37092. */
  37093. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37094. /**
  37095. * Detach the current controls from the specified dom element.
  37096. * @param element Defines the element to stop listening the inputs from
  37097. */
  37098. detachControl(element: Nullable<HTMLElement>): void;
  37099. /**
  37100. * Gets the class name of the current intput.
  37101. * @returns the class name
  37102. */
  37103. getClassName(): string;
  37104. /** @hidden */
  37105. _onLostFocus(e: FocusEvent): void;
  37106. /**
  37107. * Get the friendly name associated with the input class.
  37108. * @returns the input friendly name
  37109. */
  37110. getSimpleName(): string;
  37111. /**
  37112. * Update the current camera state depending on the inputs that have been used this frame.
  37113. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37114. */
  37115. checkInputs(): void;
  37116. }
  37117. }
  37118. declare module BABYLON {
  37119. /**
  37120. * Manage the mouse wheel inputs to control a follow camera.
  37121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37122. */
  37123. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37124. /**
  37125. * Defines the camera the input is attached to.
  37126. */
  37127. camera: FollowCamera;
  37128. /**
  37129. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37130. */
  37131. axisControlRadius: boolean;
  37132. /**
  37133. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37134. */
  37135. axisControlHeight: boolean;
  37136. /**
  37137. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37138. */
  37139. axisControlRotation: boolean;
  37140. /**
  37141. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37142. * relation to mouseWheel events.
  37143. */
  37144. wheelPrecision: number;
  37145. /**
  37146. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37147. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37148. */
  37149. wheelDeltaPercentage: number;
  37150. private _wheel;
  37151. private _observer;
  37152. /**
  37153. * Attach the input controls to a specific dom element to get the input from.
  37154. * @param element Defines the element the controls should be listened from
  37155. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37156. */
  37157. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37158. /**
  37159. * Detach the current controls from the specified dom element.
  37160. * @param element Defines the element to stop listening the inputs from
  37161. */
  37162. detachControl(element: Nullable<HTMLElement>): void;
  37163. /**
  37164. * Gets the class name of the current intput.
  37165. * @returns the class name
  37166. */
  37167. getClassName(): string;
  37168. /**
  37169. * Get the friendly name associated with the input class.
  37170. * @returns the input friendly name
  37171. */
  37172. getSimpleName(): string;
  37173. }
  37174. }
  37175. declare module BABYLON {
  37176. /**
  37177. * Manage the pointers inputs to control an follow camera.
  37178. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37179. */
  37180. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37181. /**
  37182. * Defines the camera the input is attached to.
  37183. */
  37184. camera: FollowCamera;
  37185. /**
  37186. * Gets the class name of the current input.
  37187. * @returns the class name
  37188. */
  37189. getClassName(): string;
  37190. /**
  37191. * Defines the pointer angular sensibility along the X axis or how fast is
  37192. * the camera rotating.
  37193. * A negative number will reverse the axis direction.
  37194. */
  37195. angularSensibilityX: number;
  37196. /**
  37197. * Defines the pointer angular sensibility along the Y axis or how fast is
  37198. * the camera rotating.
  37199. * A negative number will reverse the axis direction.
  37200. */
  37201. angularSensibilityY: number;
  37202. /**
  37203. * Defines the pointer pinch precision or how fast is the camera zooming.
  37204. * A negative number will reverse the axis direction.
  37205. */
  37206. pinchPrecision: number;
  37207. /**
  37208. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37209. * from 0.
  37210. * It defines the percentage of current camera.radius to use as delta when
  37211. * pinch zoom is used.
  37212. */
  37213. pinchDeltaPercentage: number;
  37214. /**
  37215. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37216. */
  37217. axisXControlRadius: boolean;
  37218. /**
  37219. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37220. */
  37221. axisXControlHeight: boolean;
  37222. /**
  37223. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37224. */
  37225. axisXControlRotation: boolean;
  37226. /**
  37227. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37228. */
  37229. axisYControlRadius: boolean;
  37230. /**
  37231. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37232. */
  37233. axisYControlHeight: boolean;
  37234. /**
  37235. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37236. */
  37237. axisYControlRotation: boolean;
  37238. /**
  37239. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37240. */
  37241. axisPinchControlRadius: boolean;
  37242. /**
  37243. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37244. */
  37245. axisPinchControlHeight: boolean;
  37246. /**
  37247. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37248. */
  37249. axisPinchControlRotation: boolean;
  37250. /**
  37251. * Log error messages if basic misconfiguration has occurred.
  37252. */
  37253. warningEnable: boolean;
  37254. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37255. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37256. private _warningCounter;
  37257. private _warning;
  37258. }
  37259. }
  37260. declare module BABYLON {
  37261. /**
  37262. * Default Inputs manager for the FollowCamera.
  37263. * It groups all the default supported inputs for ease of use.
  37264. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37265. */
  37266. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37267. /**
  37268. * Instantiates a new FollowCameraInputsManager.
  37269. * @param camera Defines the camera the inputs belong to
  37270. */
  37271. constructor(camera: FollowCamera);
  37272. /**
  37273. * Add keyboard input support to the input manager.
  37274. * @returns the current input manager
  37275. */
  37276. addKeyboard(): FollowCameraInputsManager;
  37277. /**
  37278. * Add mouse wheel input support to the input manager.
  37279. * @returns the current input manager
  37280. */
  37281. addMouseWheel(): FollowCameraInputsManager;
  37282. /**
  37283. * Add pointers input support to the input manager.
  37284. * @returns the current input manager
  37285. */
  37286. addPointers(): FollowCameraInputsManager;
  37287. /**
  37288. * Add orientation input support to the input manager.
  37289. * @returns the current input manager
  37290. */
  37291. addVRDeviceOrientation(): FollowCameraInputsManager;
  37292. }
  37293. }
  37294. declare module BABYLON {
  37295. /**
  37296. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37297. * an arc rotate version arcFollowCamera are available.
  37298. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37299. */
  37300. export class FollowCamera extends TargetCamera {
  37301. /**
  37302. * Distance the follow camera should follow an object at
  37303. */
  37304. radius: number;
  37305. /**
  37306. * Minimum allowed distance of the camera to the axis of rotation
  37307. * (The camera can not get closer).
  37308. * This can help limiting how the Camera is able to move in the scene.
  37309. */
  37310. lowerRadiusLimit: Nullable<number>;
  37311. /**
  37312. * Maximum allowed distance of the camera to the axis of rotation
  37313. * (The camera can not get further).
  37314. * This can help limiting how the Camera is able to move in the scene.
  37315. */
  37316. upperRadiusLimit: Nullable<number>;
  37317. /**
  37318. * Define a rotation offset between the camera and the object it follows
  37319. */
  37320. rotationOffset: number;
  37321. /**
  37322. * Minimum allowed angle to camera position relative to target object.
  37323. * This can help limiting how the Camera is able to move in the scene.
  37324. */
  37325. lowerRotationOffsetLimit: Nullable<number>;
  37326. /**
  37327. * Maximum allowed angle to camera position relative to target object.
  37328. * This can help limiting how the Camera is able to move in the scene.
  37329. */
  37330. upperRotationOffsetLimit: Nullable<number>;
  37331. /**
  37332. * Define a height offset between the camera and the object it follows.
  37333. * It can help following an object from the top (like a car chaing a plane)
  37334. */
  37335. heightOffset: number;
  37336. /**
  37337. * Minimum allowed height of camera position relative to target object.
  37338. * This can help limiting how the Camera is able to move in the scene.
  37339. */
  37340. lowerHeightOffsetLimit: Nullable<number>;
  37341. /**
  37342. * Maximum allowed height of camera position relative to target object.
  37343. * This can help limiting how the Camera is able to move in the scene.
  37344. */
  37345. upperHeightOffsetLimit: Nullable<number>;
  37346. /**
  37347. * Define how fast the camera can accelerate to follow it s target.
  37348. */
  37349. cameraAcceleration: number;
  37350. /**
  37351. * Define the speed limit of the camera following an object.
  37352. */
  37353. maxCameraSpeed: number;
  37354. /**
  37355. * Define the target of the camera.
  37356. */
  37357. lockedTarget: Nullable<AbstractMesh>;
  37358. /**
  37359. * Defines the input associated with the camera.
  37360. */
  37361. inputs: FollowCameraInputsManager;
  37362. /**
  37363. * Instantiates the follow camera.
  37364. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37365. * @param name Define the name of the camera in the scene
  37366. * @param position Define the position of the camera
  37367. * @param scene Define the scene the camera belong to
  37368. * @param lockedTarget Define the target of the camera
  37369. */
  37370. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37371. private _follow;
  37372. /**
  37373. * Attached controls to the current camera.
  37374. * @param element Defines the element the controls should be listened from
  37375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37376. */
  37377. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37378. /**
  37379. * Detach the current controls from the camera.
  37380. * The camera will stop reacting to inputs.
  37381. * @param element Defines the element to stop listening the inputs from
  37382. */
  37383. detachControl(element: HTMLElement): void;
  37384. /** @hidden */
  37385. _checkInputs(): void;
  37386. private _checkLimits;
  37387. /**
  37388. * Gets the camera class name.
  37389. * @returns the class name
  37390. */
  37391. getClassName(): string;
  37392. }
  37393. /**
  37394. * Arc Rotate version of the follow camera.
  37395. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37396. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37397. */
  37398. export class ArcFollowCamera extends TargetCamera {
  37399. /** The longitudinal angle of the camera */
  37400. alpha: number;
  37401. /** The latitudinal angle of the camera */
  37402. beta: number;
  37403. /** The radius of the camera from its target */
  37404. radius: number;
  37405. /** Define the camera target (the messh it should follow) */
  37406. target: Nullable<AbstractMesh>;
  37407. private _cartesianCoordinates;
  37408. /**
  37409. * Instantiates a new ArcFollowCamera
  37410. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37411. * @param name Define the name of the camera
  37412. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37413. * @param beta Define the rotation angle of the camera around the elevation axis
  37414. * @param radius Define the radius of the camera from its target point
  37415. * @param target Define the target of the camera
  37416. * @param scene Define the scene the camera belongs to
  37417. */
  37418. constructor(name: string,
  37419. /** The longitudinal angle of the camera */
  37420. alpha: number,
  37421. /** The latitudinal angle of the camera */
  37422. beta: number,
  37423. /** The radius of the camera from its target */
  37424. radius: number,
  37425. /** Define the camera target (the messh it should follow) */
  37426. target: Nullable<AbstractMesh>, scene: Scene);
  37427. private _follow;
  37428. /** @hidden */
  37429. _checkInputs(): void;
  37430. /**
  37431. * Returns the class name of the object.
  37432. * It is mostly used internally for serialization purposes.
  37433. */
  37434. getClassName(): string;
  37435. }
  37436. }
  37437. declare module BABYLON {
  37438. /**
  37439. * Manage the keyboard inputs to control the movement of a follow camera.
  37440. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37441. */
  37442. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37443. /**
  37444. * Defines the camera the input is attached to.
  37445. */
  37446. camera: FollowCamera;
  37447. /**
  37448. * Defines the list of key codes associated with the up action (increase heightOffset)
  37449. */
  37450. keysHeightOffsetIncr: number[];
  37451. /**
  37452. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37453. */
  37454. keysHeightOffsetDecr: number[];
  37455. /**
  37456. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37457. */
  37458. keysHeightOffsetModifierAlt: boolean;
  37459. /**
  37460. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37461. */
  37462. keysHeightOffsetModifierCtrl: boolean;
  37463. /**
  37464. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37465. */
  37466. keysHeightOffsetModifierShift: boolean;
  37467. /**
  37468. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37469. */
  37470. keysRotationOffsetIncr: number[];
  37471. /**
  37472. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37473. */
  37474. keysRotationOffsetDecr: number[];
  37475. /**
  37476. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37477. */
  37478. keysRotationOffsetModifierAlt: boolean;
  37479. /**
  37480. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37481. */
  37482. keysRotationOffsetModifierCtrl: boolean;
  37483. /**
  37484. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37485. */
  37486. keysRotationOffsetModifierShift: boolean;
  37487. /**
  37488. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37489. */
  37490. keysRadiusIncr: number[];
  37491. /**
  37492. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37493. */
  37494. keysRadiusDecr: number[];
  37495. /**
  37496. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37497. */
  37498. keysRadiusModifierAlt: boolean;
  37499. /**
  37500. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37501. */
  37502. keysRadiusModifierCtrl: boolean;
  37503. /**
  37504. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37505. */
  37506. keysRadiusModifierShift: boolean;
  37507. /**
  37508. * Defines the rate of change of heightOffset.
  37509. */
  37510. heightSensibility: number;
  37511. /**
  37512. * Defines the rate of change of rotationOffset.
  37513. */
  37514. rotationSensibility: number;
  37515. /**
  37516. * Defines the rate of change of radius.
  37517. */
  37518. radiusSensibility: number;
  37519. private _keys;
  37520. private _ctrlPressed;
  37521. private _altPressed;
  37522. private _shiftPressed;
  37523. private _onCanvasBlurObserver;
  37524. private _onKeyboardObserver;
  37525. private _engine;
  37526. private _scene;
  37527. /**
  37528. * Attach the input controls to a specific dom element to get the input from.
  37529. * @param element Defines the element the controls should be listened from
  37530. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37531. */
  37532. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37533. /**
  37534. * Detach the current controls from the specified dom element.
  37535. * @param element Defines the element to stop listening the inputs from
  37536. */
  37537. detachControl(element: Nullable<HTMLElement>): void;
  37538. /**
  37539. * Update the current camera state depending on the inputs that have been used this frame.
  37540. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37541. */
  37542. checkInputs(): void;
  37543. /**
  37544. * Gets the class name of the current input.
  37545. * @returns the class name
  37546. */
  37547. getClassName(): string;
  37548. /**
  37549. * Get the friendly name associated with the input class.
  37550. * @returns the input friendly name
  37551. */
  37552. getSimpleName(): string;
  37553. /**
  37554. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37555. * allow modification of the heightOffset value.
  37556. */
  37557. private _modifierHeightOffset;
  37558. /**
  37559. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37560. * allow modification of the rotationOffset value.
  37561. */
  37562. private _modifierRotationOffset;
  37563. /**
  37564. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37565. * allow modification of the radius value.
  37566. */
  37567. private _modifierRadius;
  37568. }
  37569. }
  37570. declare module BABYLON {
  37571. interface FreeCameraInputsManager {
  37572. /**
  37573. * @hidden
  37574. */
  37575. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37576. /**
  37577. * Add orientation input support to the input manager.
  37578. * @returns the current input manager
  37579. */
  37580. addDeviceOrientation(): FreeCameraInputsManager;
  37581. }
  37582. /**
  37583. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37584. * Screen rotation is taken into account.
  37585. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37586. */
  37587. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37588. private _camera;
  37589. private _screenOrientationAngle;
  37590. private _constantTranform;
  37591. private _screenQuaternion;
  37592. private _alpha;
  37593. private _beta;
  37594. private _gamma;
  37595. /**
  37596. * Can be used to detect if a device orientation sensor is availible on a device
  37597. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37598. * @returns a promise that will resolve on orientation change
  37599. */
  37600. static WaitForOrientationChangeAsync(timeout?: number): Promise<{}>;
  37601. /**
  37602. * @hidden
  37603. */
  37604. _onDeviceOrientationChangedObservable: Observable<void>;
  37605. /**
  37606. * Instantiates a new input
  37607. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37608. */
  37609. constructor();
  37610. /**
  37611. * Define the camera controlled by the input.
  37612. */
  37613. camera: FreeCamera;
  37614. /**
  37615. * Attach the input controls to a specific dom element to get the input from.
  37616. * @param element Defines the element the controls should be listened from
  37617. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37618. */
  37619. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37620. private _orientationChanged;
  37621. private _deviceOrientation;
  37622. /**
  37623. * Detach the current controls from the specified dom element.
  37624. * @param element Defines the element to stop listening the inputs from
  37625. */
  37626. detachControl(element: Nullable<HTMLElement>): void;
  37627. /**
  37628. * Update the current camera state depending on the inputs that have been used this frame.
  37629. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37630. */
  37631. checkInputs(): void;
  37632. /**
  37633. * Gets the class name of the current intput.
  37634. * @returns the class name
  37635. */
  37636. getClassName(): string;
  37637. /**
  37638. * Get the friendly name associated with the input class.
  37639. * @returns the input friendly name
  37640. */
  37641. getSimpleName(): string;
  37642. }
  37643. }
  37644. declare module BABYLON {
  37645. /**
  37646. * Manage the gamepad inputs to control a free camera.
  37647. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37648. */
  37649. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37650. /**
  37651. * Define the camera the input is attached to.
  37652. */
  37653. camera: FreeCamera;
  37654. /**
  37655. * Define the Gamepad controlling the input
  37656. */
  37657. gamepad: Nullable<Gamepad>;
  37658. /**
  37659. * Defines the gamepad rotation sensiblity.
  37660. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37661. */
  37662. gamepadAngularSensibility: number;
  37663. /**
  37664. * Defines the gamepad move sensiblity.
  37665. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37666. */
  37667. gamepadMoveSensibility: number;
  37668. private _onGamepadConnectedObserver;
  37669. private _onGamepadDisconnectedObserver;
  37670. private _cameraTransform;
  37671. private _deltaTransform;
  37672. private _vector3;
  37673. private _vector2;
  37674. /**
  37675. * Attach the input controls to a specific dom element to get the input from.
  37676. * @param element Defines the element the controls should be listened from
  37677. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37678. */
  37679. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37680. /**
  37681. * Detach the current controls from the specified dom element.
  37682. * @param element Defines the element to stop listening the inputs from
  37683. */
  37684. detachControl(element: Nullable<HTMLElement>): void;
  37685. /**
  37686. * Update the current camera state depending on the inputs that have been used this frame.
  37687. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37688. */
  37689. checkInputs(): void;
  37690. /**
  37691. * Gets the class name of the current intput.
  37692. * @returns the class name
  37693. */
  37694. getClassName(): string;
  37695. /**
  37696. * Get the friendly name associated with the input class.
  37697. * @returns the input friendly name
  37698. */
  37699. getSimpleName(): string;
  37700. }
  37701. }
  37702. declare module BABYLON {
  37703. /**
  37704. * Defines the potential axis of a Joystick
  37705. */
  37706. export enum JoystickAxis {
  37707. /** X axis */
  37708. X = 0,
  37709. /** Y axis */
  37710. Y = 1,
  37711. /** Z axis */
  37712. Z = 2
  37713. }
  37714. /**
  37715. * Class used to define virtual joystick (used in touch mode)
  37716. */
  37717. export class VirtualJoystick {
  37718. /**
  37719. * Gets or sets a boolean indicating that left and right values must be inverted
  37720. */
  37721. reverseLeftRight: boolean;
  37722. /**
  37723. * Gets or sets a boolean indicating that up and down values must be inverted
  37724. */
  37725. reverseUpDown: boolean;
  37726. /**
  37727. * Gets the offset value for the position (ie. the change of the position value)
  37728. */
  37729. deltaPosition: Vector3;
  37730. /**
  37731. * Gets a boolean indicating if the virtual joystick was pressed
  37732. */
  37733. pressed: boolean;
  37734. /**
  37735. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37736. */
  37737. static Canvas: Nullable<HTMLCanvasElement>;
  37738. private static _globalJoystickIndex;
  37739. private static vjCanvasContext;
  37740. private static vjCanvasWidth;
  37741. private static vjCanvasHeight;
  37742. private static halfWidth;
  37743. private _action;
  37744. private _axisTargetedByLeftAndRight;
  37745. private _axisTargetedByUpAndDown;
  37746. private _joystickSensibility;
  37747. private _inversedSensibility;
  37748. private _joystickPointerID;
  37749. private _joystickColor;
  37750. private _joystickPointerPos;
  37751. private _joystickPreviousPointerPos;
  37752. private _joystickPointerStartPos;
  37753. private _deltaJoystickVector;
  37754. private _leftJoystick;
  37755. private _touches;
  37756. private _onPointerDownHandlerRef;
  37757. private _onPointerMoveHandlerRef;
  37758. private _onPointerUpHandlerRef;
  37759. private _onResize;
  37760. /**
  37761. * Creates a new virtual joystick
  37762. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37763. */
  37764. constructor(leftJoystick?: boolean);
  37765. /**
  37766. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37767. * @param newJoystickSensibility defines the new sensibility
  37768. */
  37769. setJoystickSensibility(newJoystickSensibility: number): void;
  37770. private _onPointerDown;
  37771. private _onPointerMove;
  37772. private _onPointerUp;
  37773. /**
  37774. * Change the color of the virtual joystick
  37775. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37776. */
  37777. setJoystickColor(newColor: string): void;
  37778. /**
  37779. * Defines a callback to call when the joystick is touched
  37780. * @param action defines the callback
  37781. */
  37782. setActionOnTouch(action: () => any): void;
  37783. /**
  37784. * Defines which axis you'd like to control for left & right
  37785. * @param axis defines the axis to use
  37786. */
  37787. setAxisForLeftRight(axis: JoystickAxis): void;
  37788. /**
  37789. * Defines which axis you'd like to control for up & down
  37790. * @param axis defines the axis to use
  37791. */
  37792. setAxisForUpDown(axis: JoystickAxis): void;
  37793. private _drawVirtualJoystick;
  37794. /**
  37795. * Release internal HTML canvas
  37796. */
  37797. releaseCanvas(): void;
  37798. }
  37799. }
  37800. declare module BABYLON {
  37801. interface FreeCameraInputsManager {
  37802. /**
  37803. * Add virtual joystick input support to the input manager.
  37804. * @returns the current input manager
  37805. */
  37806. addVirtualJoystick(): FreeCameraInputsManager;
  37807. }
  37808. /**
  37809. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37810. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37811. */
  37812. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37813. /**
  37814. * Defines the camera the input is attached to.
  37815. */
  37816. camera: FreeCamera;
  37817. private _leftjoystick;
  37818. private _rightjoystick;
  37819. /**
  37820. * Gets the left stick of the virtual joystick.
  37821. * @returns The virtual Joystick
  37822. */
  37823. getLeftJoystick(): VirtualJoystick;
  37824. /**
  37825. * Gets the right stick of the virtual joystick.
  37826. * @returns The virtual Joystick
  37827. */
  37828. getRightJoystick(): VirtualJoystick;
  37829. /**
  37830. * Update the current camera state depending on the inputs that have been used this frame.
  37831. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37832. */
  37833. checkInputs(): void;
  37834. /**
  37835. * Attach the input controls to a specific dom element to get the input from.
  37836. * @param element Defines the element the controls should be listened from
  37837. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37838. */
  37839. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37840. /**
  37841. * Detach the current controls from the specified dom element.
  37842. * @param element Defines the element to stop listening the inputs from
  37843. */
  37844. detachControl(element: Nullable<HTMLElement>): void;
  37845. /**
  37846. * Gets the class name of the current intput.
  37847. * @returns the class name
  37848. */
  37849. getClassName(): string;
  37850. /**
  37851. * Get the friendly name associated with the input class.
  37852. * @returns the input friendly name
  37853. */
  37854. getSimpleName(): string;
  37855. }
  37856. }
  37857. declare module BABYLON {
  37858. /**
  37859. * This represents a FPS type of camera controlled by touch.
  37860. * This is like a universal camera minus the Gamepad controls.
  37861. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37862. */
  37863. export class TouchCamera extends FreeCamera {
  37864. /**
  37865. * Defines the touch sensibility for rotation.
  37866. * The higher the faster.
  37867. */
  37868. touchAngularSensibility: number;
  37869. /**
  37870. * Defines the touch sensibility for move.
  37871. * The higher the faster.
  37872. */
  37873. touchMoveSensibility: number;
  37874. /**
  37875. * Instantiates a new touch camera.
  37876. * This represents a FPS type of camera controlled by touch.
  37877. * This is like a universal camera minus the Gamepad controls.
  37878. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37879. * @param name Define the name of the camera in the scene
  37880. * @param position Define the start position of the camera in the scene
  37881. * @param scene Define the scene the camera belongs to
  37882. */
  37883. constructor(name: string, position: Vector3, scene: Scene);
  37884. /**
  37885. * Gets the current object class name.
  37886. * @return the class name
  37887. */
  37888. getClassName(): string;
  37889. /** @hidden */
  37890. _setupInputs(): void;
  37891. }
  37892. }
  37893. declare module BABYLON {
  37894. /**
  37895. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37896. * being tilted forward or back and left or right.
  37897. */
  37898. export class DeviceOrientationCamera extends FreeCamera {
  37899. private _initialQuaternion;
  37900. private _quaternionCache;
  37901. private _tmpDragQuaternion;
  37902. /**
  37903. * Creates a new device orientation camera
  37904. * @param name The name of the camera
  37905. * @param position The start position camera
  37906. * @param scene The scene the camera belongs to
  37907. */
  37908. constructor(name: string, position: Vector3, scene: Scene);
  37909. /**
  37910. * @hidden
  37911. * Disabled pointer input on first orientation sensor update (Default: true)
  37912. */
  37913. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  37914. private _dragFactor;
  37915. /**
  37916. * Enabled turning on the y axis when the orientation sensor is active
  37917. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37918. */
  37919. enableHorizontalDragging(dragFactor?: number): void;
  37920. /**
  37921. * Gets the current instance class name ("DeviceOrientationCamera").
  37922. * This helps avoiding instanceof at run time.
  37923. * @returns the class name
  37924. */
  37925. getClassName(): string;
  37926. /**
  37927. * @hidden
  37928. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37929. */
  37930. _checkInputs(): void;
  37931. /**
  37932. * Reset the camera to its default orientation on the specified axis only.
  37933. * @param axis The axis to reset
  37934. */
  37935. resetToCurrentRotation(axis?: Axis): void;
  37936. }
  37937. }
  37938. declare module BABYLON {
  37939. /**
  37940. * Defines supported buttons for XBox360 compatible gamepads
  37941. */
  37942. export enum Xbox360Button {
  37943. /** A */
  37944. A = 0,
  37945. /** B */
  37946. B = 1,
  37947. /** X */
  37948. X = 2,
  37949. /** Y */
  37950. Y = 3,
  37951. /** Start */
  37952. Start = 4,
  37953. /** Back */
  37954. Back = 5,
  37955. /** Left button */
  37956. LB = 6,
  37957. /** Right button */
  37958. RB = 7,
  37959. /** Left stick */
  37960. LeftStick = 8,
  37961. /** Right stick */
  37962. RightStick = 9
  37963. }
  37964. /** Defines values for XBox360 DPad */
  37965. export enum Xbox360Dpad {
  37966. /** Up */
  37967. Up = 0,
  37968. /** Down */
  37969. Down = 1,
  37970. /** Left */
  37971. Left = 2,
  37972. /** Right */
  37973. Right = 3
  37974. }
  37975. /**
  37976. * Defines a XBox360 gamepad
  37977. */
  37978. export class Xbox360Pad extends Gamepad {
  37979. private _leftTrigger;
  37980. private _rightTrigger;
  37981. private _onlefttriggerchanged;
  37982. private _onrighttriggerchanged;
  37983. private _onbuttondown;
  37984. private _onbuttonup;
  37985. private _ondpaddown;
  37986. private _ondpadup;
  37987. /** Observable raised when a button is pressed */
  37988. onButtonDownObservable: Observable<Xbox360Button>;
  37989. /** Observable raised when a button is released */
  37990. onButtonUpObservable: Observable<Xbox360Button>;
  37991. /** Observable raised when a pad is pressed */
  37992. onPadDownObservable: Observable<Xbox360Dpad>;
  37993. /** Observable raised when a pad is released */
  37994. onPadUpObservable: Observable<Xbox360Dpad>;
  37995. private _buttonA;
  37996. private _buttonB;
  37997. private _buttonX;
  37998. private _buttonY;
  37999. private _buttonBack;
  38000. private _buttonStart;
  38001. private _buttonLB;
  38002. private _buttonRB;
  38003. private _buttonLeftStick;
  38004. private _buttonRightStick;
  38005. private _dPadUp;
  38006. private _dPadDown;
  38007. private _dPadLeft;
  38008. private _dPadRight;
  38009. private _isXboxOnePad;
  38010. /**
  38011. * Creates a new XBox360 gamepad object
  38012. * @param id defines the id of this gamepad
  38013. * @param index defines its index
  38014. * @param gamepad defines the internal HTML gamepad object
  38015. * @param xboxOne defines if it is a XBox One gamepad
  38016. */
  38017. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38018. /**
  38019. * Defines the callback to call when left trigger is pressed
  38020. * @param callback defines the callback to use
  38021. */
  38022. onlefttriggerchanged(callback: (value: number) => void): void;
  38023. /**
  38024. * Defines the callback to call when right trigger is pressed
  38025. * @param callback defines the callback to use
  38026. */
  38027. onrighttriggerchanged(callback: (value: number) => void): void;
  38028. /**
  38029. * Gets the left trigger value
  38030. */
  38031. /**
  38032. * Sets the left trigger value
  38033. */
  38034. leftTrigger: number;
  38035. /**
  38036. * Gets the right trigger value
  38037. */
  38038. /**
  38039. * Sets the right trigger value
  38040. */
  38041. rightTrigger: number;
  38042. /**
  38043. * Defines the callback to call when a button is pressed
  38044. * @param callback defines the callback to use
  38045. */
  38046. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38047. /**
  38048. * Defines the callback to call when a button is released
  38049. * @param callback defines the callback to use
  38050. */
  38051. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38052. /**
  38053. * Defines the callback to call when a pad is pressed
  38054. * @param callback defines the callback to use
  38055. */
  38056. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38057. /**
  38058. * Defines the callback to call when a pad is released
  38059. * @param callback defines the callback to use
  38060. */
  38061. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38062. private _setButtonValue;
  38063. private _setDPadValue;
  38064. /**
  38065. * Gets the value of the `A` button
  38066. */
  38067. /**
  38068. * Sets the value of the `A` button
  38069. */
  38070. buttonA: number;
  38071. /**
  38072. * Gets the value of the `B` button
  38073. */
  38074. /**
  38075. * Sets the value of the `B` button
  38076. */
  38077. buttonB: number;
  38078. /**
  38079. * Gets the value of the `X` button
  38080. */
  38081. /**
  38082. * Sets the value of the `X` button
  38083. */
  38084. buttonX: number;
  38085. /**
  38086. * Gets the value of the `Y` button
  38087. */
  38088. /**
  38089. * Sets the value of the `Y` button
  38090. */
  38091. buttonY: number;
  38092. /**
  38093. * Gets the value of the `Start` button
  38094. */
  38095. /**
  38096. * Sets the value of the `Start` button
  38097. */
  38098. buttonStart: number;
  38099. /**
  38100. * Gets the value of the `Back` button
  38101. */
  38102. /**
  38103. * Sets the value of the `Back` button
  38104. */
  38105. buttonBack: number;
  38106. /**
  38107. * Gets the value of the `Left` button
  38108. */
  38109. /**
  38110. * Sets the value of the `Left` button
  38111. */
  38112. buttonLB: number;
  38113. /**
  38114. * Gets the value of the `Right` button
  38115. */
  38116. /**
  38117. * Sets the value of the `Right` button
  38118. */
  38119. buttonRB: number;
  38120. /**
  38121. * Gets the value of the Left joystick
  38122. */
  38123. /**
  38124. * Sets the value of the Left joystick
  38125. */
  38126. buttonLeftStick: number;
  38127. /**
  38128. * Gets the value of the Right joystick
  38129. */
  38130. /**
  38131. * Sets the value of the Right joystick
  38132. */
  38133. buttonRightStick: number;
  38134. /**
  38135. * Gets the value of D-pad up
  38136. */
  38137. /**
  38138. * Sets the value of D-pad up
  38139. */
  38140. dPadUp: number;
  38141. /**
  38142. * Gets the value of D-pad down
  38143. */
  38144. /**
  38145. * Sets the value of D-pad down
  38146. */
  38147. dPadDown: number;
  38148. /**
  38149. * Gets the value of D-pad left
  38150. */
  38151. /**
  38152. * Sets the value of D-pad left
  38153. */
  38154. dPadLeft: number;
  38155. /**
  38156. * Gets the value of D-pad right
  38157. */
  38158. /**
  38159. * Sets the value of D-pad right
  38160. */
  38161. dPadRight: number;
  38162. /**
  38163. * Force the gamepad to synchronize with device values
  38164. */
  38165. update(): void;
  38166. /**
  38167. * Disposes the gamepad
  38168. */
  38169. dispose(): void;
  38170. }
  38171. }
  38172. declare module BABYLON {
  38173. /**
  38174. * Manager for handling gamepads
  38175. */
  38176. export class GamepadManager {
  38177. private _scene?;
  38178. private _babylonGamepads;
  38179. private _oneGamepadConnected;
  38180. /** @hidden */
  38181. _isMonitoring: boolean;
  38182. private _gamepadEventSupported;
  38183. private _gamepadSupport;
  38184. /**
  38185. * observable to be triggered when the gamepad controller has been connected
  38186. */
  38187. onGamepadConnectedObservable: Observable<Gamepad>;
  38188. /**
  38189. * observable to be triggered when the gamepad controller has been disconnected
  38190. */
  38191. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38192. private _onGamepadConnectedEvent;
  38193. private _onGamepadDisconnectedEvent;
  38194. /**
  38195. * Initializes the gamepad manager
  38196. * @param _scene BabylonJS scene
  38197. */
  38198. constructor(_scene?: Scene | undefined);
  38199. /**
  38200. * The gamepads in the game pad manager
  38201. */
  38202. readonly gamepads: Gamepad[];
  38203. /**
  38204. * Get the gamepad controllers based on type
  38205. * @param type The type of gamepad controller
  38206. * @returns Nullable gamepad
  38207. */
  38208. getGamepadByType(type?: number): Nullable<Gamepad>;
  38209. /**
  38210. * Disposes the gamepad manager
  38211. */
  38212. dispose(): void;
  38213. private _addNewGamepad;
  38214. private _startMonitoringGamepads;
  38215. private _stopMonitoringGamepads;
  38216. /** @hidden */
  38217. _checkGamepadsStatus(): void;
  38218. private _updateGamepadObjects;
  38219. }
  38220. }
  38221. declare module BABYLON {
  38222. interface Scene {
  38223. /** @hidden */
  38224. _gamepadManager: Nullable<GamepadManager>;
  38225. /**
  38226. * Gets the gamepad manager associated with the scene
  38227. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38228. */
  38229. gamepadManager: GamepadManager;
  38230. }
  38231. /**
  38232. * Interface representing a free camera inputs manager
  38233. */
  38234. interface FreeCameraInputsManager {
  38235. /**
  38236. * Adds gamepad input support to the FreeCameraInputsManager.
  38237. * @returns the FreeCameraInputsManager
  38238. */
  38239. addGamepad(): FreeCameraInputsManager;
  38240. }
  38241. /**
  38242. * Interface representing an arc rotate camera inputs manager
  38243. */
  38244. interface ArcRotateCameraInputsManager {
  38245. /**
  38246. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38247. * @returns the camera inputs manager
  38248. */
  38249. addGamepad(): ArcRotateCameraInputsManager;
  38250. }
  38251. /**
  38252. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38253. */
  38254. export class GamepadSystemSceneComponent implements ISceneComponent {
  38255. /**
  38256. * The component name helpfull to identify the component in the list of scene components.
  38257. */
  38258. readonly name: string;
  38259. /**
  38260. * The scene the component belongs to.
  38261. */
  38262. scene: Scene;
  38263. /**
  38264. * Creates a new instance of the component for the given scene
  38265. * @param scene Defines the scene to register the component in
  38266. */
  38267. constructor(scene: Scene);
  38268. /**
  38269. * Registers the component in a given scene
  38270. */
  38271. register(): void;
  38272. /**
  38273. * Rebuilds the elements related to this component in case of
  38274. * context lost for instance.
  38275. */
  38276. rebuild(): void;
  38277. /**
  38278. * Disposes the component and the associated ressources
  38279. */
  38280. dispose(): void;
  38281. private _beforeCameraUpdate;
  38282. }
  38283. }
  38284. declare module BABYLON {
  38285. /**
  38286. * 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,
  38287. * which still works and will still be found in many Playgrounds.
  38288. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38289. */
  38290. export class UniversalCamera extends TouchCamera {
  38291. /**
  38292. * Defines the gamepad rotation sensiblity.
  38293. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38294. */
  38295. gamepadAngularSensibility: number;
  38296. /**
  38297. * Defines the gamepad move sensiblity.
  38298. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38299. */
  38300. gamepadMoveSensibility: number;
  38301. /**
  38302. * 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,
  38303. * which still works and will still be found in many Playgrounds.
  38304. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38305. * @param name Define the name of the camera in the scene
  38306. * @param position Define the start position of the camera in the scene
  38307. * @param scene Define the scene the camera belongs to
  38308. */
  38309. constructor(name: string, position: Vector3, scene: Scene);
  38310. /**
  38311. * Gets the current object class name.
  38312. * @return the class name
  38313. */
  38314. getClassName(): string;
  38315. }
  38316. }
  38317. declare module BABYLON {
  38318. /**
  38319. * This represents a FPS type of camera. This is only here for back compat purpose.
  38320. * Please use the UniversalCamera instead as both are identical.
  38321. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38322. */
  38323. export class GamepadCamera extends UniversalCamera {
  38324. /**
  38325. * Instantiates a new Gamepad Camera
  38326. * This represents a FPS type of camera. This is only here for back compat purpose.
  38327. * Please use the UniversalCamera instead as both are identical.
  38328. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38329. * @param name Define the name of the camera in the scene
  38330. * @param position Define the start position of the camera in the scene
  38331. * @param scene Define the scene the camera belongs to
  38332. */
  38333. constructor(name: string, position: Vector3, scene: Scene);
  38334. /**
  38335. * Gets the current object class name.
  38336. * @return the class name
  38337. */
  38338. getClassName(): string;
  38339. }
  38340. }
  38341. declare module BABYLON {
  38342. /** @hidden */
  38343. export var passPixelShader: {
  38344. name: string;
  38345. shader: string;
  38346. };
  38347. }
  38348. declare module BABYLON {
  38349. /** @hidden */
  38350. export var passCubePixelShader: {
  38351. name: string;
  38352. shader: string;
  38353. };
  38354. }
  38355. declare module BABYLON {
  38356. /**
  38357. * PassPostProcess which produces an output the same as it's input
  38358. */
  38359. export class PassPostProcess extends PostProcess {
  38360. /**
  38361. * Creates the PassPostProcess
  38362. * @param name The name of the effect.
  38363. * @param options The required width/height ratio to downsize to before computing the render pass.
  38364. * @param camera The camera to apply the render pass to.
  38365. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38366. * @param engine The engine which the post process will be applied. (default: current engine)
  38367. * @param reusable If the post process can be reused on the same frame. (default: false)
  38368. * @param textureType The type of texture to be used when performing the post processing.
  38369. * @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)
  38370. */
  38371. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38372. }
  38373. /**
  38374. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38375. */
  38376. export class PassCubePostProcess extends PostProcess {
  38377. private _face;
  38378. /**
  38379. * Gets or sets the cube face to display.
  38380. * * 0 is +X
  38381. * * 1 is -X
  38382. * * 2 is +Y
  38383. * * 3 is -Y
  38384. * * 4 is +Z
  38385. * * 5 is -Z
  38386. */
  38387. face: number;
  38388. /**
  38389. * Creates the PassCubePostProcess
  38390. * @param name The name of the effect.
  38391. * @param options The required width/height ratio to downsize to before computing the render pass.
  38392. * @param camera The camera to apply the render pass to.
  38393. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38394. * @param engine The engine which the post process will be applied. (default: current engine)
  38395. * @param reusable If the post process can be reused on the same frame. (default: false)
  38396. * @param textureType The type of texture to be used when performing the post processing.
  38397. * @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)
  38398. */
  38399. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38400. }
  38401. }
  38402. declare module BABYLON {
  38403. /** @hidden */
  38404. export var anaglyphPixelShader: {
  38405. name: string;
  38406. shader: string;
  38407. };
  38408. }
  38409. declare module BABYLON {
  38410. /**
  38411. * Postprocess used to generate anaglyphic rendering
  38412. */
  38413. export class AnaglyphPostProcess extends PostProcess {
  38414. private _passedProcess;
  38415. /**
  38416. * Creates a new AnaglyphPostProcess
  38417. * @param name defines postprocess name
  38418. * @param options defines creation options or target ratio scale
  38419. * @param rigCameras defines cameras using this postprocess
  38420. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38421. * @param engine defines hosting engine
  38422. * @param reusable defines if the postprocess will be reused multiple times per frame
  38423. */
  38424. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38425. }
  38426. }
  38427. declare module BABYLON {
  38428. /**
  38429. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38430. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38431. */
  38432. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38433. /**
  38434. * Creates a new AnaglyphArcRotateCamera
  38435. * @param name defines camera name
  38436. * @param alpha defines alpha angle (in radians)
  38437. * @param beta defines beta angle (in radians)
  38438. * @param radius defines radius
  38439. * @param target defines camera target
  38440. * @param interaxialDistance defines distance between each color axis
  38441. * @param scene defines the hosting scene
  38442. */
  38443. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38444. /**
  38445. * Gets camera class name
  38446. * @returns AnaglyphArcRotateCamera
  38447. */
  38448. getClassName(): string;
  38449. }
  38450. }
  38451. declare module BABYLON {
  38452. /**
  38453. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38454. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38455. */
  38456. export class AnaglyphFreeCamera extends FreeCamera {
  38457. /**
  38458. * Creates a new AnaglyphFreeCamera
  38459. * @param name defines camera name
  38460. * @param position defines initial position
  38461. * @param interaxialDistance defines distance between each color axis
  38462. * @param scene defines the hosting scene
  38463. */
  38464. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38465. /**
  38466. * Gets camera class name
  38467. * @returns AnaglyphFreeCamera
  38468. */
  38469. getClassName(): string;
  38470. }
  38471. }
  38472. declare module BABYLON {
  38473. /**
  38474. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38475. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38476. */
  38477. export class AnaglyphGamepadCamera extends GamepadCamera {
  38478. /**
  38479. * Creates a new AnaglyphGamepadCamera
  38480. * @param name defines camera name
  38481. * @param position defines initial position
  38482. * @param interaxialDistance defines distance between each color axis
  38483. * @param scene defines the hosting scene
  38484. */
  38485. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38486. /**
  38487. * Gets camera class name
  38488. * @returns AnaglyphGamepadCamera
  38489. */
  38490. getClassName(): string;
  38491. }
  38492. }
  38493. declare module BABYLON {
  38494. /**
  38495. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38496. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38497. */
  38498. export class AnaglyphUniversalCamera extends UniversalCamera {
  38499. /**
  38500. * Creates a new AnaglyphUniversalCamera
  38501. * @param name defines camera name
  38502. * @param position defines initial position
  38503. * @param interaxialDistance defines distance between each color axis
  38504. * @param scene defines the hosting scene
  38505. */
  38506. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38507. /**
  38508. * Gets camera class name
  38509. * @returns AnaglyphUniversalCamera
  38510. */
  38511. getClassName(): string;
  38512. }
  38513. }
  38514. declare module BABYLON {
  38515. /** @hidden */
  38516. export var stereoscopicInterlacePixelShader: {
  38517. name: string;
  38518. shader: string;
  38519. };
  38520. }
  38521. declare module BABYLON {
  38522. /**
  38523. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38524. */
  38525. export class StereoscopicInterlacePostProcess extends PostProcess {
  38526. private _stepSize;
  38527. private _passedProcess;
  38528. /**
  38529. * Initializes a StereoscopicInterlacePostProcess
  38530. * @param name The name of the effect.
  38531. * @param rigCameras The rig cameras to be appled to the post process
  38532. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38533. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38534. * @param engine The engine which the post process will be applied. (default: current engine)
  38535. * @param reusable If the post process can be reused on the same frame. (default: false)
  38536. */
  38537. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38538. }
  38539. }
  38540. declare module BABYLON {
  38541. /**
  38542. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38543. * @see http://doc.babylonjs.com/features/cameras
  38544. */
  38545. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38546. /**
  38547. * Creates a new StereoscopicArcRotateCamera
  38548. * @param name defines camera name
  38549. * @param alpha defines alpha angle (in radians)
  38550. * @param beta defines beta angle (in radians)
  38551. * @param radius defines radius
  38552. * @param target defines camera target
  38553. * @param interaxialDistance defines distance between each color axis
  38554. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38555. * @param scene defines the hosting scene
  38556. */
  38557. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38558. /**
  38559. * Gets camera class name
  38560. * @returns StereoscopicArcRotateCamera
  38561. */
  38562. getClassName(): string;
  38563. }
  38564. }
  38565. declare module BABYLON {
  38566. /**
  38567. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38568. * @see http://doc.babylonjs.com/features/cameras
  38569. */
  38570. export class StereoscopicFreeCamera extends FreeCamera {
  38571. /**
  38572. * Creates a new StereoscopicFreeCamera
  38573. * @param name defines camera name
  38574. * @param position defines initial position
  38575. * @param interaxialDistance defines distance between each color axis
  38576. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38577. * @param scene defines the hosting scene
  38578. */
  38579. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38580. /**
  38581. * Gets camera class name
  38582. * @returns StereoscopicFreeCamera
  38583. */
  38584. getClassName(): string;
  38585. }
  38586. }
  38587. declare module BABYLON {
  38588. /**
  38589. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38590. * @see http://doc.babylonjs.com/features/cameras
  38591. */
  38592. export class StereoscopicGamepadCamera extends GamepadCamera {
  38593. /**
  38594. * Creates a new StereoscopicGamepadCamera
  38595. * @param name defines camera name
  38596. * @param position defines initial position
  38597. * @param interaxialDistance defines distance between each color axis
  38598. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38599. * @param scene defines the hosting scene
  38600. */
  38601. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38602. /**
  38603. * Gets camera class name
  38604. * @returns StereoscopicGamepadCamera
  38605. */
  38606. getClassName(): string;
  38607. }
  38608. }
  38609. declare module BABYLON {
  38610. /**
  38611. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38612. * @see http://doc.babylonjs.com/features/cameras
  38613. */
  38614. export class StereoscopicUniversalCamera extends UniversalCamera {
  38615. /**
  38616. * Creates a new StereoscopicUniversalCamera
  38617. * @param name defines camera name
  38618. * @param position defines initial position
  38619. * @param interaxialDistance defines distance between each color axis
  38620. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38621. * @param scene defines the hosting scene
  38622. */
  38623. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38624. /**
  38625. * Gets camera class name
  38626. * @returns StereoscopicUniversalCamera
  38627. */
  38628. getClassName(): string;
  38629. }
  38630. }
  38631. declare module BABYLON {
  38632. /**
  38633. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38634. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38635. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38636. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38637. */
  38638. export class VirtualJoysticksCamera extends FreeCamera {
  38639. /**
  38640. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38641. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38642. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38643. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38644. * @param name Define the name of the camera in the scene
  38645. * @param position Define the start position of the camera in the scene
  38646. * @param scene Define the scene the camera belongs to
  38647. */
  38648. constructor(name: string, position: Vector3, scene: Scene);
  38649. /**
  38650. * Gets the current object class name.
  38651. * @return the class name
  38652. */
  38653. getClassName(): string;
  38654. }
  38655. }
  38656. declare module BABYLON {
  38657. /**
  38658. * This represents all the required metrics to create a VR camera.
  38659. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38660. */
  38661. export class VRCameraMetrics {
  38662. /**
  38663. * Define the horizontal resolution off the screen.
  38664. */
  38665. hResolution: number;
  38666. /**
  38667. * Define the vertical resolution off the screen.
  38668. */
  38669. vResolution: number;
  38670. /**
  38671. * Define the horizontal screen size.
  38672. */
  38673. hScreenSize: number;
  38674. /**
  38675. * Define the vertical screen size.
  38676. */
  38677. vScreenSize: number;
  38678. /**
  38679. * Define the vertical screen center position.
  38680. */
  38681. vScreenCenter: number;
  38682. /**
  38683. * Define the distance of the eyes to the screen.
  38684. */
  38685. eyeToScreenDistance: number;
  38686. /**
  38687. * Define the distance between both lenses
  38688. */
  38689. lensSeparationDistance: number;
  38690. /**
  38691. * Define the distance between both viewer's eyes.
  38692. */
  38693. interpupillaryDistance: number;
  38694. /**
  38695. * Define the distortion factor of the VR postprocess.
  38696. * Please, touch with care.
  38697. */
  38698. distortionK: number[];
  38699. /**
  38700. * Define the chromatic aberration correction factors for the VR post process.
  38701. */
  38702. chromaAbCorrection: number[];
  38703. /**
  38704. * Define the scale factor of the post process.
  38705. * The smaller the better but the slower.
  38706. */
  38707. postProcessScaleFactor: number;
  38708. /**
  38709. * Define an offset for the lens center.
  38710. */
  38711. lensCenterOffset: number;
  38712. /**
  38713. * Define if the current vr camera should compensate the distortion of the lense or not.
  38714. */
  38715. compensateDistortion: boolean;
  38716. /**
  38717. * Defines if multiview should be enabled when rendering (Default: false)
  38718. */
  38719. multiviewEnabled: boolean;
  38720. /**
  38721. * Gets the rendering aspect ratio based on the provided resolutions.
  38722. */
  38723. readonly aspectRatio: number;
  38724. /**
  38725. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38726. */
  38727. readonly aspectRatioFov: number;
  38728. /**
  38729. * @hidden
  38730. */
  38731. readonly leftHMatrix: Matrix;
  38732. /**
  38733. * @hidden
  38734. */
  38735. readonly rightHMatrix: Matrix;
  38736. /**
  38737. * @hidden
  38738. */
  38739. readonly leftPreViewMatrix: Matrix;
  38740. /**
  38741. * @hidden
  38742. */
  38743. readonly rightPreViewMatrix: Matrix;
  38744. /**
  38745. * Get the default VRMetrics based on the most generic setup.
  38746. * @returns the default vr metrics
  38747. */
  38748. static GetDefault(): VRCameraMetrics;
  38749. }
  38750. }
  38751. declare module BABYLON {
  38752. /** @hidden */
  38753. export var vrDistortionCorrectionPixelShader: {
  38754. name: string;
  38755. shader: string;
  38756. };
  38757. }
  38758. declare module BABYLON {
  38759. /**
  38760. * VRDistortionCorrectionPostProcess used for mobile VR
  38761. */
  38762. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38763. private _isRightEye;
  38764. private _distortionFactors;
  38765. private _postProcessScaleFactor;
  38766. private _lensCenterOffset;
  38767. private _scaleIn;
  38768. private _scaleFactor;
  38769. private _lensCenter;
  38770. /**
  38771. * Initializes the VRDistortionCorrectionPostProcess
  38772. * @param name The name of the effect.
  38773. * @param camera The camera to apply the render pass to.
  38774. * @param isRightEye If this is for the right eye distortion
  38775. * @param vrMetrics All the required metrics for the VR camera
  38776. */
  38777. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38778. }
  38779. }
  38780. declare module BABYLON {
  38781. /**
  38782. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38783. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38784. */
  38785. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38786. /**
  38787. * Creates a new VRDeviceOrientationArcRotateCamera
  38788. * @param name defines camera name
  38789. * @param alpha defines the camera rotation along the logitudinal axis
  38790. * @param beta defines the camera rotation along the latitudinal axis
  38791. * @param radius defines the camera distance from its target
  38792. * @param target defines the camera target
  38793. * @param scene defines the scene the camera belongs to
  38794. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38795. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38796. */
  38797. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38798. /**
  38799. * Gets camera class name
  38800. * @returns VRDeviceOrientationArcRotateCamera
  38801. */
  38802. getClassName(): string;
  38803. }
  38804. }
  38805. declare module BABYLON {
  38806. /**
  38807. * Camera used to simulate VR rendering (based on FreeCamera)
  38808. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38809. */
  38810. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38811. /**
  38812. * Creates a new VRDeviceOrientationFreeCamera
  38813. * @param name defines camera name
  38814. * @param position defines the start position of the camera
  38815. * @param scene defines the scene the camera belongs to
  38816. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38817. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38818. */
  38819. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38820. /**
  38821. * Gets camera class name
  38822. * @returns VRDeviceOrientationFreeCamera
  38823. */
  38824. getClassName(): string;
  38825. }
  38826. }
  38827. declare module BABYLON {
  38828. /**
  38829. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38830. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38831. */
  38832. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38833. /**
  38834. * Creates a new VRDeviceOrientationGamepadCamera
  38835. * @param name defines camera name
  38836. * @param position defines the start position of the camera
  38837. * @param scene defines the scene the camera belongs to
  38838. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38839. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38840. */
  38841. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38842. /**
  38843. * Gets camera class name
  38844. * @returns VRDeviceOrientationGamepadCamera
  38845. */
  38846. getClassName(): string;
  38847. }
  38848. }
  38849. declare module BABYLON {
  38850. /**
  38851. * Base class of materials working in push mode in babylon JS
  38852. * @hidden
  38853. */
  38854. export class PushMaterial extends Material {
  38855. protected _activeEffect: Effect;
  38856. protected _normalMatrix: Matrix;
  38857. /**
  38858. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38859. * This means that the material can keep using a previous shader while a new one is being compiled.
  38860. * This is mostly used when shader parallel compilation is supported (true by default)
  38861. */
  38862. allowShaderHotSwapping: boolean;
  38863. constructor(name: string, scene: Scene);
  38864. getEffect(): Effect;
  38865. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38866. /**
  38867. * Binds the given world matrix to the active effect
  38868. *
  38869. * @param world the matrix to bind
  38870. */
  38871. bindOnlyWorldMatrix(world: Matrix): void;
  38872. /**
  38873. * Binds the given normal matrix to the active effect
  38874. *
  38875. * @param normalMatrix the matrix to bind
  38876. */
  38877. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38878. bind(world: Matrix, mesh?: Mesh): void;
  38879. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38880. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38881. }
  38882. }
  38883. declare module BABYLON {
  38884. /**
  38885. * This groups all the flags used to control the materials channel.
  38886. */
  38887. export class MaterialFlags {
  38888. private static _DiffuseTextureEnabled;
  38889. /**
  38890. * Are diffuse textures enabled in the application.
  38891. */
  38892. static DiffuseTextureEnabled: boolean;
  38893. private static _AmbientTextureEnabled;
  38894. /**
  38895. * Are ambient textures enabled in the application.
  38896. */
  38897. static AmbientTextureEnabled: boolean;
  38898. private static _OpacityTextureEnabled;
  38899. /**
  38900. * Are opacity textures enabled in the application.
  38901. */
  38902. static OpacityTextureEnabled: boolean;
  38903. private static _ReflectionTextureEnabled;
  38904. /**
  38905. * Are reflection textures enabled in the application.
  38906. */
  38907. static ReflectionTextureEnabled: boolean;
  38908. private static _EmissiveTextureEnabled;
  38909. /**
  38910. * Are emissive textures enabled in the application.
  38911. */
  38912. static EmissiveTextureEnabled: boolean;
  38913. private static _SpecularTextureEnabled;
  38914. /**
  38915. * Are specular textures enabled in the application.
  38916. */
  38917. static SpecularTextureEnabled: boolean;
  38918. private static _BumpTextureEnabled;
  38919. /**
  38920. * Are bump textures enabled in the application.
  38921. */
  38922. static BumpTextureEnabled: boolean;
  38923. private static _LightmapTextureEnabled;
  38924. /**
  38925. * Are lightmap textures enabled in the application.
  38926. */
  38927. static LightmapTextureEnabled: boolean;
  38928. private static _RefractionTextureEnabled;
  38929. /**
  38930. * Are refraction textures enabled in the application.
  38931. */
  38932. static RefractionTextureEnabled: boolean;
  38933. private static _ColorGradingTextureEnabled;
  38934. /**
  38935. * Are color grading textures enabled in the application.
  38936. */
  38937. static ColorGradingTextureEnabled: boolean;
  38938. private static _FresnelEnabled;
  38939. /**
  38940. * Are fresnels enabled in the application.
  38941. */
  38942. static FresnelEnabled: boolean;
  38943. private static _ClearCoatTextureEnabled;
  38944. /**
  38945. * Are clear coat textures enabled in the application.
  38946. */
  38947. static ClearCoatTextureEnabled: boolean;
  38948. private static _ClearCoatBumpTextureEnabled;
  38949. /**
  38950. * Are clear coat bump textures enabled in the application.
  38951. */
  38952. static ClearCoatBumpTextureEnabled: boolean;
  38953. private static _ClearCoatTintTextureEnabled;
  38954. /**
  38955. * Are clear coat tint textures enabled in the application.
  38956. */
  38957. static ClearCoatTintTextureEnabled: boolean;
  38958. private static _SheenTextureEnabled;
  38959. /**
  38960. * Are sheen textures enabled in the application.
  38961. */
  38962. static SheenTextureEnabled: boolean;
  38963. private static _AnisotropicTextureEnabled;
  38964. /**
  38965. * Are anisotropic textures enabled in the application.
  38966. */
  38967. static AnisotropicTextureEnabled: boolean;
  38968. private static _ThicknessTextureEnabled;
  38969. /**
  38970. * Are thickness textures enabled in the application.
  38971. */
  38972. static ThicknessTextureEnabled: boolean;
  38973. }
  38974. }
  38975. declare module BABYLON {
  38976. /** @hidden */
  38977. export var defaultFragmentDeclaration: {
  38978. name: string;
  38979. shader: string;
  38980. };
  38981. }
  38982. declare module BABYLON {
  38983. /** @hidden */
  38984. export var defaultUboDeclaration: {
  38985. name: string;
  38986. shader: string;
  38987. };
  38988. }
  38989. declare module BABYLON {
  38990. /** @hidden */
  38991. export var lightFragmentDeclaration: {
  38992. name: string;
  38993. shader: string;
  38994. };
  38995. }
  38996. declare module BABYLON {
  38997. /** @hidden */
  38998. export var lightUboDeclaration: {
  38999. name: string;
  39000. shader: string;
  39001. };
  39002. }
  39003. declare module BABYLON {
  39004. /** @hidden */
  39005. export var lightsFragmentFunctions: {
  39006. name: string;
  39007. shader: string;
  39008. };
  39009. }
  39010. declare module BABYLON {
  39011. /** @hidden */
  39012. export var shadowsFragmentFunctions: {
  39013. name: string;
  39014. shader: string;
  39015. };
  39016. }
  39017. declare module BABYLON {
  39018. /** @hidden */
  39019. export var fresnelFunction: {
  39020. name: string;
  39021. shader: string;
  39022. };
  39023. }
  39024. declare module BABYLON {
  39025. /** @hidden */
  39026. export var reflectionFunction: {
  39027. name: string;
  39028. shader: string;
  39029. };
  39030. }
  39031. declare module BABYLON {
  39032. /** @hidden */
  39033. export var bumpFragmentFunctions: {
  39034. name: string;
  39035. shader: string;
  39036. };
  39037. }
  39038. declare module BABYLON {
  39039. /** @hidden */
  39040. export var logDepthDeclaration: {
  39041. name: string;
  39042. shader: string;
  39043. };
  39044. }
  39045. declare module BABYLON {
  39046. /** @hidden */
  39047. export var bumpFragment: {
  39048. name: string;
  39049. shader: string;
  39050. };
  39051. }
  39052. declare module BABYLON {
  39053. /** @hidden */
  39054. export var depthPrePass: {
  39055. name: string;
  39056. shader: string;
  39057. };
  39058. }
  39059. declare module BABYLON {
  39060. /** @hidden */
  39061. export var lightFragment: {
  39062. name: string;
  39063. shader: string;
  39064. };
  39065. }
  39066. declare module BABYLON {
  39067. /** @hidden */
  39068. export var logDepthFragment: {
  39069. name: string;
  39070. shader: string;
  39071. };
  39072. }
  39073. declare module BABYLON {
  39074. /** @hidden */
  39075. export var defaultPixelShader: {
  39076. name: string;
  39077. shader: string;
  39078. };
  39079. }
  39080. declare module BABYLON {
  39081. /** @hidden */
  39082. export var defaultVertexDeclaration: {
  39083. name: string;
  39084. shader: string;
  39085. };
  39086. }
  39087. declare module BABYLON {
  39088. /** @hidden */
  39089. export var bumpVertexDeclaration: {
  39090. name: string;
  39091. shader: string;
  39092. };
  39093. }
  39094. declare module BABYLON {
  39095. /** @hidden */
  39096. export var bumpVertex: {
  39097. name: string;
  39098. shader: string;
  39099. };
  39100. }
  39101. declare module BABYLON {
  39102. /** @hidden */
  39103. export var fogVertex: {
  39104. name: string;
  39105. shader: string;
  39106. };
  39107. }
  39108. declare module BABYLON {
  39109. /** @hidden */
  39110. export var shadowsVertex: {
  39111. name: string;
  39112. shader: string;
  39113. };
  39114. }
  39115. declare module BABYLON {
  39116. /** @hidden */
  39117. export var pointCloudVertex: {
  39118. name: string;
  39119. shader: string;
  39120. };
  39121. }
  39122. declare module BABYLON {
  39123. /** @hidden */
  39124. export var logDepthVertex: {
  39125. name: string;
  39126. shader: string;
  39127. };
  39128. }
  39129. declare module BABYLON {
  39130. /** @hidden */
  39131. export var defaultVertexShader: {
  39132. name: string;
  39133. shader: string;
  39134. };
  39135. }
  39136. declare module BABYLON {
  39137. /** @hidden */
  39138. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39139. MAINUV1: boolean;
  39140. MAINUV2: boolean;
  39141. DIFFUSE: boolean;
  39142. DIFFUSEDIRECTUV: number;
  39143. AMBIENT: boolean;
  39144. AMBIENTDIRECTUV: number;
  39145. OPACITY: boolean;
  39146. OPACITYDIRECTUV: number;
  39147. OPACITYRGB: boolean;
  39148. REFLECTION: boolean;
  39149. EMISSIVE: boolean;
  39150. EMISSIVEDIRECTUV: number;
  39151. SPECULAR: boolean;
  39152. SPECULARDIRECTUV: number;
  39153. BUMP: boolean;
  39154. BUMPDIRECTUV: number;
  39155. PARALLAX: boolean;
  39156. PARALLAXOCCLUSION: boolean;
  39157. SPECULAROVERALPHA: boolean;
  39158. CLIPPLANE: boolean;
  39159. CLIPPLANE2: boolean;
  39160. CLIPPLANE3: boolean;
  39161. CLIPPLANE4: boolean;
  39162. ALPHATEST: boolean;
  39163. DEPTHPREPASS: boolean;
  39164. ALPHAFROMDIFFUSE: boolean;
  39165. POINTSIZE: boolean;
  39166. FOG: boolean;
  39167. SPECULARTERM: boolean;
  39168. DIFFUSEFRESNEL: boolean;
  39169. OPACITYFRESNEL: boolean;
  39170. REFLECTIONFRESNEL: boolean;
  39171. REFRACTIONFRESNEL: boolean;
  39172. EMISSIVEFRESNEL: boolean;
  39173. FRESNEL: boolean;
  39174. NORMAL: boolean;
  39175. UV1: boolean;
  39176. UV2: boolean;
  39177. VERTEXCOLOR: boolean;
  39178. VERTEXALPHA: boolean;
  39179. NUM_BONE_INFLUENCERS: number;
  39180. BonesPerMesh: number;
  39181. BONETEXTURE: boolean;
  39182. INSTANCES: boolean;
  39183. GLOSSINESS: boolean;
  39184. ROUGHNESS: boolean;
  39185. EMISSIVEASILLUMINATION: boolean;
  39186. LINKEMISSIVEWITHDIFFUSE: boolean;
  39187. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39188. LIGHTMAP: boolean;
  39189. LIGHTMAPDIRECTUV: number;
  39190. OBJECTSPACE_NORMALMAP: boolean;
  39191. USELIGHTMAPASSHADOWMAP: boolean;
  39192. REFLECTIONMAP_3D: boolean;
  39193. REFLECTIONMAP_SPHERICAL: boolean;
  39194. REFLECTIONMAP_PLANAR: boolean;
  39195. REFLECTIONMAP_CUBIC: boolean;
  39196. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39197. REFLECTIONMAP_PROJECTION: boolean;
  39198. REFLECTIONMAP_SKYBOX: boolean;
  39199. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39200. REFLECTIONMAP_EXPLICIT: boolean;
  39201. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39202. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39203. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39204. INVERTCUBICMAP: boolean;
  39205. LOGARITHMICDEPTH: boolean;
  39206. REFRACTION: boolean;
  39207. REFRACTIONMAP_3D: boolean;
  39208. REFLECTIONOVERALPHA: boolean;
  39209. TWOSIDEDLIGHTING: boolean;
  39210. SHADOWFLOAT: boolean;
  39211. MORPHTARGETS: boolean;
  39212. MORPHTARGETS_NORMAL: boolean;
  39213. MORPHTARGETS_TANGENT: boolean;
  39214. MORPHTARGETS_UV: boolean;
  39215. NUM_MORPH_INFLUENCERS: number;
  39216. NONUNIFORMSCALING: boolean;
  39217. PREMULTIPLYALPHA: boolean;
  39218. IMAGEPROCESSING: boolean;
  39219. VIGNETTE: boolean;
  39220. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39221. VIGNETTEBLENDMODEOPAQUE: boolean;
  39222. TONEMAPPING: boolean;
  39223. TONEMAPPING_ACES: boolean;
  39224. CONTRAST: boolean;
  39225. COLORCURVES: boolean;
  39226. COLORGRADING: boolean;
  39227. COLORGRADING3D: boolean;
  39228. SAMPLER3DGREENDEPTH: boolean;
  39229. SAMPLER3DBGRMAP: boolean;
  39230. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39231. MULTIVIEW: boolean;
  39232. /**
  39233. * If the reflection texture on this material is in linear color space
  39234. * @hidden
  39235. */
  39236. IS_REFLECTION_LINEAR: boolean;
  39237. /**
  39238. * If the refraction texture on this material is in linear color space
  39239. * @hidden
  39240. */
  39241. IS_REFRACTION_LINEAR: boolean;
  39242. EXPOSURE: boolean;
  39243. constructor();
  39244. setReflectionMode(modeToEnable: string): void;
  39245. }
  39246. /**
  39247. * This is the default material used in Babylon. It is the best trade off between quality
  39248. * and performances.
  39249. * @see http://doc.babylonjs.com/babylon101/materials
  39250. */
  39251. export class StandardMaterial extends PushMaterial {
  39252. private _diffuseTexture;
  39253. /**
  39254. * The basic texture of the material as viewed under a light.
  39255. */
  39256. diffuseTexture: Nullable<BaseTexture>;
  39257. private _ambientTexture;
  39258. /**
  39259. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39260. */
  39261. ambientTexture: Nullable<BaseTexture>;
  39262. private _opacityTexture;
  39263. /**
  39264. * Define the transparency of the material from a texture.
  39265. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39266. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39267. */
  39268. opacityTexture: Nullable<BaseTexture>;
  39269. private _reflectionTexture;
  39270. /**
  39271. * Define the texture used to display the reflection.
  39272. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39273. */
  39274. reflectionTexture: Nullable<BaseTexture>;
  39275. private _emissiveTexture;
  39276. /**
  39277. * Define texture of the material as if self lit.
  39278. * This will be mixed in the final result even in the absence of light.
  39279. */
  39280. emissiveTexture: Nullable<BaseTexture>;
  39281. private _specularTexture;
  39282. /**
  39283. * Define how the color and intensity of the highlight given by the light in the material.
  39284. */
  39285. specularTexture: Nullable<BaseTexture>;
  39286. private _bumpTexture;
  39287. /**
  39288. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39289. * 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.
  39290. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39291. */
  39292. bumpTexture: Nullable<BaseTexture>;
  39293. private _lightmapTexture;
  39294. /**
  39295. * Complex lighting can be computationally expensive to compute at runtime.
  39296. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39297. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39298. */
  39299. lightmapTexture: Nullable<BaseTexture>;
  39300. private _refractionTexture;
  39301. /**
  39302. * Define the texture used to display the refraction.
  39303. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39304. */
  39305. refractionTexture: Nullable<BaseTexture>;
  39306. /**
  39307. * The color of the material lit by the environmental background lighting.
  39308. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39309. */
  39310. ambientColor: Color3;
  39311. /**
  39312. * The basic color of the material as viewed under a light.
  39313. */
  39314. diffuseColor: Color3;
  39315. /**
  39316. * Define how the color and intensity of the highlight given by the light in the material.
  39317. */
  39318. specularColor: Color3;
  39319. /**
  39320. * Define the color of the material as if self lit.
  39321. * This will be mixed in the final result even in the absence of light.
  39322. */
  39323. emissiveColor: Color3;
  39324. /**
  39325. * Defines how sharp are the highlights in the material.
  39326. * The bigger the value the sharper giving a more glossy feeling to the result.
  39327. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39328. */
  39329. specularPower: number;
  39330. private _useAlphaFromDiffuseTexture;
  39331. /**
  39332. * Does the transparency come from the diffuse texture alpha channel.
  39333. */
  39334. useAlphaFromDiffuseTexture: boolean;
  39335. private _useEmissiveAsIllumination;
  39336. /**
  39337. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39338. */
  39339. useEmissiveAsIllumination: boolean;
  39340. private _linkEmissiveWithDiffuse;
  39341. /**
  39342. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39343. * the emissive level when the final color is close to one.
  39344. */
  39345. linkEmissiveWithDiffuse: boolean;
  39346. private _useSpecularOverAlpha;
  39347. /**
  39348. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39349. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39350. */
  39351. useSpecularOverAlpha: boolean;
  39352. private _useReflectionOverAlpha;
  39353. /**
  39354. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39355. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39356. */
  39357. useReflectionOverAlpha: boolean;
  39358. private _disableLighting;
  39359. /**
  39360. * Does lights from the scene impacts this material.
  39361. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39362. */
  39363. disableLighting: boolean;
  39364. private _useObjectSpaceNormalMap;
  39365. /**
  39366. * Allows using an object space normal map (instead of tangent space).
  39367. */
  39368. useObjectSpaceNormalMap: boolean;
  39369. private _useParallax;
  39370. /**
  39371. * Is parallax enabled or not.
  39372. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39373. */
  39374. useParallax: boolean;
  39375. private _useParallaxOcclusion;
  39376. /**
  39377. * Is parallax occlusion enabled or not.
  39378. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39379. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39380. */
  39381. useParallaxOcclusion: boolean;
  39382. /**
  39383. * 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.
  39384. */
  39385. parallaxScaleBias: number;
  39386. private _roughness;
  39387. /**
  39388. * Helps to define how blurry the reflections should appears in the material.
  39389. */
  39390. roughness: number;
  39391. /**
  39392. * In case of refraction, define the value of the index of refraction.
  39393. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39394. */
  39395. indexOfRefraction: number;
  39396. /**
  39397. * Invert the refraction texture alongside the y axis.
  39398. * It can be useful with procedural textures or probe for instance.
  39399. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39400. */
  39401. invertRefractionY: boolean;
  39402. /**
  39403. * Defines the alpha limits in alpha test mode.
  39404. */
  39405. alphaCutOff: number;
  39406. private _useLightmapAsShadowmap;
  39407. /**
  39408. * In case of light mapping, define whether the map contains light or shadow informations.
  39409. */
  39410. useLightmapAsShadowmap: boolean;
  39411. private _diffuseFresnelParameters;
  39412. /**
  39413. * Define the diffuse fresnel parameters of the material.
  39414. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39415. */
  39416. diffuseFresnelParameters: FresnelParameters;
  39417. private _opacityFresnelParameters;
  39418. /**
  39419. * Define the opacity fresnel parameters of the material.
  39420. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39421. */
  39422. opacityFresnelParameters: FresnelParameters;
  39423. private _reflectionFresnelParameters;
  39424. /**
  39425. * Define the reflection fresnel parameters of the material.
  39426. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39427. */
  39428. reflectionFresnelParameters: FresnelParameters;
  39429. private _refractionFresnelParameters;
  39430. /**
  39431. * Define the refraction fresnel parameters of the material.
  39432. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39433. */
  39434. refractionFresnelParameters: FresnelParameters;
  39435. private _emissiveFresnelParameters;
  39436. /**
  39437. * Define the emissive fresnel parameters of the material.
  39438. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39439. */
  39440. emissiveFresnelParameters: FresnelParameters;
  39441. private _useReflectionFresnelFromSpecular;
  39442. /**
  39443. * If true automatically deducts the fresnels values from the material specularity.
  39444. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39445. */
  39446. useReflectionFresnelFromSpecular: boolean;
  39447. private _useGlossinessFromSpecularMapAlpha;
  39448. /**
  39449. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39450. */
  39451. useGlossinessFromSpecularMapAlpha: boolean;
  39452. private _maxSimultaneousLights;
  39453. /**
  39454. * Defines the maximum number of lights that can be used in the material
  39455. */
  39456. maxSimultaneousLights: number;
  39457. private _invertNormalMapX;
  39458. /**
  39459. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39460. */
  39461. invertNormalMapX: boolean;
  39462. private _invertNormalMapY;
  39463. /**
  39464. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39465. */
  39466. invertNormalMapY: boolean;
  39467. private _twoSidedLighting;
  39468. /**
  39469. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39470. */
  39471. twoSidedLighting: boolean;
  39472. /**
  39473. * Default configuration related to image processing available in the standard Material.
  39474. */
  39475. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39476. /**
  39477. * Gets the image processing configuration used either in this material.
  39478. */
  39479. /**
  39480. * Sets the Default image processing configuration used either in the this material.
  39481. *
  39482. * If sets to null, the scene one is in use.
  39483. */
  39484. imageProcessingConfiguration: ImageProcessingConfiguration;
  39485. /**
  39486. * Keep track of the image processing observer to allow dispose and replace.
  39487. */
  39488. private _imageProcessingObserver;
  39489. /**
  39490. * Attaches a new image processing configuration to the Standard Material.
  39491. * @param configuration
  39492. */
  39493. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39494. /**
  39495. * Gets wether the color curves effect is enabled.
  39496. */
  39497. /**
  39498. * Sets wether the color curves effect is enabled.
  39499. */
  39500. cameraColorCurvesEnabled: boolean;
  39501. /**
  39502. * Gets wether the color grading effect is enabled.
  39503. */
  39504. /**
  39505. * Gets wether the color grading effect is enabled.
  39506. */
  39507. cameraColorGradingEnabled: boolean;
  39508. /**
  39509. * Gets wether tonemapping is enabled or not.
  39510. */
  39511. /**
  39512. * Sets wether tonemapping is enabled or not
  39513. */
  39514. cameraToneMappingEnabled: boolean;
  39515. /**
  39516. * The camera exposure used on this material.
  39517. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39518. * This corresponds to a photographic exposure.
  39519. */
  39520. /**
  39521. * The camera exposure used on this material.
  39522. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39523. * This corresponds to a photographic exposure.
  39524. */
  39525. cameraExposure: number;
  39526. /**
  39527. * Gets The camera contrast used on this material.
  39528. */
  39529. /**
  39530. * Sets The camera contrast used on this material.
  39531. */
  39532. cameraContrast: number;
  39533. /**
  39534. * Gets the Color Grading 2D Lookup Texture.
  39535. */
  39536. /**
  39537. * Sets the Color Grading 2D Lookup Texture.
  39538. */
  39539. cameraColorGradingTexture: Nullable<BaseTexture>;
  39540. /**
  39541. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39542. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39543. * 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;
  39544. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39545. */
  39546. /**
  39547. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39548. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39549. * 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;
  39550. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39551. */
  39552. cameraColorCurves: Nullable<ColorCurves>;
  39553. /**
  39554. * Custom callback helping to override the default shader used in the material.
  39555. */
  39556. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39557. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39558. protected _worldViewProjectionMatrix: Matrix;
  39559. protected _globalAmbientColor: Color3;
  39560. protected _useLogarithmicDepth: boolean;
  39561. /**
  39562. * Instantiates a new standard material.
  39563. * This is the default material used in Babylon. It is the best trade off between quality
  39564. * and performances.
  39565. * @see http://doc.babylonjs.com/babylon101/materials
  39566. * @param name Define the name of the material in the scene
  39567. * @param scene Define the scene the material belong to
  39568. */
  39569. constructor(name: string, scene: Scene);
  39570. /**
  39571. * Gets a boolean indicating that current material needs to register RTT
  39572. */
  39573. readonly hasRenderTargetTextures: boolean;
  39574. /**
  39575. * Gets the current class name of the material e.g. "StandardMaterial"
  39576. * Mainly use in serialization.
  39577. * @returns the class name
  39578. */
  39579. getClassName(): string;
  39580. /**
  39581. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39582. * You can try switching to logarithmic depth.
  39583. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39584. */
  39585. useLogarithmicDepth: boolean;
  39586. /**
  39587. * Specifies if the material will require alpha blending
  39588. * @returns a boolean specifying if alpha blending is needed
  39589. */
  39590. needAlphaBlending(): boolean;
  39591. /**
  39592. * Specifies if this material should be rendered in alpha test mode
  39593. * @returns a boolean specifying if an alpha test is needed.
  39594. */
  39595. needAlphaTesting(): boolean;
  39596. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39597. /**
  39598. * Get the texture used for alpha test purpose.
  39599. * @returns the diffuse texture in case of the standard material.
  39600. */
  39601. getAlphaTestTexture(): Nullable<BaseTexture>;
  39602. /**
  39603. * Get if the submesh is ready to be used and all its information available.
  39604. * Child classes can use it to update shaders
  39605. * @param mesh defines the mesh to check
  39606. * @param subMesh defines which submesh to check
  39607. * @param useInstances specifies that instances should be used
  39608. * @returns a boolean indicating that the submesh is ready or not
  39609. */
  39610. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39611. /**
  39612. * Builds the material UBO layouts.
  39613. * Used internally during the effect preparation.
  39614. */
  39615. buildUniformLayout(): void;
  39616. /**
  39617. * Unbinds the material from the mesh
  39618. */
  39619. unbind(): void;
  39620. /**
  39621. * Binds the submesh to this material by preparing the effect and shader to draw
  39622. * @param world defines the world transformation matrix
  39623. * @param mesh defines the mesh containing the submesh
  39624. * @param subMesh defines the submesh to bind the material to
  39625. */
  39626. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39627. /**
  39628. * Get the list of animatables in the material.
  39629. * @returns the list of animatables object used in the material
  39630. */
  39631. getAnimatables(): IAnimatable[];
  39632. /**
  39633. * Gets the active textures from the material
  39634. * @returns an array of textures
  39635. */
  39636. getActiveTextures(): BaseTexture[];
  39637. /**
  39638. * Specifies if the material uses a texture
  39639. * @param texture defines the texture to check against the material
  39640. * @returns a boolean specifying if the material uses the texture
  39641. */
  39642. hasTexture(texture: BaseTexture): boolean;
  39643. /**
  39644. * Disposes the material
  39645. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39646. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39647. */
  39648. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39649. /**
  39650. * Makes a duplicate of the material, and gives it a new name
  39651. * @param name defines the new name for the duplicated material
  39652. * @returns the cloned material
  39653. */
  39654. clone(name: string): StandardMaterial;
  39655. /**
  39656. * Serializes this material in a JSON representation
  39657. * @returns the serialized material object
  39658. */
  39659. serialize(): any;
  39660. /**
  39661. * Creates a standard material from parsed material data
  39662. * @param source defines the JSON representation of the material
  39663. * @param scene defines the hosting scene
  39664. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39665. * @returns a new standard material
  39666. */
  39667. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39668. /**
  39669. * Are diffuse textures enabled in the application.
  39670. */
  39671. static DiffuseTextureEnabled: boolean;
  39672. /**
  39673. * Are ambient textures enabled in the application.
  39674. */
  39675. static AmbientTextureEnabled: boolean;
  39676. /**
  39677. * Are opacity textures enabled in the application.
  39678. */
  39679. static OpacityTextureEnabled: boolean;
  39680. /**
  39681. * Are reflection textures enabled in the application.
  39682. */
  39683. static ReflectionTextureEnabled: boolean;
  39684. /**
  39685. * Are emissive textures enabled in the application.
  39686. */
  39687. static EmissiveTextureEnabled: boolean;
  39688. /**
  39689. * Are specular textures enabled in the application.
  39690. */
  39691. static SpecularTextureEnabled: boolean;
  39692. /**
  39693. * Are bump textures enabled in the application.
  39694. */
  39695. static BumpTextureEnabled: boolean;
  39696. /**
  39697. * Are lightmap textures enabled in the application.
  39698. */
  39699. static LightmapTextureEnabled: boolean;
  39700. /**
  39701. * Are refraction textures enabled in the application.
  39702. */
  39703. static RefractionTextureEnabled: boolean;
  39704. /**
  39705. * Are color grading textures enabled in the application.
  39706. */
  39707. static ColorGradingTextureEnabled: boolean;
  39708. /**
  39709. * Are fresnels enabled in the application.
  39710. */
  39711. static FresnelEnabled: boolean;
  39712. }
  39713. }
  39714. declare module BABYLON {
  39715. /**
  39716. * A class extending Texture allowing drawing on a texture
  39717. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39718. */
  39719. export class DynamicTexture extends Texture {
  39720. private _generateMipMaps;
  39721. private _canvas;
  39722. private _context;
  39723. private _engine;
  39724. /**
  39725. * Creates a DynamicTexture
  39726. * @param name defines the name of the texture
  39727. * @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
  39728. * @param scene defines the scene where you want the texture
  39729. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39730. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39731. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39732. */
  39733. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39734. /**
  39735. * Get the current class name of the texture useful for serialization or dynamic coding.
  39736. * @returns "DynamicTexture"
  39737. */
  39738. getClassName(): string;
  39739. /**
  39740. * Gets the current state of canRescale
  39741. */
  39742. readonly canRescale: boolean;
  39743. private _recreate;
  39744. /**
  39745. * Scales the texture
  39746. * @param ratio the scale factor to apply to both width and height
  39747. */
  39748. scale(ratio: number): void;
  39749. /**
  39750. * Resizes the texture
  39751. * @param width the new width
  39752. * @param height the new height
  39753. */
  39754. scaleTo(width: number, height: number): void;
  39755. /**
  39756. * Gets the context of the canvas used by the texture
  39757. * @returns the canvas context of the dynamic texture
  39758. */
  39759. getContext(): CanvasRenderingContext2D;
  39760. /**
  39761. * Clears the texture
  39762. */
  39763. clear(): void;
  39764. /**
  39765. * Updates the texture
  39766. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39767. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39768. */
  39769. update(invertY?: boolean, premulAlpha?: boolean): void;
  39770. /**
  39771. * Draws text onto the texture
  39772. * @param text defines the text to be drawn
  39773. * @param x defines the placement of the text from the left
  39774. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39775. * @param font defines the font to be used with font-style, font-size, font-name
  39776. * @param color defines the color used for the text
  39777. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39778. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39779. * @param update defines whether texture is immediately update (default is true)
  39780. */
  39781. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39782. /**
  39783. * Clones the texture
  39784. * @returns the clone of the texture.
  39785. */
  39786. clone(): DynamicTexture;
  39787. /**
  39788. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39789. * @returns a serialized dynamic texture object
  39790. */
  39791. serialize(): any;
  39792. /** @hidden */
  39793. _rebuild(): void;
  39794. }
  39795. }
  39796. declare module BABYLON {
  39797. /** @hidden */
  39798. export var imageProcessingPixelShader: {
  39799. name: string;
  39800. shader: string;
  39801. };
  39802. }
  39803. declare module BABYLON {
  39804. /**
  39805. * ImageProcessingPostProcess
  39806. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39807. */
  39808. export class ImageProcessingPostProcess extends PostProcess {
  39809. /**
  39810. * Default configuration related to image processing available in the PBR Material.
  39811. */
  39812. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39813. /**
  39814. * Gets the image processing configuration used either in this material.
  39815. */
  39816. /**
  39817. * Sets the Default image processing configuration used either in the this material.
  39818. *
  39819. * If sets to null, the scene one is in use.
  39820. */
  39821. imageProcessingConfiguration: ImageProcessingConfiguration;
  39822. /**
  39823. * Keep track of the image processing observer to allow dispose and replace.
  39824. */
  39825. private _imageProcessingObserver;
  39826. /**
  39827. * Attaches a new image processing configuration to the PBR Material.
  39828. * @param configuration
  39829. */
  39830. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39831. /**
  39832. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39833. */
  39834. /**
  39835. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39836. */
  39837. colorCurves: Nullable<ColorCurves>;
  39838. /**
  39839. * Gets wether the color curves effect is enabled.
  39840. */
  39841. /**
  39842. * Sets wether the color curves effect is enabled.
  39843. */
  39844. colorCurvesEnabled: boolean;
  39845. /**
  39846. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39847. */
  39848. /**
  39849. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39850. */
  39851. colorGradingTexture: Nullable<BaseTexture>;
  39852. /**
  39853. * Gets wether the color grading effect is enabled.
  39854. */
  39855. /**
  39856. * Gets wether the color grading effect is enabled.
  39857. */
  39858. colorGradingEnabled: boolean;
  39859. /**
  39860. * Gets exposure used in the effect.
  39861. */
  39862. /**
  39863. * Sets exposure used in the effect.
  39864. */
  39865. exposure: number;
  39866. /**
  39867. * Gets wether tonemapping is enabled or not.
  39868. */
  39869. /**
  39870. * Sets wether tonemapping is enabled or not
  39871. */
  39872. toneMappingEnabled: boolean;
  39873. /**
  39874. * Gets the type of tone mapping effect.
  39875. */
  39876. /**
  39877. * Sets the type of tone mapping effect.
  39878. */
  39879. toneMappingType: number;
  39880. /**
  39881. * Gets contrast used in the effect.
  39882. */
  39883. /**
  39884. * Sets contrast used in the effect.
  39885. */
  39886. contrast: number;
  39887. /**
  39888. * Gets Vignette stretch size.
  39889. */
  39890. /**
  39891. * Sets Vignette stretch size.
  39892. */
  39893. vignetteStretch: number;
  39894. /**
  39895. * Gets Vignette centre X Offset.
  39896. */
  39897. /**
  39898. * Sets Vignette centre X Offset.
  39899. */
  39900. vignetteCentreX: number;
  39901. /**
  39902. * Gets Vignette centre Y Offset.
  39903. */
  39904. /**
  39905. * Sets Vignette centre Y Offset.
  39906. */
  39907. vignetteCentreY: number;
  39908. /**
  39909. * Gets Vignette weight or intensity of the vignette effect.
  39910. */
  39911. /**
  39912. * Sets Vignette weight or intensity of the vignette effect.
  39913. */
  39914. vignetteWeight: number;
  39915. /**
  39916. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39917. * if vignetteEnabled is set to true.
  39918. */
  39919. /**
  39920. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39921. * if vignetteEnabled is set to true.
  39922. */
  39923. vignetteColor: Color4;
  39924. /**
  39925. * Gets Camera field of view used by the Vignette effect.
  39926. */
  39927. /**
  39928. * Sets Camera field of view used by the Vignette effect.
  39929. */
  39930. vignetteCameraFov: number;
  39931. /**
  39932. * Gets the vignette blend mode allowing different kind of effect.
  39933. */
  39934. /**
  39935. * Sets the vignette blend mode allowing different kind of effect.
  39936. */
  39937. vignetteBlendMode: number;
  39938. /**
  39939. * Gets wether the vignette effect is enabled.
  39940. */
  39941. /**
  39942. * Sets wether the vignette effect is enabled.
  39943. */
  39944. vignetteEnabled: boolean;
  39945. private _fromLinearSpace;
  39946. /**
  39947. * Gets wether the input of the processing is in Gamma or Linear Space.
  39948. */
  39949. /**
  39950. * Sets wether the input of the processing is in Gamma or Linear Space.
  39951. */
  39952. fromLinearSpace: boolean;
  39953. /**
  39954. * Defines cache preventing GC.
  39955. */
  39956. private _defines;
  39957. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39958. /**
  39959. * "ImageProcessingPostProcess"
  39960. * @returns "ImageProcessingPostProcess"
  39961. */
  39962. getClassName(): string;
  39963. protected _updateParameters(): void;
  39964. dispose(camera?: Camera): void;
  39965. }
  39966. }
  39967. declare module BABYLON {
  39968. /**
  39969. * Class containing static functions to help procedurally build meshes
  39970. */
  39971. export class GroundBuilder {
  39972. /**
  39973. * Creates a ground mesh
  39974. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39975. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39977. * @param name defines the name of the mesh
  39978. * @param options defines the options used to create the mesh
  39979. * @param scene defines the hosting scene
  39980. * @returns the ground mesh
  39981. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39982. */
  39983. static CreateGround(name: string, options: {
  39984. width?: number;
  39985. height?: number;
  39986. subdivisions?: number;
  39987. subdivisionsX?: number;
  39988. subdivisionsY?: number;
  39989. updatable?: boolean;
  39990. }, scene: any): Mesh;
  39991. /**
  39992. * Creates a tiled ground mesh
  39993. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39994. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39995. * * 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
  39996. * * 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
  39997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39998. * @param name defines the name of the mesh
  39999. * @param options defines the options used to create the mesh
  40000. * @param scene defines the hosting scene
  40001. * @returns the tiled ground mesh
  40002. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40003. */
  40004. static CreateTiledGround(name: string, options: {
  40005. xmin: number;
  40006. zmin: number;
  40007. xmax: number;
  40008. zmax: number;
  40009. subdivisions?: {
  40010. w: number;
  40011. h: number;
  40012. };
  40013. precision?: {
  40014. w: number;
  40015. h: number;
  40016. };
  40017. updatable?: boolean;
  40018. }, scene?: Nullable<Scene>): Mesh;
  40019. /**
  40020. * Creates a ground mesh from a height map
  40021. * * The parameter `url` sets the URL of the height map image resource.
  40022. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40023. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40024. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40025. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40026. * * 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.
  40027. * * 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).
  40028. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40030. * @param name defines the name of the mesh
  40031. * @param url defines the url to the height map
  40032. * @param options defines the options used to create the mesh
  40033. * @param scene defines the hosting scene
  40034. * @returns the ground mesh
  40035. * @see https://doc.babylonjs.com/babylon101/height_map
  40036. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40037. */
  40038. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40039. width?: number;
  40040. height?: number;
  40041. subdivisions?: number;
  40042. minHeight?: number;
  40043. maxHeight?: number;
  40044. colorFilter?: Color3;
  40045. alphaFilter?: number;
  40046. updatable?: boolean;
  40047. onReady?: (mesh: GroundMesh) => void;
  40048. }, scene?: Nullable<Scene>): GroundMesh;
  40049. }
  40050. }
  40051. declare module BABYLON {
  40052. /**
  40053. * Class containing static functions to help procedurally build meshes
  40054. */
  40055. export class TorusBuilder {
  40056. /**
  40057. * Creates a torus mesh
  40058. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40059. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40060. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40062. * * 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
  40063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40064. * @param name defines the name of the mesh
  40065. * @param options defines the options used to create the mesh
  40066. * @param scene defines the hosting scene
  40067. * @returns the torus mesh
  40068. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40069. */
  40070. static CreateTorus(name: string, options: {
  40071. diameter?: number;
  40072. thickness?: number;
  40073. tessellation?: number;
  40074. updatable?: boolean;
  40075. sideOrientation?: number;
  40076. frontUVs?: Vector4;
  40077. backUVs?: Vector4;
  40078. }, scene: any): Mesh;
  40079. }
  40080. }
  40081. declare module BABYLON {
  40082. /**
  40083. * Class containing static functions to help procedurally build meshes
  40084. */
  40085. export class CylinderBuilder {
  40086. /**
  40087. * Creates a cylinder or a cone mesh
  40088. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40089. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40090. * * 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.
  40091. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40092. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40093. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40094. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40095. * * 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).
  40096. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40097. * * 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).
  40098. * * 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
  40099. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40100. * * 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
  40101. * * 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.
  40102. * * If `enclose` is false, a ring surface is one element.
  40103. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40104. * * 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
  40105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40106. * * 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
  40107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40108. * @param name defines the name of the mesh
  40109. * @param options defines the options used to create the mesh
  40110. * @param scene defines the hosting scene
  40111. * @returns the cylinder mesh
  40112. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40113. */
  40114. static CreateCylinder(name: string, options: {
  40115. height?: number;
  40116. diameterTop?: number;
  40117. diameterBottom?: number;
  40118. diameter?: number;
  40119. tessellation?: number;
  40120. subdivisions?: number;
  40121. arc?: number;
  40122. faceColors?: Color4[];
  40123. faceUV?: Vector4[];
  40124. updatable?: boolean;
  40125. hasRings?: boolean;
  40126. enclose?: boolean;
  40127. cap?: number;
  40128. sideOrientation?: number;
  40129. frontUVs?: Vector4;
  40130. backUVs?: Vector4;
  40131. }, scene: any): Mesh;
  40132. }
  40133. }
  40134. declare module BABYLON {
  40135. /**
  40136. * Options to modify the vr teleportation behavior.
  40137. */
  40138. export interface VRTeleportationOptions {
  40139. /**
  40140. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40141. */
  40142. floorMeshName?: string;
  40143. /**
  40144. * A list of meshes to be used as the teleportation floor. (default: empty)
  40145. */
  40146. floorMeshes?: Mesh[];
  40147. }
  40148. /**
  40149. * Options to modify the vr experience helper's behavior.
  40150. */
  40151. export interface VRExperienceHelperOptions extends WebVROptions {
  40152. /**
  40153. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40154. */
  40155. createDeviceOrientationCamera?: boolean;
  40156. /**
  40157. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40158. */
  40159. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40160. /**
  40161. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40162. */
  40163. laserToggle?: boolean;
  40164. /**
  40165. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40166. */
  40167. floorMeshes?: Mesh[];
  40168. /**
  40169. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40170. */
  40171. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40172. }
  40173. /**
  40174. * Event containing information after VR has been entered
  40175. */
  40176. export class OnAfterEnteringVRObservableEvent {
  40177. /**
  40178. * If entering vr was successful
  40179. */
  40180. success: boolean;
  40181. }
  40182. /**
  40183. * Helps to quickly add VR support to an existing scene.
  40184. * See http://doc.babylonjs.com/how_to/webvr_helper
  40185. */
  40186. export class VRExperienceHelper {
  40187. /** Options to modify the vr experience helper's behavior. */
  40188. webVROptions: VRExperienceHelperOptions;
  40189. private _scene;
  40190. private _position;
  40191. private _btnVR;
  40192. private _btnVRDisplayed;
  40193. private _webVRsupported;
  40194. private _webVRready;
  40195. private _webVRrequesting;
  40196. private _webVRpresenting;
  40197. private _hasEnteredVR;
  40198. private _fullscreenVRpresenting;
  40199. private _canvas;
  40200. private _webVRCamera;
  40201. private _vrDeviceOrientationCamera;
  40202. private _deviceOrientationCamera;
  40203. private _existingCamera;
  40204. private _onKeyDown;
  40205. private _onVrDisplayPresentChange;
  40206. private _onVRDisplayChanged;
  40207. private _onVRRequestPresentStart;
  40208. private _onVRRequestPresentComplete;
  40209. /**
  40210. * Observable raised right before entering VR.
  40211. */
  40212. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40213. /**
  40214. * Observable raised when entering VR has completed.
  40215. */
  40216. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40217. /**
  40218. * Observable raised when exiting VR.
  40219. */
  40220. onExitingVRObservable: Observable<VRExperienceHelper>;
  40221. /**
  40222. * Observable raised when controller mesh is loaded.
  40223. */
  40224. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40225. /** Return this.onEnteringVRObservable
  40226. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40227. */
  40228. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40229. /** Return this.onExitingVRObservable
  40230. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40231. */
  40232. readonly onExitingVR: Observable<VRExperienceHelper>;
  40233. /** Return this.onControllerMeshLoadedObservable
  40234. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40235. */
  40236. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40237. private _rayLength;
  40238. private _useCustomVRButton;
  40239. private _teleportationRequested;
  40240. private _teleportActive;
  40241. private _floorMeshName;
  40242. private _floorMeshesCollection;
  40243. private _rotationAllowed;
  40244. private _teleportBackwardsVector;
  40245. private _teleportationTarget;
  40246. private _isDefaultTeleportationTarget;
  40247. private _postProcessMove;
  40248. private _teleportationFillColor;
  40249. private _teleportationBorderColor;
  40250. private _rotationAngle;
  40251. private _haloCenter;
  40252. private _cameraGazer;
  40253. private _padSensibilityUp;
  40254. private _padSensibilityDown;
  40255. private _leftController;
  40256. private _rightController;
  40257. /**
  40258. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40259. */
  40260. onNewMeshSelected: Observable<AbstractMesh>;
  40261. /**
  40262. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40263. */
  40264. onNewMeshPicked: Observable<PickingInfo>;
  40265. private _circleEase;
  40266. /**
  40267. * Observable raised before camera teleportation
  40268. */
  40269. onBeforeCameraTeleport: Observable<Vector3>;
  40270. /**
  40271. * Observable raised after camera teleportation
  40272. */
  40273. onAfterCameraTeleport: Observable<Vector3>;
  40274. /**
  40275. * Observable raised when current selected mesh gets unselected
  40276. */
  40277. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40278. private _raySelectionPredicate;
  40279. /**
  40280. * To be optionaly changed by user to define custom ray selection
  40281. */
  40282. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40283. /**
  40284. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40285. */
  40286. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40287. /**
  40288. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40289. */
  40290. teleportationEnabled: boolean;
  40291. private _defaultHeight;
  40292. private _teleportationInitialized;
  40293. private _interactionsEnabled;
  40294. private _interactionsRequested;
  40295. private _displayGaze;
  40296. private _displayLaserPointer;
  40297. /**
  40298. * The mesh used to display where the user is going to teleport.
  40299. */
  40300. /**
  40301. * Sets the mesh to be used to display where the user is going to teleport.
  40302. */
  40303. teleportationTarget: Mesh;
  40304. /**
  40305. * 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
  40306. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40307. * See http://doc.babylonjs.com/resources/baking_transformations
  40308. */
  40309. gazeTrackerMesh: Mesh;
  40310. /**
  40311. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40312. */
  40313. updateGazeTrackerScale: boolean;
  40314. /**
  40315. * If the gaze trackers color should be updated when selecting meshes
  40316. */
  40317. updateGazeTrackerColor: boolean;
  40318. /**
  40319. * The gaze tracking mesh corresponding to the left controller
  40320. */
  40321. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40322. /**
  40323. * The gaze tracking mesh corresponding to the right controller
  40324. */
  40325. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40326. /**
  40327. * If the ray of the gaze should be displayed.
  40328. */
  40329. /**
  40330. * Sets if the ray of the gaze should be displayed.
  40331. */
  40332. displayGaze: boolean;
  40333. /**
  40334. * If the ray of the LaserPointer should be displayed.
  40335. */
  40336. /**
  40337. * Sets if the ray of the LaserPointer should be displayed.
  40338. */
  40339. displayLaserPointer: boolean;
  40340. /**
  40341. * The deviceOrientationCamera used as the camera when not in VR.
  40342. */
  40343. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40344. /**
  40345. * Based on the current WebVR support, returns the current VR camera used.
  40346. */
  40347. readonly currentVRCamera: Nullable<Camera>;
  40348. /**
  40349. * The webVRCamera which is used when in VR.
  40350. */
  40351. readonly webVRCamera: WebVRFreeCamera;
  40352. /**
  40353. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40354. */
  40355. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40356. private readonly _teleportationRequestInitiated;
  40357. /**
  40358. * Defines wether or not Pointer lock should be requested when switching to
  40359. * full screen.
  40360. */
  40361. requestPointerLockOnFullScreen: boolean;
  40362. /**
  40363. * Instantiates a VRExperienceHelper.
  40364. * Helps to quickly add VR support to an existing scene.
  40365. * @param scene The scene the VRExperienceHelper belongs to.
  40366. * @param webVROptions Options to modify the vr experience helper's behavior.
  40367. */
  40368. constructor(scene: Scene,
  40369. /** Options to modify the vr experience helper's behavior. */
  40370. webVROptions?: VRExperienceHelperOptions);
  40371. private _onDefaultMeshLoaded;
  40372. private _onResize;
  40373. private _onFullscreenChange;
  40374. /**
  40375. * Gets a value indicating if we are currently in VR mode.
  40376. */
  40377. readonly isInVRMode: boolean;
  40378. private onVrDisplayPresentChange;
  40379. private onVRDisplayChanged;
  40380. private moveButtonToBottomRight;
  40381. private displayVRButton;
  40382. private updateButtonVisibility;
  40383. private _cachedAngularSensibility;
  40384. /**
  40385. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40386. * Otherwise, will use the fullscreen API.
  40387. */
  40388. enterVR(): void;
  40389. /**
  40390. * Attempt to exit VR, or fullscreen.
  40391. */
  40392. exitVR(): void;
  40393. /**
  40394. * The position of the vr experience helper.
  40395. */
  40396. /**
  40397. * Sets the position of the vr experience helper.
  40398. */
  40399. position: Vector3;
  40400. /**
  40401. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40402. */
  40403. enableInteractions(): void;
  40404. private readonly _noControllerIsActive;
  40405. private beforeRender;
  40406. private _isTeleportationFloor;
  40407. /**
  40408. * Adds a floor mesh to be used for teleportation.
  40409. * @param floorMesh the mesh to be used for teleportation.
  40410. */
  40411. addFloorMesh(floorMesh: Mesh): void;
  40412. /**
  40413. * Removes a floor mesh from being used for teleportation.
  40414. * @param floorMesh the mesh to be removed.
  40415. */
  40416. removeFloorMesh(floorMesh: Mesh): void;
  40417. /**
  40418. * Enables interactions and teleportation using the VR controllers and gaze.
  40419. * @param vrTeleportationOptions options to modify teleportation behavior.
  40420. */
  40421. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40422. private _onNewGamepadConnected;
  40423. private _tryEnableInteractionOnController;
  40424. private _onNewGamepadDisconnected;
  40425. private _enableInteractionOnController;
  40426. private _checkTeleportWithRay;
  40427. private _checkRotate;
  40428. private _checkTeleportBackwards;
  40429. private _enableTeleportationOnController;
  40430. private _createTeleportationCircles;
  40431. private _displayTeleportationTarget;
  40432. private _hideTeleportationTarget;
  40433. private _rotateCamera;
  40434. private _moveTeleportationSelectorTo;
  40435. private _workingVector;
  40436. private _workingQuaternion;
  40437. private _workingMatrix;
  40438. /**
  40439. * Teleports the users feet to the desired location
  40440. * @param location The location where the user's feet should be placed
  40441. */
  40442. teleportCamera(location: Vector3): void;
  40443. private _convertNormalToDirectionOfRay;
  40444. private _castRayAndSelectObject;
  40445. private _notifySelectedMeshUnselected;
  40446. /**
  40447. * Sets the color of the laser ray from the vr controllers.
  40448. * @param color new color for the ray.
  40449. */
  40450. changeLaserColor(color: Color3): void;
  40451. /**
  40452. * Sets the color of the ray from the vr headsets gaze.
  40453. * @param color new color for the ray.
  40454. */
  40455. changeGazeColor(color: Color3): void;
  40456. /**
  40457. * Exits VR and disposes of the vr experience helper
  40458. */
  40459. dispose(): void;
  40460. /**
  40461. * Gets the name of the VRExperienceHelper class
  40462. * @returns "VRExperienceHelper"
  40463. */
  40464. getClassName(): string;
  40465. }
  40466. }
  40467. declare module BABYLON {
  40468. /**
  40469. * Manages an XRSession
  40470. * @see https://doc.babylonjs.com/how_to/webxr
  40471. */
  40472. export class WebXRSessionManager implements IDisposable {
  40473. private scene;
  40474. /**
  40475. * Fires every time a new xrFrame arrives which can be used to update the camera
  40476. */
  40477. onXRFrameObservable: Observable<any>;
  40478. /**
  40479. * Fires when the xr session is ended either by the device or manually done
  40480. */
  40481. onXRSessionEnded: Observable<any>;
  40482. /** @hidden */
  40483. _xrSession: XRSession;
  40484. /** @hidden */
  40485. _frameOfReference: XRFrameOfReference;
  40486. /** @hidden */
  40487. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40488. /** @hidden */
  40489. _currentXRFrame: Nullable<XRFrame>;
  40490. private _xrNavigator;
  40491. private _xrDevice;
  40492. private _tmpMatrix;
  40493. /**
  40494. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40495. * @param scene The scene which the session should be created for
  40496. */
  40497. constructor(scene: Scene);
  40498. /**
  40499. * Initializes the manager
  40500. * After initialization enterXR can be called to start an XR session
  40501. * @returns Promise which resolves after it is initialized
  40502. */
  40503. initializeAsync(): Promise<void>;
  40504. /**
  40505. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40506. * @param sessionCreationOptions xr options to create the session with
  40507. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40508. * @returns Promise which resolves after it enters XR
  40509. */
  40510. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40511. /**
  40512. * Stops the xrSession and restores the renderloop
  40513. * @returns Promise which resolves after it exits XR
  40514. */
  40515. exitXRAsync(): Promise<void>;
  40516. /**
  40517. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40518. * @param ray ray to cast into the environment
  40519. * @returns Promise which resolves with a collision point in the environment if it exists
  40520. */
  40521. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40522. /**
  40523. * Checks if a session would be supported for the creation options specified
  40524. * @param options creation options to check if they are supported
  40525. * @returns true if supported
  40526. */
  40527. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40528. /**
  40529. * @hidden
  40530. * Converts the render layer of xrSession to a render target
  40531. * @param session session to create render target for
  40532. * @param scene scene the new render target should be created for
  40533. */
  40534. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40535. /**
  40536. * Disposes of the session manager
  40537. */
  40538. dispose(): void;
  40539. }
  40540. }
  40541. declare module BABYLON {
  40542. /**
  40543. * WebXR Camera which holds the views for the xrSession
  40544. * @see https://doc.babylonjs.com/how_to/webxr
  40545. */
  40546. export class WebXRCamera extends FreeCamera {
  40547. private static _TmpMatrix;
  40548. /**
  40549. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40550. * @param name the name of the camera
  40551. * @param scene the scene to add the camera to
  40552. */
  40553. constructor(name: string, scene: Scene);
  40554. private _updateNumberOfRigCameras;
  40555. /** @hidden */
  40556. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40557. /**
  40558. * Updates the cameras position from the current pose information of the XR session
  40559. * @param xrSessionManager the session containing pose information
  40560. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40561. */
  40562. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40563. }
  40564. }
  40565. declare module BABYLON {
  40566. /**
  40567. * States of the webXR experience
  40568. */
  40569. export enum WebXRState {
  40570. /**
  40571. * Transitioning to being in XR mode
  40572. */
  40573. ENTERING_XR = 0,
  40574. /**
  40575. * Transitioning to non XR mode
  40576. */
  40577. EXITING_XR = 1,
  40578. /**
  40579. * In XR mode and presenting
  40580. */
  40581. IN_XR = 2,
  40582. /**
  40583. * Not entered XR mode
  40584. */
  40585. NOT_IN_XR = 3
  40586. }
  40587. /**
  40588. * Helper class used to enable XR
  40589. * @see https://doc.babylonjs.com/how_to/webxr
  40590. */
  40591. export class WebXRExperienceHelper implements IDisposable {
  40592. private scene;
  40593. /**
  40594. * 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
  40595. */
  40596. container: AbstractMesh;
  40597. /**
  40598. * Camera used to render xr content
  40599. */
  40600. camera: WebXRCamera;
  40601. /**
  40602. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40603. */
  40604. state: WebXRState;
  40605. private _setState;
  40606. private static _TmpVector;
  40607. /**
  40608. * Fires when the state of the experience helper has changed
  40609. */
  40610. onStateChangedObservable: Observable<WebXRState>;
  40611. /** @hidden */
  40612. _sessionManager: WebXRSessionManager;
  40613. private _nonVRCamera;
  40614. private _originalSceneAutoClear;
  40615. private _supported;
  40616. /**
  40617. * Creates the experience helper
  40618. * @param scene the scene to attach the experience helper to
  40619. * @returns a promise for the experience helper
  40620. */
  40621. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40622. /**
  40623. * Creates a WebXRExperienceHelper
  40624. * @param scene The scene the helper should be created in
  40625. */
  40626. private constructor();
  40627. /**
  40628. * Exits XR mode and returns the scene to its original state
  40629. * @returns promise that resolves after xr mode has exited
  40630. */
  40631. exitXRAsync(): Promise<void>;
  40632. /**
  40633. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40634. * @param sessionCreationOptions options for the XR session
  40635. * @param frameOfReference frame of reference of the XR session
  40636. * @returns promise that resolves after xr mode has entered
  40637. */
  40638. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40639. /**
  40640. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40641. * @param ray ray to cast into the environment
  40642. * @returns Promise which resolves with a collision point in the environment if it exists
  40643. */
  40644. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40645. /**
  40646. * Updates the global position of the camera by moving the camera's container
  40647. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40648. * @param position The desired global position of the camera
  40649. */
  40650. setPositionOfCameraUsingContainer(position: Vector3): void;
  40651. /**
  40652. * Rotates the xr camera by rotating the camera's container around the camera's position
  40653. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40654. * @param rotation the desired quaternion rotation to apply to the camera
  40655. */
  40656. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40657. /**
  40658. * Checks if the creation options are supported by the xr session
  40659. * @param options creation options
  40660. * @returns true if supported
  40661. */
  40662. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40663. /**
  40664. * Disposes of the experience helper
  40665. */
  40666. dispose(): void;
  40667. }
  40668. }
  40669. declare module BABYLON {
  40670. /**
  40671. * Button which can be used to enter a different mode of XR
  40672. */
  40673. export class WebXREnterExitUIButton {
  40674. /** button element */
  40675. element: HTMLElement;
  40676. /** XR initialization options for the button */
  40677. initializationOptions: XRSessionCreationOptions;
  40678. /**
  40679. * Creates a WebXREnterExitUIButton
  40680. * @param element button element
  40681. * @param initializationOptions XR initialization options for the button
  40682. */
  40683. constructor(
  40684. /** button element */
  40685. element: HTMLElement,
  40686. /** XR initialization options for the button */
  40687. initializationOptions: XRSessionCreationOptions);
  40688. /**
  40689. * Overwritable function which can be used to update the button's visuals when the state changes
  40690. * @param activeButton the current active button in the UI
  40691. */
  40692. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40693. }
  40694. /**
  40695. * Options to create the webXR UI
  40696. */
  40697. export class WebXREnterExitUIOptions {
  40698. /**
  40699. * Context to enter xr with
  40700. */
  40701. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40702. /**
  40703. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40704. */
  40705. customButtons?: Array<WebXREnterExitUIButton>;
  40706. }
  40707. /**
  40708. * UI to allow the user to enter/exit XR mode
  40709. */
  40710. export class WebXREnterExitUI implements IDisposable {
  40711. private scene;
  40712. private _overlay;
  40713. private _buttons;
  40714. private _activeButton;
  40715. /**
  40716. * Fired every time the active button is changed.
  40717. *
  40718. * When xr is entered via a button that launches xr that button will be the callback parameter
  40719. *
  40720. * When exiting xr the callback parameter will be null)
  40721. */
  40722. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40723. /**
  40724. * Creates UI to allow the user to enter/exit XR mode
  40725. * @param scene the scene to add the ui to
  40726. * @param helper the xr experience helper to enter/exit xr with
  40727. * @param options options to configure the UI
  40728. * @returns the created ui
  40729. */
  40730. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40731. private constructor();
  40732. private _updateButtons;
  40733. /**
  40734. * Disposes of the object
  40735. */
  40736. dispose(): void;
  40737. }
  40738. }
  40739. declare module BABYLON {
  40740. /**
  40741. * Represents an XR input
  40742. */
  40743. export class WebXRController {
  40744. /**
  40745. * 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
  40746. */
  40747. grip?: AbstractMesh;
  40748. /**
  40749. * Pointer which can be used to select objects or attach a visible laser to
  40750. */
  40751. pointer: AbstractMesh;
  40752. /**
  40753. * Creates the controller
  40754. * @see https://doc.babylonjs.com/how_to/webxr
  40755. * @param scene the scene which the controller should be associated to
  40756. */
  40757. constructor(scene: Scene);
  40758. /**
  40759. * Disposes of the object
  40760. */
  40761. dispose(): void;
  40762. }
  40763. /**
  40764. * XR input used to track XR inputs such as controllers/rays
  40765. */
  40766. export class WebXRInput implements IDisposable {
  40767. private helper;
  40768. /**
  40769. * XR controllers being tracked
  40770. */
  40771. controllers: Array<WebXRController>;
  40772. private _tmpMatrix;
  40773. private _frameObserver;
  40774. /**
  40775. * Initializes the WebXRInput
  40776. * @param helper experience helper which the input should be created for
  40777. */
  40778. constructor(helper: WebXRExperienceHelper);
  40779. /**
  40780. * Disposes of the object
  40781. */
  40782. dispose(): void;
  40783. }
  40784. }
  40785. declare module BABYLON {
  40786. /**
  40787. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40788. */
  40789. export class WebXRManagedOutputCanvas implements IDisposable {
  40790. private _canvas;
  40791. /**
  40792. * xrpresent context of the canvas which can be used to display/mirror xr content
  40793. */
  40794. canvasContext: Nullable<WebGLRenderingContext>;
  40795. /**
  40796. * Initializes the canvas to be added/removed upon entering/exiting xr
  40797. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40798. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40799. */
  40800. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40801. /**
  40802. * Disposes of the object
  40803. */
  40804. dispose(): void;
  40805. private _setManagedOutputCanvas;
  40806. private _addCanvas;
  40807. private _removeCanvas;
  40808. }
  40809. }
  40810. declare module BABYLON {
  40811. /**
  40812. * Contains an array of blocks representing the octree
  40813. */
  40814. export interface IOctreeContainer<T> {
  40815. /**
  40816. * Blocks within the octree
  40817. */
  40818. blocks: Array<OctreeBlock<T>>;
  40819. }
  40820. /**
  40821. * Class used to store a cell in an octree
  40822. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40823. */
  40824. export class OctreeBlock<T> {
  40825. /**
  40826. * Gets the content of the current block
  40827. */
  40828. entries: T[];
  40829. /**
  40830. * Gets the list of block children
  40831. */
  40832. blocks: Array<OctreeBlock<T>>;
  40833. private _depth;
  40834. private _maxDepth;
  40835. private _capacity;
  40836. private _minPoint;
  40837. private _maxPoint;
  40838. private _boundingVectors;
  40839. private _creationFunc;
  40840. /**
  40841. * Creates a new block
  40842. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40843. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40844. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40845. * @param depth defines the current depth of this block in the octree
  40846. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40847. * @param creationFunc defines a callback to call when an element is added to the block
  40848. */
  40849. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40850. /**
  40851. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40852. */
  40853. readonly capacity: number;
  40854. /**
  40855. * Gets the minimum vector (in world space) of the block's bounding box
  40856. */
  40857. readonly minPoint: Vector3;
  40858. /**
  40859. * Gets the maximum vector (in world space) of the block's bounding box
  40860. */
  40861. readonly maxPoint: Vector3;
  40862. /**
  40863. * Add a new element to this block
  40864. * @param entry defines the element to add
  40865. */
  40866. addEntry(entry: T): void;
  40867. /**
  40868. * Remove an element from this block
  40869. * @param entry defines the element to remove
  40870. */
  40871. removeEntry(entry: T): void;
  40872. /**
  40873. * Add an array of elements to this block
  40874. * @param entries defines the array of elements to add
  40875. */
  40876. addEntries(entries: T[]): void;
  40877. /**
  40878. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40879. * @param frustumPlanes defines the frustum planes to test
  40880. * @param selection defines the array to store current content if selection is positive
  40881. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40882. */
  40883. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40884. /**
  40885. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40886. * @param sphereCenter defines the bounding sphere center
  40887. * @param sphereRadius defines the bounding sphere radius
  40888. * @param selection defines the array to store current content if selection is positive
  40889. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40890. */
  40891. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40892. /**
  40893. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40894. * @param ray defines the ray to test with
  40895. * @param selection defines the array to store current content if selection is positive
  40896. */
  40897. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40898. /**
  40899. * Subdivide the content into child blocks (this block will then be empty)
  40900. */
  40901. createInnerBlocks(): void;
  40902. /**
  40903. * @hidden
  40904. */
  40905. 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;
  40906. }
  40907. }
  40908. declare module BABYLON {
  40909. /**
  40910. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40911. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40912. */
  40913. export class Octree<T> {
  40914. /** 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.) */
  40915. maxDepth: number;
  40916. /**
  40917. * Blocks within the octree containing objects
  40918. */
  40919. blocks: Array<OctreeBlock<T>>;
  40920. /**
  40921. * Content stored in the octree
  40922. */
  40923. dynamicContent: T[];
  40924. private _maxBlockCapacity;
  40925. private _selectionContent;
  40926. private _creationFunc;
  40927. /**
  40928. * Creates a octree
  40929. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40930. * @param creationFunc function to be used to instatiate the octree
  40931. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40932. * @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.)
  40933. */
  40934. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40935. /** 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.) */
  40936. maxDepth?: number);
  40937. /**
  40938. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40939. * @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);
  40940. * @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);
  40941. * @param entries meshes to be added to the octree blocks
  40942. */
  40943. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40944. /**
  40945. * Adds a mesh to the octree
  40946. * @param entry Mesh to add to the octree
  40947. */
  40948. addMesh(entry: T): void;
  40949. /**
  40950. * Remove an element from the octree
  40951. * @param entry defines the element to remove
  40952. */
  40953. removeMesh(entry: T): void;
  40954. /**
  40955. * Selects an array of meshes within the frustum
  40956. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40957. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40958. * @returns array of meshes within the frustum
  40959. */
  40960. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40961. /**
  40962. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40963. * @param sphereCenter defines the bounding sphere center
  40964. * @param sphereRadius defines the bounding sphere radius
  40965. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40966. * @returns an array of objects that intersect the sphere
  40967. */
  40968. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40969. /**
  40970. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40971. * @param ray defines the ray to test with
  40972. * @returns array of intersected objects
  40973. */
  40974. intersectsRay(ray: Ray): SmartArray<T>;
  40975. /**
  40976. * Adds a mesh into the octree block if it intersects the block
  40977. */
  40978. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40979. /**
  40980. * Adds a submesh into the octree block if it intersects the block
  40981. */
  40982. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40983. }
  40984. }
  40985. declare module BABYLON {
  40986. interface Scene {
  40987. /**
  40988. * @hidden
  40989. * Backing Filed
  40990. */
  40991. _selectionOctree: Octree<AbstractMesh>;
  40992. /**
  40993. * Gets the octree used to boost mesh selection (picking)
  40994. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40995. */
  40996. selectionOctree: Octree<AbstractMesh>;
  40997. /**
  40998. * Creates or updates the octree used to boost selection (picking)
  40999. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41000. * @param maxCapacity defines the maximum capacity per leaf
  41001. * @param maxDepth defines the maximum depth of the octree
  41002. * @returns an octree of AbstractMesh
  41003. */
  41004. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41005. }
  41006. interface AbstractMesh {
  41007. /**
  41008. * @hidden
  41009. * Backing Field
  41010. */
  41011. _submeshesOctree: Octree<SubMesh>;
  41012. /**
  41013. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41014. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41015. * @param maxCapacity defines the maximum size of each block (64 by default)
  41016. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41017. * @returns the new octree
  41018. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41019. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41020. */
  41021. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41022. }
  41023. /**
  41024. * Defines the octree scene component responsible to manage any octrees
  41025. * in a given scene.
  41026. */
  41027. export class OctreeSceneComponent {
  41028. /**
  41029. * The component name help to identify the component in the list of scene components.
  41030. */
  41031. readonly name: string;
  41032. /**
  41033. * The scene the component belongs to.
  41034. */
  41035. scene: Scene;
  41036. /**
  41037. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41038. */
  41039. readonly checksIsEnabled: boolean;
  41040. /**
  41041. * Creates a new instance of the component for the given scene
  41042. * @param scene Defines the scene to register the component in
  41043. */
  41044. constructor(scene: Scene);
  41045. /**
  41046. * Registers the component in a given scene
  41047. */
  41048. register(): void;
  41049. /**
  41050. * Return the list of active meshes
  41051. * @returns the list of active meshes
  41052. */
  41053. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41054. /**
  41055. * Return the list of active sub meshes
  41056. * @param mesh The mesh to get the candidates sub meshes from
  41057. * @returns the list of active sub meshes
  41058. */
  41059. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41060. private _tempRay;
  41061. /**
  41062. * Return the list of sub meshes intersecting with a given local ray
  41063. * @param mesh defines the mesh to find the submesh for
  41064. * @param localRay defines the ray in local space
  41065. * @returns the list of intersecting sub meshes
  41066. */
  41067. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41068. /**
  41069. * Return the list of sub meshes colliding with a collider
  41070. * @param mesh defines the mesh to find the submesh for
  41071. * @param collider defines the collider to evaluate the collision against
  41072. * @returns the list of colliding sub meshes
  41073. */
  41074. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41075. /**
  41076. * Rebuilds the elements related to this component in case of
  41077. * context lost for instance.
  41078. */
  41079. rebuild(): void;
  41080. /**
  41081. * Disposes the component and the associated ressources.
  41082. */
  41083. dispose(): void;
  41084. }
  41085. }
  41086. declare module BABYLON {
  41087. /**
  41088. * Renders a layer on top of an existing scene
  41089. */
  41090. export class UtilityLayerRenderer implements IDisposable {
  41091. /** the original scene that will be rendered on top of */
  41092. originalScene: Scene;
  41093. private _pointerCaptures;
  41094. private _lastPointerEvents;
  41095. private static _DefaultUtilityLayer;
  41096. private static _DefaultKeepDepthUtilityLayer;
  41097. private _sharedGizmoLight;
  41098. private _renderCamera;
  41099. /**
  41100. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  41101. * @returns the camera that is used when rendering the utility layer
  41102. */
  41103. getRenderCamera(): Nullable<Camera>;
  41104. /**
  41105. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  41106. * @param cam the camera that should be used when rendering the utility layer
  41107. */
  41108. setRenderCamera(cam: Nullable<Camera>): void;
  41109. /**
  41110. * @hidden
  41111. * Light which used by gizmos to get light shading
  41112. */
  41113. _getSharedGizmoLight(): HemisphericLight;
  41114. /**
  41115. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41116. */
  41117. pickUtilitySceneFirst: boolean;
  41118. /**
  41119. * 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)
  41120. */
  41121. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41122. /**
  41123. * 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)
  41124. */
  41125. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41126. /**
  41127. * The scene that is rendered on top of the original scene
  41128. */
  41129. utilityLayerScene: Scene;
  41130. /**
  41131. * If the utility layer should automatically be rendered on top of existing scene
  41132. */
  41133. shouldRender: boolean;
  41134. /**
  41135. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41136. */
  41137. onlyCheckPointerDownEvents: boolean;
  41138. /**
  41139. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41140. */
  41141. processAllEvents: boolean;
  41142. /**
  41143. * Observable raised when the pointer move from the utility layer scene to the main scene
  41144. */
  41145. onPointerOutObservable: Observable<number>;
  41146. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41147. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41148. private _afterRenderObserver;
  41149. private _sceneDisposeObserver;
  41150. private _originalPointerObserver;
  41151. /**
  41152. * Instantiates a UtilityLayerRenderer
  41153. * @param originalScene the original scene that will be rendered on top of
  41154. * @param handleEvents boolean indicating if the utility layer should handle events
  41155. */
  41156. constructor(
  41157. /** the original scene that will be rendered on top of */
  41158. originalScene: Scene, handleEvents?: boolean);
  41159. private _notifyObservers;
  41160. /**
  41161. * Renders the utility layers scene on top of the original scene
  41162. */
  41163. render(): void;
  41164. /**
  41165. * Disposes of the renderer
  41166. */
  41167. dispose(): void;
  41168. private _updateCamera;
  41169. }
  41170. }
  41171. declare module BABYLON {
  41172. /**
  41173. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41174. */
  41175. export class Gizmo implements IDisposable {
  41176. /** The utility layer the gizmo will be added to */
  41177. gizmoLayer: UtilityLayerRenderer;
  41178. /**
  41179. * The root mesh of the gizmo
  41180. */
  41181. _rootMesh: Mesh;
  41182. private _attachedMesh;
  41183. /**
  41184. * Ratio for the scale of the gizmo (Default: 1)
  41185. */
  41186. scaleRatio: number;
  41187. /**
  41188. * If a custom mesh has been set (Default: false)
  41189. */
  41190. protected _customMeshSet: boolean;
  41191. /**
  41192. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41193. * * When set, interactions will be enabled
  41194. */
  41195. attachedMesh: Nullable<AbstractMesh>;
  41196. /**
  41197. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41198. * @param mesh The mesh to replace the default mesh of the gizmo
  41199. */
  41200. setCustomMesh(mesh: Mesh): void;
  41201. /**
  41202. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41203. */
  41204. updateGizmoRotationToMatchAttachedMesh: boolean;
  41205. /**
  41206. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41207. */
  41208. updateGizmoPositionToMatchAttachedMesh: boolean;
  41209. /**
  41210. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41211. */
  41212. protected _updateScale: boolean;
  41213. protected _interactionsEnabled: boolean;
  41214. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41215. private _beforeRenderObserver;
  41216. private _tempVector;
  41217. /**
  41218. * Creates a gizmo
  41219. * @param gizmoLayer The utility layer the gizmo will be added to
  41220. */
  41221. constructor(
  41222. /** The utility layer the gizmo will be added to */
  41223. gizmoLayer?: UtilityLayerRenderer);
  41224. /**
  41225. * Updates the gizmo to match the attached mesh's position/rotation
  41226. */
  41227. protected _update(): void;
  41228. /**
  41229. * Disposes of the gizmo
  41230. */
  41231. dispose(): void;
  41232. }
  41233. }
  41234. declare module BABYLON {
  41235. /**
  41236. * Single plane drag gizmo
  41237. */
  41238. export class PlaneDragGizmo extends Gizmo {
  41239. /**
  41240. * Drag behavior responsible for the gizmos dragging interactions
  41241. */
  41242. dragBehavior: PointerDragBehavior;
  41243. private _pointerObserver;
  41244. /**
  41245. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41246. */
  41247. snapDistance: number;
  41248. /**
  41249. * Event that fires each time the gizmo snaps to a new location.
  41250. * * snapDistance is the the change in distance
  41251. */
  41252. onSnapObservable: Observable<{
  41253. snapDistance: number;
  41254. }>;
  41255. private _plane;
  41256. private _coloredMaterial;
  41257. private _hoverMaterial;
  41258. private _isEnabled;
  41259. private _parent;
  41260. /** @hidden */
  41261. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  41262. /** @hidden */
  41263. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41264. /**
  41265. * Creates a PlaneDragGizmo
  41266. * @param gizmoLayer The utility layer the gizmo will be added to
  41267. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  41268. * @param color The color of the gizmo
  41269. */
  41270. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41271. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41272. /**
  41273. * If the gizmo is enabled
  41274. */
  41275. isEnabled: boolean;
  41276. /**
  41277. * Disposes of the gizmo
  41278. */
  41279. dispose(): void;
  41280. }
  41281. }
  41282. declare module BABYLON {
  41283. /**
  41284. * Gizmo that enables dragging a mesh along 3 axis
  41285. */
  41286. export class PositionGizmo extends Gizmo {
  41287. /**
  41288. * Internal gizmo used for interactions on the x axis
  41289. */
  41290. xGizmo: AxisDragGizmo;
  41291. /**
  41292. * Internal gizmo used for interactions on the y axis
  41293. */
  41294. yGizmo: AxisDragGizmo;
  41295. /**
  41296. * Internal gizmo used for interactions on the z axis
  41297. */
  41298. zGizmo: AxisDragGizmo;
  41299. /**
  41300. * Internal gizmo used for interactions on the yz plane
  41301. */
  41302. xPlaneGizmo: PlaneDragGizmo;
  41303. /**
  41304. * Internal gizmo used for interactions on the xz plane
  41305. */
  41306. yPlaneGizmo: PlaneDragGizmo;
  41307. /**
  41308. * Internal gizmo used for interactions on the xy plane
  41309. */
  41310. zPlaneGizmo: PlaneDragGizmo;
  41311. /**
  41312. * private variables
  41313. */
  41314. private _meshAttached;
  41315. private _updateGizmoRotationToMatchAttachedMesh;
  41316. private _snapDistance;
  41317. private _scaleRatio;
  41318. /** Fires an event when any of it's sub gizmos are dragged */
  41319. onDragStartObservable: Observable<{}>;
  41320. /** Fires an event when any of it's sub gizmos are released from dragging */
  41321. onDragEndObservable: Observable<{}>;
  41322. /**
  41323. * If set to true, planar drag is enabled
  41324. */
  41325. private _planarGizmoEnabled;
  41326. attachedMesh: Nullable<AbstractMesh>;
  41327. /**
  41328. * Creates a PositionGizmo
  41329. * @param gizmoLayer The utility layer the gizmo will be added to
  41330. */
  41331. constructor(gizmoLayer?: UtilityLayerRenderer);
  41332. /**
  41333. * If the planar drag gizmo is enabled
  41334. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  41335. */
  41336. planarGizmoEnabled: boolean;
  41337. updateGizmoRotationToMatchAttachedMesh: boolean;
  41338. /**
  41339. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41340. */
  41341. snapDistance: number;
  41342. /**
  41343. * Ratio for the scale of the gizmo (Default: 1)
  41344. */
  41345. scaleRatio: number;
  41346. /**
  41347. * Disposes of the gizmo
  41348. */
  41349. dispose(): void;
  41350. /**
  41351. * CustomMeshes are not supported by this gizmo
  41352. * @param mesh The mesh to replace the default mesh of the gizmo
  41353. */
  41354. setCustomMesh(mesh: Mesh): void;
  41355. }
  41356. }
  41357. declare module BABYLON {
  41358. /**
  41359. * Single axis drag gizmo
  41360. */
  41361. export class AxisDragGizmo extends Gizmo {
  41362. /**
  41363. * Drag behavior responsible for the gizmos dragging interactions
  41364. */
  41365. dragBehavior: PointerDragBehavior;
  41366. private _pointerObserver;
  41367. /**
  41368. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41369. */
  41370. snapDistance: number;
  41371. /**
  41372. * Event that fires each time the gizmo snaps to a new location.
  41373. * * snapDistance is the the change in distance
  41374. */
  41375. onSnapObservable: Observable<{
  41376. snapDistance: number;
  41377. }>;
  41378. private _isEnabled;
  41379. private _parent;
  41380. private _arrow;
  41381. private _coloredMaterial;
  41382. private _hoverMaterial;
  41383. /** @hidden */
  41384. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41385. /** @hidden */
  41386. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41387. /**
  41388. * Creates an AxisDragGizmo
  41389. * @param gizmoLayer The utility layer the gizmo will be added to
  41390. * @param dragAxis The axis which the gizmo will be able to drag on
  41391. * @param color The color of the gizmo
  41392. */
  41393. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41394. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41395. /**
  41396. * If the gizmo is enabled
  41397. */
  41398. isEnabled: boolean;
  41399. /**
  41400. * Disposes of the gizmo
  41401. */
  41402. dispose(): void;
  41403. }
  41404. }
  41405. declare module BABYLON.Debug {
  41406. /**
  41407. * The Axes viewer will show 3 axes in a specific point in space
  41408. */
  41409. export class AxesViewer {
  41410. private _xAxis;
  41411. private _yAxis;
  41412. private _zAxis;
  41413. private _scaleLinesFactor;
  41414. private _instanced;
  41415. /**
  41416. * Gets the hosting scene
  41417. */
  41418. scene: Scene;
  41419. /**
  41420. * Gets or sets a number used to scale line length
  41421. */
  41422. scaleLines: number;
  41423. /** Gets the node hierarchy used to render x-axis */
  41424. readonly xAxis: TransformNode;
  41425. /** Gets the node hierarchy used to render y-axis */
  41426. readonly yAxis: TransformNode;
  41427. /** Gets the node hierarchy used to render z-axis */
  41428. readonly zAxis: TransformNode;
  41429. /**
  41430. * Creates a new AxesViewer
  41431. * @param scene defines the hosting scene
  41432. * @param scaleLines defines a number used to scale line length (1 by default)
  41433. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41434. * @param xAxis defines the node hierarchy used to render the x-axis
  41435. * @param yAxis defines the node hierarchy used to render the y-axis
  41436. * @param zAxis defines the node hierarchy used to render the z-axis
  41437. */
  41438. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41439. /**
  41440. * Force the viewer to update
  41441. * @param position defines the position of the viewer
  41442. * @param xaxis defines the x axis of the viewer
  41443. * @param yaxis defines the y axis of the viewer
  41444. * @param zaxis defines the z axis of the viewer
  41445. */
  41446. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41447. /**
  41448. * Creates an instance of this axes viewer.
  41449. * @returns a new axes viewer with instanced meshes
  41450. */
  41451. createInstance(): AxesViewer;
  41452. /** Releases resources */
  41453. dispose(): void;
  41454. private static _SetRenderingGroupId;
  41455. }
  41456. }
  41457. declare module BABYLON.Debug {
  41458. /**
  41459. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41460. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41461. */
  41462. export class BoneAxesViewer extends AxesViewer {
  41463. /**
  41464. * Gets or sets the target mesh where to display the axes viewer
  41465. */
  41466. mesh: Nullable<Mesh>;
  41467. /**
  41468. * Gets or sets the target bone where to display the axes viewer
  41469. */
  41470. bone: Nullable<Bone>;
  41471. /** Gets current position */
  41472. pos: Vector3;
  41473. /** Gets direction of X axis */
  41474. xaxis: Vector3;
  41475. /** Gets direction of Y axis */
  41476. yaxis: Vector3;
  41477. /** Gets direction of Z axis */
  41478. zaxis: Vector3;
  41479. /**
  41480. * Creates a new BoneAxesViewer
  41481. * @param scene defines the hosting scene
  41482. * @param bone defines the target bone
  41483. * @param mesh defines the target mesh
  41484. * @param scaleLines defines a scaling factor for line length (1 by default)
  41485. */
  41486. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41487. /**
  41488. * Force the viewer to update
  41489. */
  41490. update(): void;
  41491. /** Releases resources */
  41492. dispose(): void;
  41493. }
  41494. }
  41495. declare module BABYLON {
  41496. /**
  41497. * Interface used to define scene explorer extensibility option
  41498. */
  41499. export interface IExplorerExtensibilityOption {
  41500. /**
  41501. * Define the option label
  41502. */
  41503. label: string;
  41504. /**
  41505. * Defines the action to execute on click
  41506. */
  41507. action: (entity: any) => void;
  41508. }
  41509. /**
  41510. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41511. */
  41512. export interface IExplorerExtensibilityGroup {
  41513. /**
  41514. * Defines a predicate to test if a given type mut be extended
  41515. */
  41516. predicate: (entity: any) => boolean;
  41517. /**
  41518. * Gets the list of options added to a type
  41519. */
  41520. entries: IExplorerExtensibilityOption[];
  41521. }
  41522. /**
  41523. * Interface used to define the options to use to create the Inspector
  41524. */
  41525. export interface IInspectorOptions {
  41526. /**
  41527. * Display in overlay mode (default: false)
  41528. */
  41529. overlay?: boolean;
  41530. /**
  41531. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41532. */
  41533. globalRoot?: HTMLElement;
  41534. /**
  41535. * Display the Scene explorer
  41536. */
  41537. showExplorer?: boolean;
  41538. /**
  41539. * Display the property inspector
  41540. */
  41541. showInspector?: boolean;
  41542. /**
  41543. * Display in embed mode (both panes on the right)
  41544. */
  41545. embedMode?: boolean;
  41546. /**
  41547. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41548. */
  41549. handleResize?: boolean;
  41550. /**
  41551. * Allow the panes to popup (default: true)
  41552. */
  41553. enablePopup?: boolean;
  41554. /**
  41555. * Allow the panes to be closed by users (default: true)
  41556. */
  41557. enableClose?: boolean;
  41558. /**
  41559. * Optional list of extensibility entries
  41560. */
  41561. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41562. /**
  41563. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41564. */
  41565. inspectorURL?: string;
  41566. }
  41567. interface Scene {
  41568. /**
  41569. * @hidden
  41570. * Backing field
  41571. */
  41572. _debugLayer: DebugLayer;
  41573. /**
  41574. * Gets the debug layer (aka Inspector) associated with the scene
  41575. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41576. */
  41577. debugLayer: DebugLayer;
  41578. }
  41579. /**
  41580. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41581. * what is happening in your scene
  41582. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41583. */
  41584. export class DebugLayer {
  41585. /**
  41586. * Define the url to get the inspector script from.
  41587. * By default it uses the babylonjs CDN.
  41588. * @ignoreNaming
  41589. */
  41590. static InspectorURL: string;
  41591. private _scene;
  41592. private BJSINSPECTOR;
  41593. private _onPropertyChangedObservable?;
  41594. /**
  41595. * Observable triggered when a property is changed through the inspector.
  41596. */
  41597. readonly onPropertyChangedObservable: any;
  41598. /**
  41599. * Instantiates a new debug layer.
  41600. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41601. * what is happening in your scene
  41602. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41603. * @param scene Defines the scene to inspect
  41604. */
  41605. constructor(scene: Scene);
  41606. /** Creates the inspector window. */
  41607. private _createInspector;
  41608. /**
  41609. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41610. * @param entity defines the entity to select
  41611. * @param lineContainerTitle defines the specific block to highlight
  41612. */
  41613. select(entity: any, lineContainerTitle?: string): void;
  41614. /** Get the inspector from bundle or global */
  41615. private _getGlobalInspector;
  41616. /**
  41617. * Get if the inspector is visible or not.
  41618. * @returns true if visible otherwise, false
  41619. */
  41620. isVisible(): boolean;
  41621. /**
  41622. * Hide the inspector and close its window.
  41623. */
  41624. hide(): void;
  41625. /**
  41626. * Launch the debugLayer.
  41627. * @param config Define the configuration of the inspector
  41628. * @return a promise fulfilled when the debug layer is visible
  41629. */
  41630. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41631. }
  41632. }
  41633. declare module BABYLON {
  41634. /**
  41635. * Class containing static functions to help procedurally build meshes
  41636. */
  41637. export class BoxBuilder {
  41638. /**
  41639. * Creates a box mesh
  41640. * * The parameter `size` sets the size (float) of each box side (default 1)
  41641. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41642. * * 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)
  41643. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41645. * * 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
  41646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41647. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41648. * @param name defines the name of the mesh
  41649. * @param options defines the options used to create the mesh
  41650. * @param scene defines the hosting scene
  41651. * @returns the box mesh
  41652. */
  41653. static CreateBox(name: string, options: {
  41654. size?: number;
  41655. width?: number;
  41656. height?: number;
  41657. depth?: number;
  41658. faceUV?: Vector4[];
  41659. faceColors?: Color4[];
  41660. sideOrientation?: number;
  41661. frontUVs?: Vector4;
  41662. backUVs?: Vector4;
  41663. wrap?: boolean;
  41664. topBaseAt?: number;
  41665. bottomBaseAt?: number;
  41666. updatable?: boolean;
  41667. }, scene?: Nullable<Scene>): Mesh;
  41668. }
  41669. }
  41670. declare module BABYLON {
  41671. /**
  41672. * Class containing static functions to help procedurally build meshes
  41673. */
  41674. export class SphereBuilder {
  41675. /**
  41676. * Creates a sphere mesh
  41677. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41678. * * 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`)
  41679. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41680. * * 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
  41681. * * 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)
  41682. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41683. * * 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
  41684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41685. * @param name defines the name of the mesh
  41686. * @param options defines the options used to create the mesh
  41687. * @param scene defines the hosting scene
  41688. * @returns the sphere mesh
  41689. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41690. */
  41691. static CreateSphere(name: string, options: {
  41692. segments?: number;
  41693. diameter?: number;
  41694. diameterX?: number;
  41695. diameterY?: number;
  41696. diameterZ?: number;
  41697. arc?: number;
  41698. slice?: number;
  41699. sideOrientation?: number;
  41700. frontUVs?: Vector4;
  41701. backUVs?: Vector4;
  41702. updatable?: boolean;
  41703. }, scene: any): Mesh;
  41704. }
  41705. }
  41706. declare module BABYLON.Debug {
  41707. /**
  41708. * Used to show the physics impostor around the specific mesh
  41709. */
  41710. export class PhysicsViewer {
  41711. /** @hidden */
  41712. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41713. /** @hidden */
  41714. protected _meshes: Array<Nullable<AbstractMesh>>;
  41715. /** @hidden */
  41716. protected _scene: Nullable<Scene>;
  41717. /** @hidden */
  41718. protected _numMeshes: number;
  41719. /** @hidden */
  41720. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41721. private _renderFunction;
  41722. private _utilityLayer;
  41723. private _debugBoxMesh;
  41724. private _debugSphereMesh;
  41725. private _debugCylinderMesh;
  41726. private _debugMaterial;
  41727. private _debugMeshMeshes;
  41728. /**
  41729. * Creates a new PhysicsViewer
  41730. * @param scene defines the hosting scene
  41731. */
  41732. constructor(scene: Scene);
  41733. /** @hidden */
  41734. protected _updateDebugMeshes(): void;
  41735. /**
  41736. * Renders a specified physic impostor
  41737. * @param impostor defines the impostor to render
  41738. * @param targetMesh defines the mesh represented by the impostor
  41739. * @returns the new debug mesh used to render the impostor
  41740. */
  41741. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  41742. /**
  41743. * Hides a specified physic impostor
  41744. * @param impostor defines the impostor to hide
  41745. */
  41746. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41747. private _getDebugMaterial;
  41748. private _getDebugBoxMesh;
  41749. private _getDebugSphereMesh;
  41750. private _getDebugCylinderMesh;
  41751. private _getDebugMeshMesh;
  41752. private _getDebugMesh;
  41753. /** Releases all resources */
  41754. dispose(): void;
  41755. }
  41756. }
  41757. declare module BABYLON {
  41758. /**
  41759. * Class containing static functions to help procedurally build meshes
  41760. */
  41761. export class LinesBuilder {
  41762. /**
  41763. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41764. * * 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
  41765. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41766. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41767. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41768. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41769. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41770. * * 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
  41771. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  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#line-system
  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 system mesh
  41778. */
  41779. static CreateLineSystem(name: string, options: {
  41780. lines: Vector3[][];
  41781. updatable?: boolean;
  41782. instance?: Nullable<LinesMesh>;
  41783. colors?: Nullable<Color4[][]>;
  41784. useVertexAlpha?: boolean;
  41785. }, scene: Nullable<Scene>): LinesMesh;
  41786. /**
  41787. * Creates a line mesh
  41788. * 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
  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 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
  41792. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41793. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41794. * * When updating an instance, remember that only point positions can change, not the number of points
  41795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41796. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41797. * @param name defines the name of the new line system
  41798. * @param options defines the options used to create the line system
  41799. * @param scene defines the hosting scene
  41800. * @returns a new line mesh
  41801. */
  41802. static CreateLines(name: string, options: {
  41803. points: Vector3[];
  41804. updatable?: boolean;
  41805. instance?: Nullable<LinesMesh>;
  41806. colors?: Color4[];
  41807. useVertexAlpha?: boolean;
  41808. }, scene?: Nullable<Scene>): LinesMesh;
  41809. /**
  41810. * Creates a dashed line mesh
  41811. * * 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
  41812. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41813. * * The parameter `points` is an array successive Vector3
  41814. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41815. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41816. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41817. * * 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
  41818. * * When updating an instance, remember that only point positions can change, not the number of points
  41819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41820. * @param name defines the name of the mesh
  41821. * @param options defines the options used to create the mesh
  41822. * @param scene defines the hosting scene
  41823. * @returns the dashed line mesh
  41824. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41825. */
  41826. static CreateDashedLines(name: string, options: {
  41827. points: Vector3[];
  41828. dashSize?: number;
  41829. gapSize?: number;
  41830. dashNb?: number;
  41831. updatable?: boolean;
  41832. instance?: LinesMesh;
  41833. }, scene?: Nullable<Scene>): LinesMesh;
  41834. }
  41835. }
  41836. declare module BABYLON {
  41837. /**
  41838. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41839. * in order to better appreciate the issue one might have.
  41840. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41841. */
  41842. export class RayHelper {
  41843. /**
  41844. * Defines the ray we are currently tryin to visualize.
  41845. */
  41846. ray: Nullable<Ray>;
  41847. private _renderPoints;
  41848. private _renderLine;
  41849. private _renderFunction;
  41850. private _scene;
  41851. private _updateToMeshFunction;
  41852. private _attachedToMesh;
  41853. private _meshSpaceDirection;
  41854. private _meshSpaceOrigin;
  41855. /**
  41856. * Helper function to create a colored helper in a scene in one line.
  41857. * @param ray Defines the ray we are currently tryin to visualize
  41858. * @param scene Defines the scene the ray is used in
  41859. * @param color Defines the color we want to see the ray in
  41860. * @returns The newly created ray helper.
  41861. */
  41862. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41863. /**
  41864. * Instantiate a new ray helper.
  41865. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41866. * in order to better appreciate the issue one might have.
  41867. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41868. * @param ray Defines the ray we are currently tryin to visualize
  41869. */
  41870. constructor(ray: Ray);
  41871. /**
  41872. * Shows the ray we are willing to debug.
  41873. * @param scene Defines the scene the ray needs to be rendered in
  41874. * @param color Defines the color the ray needs to be rendered in
  41875. */
  41876. show(scene: Scene, color?: Color3): void;
  41877. /**
  41878. * Hides the ray we are debugging.
  41879. */
  41880. hide(): void;
  41881. private _render;
  41882. /**
  41883. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41884. * @param mesh Defines the mesh we want the helper attached to
  41885. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41886. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41887. * @param length Defines the length of the ray
  41888. */
  41889. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41890. /**
  41891. * Detach the ray helper from the mesh it has previously been attached to.
  41892. */
  41893. detachFromMesh(): void;
  41894. private _updateToMesh;
  41895. /**
  41896. * Dispose the helper and release its associated resources.
  41897. */
  41898. dispose(): void;
  41899. }
  41900. }
  41901. declare module BABYLON.Debug {
  41902. /**
  41903. * Class used to render a debug view of a given skeleton
  41904. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41905. */
  41906. export class SkeletonViewer {
  41907. /** defines the skeleton to render */
  41908. skeleton: Skeleton;
  41909. /** defines the mesh attached to the skeleton */
  41910. mesh: AbstractMesh;
  41911. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41912. autoUpdateBonesMatrices: boolean;
  41913. /** defines the rendering group id to use with the viewer */
  41914. renderingGroupId: number;
  41915. /** Gets or sets the color used to render the skeleton */
  41916. color: Color3;
  41917. private _scene;
  41918. private _debugLines;
  41919. private _debugMesh;
  41920. private _isEnabled;
  41921. private _renderFunction;
  41922. private _utilityLayer;
  41923. /**
  41924. * Returns the mesh used to render the bones
  41925. */
  41926. readonly debugMesh: Nullable<LinesMesh>;
  41927. /**
  41928. * Creates a new SkeletonViewer
  41929. * @param skeleton defines the skeleton to render
  41930. * @param mesh defines the mesh attached to the skeleton
  41931. * @param scene defines the hosting scene
  41932. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41933. * @param renderingGroupId defines the rendering group id to use with the viewer
  41934. */
  41935. constructor(
  41936. /** defines the skeleton to render */
  41937. skeleton: Skeleton,
  41938. /** defines the mesh attached to the skeleton */
  41939. mesh: AbstractMesh, scene: Scene,
  41940. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41941. autoUpdateBonesMatrices?: boolean,
  41942. /** defines the rendering group id to use with the viewer */
  41943. renderingGroupId?: number);
  41944. /** Gets or sets a boolean indicating if the viewer is enabled */
  41945. isEnabled: boolean;
  41946. private _getBonePosition;
  41947. private _getLinesForBonesWithLength;
  41948. private _getLinesForBonesNoLength;
  41949. /** Update the viewer to sync with current skeleton state */
  41950. update(): void;
  41951. /** Release associated resources */
  41952. dispose(): void;
  41953. }
  41954. }
  41955. declare module BABYLON {
  41956. /**
  41957. * Options to create the null engine
  41958. */
  41959. export class NullEngineOptions {
  41960. /**
  41961. * Render width (Default: 512)
  41962. */
  41963. renderWidth: number;
  41964. /**
  41965. * Render height (Default: 256)
  41966. */
  41967. renderHeight: number;
  41968. /**
  41969. * Texture size (Default: 512)
  41970. */
  41971. textureSize: number;
  41972. /**
  41973. * If delta time between frames should be constant
  41974. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41975. */
  41976. deterministicLockstep: boolean;
  41977. /**
  41978. * Maximum about of steps between frames (Default: 4)
  41979. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41980. */
  41981. lockstepMaxSteps: number;
  41982. }
  41983. /**
  41984. * The null engine class provides support for headless version of babylon.js.
  41985. * This can be used in server side scenario or for testing purposes
  41986. */
  41987. export class NullEngine extends Engine {
  41988. private _options;
  41989. /**
  41990. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41991. */
  41992. isDeterministicLockStep(): boolean;
  41993. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41994. getLockstepMaxSteps(): number;
  41995. /**
  41996. * Sets hardware scaling, used to save performance if needed
  41997. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41998. */
  41999. getHardwareScalingLevel(): number;
  42000. constructor(options?: NullEngineOptions);
  42001. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42002. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42003. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42004. getRenderWidth(useScreen?: boolean): number;
  42005. getRenderHeight(useScreen?: boolean): number;
  42006. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42007. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42008. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42009. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42010. bindSamplers(effect: Effect): void;
  42011. enableEffect(effect: Effect): void;
  42012. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42013. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42014. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42015. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42016. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42017. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42018. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42019. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42020. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42021. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42022. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42023. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42024. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42025. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42026. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42027. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42028. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42029. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42030. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42031. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42032. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42033. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42034. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42035. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42036. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42037. bindBuffers(vertexBuffers: {
  42038. [key: string]: VertexBuffer;
  42039. }, indexBuffer: DataBuffer, effect: Effect): void;
  42040. wipeCaches(bruteForce?: boolean): void;
  42041. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42042. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42043. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42044. /** @hidden */
  42045. _createTexture(): WebGLTexture;
  42046. /** @hidden */
  42047. _releaseTexture(texture: InternalTexture): void;
  42048. 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;
  42049. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42050. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42051. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42052. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42053. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  42054. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42055. areAllEffectsReady(): boolean;
  42056. /**
  42057. * @hidden
  42058. * Get the current error code of the webGL context
  42059. * @returns the error code
  42060. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42061. */
  42062. getError(): number;
  42063. /** @hidden */
  42064. _getUnpackAlignement(): number;
  42065. /** @hidden */
  42066. _unpackFlipY(value: boolean): void;
  42067. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42068. /**
  42069. * Updates a dynamic vertex buffer.
  42070. * @param vertexBuffer the vertex buffer to update
  42071. * @param data the data used to update the vertex buffer
  42072. * @param byteOffset the byte offset of the data (optional)
  42073. * @param byteLength the byte length of the data (optional)
  42074. */
  42075. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42076. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42077. /** @hidden */
  42078. _bindTexture(channel: number, texture: InternalTexture): void;
  42079. /** @hidden */
  42080. _releaseBuffer(buffer: DataBuffer): boolean;
  42081. releaseEffects(): void;
  42082. displayLoadingUI(): void;
  42083. hideLoadingUI(): void;
  42084. /** @hidden */
  42085. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42086. /** @hidden */
  42087. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42088. /** @hidden */
  42089. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42090. /** @hidden */
  42091. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42092. }
  42093. }
  42094. declare module BABYLON {
  42095. /** @hidden */
  42096. export class _OcclusionDataStorage {
  42097. /** @hidden */
  42098. occlusionInternalRetryCounter: number;
  42099. /** @hidden */
  42100. isOcclusionQueryInProgress: boolean;
  42101. /** @hidden */
  42102. isOccluded: boolean;
  42103. /** @hidden */
  42104. occlusionRetryCount: number;
  42105. /** @hidden */
  42106. occlusionType: number;
  42107. /** @hidden */
  42108. occlusionQueryAlgorithmType: number;
  42109. }
  42110. interface Engine {
  42111. /**
  42112. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42113. * @return the new query
  42114. */
  42115. createQuery(): WebGLQuery;
  42116. /**
  42117. * Delete and release a webGL query
  42118. * @param query defines the query to delete
  42119. * @return the current engine
  42120. */
  42121. deleteQuery(query: WebGLQuery): Engine;
  42122. /**
  42123. * Check if a given query has resolved and got its value
  42124. * @param query defines the query to check
  42125. * @returns true if the query got its value
  42126. */
  42127. isQueryResultAvailable(query: WebGLQuery): boolean;
  42128. /**
  42129. * Gets the value of a given query
  42130. * @param query defines the query to check
  42131. * @returns the value of the query
  42132. */
  42133. getQueryResult(query: WebGLQuery): number;
  42134. /**
  42135. * Initiates an occlusion query
  42136. * @param algorithmType defines the algorithm to use
  42137. * @param query defines the query to use
  42138. * @returns the current engine
  42139. * @see http://doc.babylonjs.com/features/occlusionquery
  42140. */
  42141. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42142. /**
  42143. * Ends an occlusion query
  42144. * @see http://doc.babylonjs.com/features/occlusionquery
  42145. * @param algorithmType defines the algorithm to use
  42146. * @returns the current engine
  42147. */
  42148. endOcclusionQuery(algorithmType: number): Engine;
  42149. /**
  42150. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42151. * Please note that only one query can be issued at a time
  42152. * @returns a time token used to track the time span
  42153. */
  42154. startTimeQuery(): Nullable<_TimeToken>;
  42155. /**
  42156. * Ends a time query
  42157. * @param token defines the token used to measure the time span
  42158. * @returns the time spent (in ns)
  42159. */
  42160. endTimeQuery(token: _TimeToken): int;
  42161. /** @hidden */
  42162. _currentNonTimestampToken: Nullable<_TimeToken>;
  42163. /** @hidden */
  42164. _createTimeQuery(): WebGLQuery;
  42165. /** @hidden */
  42166. _deleteTimeQuery(query: WebGLQuery): void;
  42167. /** @hidden */
  42168. _getGlAlgorithmType(algorithmType: number): number;
  42169. /** @hidden */
  42170. _getTimeQueryResult(query: WebGLQuery): any;
  42171. /** @hidden */
  42172. _getTimeQueryAvailability(query: WebGLQuery): any;
  42173. }
  42174. interface AbstractMesh {
  42175. /**
  42176. * Backing filed
  42177. * @hidden
  42178. */
  42179. __occlusionDataStorage: _OcclusionDataStorage;
  42180. /**
  42181. * Access property
  42182. * @hidden
  42183. */
  42184. _occlusionDataStorage: _OcclusionDataStorage;
  42185. /**
  42186. * 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.
  42187. * The default value is -1 which means don't break the query and wait till the result
  42188. * @see http://doc.babylonjs.com/features/occlusionquery
  42189. */
  42190. occlusionRetryCount: number;
  42191. /**
  42192. * 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:
  42193. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42194. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42195. * * 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.
  42196. * @see http://doc.babylonjs.com/features/occlusionquery
  42197. */
  42198. occlusionType: number;
  42199. /**
  42200. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42201. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42202. * * 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.
  42203. * @see http://doc.babylonjs.com/features/occlusionquery
  42204. */
  42205. occlusionQueryAlgorithmType: number;
  42206. /**
  42207. * 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
  42208. * @see http://doc.babylonjs.com/features/occlusionquery
  42209. */
  42210. isOccluded: boolean;
  42211. /**
  42212. * Flag to check the progress status of the query
  42213. * @see http://doc.babylonjs.com/features/occlusionquery
  42214. */
  42215. isOcclusionQueryInProgress: boolean;
  42216. }
  42217. }
  42218. declare module BABYLON {
  42219. /** @hidden */
  42220. export var _forceTransformFeedbackToBundle: boolean;
  42221. interface Engine {
  42222. /**
  42223. * Creates a webGL transform feedback object
  42224. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42225. * @returns the webGL transform feedback object
  42226. */
  42227. createTransformFeedback(): WebGLTransformFeedback;
  42228. /**
  42229. * Delete a webGL transform feedback object
  42230. * @param value defines the webGL transform feedback object to delete
  42231. */
  42232. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42233. /**
  42234. * Bind a webGL transform feedback object to the webgl context
  42235. * @param value defines the webGL transform feedback object to bind
  42236. */
  42237. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42238. /**
  42239. * Begins a transform feedback operation
  42240. * @param usePoints defines if points or triangles must be used
  42241. */
  42242. beginTransformFeedback(usePoints: boolean): void;
  42243. /**
  42244. * Ends a transform feedback operation
  42245. */
  42246. endTransformFeedback(): void;
  42247. /**
  42248. * Specify the varyings to use with transform feedback
  42249. * @param program defines the associated webGL program
  42250. * @param value defines the list of strings representing the varying names
  42251. */
  42252. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42253. /**
  42254. * Bind a webGL buffer for a transform feedback operation
  42255. * @param value defines the webGL buffer to bind
  42256. */
  42257. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  42258. }
  42259. }
  42260. declare module BABYLON {
  42261. /**
  42262. * Creation options of the multi render target texture.
  42263. */
  42264. export interface IMultiRenderTargetOptions {
  42265. /**
  42266. * Define if the texture needs to create mip maps after render.
  42267. */
  42268. generateMipMaps?: boolean;
  42269. /**
  42270. * Define the types of all the draw buffers we want to create
  42271. */
  42272. types?: number[];
  42273. /**
  42274. * Define the sampling modes of all the draw buffers we want to create
  42275. */
  42276. samplingModes?: number[];
  42277. /**
  42278. * Define if a depth buffer is required
  42279. */
  42280. generateDepthBuffer?: boolean;
  42281. /**
  42282. * Define if a stencil buffer is required
  42283. */
  42284. generateStencilBuffer?: boolean;
  42285. /**
  42286. * Define if a depth texture is required instead of a depth buffer
  42287. */
  42288. generateDepthTexture?: boolean;
  42289. /**
  42290. * Define the number of desired draw buffers
  42291. */
  42292. textureCount?: number;
  42293. /**
  42294. * Define if aspect ratio should be adapted to the texture or stay the scene one
  42295. */
  42296. doNotChangeAspectRatio?: boolean;
  42297. /**
  42298. * Define the default type of the buffers we are creating
  42299. */
  42300. defaultType?: number;
  42301. }
  42302. /**
  42303. * A multi render target, like a render target provides the ability to render to a texture.
  42304. * Unlike the render target, it can render to several draw buffers in one draw.
  42305. * This is specially interesting in deferred rendering or for any effects requiring more than
  42306. * just one color from a single pass.
  42307. */
  42308. export class MultiRenderTarget extends RenderTargetTexture {
  42309. private _internalTextures;
  42310. private _textures;
  42311. private _multiRenderTargetOptions;
  42312. /**
  42313. * Get if draw buffers are currently supported by the used hardware and browser.
  42314. */
  42315. readonly isSupported: boolean;
  42316. /**
  42317. * Get the list of textures generated by the multi render target.
  42318. */
  42319. readonly textures: Texture[];
  42320. /**
  42321. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  42322. */
  42323. readonly depthTexture: Texture;
  42324. /**
  42325. * Set the wrapping mode on U of all the textures we are rendering to.
  42326. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  42327. */
  42328. wrapU: number;
  42329. /**
  42330. * Set the wrapping mode on V of all the textures we are rendering to.
  42331. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  42332. */
  42333. wrapV: number;
  42334. /**
  42335. * Instantiate a new multi render target texture.
  42336. * A multi render target, like a render target provides the ability to render to a texture.
  42337. * Unlike the render target, it can render to several draw buffers in one draw.
  42338. * This is specially interesting in deferred rendering or for any effects requiring more than
  42339. * just one color from a single pass.
  42340. * @param name Define the name of the texture
  42341. * @param size Define the size of the buffers to render to
  42342. * @param count Define the number of target we are rendering into
  42343. * @param scene Define the scene the texture belongs to
  42344. * @param options Define the options used to create the multi render target
  42345. */
  42346. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  42347. /** @hidden */
  42348. _rebuild(): void;
  42349. private _createInternalTextures;
  42350. private _createTextures;
  42351. /**
  42352. * Define the number of samples used if MSAA is enabled.
  42353. */
  42354. samples: number;
  42355. /**
  42356. * Resize all the textures in the multi render target.
  42357. * Be carrefull as it will recreate all the data in the new texture.
  42358. * @param size Define the new size
  42359. */
  42360. resize(size: any): void;
  42361. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  42362. /**
  42363. * Dispose the render targets and their associated resources
  42364. */
  42365. dispose(): void;
  42366. /**
  42367. * Release all the underlying texture used as draw buffers.
  42368. */
  42369. releaseInternalTextures(): void;
  42370. }
  42371. }
  42372. declare module BABYLON {
  42373. interface Engine {
  42374. /**
  42375. * Unbind a list of render target textures from the webGL context
  42376. * This is used only when drawBuffer extension or webGL2 are active
  42377. * @param textures defines the render target textures to unbind
  42378. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  42379. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  42380. */
  42381. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  42382. /**
  42383. * Create a multi render target texture
  42384. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  42385. * @param size defines the size of the texture
  42386. * @param options defines the creation options
  42387. * @returns the cube texture as an InternalTexture
  42388. */
  42389. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  42390. /**
  42391. * Update the sample count for a given multiple render target texture
  42392. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42393. * @param textures defines the textures to update
  42394. * @param samples defines the sample count to set
  42395. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42396. */
  42397. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  42398. }
  42399. }
  42400. declare module BABYLON {
  42401. /**
  42402. * Gather the list of clipboard event types as constants.
  42403. */
  42404. export class ClipboardEventTypes {
  42405. /**
  42406. * The clipboard event is fired when a copy command is active (pressed).
  42407. */
  42408. static readonly COPY: number;
  42409. /**
  42410. * The clipboard event is fired when a cut command is active (pressed).
  42411. */
  42412. static readonly CUT: number;
  42413. /**
  42414. * The clipboard event is fired when a paste command is active (pressed).
  42415. */
  42416. static readonly PASTE: number;
  42417. }
  42418. /**
  42419. * This class is used to store clipboard related info for the onClipboardObservable event.
  42420. */
  42421. export class ClipboardInfo {
  42422. /**
  42423. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42424. */
  42425. type: number;
  42426. /**
  42427. * Defines the related dom event
  42428. */
  42429. event: ClipboardEvent;
  42430. /**
  42431. *Creates an instance of ClipboardInfo.
  42432. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42433. * @param event Defines the related dom event
  42434. */
  42435. constructor(
  42436. /**
  42437. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42438. */
  42439. type: number,
  42440. /**
  42441. * Defines the related dom event
  42442. */
  42443. event: ClipboardEvent);
  42444. /**
  42445. * Get the clipboard event's type from the keycode.
  42446. * @param keyCode Defines the keyCode for the current keyboard event.
  42447. * @return {number}
  42448. */
  42449. static GetTypeFromCharacter(keyCode: number): number;
  42450. }
  42451. }
  42452. declare module BABYLON {
  42453. /**
  42454. * Class used to represent data loading progression
  42455. */
  42456. export class SceneLoaderProgressEvent {
  42457. /** defines if data length to load can be evaluated */
  42458. readonly lengthComputable: boolean;
  42459. /** defines the loaded data length */
  42460. readonly loaded: number;
  42461. /** defines the data length to load */
  42462. readonly total: number;
  42463. /**
  42464. * Create a new progress event
  42465. * @param lengthComputable defines if data length to load can be evaluated
  42466. * @param loaded defines the loaded data length
  42467. * @param total defines the data length to load
  42468. */
  42469. constructor(
  42470. /** defines if data length to load can be evaluated */
  42471. lengthComputable: boolean,
  42472. /** defines the loaded data length */
  42473. loaded: number,
  42474. /** defines the data length to load */
  42475. total: number);
  42476. /**
  42477. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42478. * @param event defines the source event
  42479. * @returns a new SceneLoaderProgressEvent
  42480. */
  42481. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42482. }
  42483. /**
  42484. * Interface used by SceneLoader plugins to define supported file extensions
  42485. */
  42486. export interface ISceneLoaderPluginExtensions {
  42487. /**
  42488. * Defines the list of supported extensions
  42489. */
  42490. [extension: string]: {
  42491. isBinary: boolean;
  42492. };
  42493. }
  42494. /**
  42495. * Interface used by SceneLoader plugin factory
  42496. */
  42497. export interface ISceneLoaderPluginFactory {
  42498. /**
  42499. * Defines the name of the factory
  42500. */
  42501. name: string;
  42502. /**
  42503. * Function called to create a new plugin
  42504. * @return the new plugin
  42505. */
  42506. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42507. /**
  42508. * Boolean indicating if the plugin can direct load specific data
  42509. */
  42510. canDirectLoad?: (data: string) => boolean;
  42511. }
  42512. /**
  42513. * Interface used to define a SceneLoader plugin
  42514. */
  42515. export interface ISceneLoaderPlugin {
  42516. /**
  42517. * The friendly name of this plugin.
  42518. */
  42519. name: string;
  42520. /**
  42521. * The file extensions supported by this plugin.
  42522. */
  42523. extensions: string | ISceneLoaderPluginExtensions;
  42524. /**
  42525. * Import meshes into a scene.
  42526. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42527. * @param scene The scene to import into
  42528. * @param data The data to import
  42529. * @param rootUrl The root url for scene and resources
  42530. * @param meshes The meshes array to import into
  42531. * @param particleSystems The particle systems array to import into
  42532. * @param skeletons The skeletons array to import into
  42533. * @param onError The callback when import fails
  42534. * @returns True if successful or false otherwise
  42535. */
  42536. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42537. /**
  42538. * Load into a scene.
  42539. * @param scene The scene to load into
  42540. * @param data The data to import
  42541. * @param rootUrl The root url for scene and resources
  42542. * @param onError The callback when import fails
  42543. * @returns true if successful or false otherwise
  42544. */
  42545. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42546. /**
  42547. * The callback that returns true if the data can be directly loaded.
  42548. */
  42549. canDirectLoad?: (data: string) => boolean;
  42550. /**
  42551. * The callback that allows custom handling of the root url based on the response url.
  42552. */
  42553. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42554. /**
  42555. * Load into an asset container.
  42556. * @param scene The scene to load into
  42557. * @param data The data to import
  42558. * @param rootUrl The root url for scene and resources
  42559. * @param onError The callback when import fails
  42560. * @returns The loaded asset container
  42561. */
  42562. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42563. }
  42564. /**
  42565. * Interface used to define an async SceneLoader plugin
  42566. */
  42567. export interface ISceneLoaderPluginAsync {
  42568. /**
  42569. * The friendly name of this plugin.
  42570. */
  42571. name: string;
  42572. /**
  42573. * The file extensions supported by this plugin.
  42574. */
  42575. extensions: string | ISceneLoaderPluginExtensions;
  42576. /**
  42577. * Import meshes into a scene.
  42578. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42579. * @param scene The scene to import into
  42580. * @param data The data to import
  42581. * @param rootUrl The root url for scene and resources
  42582. * @param onProgress The callback when the load progresses
  42583. * @param fileName Defines the name of the file to load
  42584. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42585. */
  42586. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42587. meshes: AbstractMesh[];
  42588. particleSystems: IParticleSystem[];
  42589. skeletons: Skeleton[];
  42590. animationGroups: AnimationGroup[];
  42591. }>;
  42592. /**
  42593. * Load into a scene.
  42594. * @param scene The scene to load into
  42595. * @param data The data to import
  42596. * @param rootUrl The root url for scene and resources
  42597. * @param onProgress The callback when the load progresses
  42598. * @param fileName Defines the name of the file to load
  42599. * @returns Nothing
  42600. */
  42601. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42602. /**
  42603. * The callback that returns true if the data can be directly loaded.
  42604. */
  42605. canDirectLoad?: (data: string) => boolean;
  42606. /**
  42607. * The callback that allows custom handling of the root url based on the response url.
  42608. */
  42609. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42610. /**
  42611. * Load into an asset container.
  42612. * @param scene The scene to load into
  42613. * @param data The data to import
  42614. * @param rootUrl The root url for scene and resources
  42615. * @param onProgress The callback when the load progresses
  42616. * @param fileName Defines the name of the file to load
  42617. * @returns The loaded asset container
  42618. */
  42619. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42620. }
  42621. /**
  42622. * Class used to load scene from various file formats using registered plugins
  42623. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42624. */
  42625. export class SceneLoader {
  42626. /**
  42627. * No logging while loading
  42628. */
  42629. static readonly NO_LOGGING: number;
  42630. /**
  42631. * Minimal logging while loading
  42632. */
  42633. static readonly MINIMAL_LOGGING: number;
  42634. /**
  42635. * Summary logging while loading
  42636. */
  42637. static readonly SUMMARY_LOGGING: number;
  42638. /**
  42639. * Detailled logging while loading
  42640. */
  42641. static readonly DETAILED_LOGGING: number;
  42642. /**
  42643. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42644. */
  42645. static ForceFullSceneLoadingForIncremental: boolean;
  42646. /**
  42647. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42648. */
  42649. static ShowLoadingScreen: boolean;
  42650. /**
  42651. * Defines the current logging level (while loading the scene)
  42652. * @ignorenaming
  42653. */
  42654. static loggingLevel: number;
  42655. /**
  42656. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42657. */
  42658. static CleanBoneMatrixWeights: boolean;
  42659. /**
  42660. * Event raised when a plugin is used to load a scene
  42661. */
  42662. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42663. private static _registeredPlugins;
  42664. private static _getDefaultPlugin;
  42665. private static _getPluginForExtension;
  42666. private static _getPluginForDirectLoad;
  42667. private static _getPluginForFilename;
  42668. private static _getDirectLoad;
  42669. private static _loadData;
  42670. private static _getFileInfo;
  42671. /**
  42672. * Gets a plugin that can load the given extension
  42673. * @param extension defines the extension to load
  42674. * @returns a plugin or null if none works
  42675. */
  42676. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42677. /**
  42678. * Gets a boolean indicating that the given extension can be loaded
  42679. * @param extension defines the extension to load
  42680. * @returns true if the extension is supported
  42681. */
  42682. static IsPluginForExtensionAvailable(extension: string): boolean;
  42683. /**
  42684. * Adds a new plugin to the list of registered plugins
  42685. * @param plugin defines the plugin to add
  42686. */
  42687. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42688. /**
  42689. * Import meshes into a scene
  42690. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42691. * @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)
  42692. * @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)
  42693. * @param scene the instance of BABYLON.Scene to append to
  42694. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42695. * @param onProgress a callback with a progress event for each file being loaded
  42696. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42697. * @param pluginExtension the extension used to determine the plugin
  42698. * @returns The loaded plugin
  42699. */
  42700. 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>;
  42701. /**
  42702. * Import meshes into a scene
  42703. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42704. * @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)
  42705. * @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)
  42706. * @param scene the instance of BABYLON.Scene to append to
  42707. * @param onProgress a callback with a progress event for each file being loaded
  42708. * @param pluginExtension the extension used to determine the plugin
  42709. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42710. */
  42711. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42712. meshes: AbstractMesh[];
  42713. particleSystems: IParticleSystem[];
  42714. skeletons: Skeleton[];
  42715. animationGroups: AnimationGroup[];
  42716. }>;
  42717. /**
  42718. * Load a scene
  42719. * @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)
  42720. * @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)
  42721. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42722. * @param onSuccess a callback with the scene when import succeeds
  42723. * @param onProgress a callback with a progress event for each file being loaded
  42724. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42725. * @param pluginExtension the extension used to determine the plugin
  42726. * @returns The loaded plugin
  42727. */
  42728. 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>;
  42729. /**
  42730. * Load a scene
  42731. * @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)
  42732. * @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)
  42733. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42734. * @param onProgress a callback with a progress event for each file being loaded
  42735. * @param pluginExtension the extension used to determine the plugin
  42736. * @returns The loaded scene
  42737. */
  42738. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42739. /**
  42740. * Append a scene
  42741. * @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)
  42742. * @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)
  42743. * @param scene is the instance of BABYLON.Scene to append to
  42744. * @param onSuccess a callback with the scene when import succeeds
  42745. * @param onProgress a callback with a progress event for each file being loaded
  42746. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42747. * @param pluginExtension the extension used to determine the plugin
  42748. * @returns The loaded plugin
  42749. */
  42750. 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>;
  42751. /**
  42752. * Append a scene
  42753. * @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)
  42754. * @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)
  42755. * @param scene is the instance of BABYLON.Scene to append to
  42756. * @param onProgress a callback with a progress event for each file being loaded
  42757. * @param pluginExtension the extension used to determine the plugin
  42758. * @returns The given scene
  42759. */
  42760. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42761. /**
  42762. * Load a scene into an asset container
  42763. * @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)
  42764. * @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)
  42765. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42766. * @param onSuccess a callback with the scene when import succeeds
  42767. * @param onProgress a callback with a progress event for each file being loaded
  42768. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42769. * @param pluginExtension the extension used to determine the plugin
  42770. * @returns The loaded plugin
  42771. */
  42772. 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>;
  42773. /**
  42774. * Load a scene into an asset container
  42775. * @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)
  42776. * @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)
  42777. * @param scene is the instance of Scene to append to
  42778. * @param onProgress a callback with a progress event for each file being loaded
  42779. * @param pluginExtension the extension used to determine the plugin
  42780. * @returns The loaded asset container
  42781. */
  42782. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42783. }
  42784. }
  42785. declare module BABYLON {
  42786. /**
  42787. * Google Daydream controller
  42788. */
  42789. export class DaydreamController extends WebVRController {
  42790. /**
  42791. * Base Url for the controller model.
  42792. */
  42793. static MODEL_BASE_URL: string;
  42794. /**
  42795. * File name for the controller model.
  42796. */
  42797. static MODEL_FILENAME: string;
  42798. /**
  42799. * Gamepad Id prefix used to identify Daydream Controller.
  42800. */
  42801. static readonly GAMEPAD_ID_PREFIX: string;
  42802. /**
  42803. * Creates a new DaydreamController from a gamepad
  42804. * @param vrGamepad the gamepad that the controller should be created from
  42805. */
  42806. constructor(vrGamepad: any);
  42807. /**
  42808. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42809. * @param scene scene in which to add meshes
  42810. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42811. */
  42812. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42813. /**
  42814. * Called once for each button that changed state since the last frame
  42815. * @param buttonIdx Which button index changed
  42816. * @param state New state of the button
  42817. * @param changes Which properties on the state changed since last frame
  42818. */
  42819. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42820. }
  42821. }
  42822. declare module BABYLON {
  42823. /**
  42824. * Gear VR Controller
  42825. */
  42826. export class GearVRController extends WebVRController {
  42827. /**
  42828. * Base Url for the controller model.
  42829. */
  42830. static MODEL_BASE_URL: string;
  42831. /**
  42832. * File name for the controller model.
  42833. */
  42834. static MODEL_FILENAME: string;
  42835. /**
  42836. * Gamepad Id prefix used to identify this controller.
  42837. */
  42838. static readonly GAMEPAD_ID_PREFIX: string;
  42839. private readonly _buttonIndexToObservableNameMap;
  42840. /**
  42841. * Creates a new GearVRController from a gamepad
  42842. * @param vrGamepad the gamepad that the controller should be created from
  42843. */
  42844. constructor(vrGamepad: any);
  42845. /**
  42846. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42847. * @param scene scene in which to add meshes
  42848. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42849. */
  42850. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42851. /**
  42852. * Called once for each button that changed state since the last frame
  42853. * @param buttonIdx Which button index changed
  42854. * @param state New state of the button
  42855. * @param changes Which properties on the state changed since last frame
  42856. */
  42857. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42858. }
  42859. }
  42860. declare module BABYLON {
  42861. /**
  42862. * Generic Controller
  42863. */
  42864. export class GenericController extends WebVRController {
  42865. /**
  42866. * Base Url for the controller model.
  42867. */
  42868. static readonly MODEL_BASE_URL: string;
  42869. /**
  42870. * File name for the controller model.
  42871. */
  42872. static readonly MODEL_FILENAME: string;
  42873. /**
  42874. * Creates a new GenericController from a gamepad
  42875. * @param vrGamepad the gamepad that the controller should be created from
  42876. */
  42877. constructor(vrGamepad: any);
  42878. /**
  42879. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42880. * @param scene scene in which to add meshes
  42881. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42882. */
  42883. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42884. /**
  42885. * Called once for each button that changed state since the last frame
  42886. * @param buttonIdx Which button index changed
  42887. * @param state New state of the button
  42888. * @param changes Which properties on the state changed since last frame
  42889. */
  42890. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42891. }
  42892. }
  42893. declare module BABYLON {
  42894. /**
  42895. * Oculus Touch Controller
  42896. */
  42897. export class OculusTouchController extends WebVRController {
  42898. /**
  42899. * Base Url for the controller model.
  42900. */
  42901. static MODEL_BASE_URL: string;
  42902. /**
  42903. * File name for the left controller model.
  42904. */
  42905. static MODEL_LEFT_FILENAME: string;
  42906. /**
  42907. * File name for the right controller model.
  42908. */
  42909. static MODEL_RIGHT_FILENAME: string;
  42910. /**
  42911. * Base Url for the Quest controller model.
  42912. */
  42913. static QUEST_MODEL_BASE_URL: string;
  42914. /**
  42915. * @hidden
  42916. * If the controllers are running on a device that needs the updated Quest controller models
  42917. */
  42918. static _IsQuest: boolean;
  42919. /**
  42920. * Fired when the secondary trigger on this controller is modified
  42921. */
  42922. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42923. /**
  42924. * Fired when the thumb rest on this controller is modified
  42925. */
  42926. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42927. /**
  42928. * Creates a new OculusTouchController from a gamepad
  42929. * @param vrGamepad the gamepad that the controller should be created from
  42930. */
  42931. constructor(vrGamepad: any);
  42932. /**
  42933. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42934. * @param scene scene in which to add meshes
  42935. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42936. */
  42937. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42938. /**
  42939. * Fired when the A button on this controller is modified
  42940. */
  42941. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42942. /**
  42943. * Fired when the B button on this controller is modified
  42944. */
  42945. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42946. /**
  42947. * Fired when the X button on this controller is modified
  42948. */
  42949. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42950. /**
  42951. * Fired when the Y button on this controller is modified
  42952. */
  42953. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42954. /**
  42955. * Called once for each button that changed state since the last frame
  42956. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42957. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42958. * 2) secondary trigger (same)
  42959. * 3) A (right) X (left), touch, pressed = value
  42960. * 4) B / Y
  42961. * 5) thumb rest
  42962. * @param buttonIdx Which button index changed
  42963. * @param state New state of the button
  42964. * @param changes Which properties on the state changed since last frame
  42965. */
  42966. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42967. }
  42968. }
  42969. declare module BABYLON {
  42970. /**
  42971. * Vive Controller
  42972. */
  42973. export class ViveController extends WebVRController {
  42974. /**
  42975. * Base Url for the controller model.
  42976. */
  42977. static MODEL_BASE_URL: string;
  42978. /**
  42979. * File name for the controller model.
  42980. */
  42981. static MODEL_FILENAME: string;
  42982. /**
  42983. * Creates a new ViveController from a gamepad
  42984. * @param vrGamepad the gamepad that the controller should be created from
  42985. */
  42986. constructor(vrGamepad: any);
  42987. /**
  42988. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42989. * @param scene scene in which to add meshes
  42990. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42991. */
  42992. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42993. /**
  42994. * Fired when the left button on this controller is modified
  42995. */
  42996. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42997. /**
  42998. * Fired when the right button on this controller is modified
  42999. */
  43000. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43001. /**
  43002. * Fired when the menu button on this controller is modified
  43003. */
  43004. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43005. /**
  43006. * Called once for each button that changed state since the last frame
  43007. * Vive mapping:
  43008. * 0: touchpad
  43009. * 1: trigger
  43010. * 2: left AND right buttons
  43011. * 3: menu button
  43012. * @param buttonIdx Which button index changed
  43013. * @param state New state of the button
  43014. * @param changes Which properties on the state changed since last frame
  43015. */
  43016. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43017. }
  43018. }
  43019. declare module BABYLON {
  43020. /**
  43021. * Defines the WindowsMotionController object that the state of the windows motion controller
  43022. */
  43023. export class WindowsMotionController extends WebVRController {
  43024. /**
  43025. * The base url used to load the left and right controller models
  43026. */
  43027. static MODEL_BASE_URL: string;
  43028. /**
  43029. * The name of the left controller model file
  43030. */
  43031. static MODEL_LEFT_FILENAME: string;
  43032. /**
  43033. * The name of the right controller model file
  43034. */
  43035. static MODEL_RIGHT_FILENAME: string;
  43036. /**
  43037. * The controller name prefix for this controller type
  43038. */
  43039. static readonly GAMEPAD_ID_PREFIX: string;
  43040. /**
  43041. * The controller id pattern for this controller type
  43042. */
  43043. private static readonly GAMEPAD_ID_PATTERN;
  43044. private _loadedMeshInfo;
  43045. private readonly _mapping;
  43046. /**
  43047. * Fired when the trackpad on this controller is clicked
  43048. */
  43049. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43050. /**
  43051. * Fired when the trackpad on this controller is modified
  43052. */
  43053. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43054. /**
  43055. * The current x and y values of this controller's trackpad
  43056. */
  43057. trackpad: StickValues;
  43058. /**
  43059. * Creates a new WindowsMotionController from a gamepad
  43060. * @param vrGamepad the gamepad that the controller should be created from
  43061. */
  43062. constructor(vrGamepad: any);
  43063. /**
  43064. * Fired when the trigger on this controller is modified
  43065. */
  43066. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43067. /**
  43068. * Fired when the menu button on this controller is modified
  43069. */
  43070. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43071. /**
  43072. * Fired when the grip button on this controller is modified
  43073. */
  43074. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43075. /**
  43076. * Fired when the thumbstick button on this controller is modified
  43077. */
  43078. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43079. /**
  43080. * Fired when the touchpad button on this controller is modified
  43081. */
  43082. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43083. /**
  43084. * Fired when the touchpad values on this controller are modified
  43085. */
  43086. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43087. private _updateTrackpad;
  43088. /**
  43089. * Called once per frame by the engine.
  43090. */
  43091. update(): void;
  43092. /**
  43093. * Called once for each button that changed state since the last frame
  43094. * @param buttonIdx Which button index changed
  43095. * @param state New state of the button
  43096. * @param changes Which properties on the state changed since last frame
  43097. */
  43098. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43099. /**
  43100. * Moves the buttons on the controller mesh based on their current state
  43101. * @param buttonName the name of the button to move
  43102. * @param buttonValue the value of the button which determines the buttons new position
  43103. */
  43104. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43105. /**
  43106. * Moves the axis on the controller mesh based on its current state
  43107. * @param axis the index of the axis
  43108. * @param axisValue the value of the axis which determines the meshes new position
  43109. * @hidden
  43110. */
  43111. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43112. /**
  43113. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43114. * @param scene scene in which to add meshes
  43115. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43116. */
  43117. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43118. /**
  43119. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43120. * can be transformed by button presses and axes values, based on this._mapping.
  43121. *
  43122. * @param scene scene in which the meshes exist
  43123. * @param meshes list of meshes that make up the controller model to process
  43124. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43125. */
  43126. private processModel;
  43127. private createMeshInfo;
  43128. /**
  43129. * Gets the ray of the controller in the direction the controller is pointing
  43130. * @param length the length the resulting ray should be
  43131. * @returns a ray in the direction the controller is pointing
  43132. */
  43133. getForwardRay(length?: number): Ray;
  43134. /**
  43135. * Disposes of the controller
  43136. */
  43137. dispose(): void;
  43138. }
  43139. }
  43140. declare module BABYLON {
  43141. /**
  43142. * Class containing static functions to help procedurally build meshes
  43143. */
  43144. export class PolyhedronBuilder {
  43145. /**
  43146. * Creates a polyhedron mesh
  43147. * * 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
  43148. * * The parameter `size` (positive float, default 1) sets the polygon size
  43149. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43150. * * 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`
  43151. * * 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
  43152. * * 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)`)
  43153. * * 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
  43154. * * 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
  43155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43156. * * 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
  43157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43158. * @param name defines the name of the mesh
  43159. * @param options defines the options used to create the mesh
  43160. * @param scene defines the hosting scene
  43161. * @returns the polyhedron mesh
  43162. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43163. */
  43164. static CreatePolyhedron(name: string, options: {
  43165. type?: number;
  43166. size?: number;
  43167. sizeX?: number;
  43168. sizeY?: number;
  43169. sizeZ?: number;
  43170. custom?: any;
  43171. faceUV?: Vector4[];
  43172. faceColors?: Color4[];
  43173. flat?: boolean;
  43174. updatable?: boolean;
  43175. sideOrientation?: number;
  43176. frontUVs?: Vector4;
  43177. backUVs?: Vector4;
  43178. }, scene?: Nullable<Scene>): Mesh;
  43179. }
  43180. }
  43181. declare module BABYLON {
  43182. /**
  43183. * Gizmo that enables scaling a mesh along 3 axis
  43184. */
  43185. export class ScaleGizmo extends Gizmo {
  43186. /**
  43187. * Internal gizmo used for interactions on the x axis
  43188. */
  43189. xGizmo: AxisScaleGizmo;
  43190. /**
  43191. * Internal gizmo used for interactions on the y axis
  43192. */
  43193. yGizmo: AxisScaleGizmo;
  43194. /**
  43195. * Internal gizmo used for interactions on the z axis
  43196. */
  43197. zGizmo: AxisScaleGizmo;
  43198. /**
  43199. * Internal gizmo used to scale all axis equally
  43200. */
  43201. uniformScaleGizmo: AxisScaleGizmo;
  43202. private _meshAttached;
  43203. private _updateGizmoRotationToMatchAttachedMesh;
  43204. private _snapDistance;
  43205. private _scaleRatio;
  43206. private _uniformScalingMesh;
  43207. private _octahedron;
  43208. /** Fires an event when any of it's sub gizmos are dragged */
  43209. onDragStartObservable: Observable<{}>;
  43210. /** Fires an event when any of it's sub gizmos are released from dragging */
  43211. onDragEndObservable: Observable<{}>;
  43212. attachedMesh: Nullable<AbstractMesh>;
  43213. /**
  43214. * Creates a ScaleGizmo
  43215. * @param gizmoLayer The utility layer the gizmo will be added to
  43216. */
  43217. constructor(gizmoLayer?: UtilityLayerRenderer);
  43218. updateGizmoRotationToMatchAttachedMesh: boolean;
  43219. /**
  43220. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43221. */
  43222. snapDistance: number;
  43223. /**
  43224. * Ratio for the scale of the gizmo (Default: 1)
  43225. */
  43226. scaleRatio: number;
  43227. /**
  43228. * Disposes of the gizmo
  43229. */
  43230. dispose(): void;
  43231. }
  43232. }
  43233. declare module BABYLON {
  43234. /**
  43235. * Single axis scale gizmo
  43236. */
  43237. export class AxisScaleGizmo extends Gizmo {
  43238. /**
  43239. * Drag behavior responsible for the gizmos dragging interactions
  43240. */
  43241. dragBehavior: PointerDragBehavior;
  43242. private _pointerObserver;
  43243. /**
  43244. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43245. */
  43246. snapDistance: number;
  43247. /**
  43248. * Event that fires each time the gizmo snaps to a new location.
  43249. * * snapDistance is the the change in distance
  43250. */
  43251. onSnapObservable: Observable<{
  43252. snapDistance: number;
  43253. }>;
  43254. /**
  43255. * If the scaling operation should be done on all axis (default: false)
  43256. */
  43257. uniformScaling: boolean;
  43258. private _isEnabled;
  43259. private _parent;
  43260. private _arrow;
  43261. private _coloredMaterial;
  43262. private _hoverMaterial;
  43263. /**
  43264. * Creates an AxisScaleGizmo
  43265. * @param gizmoLayer The utility layer the gizmo will be added to
  43266. * @param dragAxis The axis which the gizmo will be able to scale on
  43267. * @param color The color of the gizmo
  43268. */
  43269. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  43270. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43271. /**
  43272. * If the gizmo is enabled
  43273. */
  43274. isEnabled: boolean;
  43275. /**
  43276. * Disposes of the gizmo
  43277. */
  43278. dispose(): void;
  43279. /**
  43280. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43281. * @param mesh The mesh to replace the default mesh of the gizmo
  43282. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43283. */
  43284. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43285. }
  43286. }
  43287. declare module BABYLON {
  43288. /**
  43289. * Bounding box gizmo
  43290. */
  43291. export class BoundingBoxGizmo extends Gizmo {
  43292. private _lineBoundingBox;
  43293. private _rotateSpheresParent;
  43294. private _scaleBoxesParent;
  43295. private _boundingDimensions;
  43296. private _renderObserver;
  43297. private _pointerObserver;
  43298. private _scaleDragSpeed;
  43299. private _tmpQuaternion;
  43300. private _tmpVector;
  43301. private _tmpRotationMatrix;
  43302. /**
  43303. * 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)
  43304. */
  43305. ignoreChildren: boolean;
  43306. /**
  43307. * 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)
  43308. */
  43309. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43310. /**
  43311. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43312. */
  43313. rotationSphereSize: number;
  43314. /**
  43315. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43316. */
  43317. scaleBoxSize: number;
  43318. /**
  43319. * 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)
  43320. */
  43321. fixedDragMeshScreenSize: boolean;
  43322. /**
  43323. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43324. */
  43325. fixedDragMeshScreenSizeDistanceFactor: number;
  43326. /**
  43327. * Fired when a rotation sphere or scale box is dragged
  43328. */
  43329. onDragStartObservable: Observable<{}>;
  43330. /**
  43331. * Fired when a scale box is dragged
  43332. */
  43333. onScaleBoxDragObservable: Observable<{}>;
  43334. /**
  43335. * Fired when a scale box drag is ended
  43336. */
  43337. onScaleBoxDragEndObservable: Observable<{}>;
  43338. /**
  43339. * Fired when a rotation sphere is dragged
  43340. */
  43341. onRotationSphereDragObservable: Observable<{}>;
  43342. /**
  43343. * Fired when a rotation sphere drag is ended
  43344. */
  43345. onRotationSphereDragEndObservable: Observable<{}>;
  43346. /**
  43347. * 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)
  43348. */
  43349. scalePivot: Nullable<Vector3>;
  43350. /**
  43351. * Mesh used as a pivot to rotate the attached mesh
  43352. */
  43353. private _anchorMesh;
  43354. private _existingMeshScale;
  43355. private _dragMesh;
  43356. private pointerDragBehavior;
  43357. private coloredMaterial;
  43358. private hoverColoredMaterial;
  43359. /**
  43360. * Sets the color of the bounding box gizmo
  43361. * @param color the color to set
  43362. */
  43363. setColor(color: Color3): void;
  43364. /**
  43365. * Creates an BoundingBoxGizmo
  43366. * @param gizmoLayer The utility layer the gizmo will be added to
  43367. * @param color The color of the gizmo
  43368. */
  43369. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43370. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43371. private _selectNode;
  43372. /**
  43373. * Updates the bounding box information for the Gizmo
  43374. */
  43375. updateBoundingBox(): void;
  43376. private _updateRotationSpheres;
  43377. private _updateScaleBoxes;
  43378. /**
  43379. * Enables rotation on the specified axis and disables rotation on the others
  43380. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43381. */
  43382. setEnabledRotationAxis(axis: string): void;
  43383. /**
  43384. * Enables/disables scaling
  43385. * @param enable if scaling should be enabled
  43386. */
  43387. setEnabledScaling(enable: boolean): void;
  43388. private _updateDummy;
  43389. /**
  43390. * Enables a pointer drag behavior on the bounding box of the gizmo
  43391. */
  43392. enableDragBehavior(): void;
  43393. /**
  43394. * Disposes of the gizmo
  43395. */
  43396. dispose(): void;
  43397. /**
  43398. * 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)
  43399. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43400. * @returns the bounding box mesh with the passed in mesh as a child
  43401. */
  43402. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43403. /**
  43404. * CustomMeshes are not supported by this gizmo
  43405. * @param mesh The mesh to replace the default mesh of the gizmo
  43406. */
  43407. setCustomMesh(mesh: Mesh): void;
  43408. }
  43409. }
  43410. declare module BABYLON {
  43411. /**
  43412. * Single plane rotation gizmo
  43413. */
  43414. export class PlaneRotationGizmo extends Gizmo {
  43415. /**
  43416. * Drag behavior responsible for the gizmos dragging interactions
  43417. */
  43418. dragBehavior: PointerDragBehavior;
  43419. private _pointerObserver;
  43420. /**
  43421. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43422. */
  43423. snapDistance: number;
  43424. /**
  43425. * Event that fires each time the gizmo snaps to a new location.
  43426. * * snapDistance is the the change in distance
  43427. */
  43428. onSnapObservable: Observable<{
  43429. snapDistance: number;
  43430. }>;
  43431. private _isEnabled;
  43432. private _parent;
  43433. /**
  43434. * Creates a PlaneRotationGizmo
  43435. * @param gizmoLayer The utility layer the gizmo will be added to
  43436. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43437. * @param color The color of the gizmo
  43438. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43439. */
  43440. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  43441. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43442. /**
  43443. * If the gizmo is enabled
  43444. */
  43445. isEnabled: boolean;
  43446. /**
  43447. * Disposes of the gizmo
  43448. */
  43449. dispose(): void;
  43450. }
  43451. }
  43452. declare module BABYLON {
  43453. /**
  43454. * Gizmo that enables rotating a mesh along 3 axis
  43455. */
  43456. export class RotationGizmo extends Gizmo {
  43457. /**
  43458. * Internal gizmo used for interactions on the x axis
  43459. */
  43460. xGizmo: PlaneRotationGizmo;
  43461. /**
  43462. * Internal gizmo used for interactions on the y axis
  43463. */
  43464. yGizmo: PlaneRotationGizmo;
  43465. /**
  43466. * Internal gizmo used for interactions on the z axis
  43467. */
  43468. zGizmo: PlaneRotationGizmo;
  43469. /** Fires an event when any of it's sub gizmos are dragged */
  43470. onDragStartObservable: Observable<{}>;
  43471. /** Fires an event when any of it's sub gizmos are released from dragging */
  43472. onDragEndObservable: Observable<{}>;
  43473. private _meshAttached;
  43474. attachedMesh: Nullable<AbstractMesh>;
  43475. /**
  43476. * Creates a RotationGizmo
  43477. * @param gizmoLayer The utility layer the gizmo will be added to
  43478. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43479. */
  43480. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43481. updateGizmoRotationToMatchAttachedMesh: boolean;
  43482. /**
  43483. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43484. */
  43485. snapDistance: number;
  43486. /**
  43487. * Ratio for the scale of the gizmo (Default: 1)
  43488. */
  43489. scaleRatio: number;
  43490. /**
  43491. * Disposes of the gizmo
  43492. */
  43493. dispose(): void;
  43494. /**
  43495. * CustomMeshes are not supported by this gizmo
  43496. * @param mesh The mesh to replace the default mesh of the gizmo
  43497. */
  43498. setCustomMesh(mesh: Mesh): void;
  43499. }
  43500. }
  43501. declare module BABYLON {
  43502. /**
  43503. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43504. */
  43505. export class GizmoManager implements IDisposable {
  43506. private scene;
  43507. /**
  43508. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43509. */
  43510. gizmos: {
  43511. positionGizmo: Nullable<PositionGizmo>;
  43512. rotationGizmo: Nullable<RotationGizmo>;
  43513. scaleGizmo: Nullable<ScaleGizmo>;
  43514. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43515. };
  43516. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43517. clearGizmoOnEmptyPointerEvent: boolean;
  43518. /** Fires an event when the manager is attached to a mesh */
  43519. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43520. private _gizmosEnabled;
  43521. private _pointerObserver;
  43522. private _attachedMesh;
  43523. private _boundingBoxColor;
  43524. private _defaultUtilityLayer;
  43525. private _defaultKeepDepthUtilityLayer;
  43526. /**
  43527. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43528. */
  43529. boundingBoxDragBehavior: SixDofDragBehavior;
  43530. /**
  43531. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43532. */
  43533. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43534. /**
  43535. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43536. */
  43537. usePointerToAttachGizmos: boolean;
  43538. /**
  43539. * Utility layer that the bounding box gizmo belongs to
  43540. */
  43541. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  43542. /**
  43543. * Utility layer that all gizmos besides bounding box belong to
  43544. */
  43545. readonly utilityLayer: UtilityLayerRenderer;
  43546. /**
  43547. * Instatiates a gizmo manager
  43548. * @param scene the scene to overlay the gizmos on top of
  43549. */
  43550. constructor(scene: Scene);
  43551. /**
  43552. * Attaches a set of gizmos to the specified mesh
  43553. * @param mesh The mesh the gizmo's should be attached to
  43554. */
  43555. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43556. /**
  43557. * If the position gizmo is enabled
  43558. */
  43559. positionGizmoEnabled: boolean;
  43560. /**
  43561. * If the rotation gizmo is enabled
  43562. */
  43563. rotationGizmoEnabled: boolean;
  43564. /**
  43565. * If the scale gizmo is enabled
  43566. */
  43567. scaleGizmoEnabled: boolean;
  43568. /**
  43569. * If the boundingBox gizmo is enabled
  43570. */
  43571. boundingBoxGizmoEnabled: boolean;
  43572. /**
  43573. * Disposes of the gizmo manager
  43574. */
  43575. dispose(): void;
  43576. }
  43577. }
  43578. declare module BABYLON {
  43579. /**
  43580. * A directional light is defined by a direction (what a surprise!).
  43581. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  43582. * 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.
  43583. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43584. */
  43585. export class DirectionalLight extends ShadowLight {
  43586. private _shadowFrustumSize;
  43587. /**
  43588. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  43589. */
  43590. /**
  43591. * Specifies a fix frustum size for the shadow generation.
  43592. */
  43593. shadowFrustumSize: number;
  43594. private _shadowOrthoScale;
  43595. /**
  43596. * Gets the shadow projection scale against the optimal computed one.
  43597. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43598. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43599. */
  43600. /**
  43601. * Sets the shadow projection scale against the optimal computed one.
  43602. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43603. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43604. */
  43605. shadowOrthoScale: number;
  43606. /**
  43607. * Automatically compute the projection matrix to best fit (including all the casters)
  43608. * on each frame.
  43609. */
  43610. autoUpdateExtends: boolean;
  43611. private _orthoLeft;
  43612. private _orthoRight;
  43613. private _orthoTop;
  43614. private _orthoBottom;
  43615. /**
  43616. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  43617. * The directional light is emitted from everywhere in the given direction.
  43618. * It can cast shadows.
  43619. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43620. * @param name The friendly name of the light
  43621. * @param direction The direction of the light
  43622. * @param scene The scene the light belongs to
  43623. */
  43624. constructor(name: string, direction: Vector3, scene: Scene);
  43625. /**
  43626. * Returns the string "DirectionalLight".
  43627. * @return The class name
  43628. */
  43629. getClassName(): string;
  43630. /**
  43631. * Returns the integer 1.
  43632. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43633. */
  43634. getTypeID(): number;
  43635. /**
  43636. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  43637. * Returns the DirectionalLight Shadow projection matrix.
  43638. */
  43639. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43640. /**
  43641. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  43642. * Returns the DirectionalLight Shadow projection matrix.
  43643. */
  43644. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  43645. /**
  43646. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  43647. * Returns the DirectionalLight Shadow projection matrix.
  43648. */
  43649. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43650. protected _buildUniformLayout(): void;
  43651. /**
  43652. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  43653. * @param effect The effect to update
  43654. * @param lightIndex The index of the light in the effect to update
  43655. * @returns The directional light
  43656. */
  43657. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  43658. /**
  43659. * Gets the minZ used for shadow according to both the scene and the light.
  43660. *
  43661. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43662. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43663. * @param activeCamera The camera we are returning the min for
  43664. * @returns the depth min z
  43665. */
  43666. getDepthMinZ(activeCamera: Camera): number;
  43667. /**
  43668. * Gets the maxZ used for shadow according to both the scene and the light.
  43669. *
  43670. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43671. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43672. * @param activeCamera The camera we are returning the max for
  43673. * @returns the depth max z
  43674. */
  43675. getDepthMaxZ(activeCamera: Camera): number;
  43676. /**
  43677. * Prepares the list of defines specific to the light type.
  43678. * @param defines the list of defines
  43679. * @param lightIndex defines the index of the light for the effect
  43680. */
  43681. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43682. }
  43683. }
  43684. declare module BABYLON {
  43685. /**
  43686. * Class containing static functions to help procedurally build meshes
  43687. */
  43688. export class HemisphereBuilder {
  43689. /**
  43690. * Creates a hemisphere mesh
  43691. * @param name defines the name of the mesh
  43692. * @param options defines the options used to create the mesh
  43693. * @param scene defines the hosting scene
  43694. * @returns the hemisphere mesh
  43695. */
  43696. static CreateHemisphere(name: string, options: {
  43697. segments?: number;
  43698. diameter?: number;
  43699. sideOrientation?: number;
  43700. }, scene: any): Mesh;
  43701. }
  43702. }
  43703. declare module BABYLON {
  43704. /**
  43705. * A spot light is defined by a position, a direction, an angle, and an exponent.
  43706. * These values define a cone of light starting from the position, emitting toward the direction.
  43707. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  43708. * and the exponent defines the speed of the decay of the light with distance (reach).
  43709. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43710. */
  43711. export class SpotLight extends ShadowLight {
  43712. private _angle;
  43713. private _innerAngle;
  43714. private _cosHalfAngle;
  43715. private _lightAngleScale;
  43716. private _lightAngleOffset;
  43717. /**
  43718. * Gets the cone angle of the spot light in Radians.
  43719. */
  43720. /**
  43721. * Sets the cone angle of the spot light in Radians.
  43722. */
  43723. angle: number;
  43724. /**
  43725. * Only used in gltf falloff mode, this defines the angle where
  43726. * the directional falloff will start before cutting at angle which could be seen
  43727. * as outer angle.
  43728. */
  43729. /**
  43730. * Only used in gltf falloff mode, this defines the angle where
  43731. * the directional falloff will start before cutting at angle which could be seen
  43732. * as outer angle.
  43733. */
  43734. innerAngle: number;
  43735. private _shadowAngleScale;
  43736. /**
  43737. * Allows scaling the angle of the light for shadow generation only.
  43738. */
  43739. /**
  43740. * Allows scaling the angle of the light for shadow generation only.
  43741. */
  43742. shadowAngleScale: number;
  43743. /**
  43744. * The light decay speed with the distance from the emission spot.
  43745. */
  43746. exponent: number;
  43747. private _projectionTextureMatrix;
  43748. /**
  43749. * Allows reading the projecton texture
  43750. */
  43751. readonly projectionTextureMatrix: Matrix;
  43752. protected _projectionTextureLightNear: number;
  43753. /**
  43754. * Gets the near clip of the Spotlight for texture projection.
  43755. */
  43756. /**
  43757. * Sets the near clip of the Spotlight for texture projection.
  43758. */
  43759. projectionTextureLightNear: number;
  43760. protected _projectionTextureLightFar: number;
  43761. /**
  43762. * Gets the far clip of the Spotlight for texture projection.
  43763. */
  43764. /**
  43765. * Sets the far clip of the Spotlight for texture projection.
  43766. */
  43767. projectionTextureLightFar: number;
  43768. protected _projectionTextureUpDirection: Vector3;
  43769. /**
  43770. * Gets the Up vector of the Spotlight for texture projection.
  43771. */
  43772. /**
  43773. * Sets the Up vector of the Spotlight for texture projection.
  43774. */
  43775. projectionTextureUpDirection: Vector3;
  43776. private _projectionTexture;
  43777. /**
  43778. * Gets the projection texture of the light.
  43779. */
  43780. /**
  43781. * Sets the projection texture of the light.
  43782. */
  43783. projectionTexture: Nullable<BaseTexture>;
  43784. private _projectionTextureViewLightDirty;
  43785. private _projectionTextureProjectionLightDirty;
  43786. private _projectionTextureDirty;
  43787. private _projectionTextureViewTargetVector;
  43788. private _projectionTextureViewLightMatrix;
  43789. private _projectionTextureProjectionLightMatrix;
  43790. private _projectionTextureScalingMatrix;
  43791. /**
  43792. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  43793. * It can cast shadows.
  43794. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43795. * @param name The light friendly name
  43796. * @param position The position of the spot light in the scene
  43797. * @param direction The direction of the light in the scene
  43798. * @param angle The cone angle of the light in Radians
  43799. * @param exponent The light decay speed with the distance from the emission spot
  43800. * @param scene The scene the lights belongs to
  43801. */
  43802. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  43803. /**
  43804. * Returns the string "SpotLight".
  43805. * @returns the class name
  43806. */
  43807. getClassName(): string;
  43808. /**
  43809. * Returns the integer 2.
  43810. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43811. */
  43812. getTypeID(): number;
  43813. /**
  43814. * Overrides the direction setter to recompute the projection texture view light Matrix.
  43815. */
  43816. protected _setDirection(value: Vector3): void;
  43817. /**
  43818. * Overrides the position setter to recompute the projection texture view light Matrix.
  43819. */
  43820. protected _setPosition(value: Vector3): void;
  43821. /**
  43822. * 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.
  43823. * Returns the SpotLight.
  43824. */
  43825. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43826. protected _computeProjectionTextureViewLightMatrix(): void;
  43827. protected _computeProjectionTextureProjectionLightMatrix(): void;
  43828. /**
  43829. * Main function for light texture projection matrix computing.
  43830. */
  43831. protected _computeProjectionTextureMatrix(): void;
  43832. protected _buildUniformLayout(): void;
  43833. private _computeAngleValues;
  43834. /**
  43835. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  43836. * @param effect The effect to update
  43837. * @param lightIndex The index of the light in the effect to update
  43838. * @returns The spot light
  43839. */
  43840. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  43841. /**
  43842. * Disposes the light and the associated resources.
  43843. */
  43844. dispose(): void;
  43845. /**
  43846. * Prepares the list of defines specific to the light type.
  43847. * @param defines the list of defines
  43848. * @param lightIndex defines the index of the light for the effect
  43849. */
  43850. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43851. }
  43852. }
  43853. declare module BABYLON {
  43854. /**
  43855. * Gizmo that enables viewing a light
  43856. */
  43857. export class LightGizmo extends Gizmo {
  43858. private _lightMesh;
  43859. private _material;
  43860. private cachedPosition;
  43861. private cachedForward;
  43862. /**
  43863. * Creates a LightGizmo
  43864. * @param gizmoLayer The utility layer the gizmo will be added to
  43865. */
  43866. constructor(gizmoLayer?: UtilityLayerRenderer);
  43867. private _light;
  43868. /**
  43869. * The light that the gizmo is attached to
  43870. */
  43871. light: Nullable<Light>;
  43872. /**
  43873. * @hidden
  43874. * Updates the gizmo to match the attached mesh's position/rotation
  43875. */
  43876. protected _update(): void;
  43877. private static _Scale;
  43878. /**
  43879. * Creates the lines for a light mesh
  43880. */
  43881. private static _createLightLines;
  43882. /**
  43883. * Disposes of the light gizmo
  43884. */
  43885. dispose(): void;
  43886. private static _CreateHemisphericLightMesh;
  43887. private static _CreatePointLightMesh;
  43888. private static _CreateSpotLightMesh;
  43889. private static _CreateDirectionalLightMesh;
  43890. }
  43891. }
  43892. declare module BABYLON {
  43893. /** @hidden */
  43894. export var backgroundFragmentDeclaration: {
  43895. name: string;
  43896. shader: string;
  43897. };
  43898. }
  43899. declare module BABYLON {
  43900. /** @hidden */
  43901. export var backgroundUboDeclaration: {
  43902. name: string;
  43903. shader: string;
  43904. };
  43905. }
  43906. declare module BABYLON {
  43907. /** @hidden */
  43908. export var backgroundPixelShader: {
  43909. name: string;
  43910. shader: string;
  43911. };
  43912. }
  43913. declare module BABYLON {
  43914. /** @hidden */
  43915. export var backgroundVertexDeclaration: {
  43916. name: string;
  43917. shader: string;
  43918. };
  43919. }
  43920. declare module BABYLON {
  43921. /** @hidden */
  43922. export var backgroundVertexShader: {
  43923. name: string;
  43924. shader: string;
  43925. };
  43926. }
  43927. declare module BABYLON {
  43928. /**
  43929. * Background material used to create an efficient environement around your scene.
  43930. */
  43931. export class BackgroundMaterial extends PushMaterial {
  43932. /**
  43933. * Standard reflectance value at parallel view angle.
  43934. */
  43935. static StandardReflectance0: number;
  43936. /**
  43937. * Standard reflectance value at grazing angle.
  43938. */
  43939. static StandardReflectance90: number;
  43940. protected _primaryColor: Color3;
  43941. /**
  43942. * Key light Color (multiply against the environement texture)
  43943. */
  43944. primaryColor: Color3;
  43945. protected __perceptualColor: Nullable<Color3>;
  43946. /**
  43947. * Experimental Internal Use Only.
  43948. *
  43949. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43950. * This acts as a helper to set the primary color to a more "human friendly" value.
  43951. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43952. * output color as close as possible from the chosen value.
  43953. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43954. * part of lighting setup.)
  43955. */
  43956. _perceptualColor: Nullable<Color3>;
  43957. protected _primaryColorShadowLevel: float;
  43958. /**
  43959. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43960. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43961. */
  43962. primaryColorShadowLevel: float;
  43963. protected _primaryColorHighlightLevel: float;
  43964. /**
  43965. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43966. * The primary color is used at the level chosen to define what the white area would look.
  43967. */
  43968. primaryColorHighlightLevel: float;
  43969. protected _reflectionTexture: Nullable<BaseTexture>;
  43970. /**
  43971. * Reflection Texture used in the material.
  43972. * Should be author in a specific way for the best result (refer to the documentation).
  43973. */
  43974. reflectionTexture: Nullable<BaseTexture>;
  43975. protected _reflectionBlur: float;
  43976. /**
  43977. * Reflection Texture level of blur.
  43978. *
  43979. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43980. * texture twice.
  43981. */
  43982. reflectionBlur: float;
  43983. protected _diffuseTexture: Nullable<BaseTexture>;
  43984. /**
  43985. * Diffuse Texture used in the material.
  43986. * Should be author in a specific way for the best result (refer to the documentation).
  43987. */
  43988. diffuseTexture: Nullable<BaseTexture>;
  43989. protected _shadowLights: Nullable<IShadowLight[]>;
  43990. /**
  43991. * Specify the list of lights casting shadow on the material.
  43992. * All scene shadow lights will be included if null.
  43993. */
  43994. shadowLights: Nullable<IShadowLight[]>;
  43995. protected _shadowLevel: float;
  43996. /**
  43997. * Helps adjusting the shadow to a softer level if required.
  43998. * 0 means black shadows and 1 means no shadows.
  43999. */
  44000. shadowLevel: float;
  44001. protected _sceneCenter: Vector3;
  44002. /**
  44003. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44004. * It is usually zero but might be interesting to modify according to your setup.
  44005. */
  44006. sceneCenter: Vector3;
  44007. protected _opacityFresnel: boolean;
  44008. /**
  44009. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44010. * This helps ensuring a nice transition when the camera goes under the ground.
  44011. */
  44012. opacityFresnel: boolean;
  44013. protected _reflectionFresnel: boolean;
  44014. /**
  44015. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44016. * This helps adding a mirror texture on the ground.
  44017. */
  44018. reflectionFresnel: boolean;
  44019. protected _reflectionFalloffDistance: number;
  44020. /**
  44021. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44022. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44023. */
  44024. reflectionFalloffDistance: number;
  44025. protected _reflectionAmount: number;
  44026. /**
  44027. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44028. */
  44029. reflectionAmount: number;
  44030. protected _reflectionReflectance0: number;
  44031. /**
  44032. * This specifies the weight of the reflection at grazing angle.
  44033. */
  44034. reflectionReflectance0: number;
  44035. protected _reflectionReflectance90: number;
  44036. /**
  44037. * This specifies the weight of the reflection at a perpendicular point of view.
  44038. */
  44039. reflectionReflectance90: number;
  44040. /**
  44041. * Sets the reflection reflectance fresnel values according to the default standard
  44042. * empirically know to work well :-)
  44043. */
  44044. reflectionStandardFresnelWeight: number;
  44045. protected _useRGBColor: boolean;
  44046. /**
  44047. * Helps to directly use the maps channels instead of their level.
  44048. */
  44049. useRGBColor: boolean;
  44050. protected _enableNoise: boolean;
  44051. /**
  44052. * This helps reducing the banding effect that could occur on the background.
  44053. */
  44054. enableNoise: boolean;
  44055. /**
  44056. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44057. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44058. * Recommended to be keep at 1.0 except for special cases.
  44059. */
  44060. fovMultiplier: number;
  44061. private _fovMultiplier;
  44062. /**
  44063. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44064. */
  44065. useEquirectangularFOV: boolean;
  44066. private _maxSimultaneousLights;
  44067. /**
  44068. * Number of Simultaneous lights allowed on the material.
  44069. */
  44070. maxSimultaneousLights: int;
  44071. /**
  44072. * Default configuration related to image processing available in the Background Material.
  44073. */
  44074. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44075. /**
  44076. * Keep track of the image processing observer to allow dispose and replace.
  44077. */
  44078. private _imageProcessingObserver;
  44079. /**
  44080. * Attaches a new image processing configuration to the PBR Material.
  44081. * @param configuration (if null the scene configuration will be use)
  44082. */
  44083. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44084. /**
  44085. * Gets the image processing configuration used either in this material.
  44086. */
  44087. /**
  44088. * Sets the Default image processing configuration used either in the this material.
  44089. *
  44090. * If sets to null, the scene one is in use.
  44091. */
  44092. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44093. /**
  44094. * Gets wether the color curves effect is enabled.
  44095. */
  44096. /**
  44097. * Sets wether the color curves effect is enabled.
  44098. */
  44099. cameraColorCurvesEnabled: boolean;
  44100. /**
  44101. * Gets wether the color grading effect is enabled.
  44102. */
  44103. /**
  44104. * Gets wether the color grading effect is enabled.
  44105. */
  44106. cameraColorGradingEnabled: boolean;
  44107. /**
  44108. * Gets wether tonemapping is enabled or not.
  44109. */
  44110. /**
  44111. * Sets wether tonemapping is enabled or not
  44112. */
  44113. cameraToneMappingEnabled: boolean;
  44114. /**
  44115. * The camera exposure used on this material.
  44116. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44117. * This corresponds to a photographic exposure.
  44118. */
  44119. /**
  44120. * The camera exposure used on this material.
  44121. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44122. * This corresponds to a photographic exposure.
  44123. */
  44124. cameraExposure: float;
  44125. /**
  44126. * Gets The camera contrast used on this material.
  44127. */
  44128. /**
  44129. * Sets The camera contrast used on this material.
  44130. */
  44131. cameraContrast: float;
  44132. /**
  44133. * Gets the Color Grading 2D Lookup Texture.
  44134. */
  44135. /**
  44136. * Sets the Color Grading 2D Lookup Texture.
  44137. */
  44138. cameraColorGradingTexture: Nullable<BaseTexture>;
  44139. /**
  44140. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44141. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44142. * 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;
  44143. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44144. */
  44145. /**
  44146. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44147. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44148. * 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;
  44149. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44150. */
  44151. cameraColorCurves: Nullable<ColorCurves>;
  44152. /**
  44153. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44154. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44155. */
  44156. switchToBGR: boolean;
  44157. private _renderTargets;
  44158. private _reflectionControls;
  44159. private _white;
  44160. private _primaryShadowColor;
  44161. private _primaryHighlightColor;
  44162. /**
  44163. * Instantiates a Background Material in the given scene
  44164. * @param name The friendly name of the material
  44165. * @param scene The scene to add the material to
  44166. */
  44167. constructor(name: string, scene: Scene);
  44168. /**
  44169. * Gets a boolean indicating that current material needs to register RTT
  44170. */
  44171. readonly hasRenderTargetTextures: boolean;
  44172. /**
  44173. * The entire material has been created in order to prevent overdraw.
  44174. * @returns false
  44175. */
  44176. needAlphaTesting(): boolean;
  44177. /**
  44178. * The entire material has been created in order to prevent overdraw.
  44179. * @returns true if blending is enable
  44180. */
  44181. needAlphaBlending(): boolean;
  44182. /**
  44183. * Checks wether the material is ready to be rendered for a given mesh.
  44184. * @param mesh The mesh to render
  44185. * @param subMesh The submesh to check against
  44186. * @param useInstances Specify wether or not the material is used with instances
  44187. * @returns true if all the dependencies are ready (Textures, Effects...)
  44188. */
  44189. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44190. /**
  44191. * Compute the primary color according to the chosen perceptual color.
  44192. */
  44193. private _computePrimaryColorFromPerceptualColor;
  44194. /**
  44195. * Compute the highlights and shadow colors according to their chosen levels.
  44196. */
  44197. private _computePrimaryColors;
  44198. /**
  44199. * Build the uniform buffer used in the material.
  44200. */
  44201. buildUniformLayout(): void;
  44202. /**
  44203. * Unbind the material.
  44204. */
  44205. unbind(): void;
  44206. /**
  44207. * Bind only the world matrix to the material.
  44208. * @param world The world matrix to bind.
  44209. */
  44210. bindOnlyWorldMatrix(world: Matrix): void;
  44211. /**
  44212. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44213. * @param world The world matrix to bind.
  44214. * @param subMesh The submesh to bind for.
  44215. */
  44216. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44217. /**
  44218. * Dispose the material.
  44219. * @param forceDisposeEffect Force disposal of the associated effect.
  44220. * @param forceDisposeTextures Force disposal of the associated textures.
  44221. */
  44222. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44223. /**
  44224. * Clones the material.
  44225. * @param name The cloned name.
  44226. * @returns The cloned material.
  44227. */
  44228. clone(name: string): BackgroundMaterial;
  44229. /**
  44230. * Serializes the current material to its JSON representation.
  44231. * @returns The JSON representation.
  44232. */
  44233. serialize(): any;
  44234. /**
  44235. * Gets the class name of the material
  44236. * @returns "BackgroundMaterial"
  44237. */
  44238. getClassName(): string;
  44239. /**
  44240. * Parse a JSON input to create back a background material.
  44241. * @param source The JSON data to parse
  44242. * @param scene The scene to create the parsed material in
  44243. * @param rootUrl The root url of the assets the material depends upon
  44244. * @returns the instantiated BackgroundMaterial.
  44245. */
  44246. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44247. }
  44248. }
  44249. declare module BABYLON {
  44250. /**
  44251. * Represents the different options available during the creation of
  44252. * a Environment helper.
  44253. *
  44254. * This can control the default ground, skybox and image processing setup of your scene.
  44255. */
  44256. export interface IEnvironmentHelperOptions {
  44257. /**
  44258. * Specifies wether or not to create a ground.
  44259. * True by default.
  44260. */
  44261. createGround: boolean;
  44262. /**
  44263. * Specifies the ground size.
  44264. * 15 by default.
  44265. */
  44266. groundSize: number;
  44267. /**
  44268. * The texture used on the ground for the main color.
  44269. * Comes from the BabylonJS CDN by default.
  44270. *
  44271. * Remarks: Can be either a texture or a url.
  44272. */
  44273. groundTexture: string | BaseTexture;
  44274. /**
  44275. * The color mixed in the ground texture by default.
  44276. * BabylonJS clearColor by default.
  44277. */
  44278. groundColor: Color3;
  44279. /**
  44280. * Specifies the ground opacity.
  44281. * 1 by default.
  44282. */
  44283. groundOpacity: number;
  44284. /**
  44285. * Enables the ground to receive shadows.
  44286. * True by default.
  44287. */
  44288. enableGroundShadow: boolean;
  44289. /**
  44290. * Helps preventing the shadow to be fully black on the ground.
  44291. * 0.5 by default.
  44292. */
  44293. groundShadowLevel: number;
  44294. /**
  44295. * Creates a mirror texture attach to the ground.
  44296. * false by default.
  44297. */
  44298. enableGroundMirror: boolean;
  44299. /**
  44300. * Specifies the ground mirror size ratio.
  44301. * 0.3 by default as the default kernel is 64.
  44302. */
  44303. groundMirrorSizeRatio: number;
  44304. /**
  44305. * Specifies the ground mirror blur kernel size.
  44306. * 64 by default.
  44307. */
  44308. groundMirrorBlurKernel: number;
  44309. /**
  44310. * Specifies the ground mirror visibility amount.
  44311. * 1 by default
  44312. */
  44313. groundMirrorAmount: number;
  44314. /**
  44315. * Specifies the ground mirror reflectance weight.
  44316. * This uses the standard weight of the background material to setup the fresnel effect
  44317. * of the mirror.
  44318. * 1 by default.
  44319. */
  44320. groundMirrorFresnelWeight: number;
  44321. /**
  44322. * Specifies the ground mirror Falloff distance.
  44323. * This can helps reducing the size of the reflection.
  44324. * 0 by Default.
  44325. */
  44326. groundMirrorFallOffDistance: number;
  44327. /**
  44328. * Specifies the ground mirror texture type.
  44329. * Unsigned Int by Default.
  44330. */
  44331. groundMirrorTextureType: number;
  44332. /**
  44333. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44334. * the shown objects.
  44335. */
  44336. groundYBias: number;
  44337. /**
  44338. * Specifies wether or not to create a skybox.
  44339. * True by default.
  44340. */
  44341. createSkybox: boolean;
  44342. /**
  44343. * Specifies the skybox size.
  44344. * 20 by default.
  44345. */
  44346. skyboxSize: number;
  44347. /**
  44348. * The texture used on the skybox for the main color.
  44349. * Comes from the BabylonJS CDN by default.
  44350. *
  44351. * Remarks: Can be either a texture or a url.
  44352. */
  44353. skyboxTexture: string | BaseTexture;
  44354. /**
  44355. * The color mixed in the skybox texture by default.
  44356. * BabylonJS clearColor by default.
  44357. */
  44358. skyboxColor: Color3;
  44359. /**
  44360. * The background rotation around the Y axis of the scene.
  44361. * This helps aligning the key lights of your scene with the background.
  44362. * 0 by default.
  44363. */
  44364. backgroundYRotation: number;
  44365. /**
  44366. * Compute automatically the size of the elements to best fit with the scene.
  44367. */
  44368. sizeAuto: boolean;
  44369. /**
  44370. * Default position of the rootMesh if autoSize is not true.
  44371. */
  44372. rootPosition: Vector3;
  44373. /**
  44374. * Sets up the image processing in the scene.
  44375. * true by default.
  44376. */
  44377. setupImageProcessing: boolean;
  44378. /**
  44379. * The texture used as your environment texture in the scene.
  44380. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44381. *
  44382. * Remarks: Can be either a texture or a url.
  44383. */
  44384. environmentTexture: string | BaseTexture;
  44385. /**
  44386. * The value of the exposure to apply to the scene.
  44387. * 0.6 by default if setupImageProcessing is true.
  44388. */
  44389. cameraExposure: number;
  44390. /**
  44391. * The value of the contrast to apply to the scene.
  44392. * 1.6 by default if setupImageProcessing is true.
  44393. */
  44394. cameraContrast: number;
  44395. /**
  44396. * Specifies wether or not tonemapping should be enabled in the scene.
  44397. * true by default if setupImageProcessing is true.
  44398. */
  44399. toneMappingEnabled: boolean;
  44400. }
  44401. /**
  44402. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44403. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44404. * It also helps with the default setup of your imageProcessing configuration.
  44405. */
  44406. export class EnvironmentHelper {
  44407. /**
  44408. * Default ground texture URL.
  44409. */
  44410. private static _groundTextureCDNUrl;
  44411. /**
  44412. * Default skybox texture URL.
  44413. */
  44414. private static _skyboxTextureCDNUrl;
  44415. /**
  44416. * Default environment texture URL.
  44417. */
  44418. private static _environmentTextureCDNUrl;
  44419. /**
  44420. * Creates the default options for the helper.
  44421. */
  44422. private static _getDefaultOptions;
  44423. private _rootMesh;
  44424. /**
  44425. * Gets the root mesh created by the helper.
  44426. */
  44427. readonly rootMesh: Mesh;
  44428. private _skybox;
  44429. /**
  44430. * Gets the skybox created by the helper.
  44431. */
  44432. readonly skybox: Nullable<Mesh>;
  44433. private _skyboxTexture;
  44434. /**
  44435. * Gets the skybox texture created by the helper.
  44436. */
  44437. readonly skyboxTexture: Nullable<BaseTexture>;
  44438. private _skyboxMaterial;
  44439. /**
  44440. * Gets the skybox material created by the helper.
  44441. */
  44442. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44443. private _ground;
  44444. /**
  44445. * Gets the ground mesh created by the helper.
  44446. */
  44447. readonly ground: Nullable<Mesh>;
  44448. private _groundTexture;
  44449. /**
  44450. * Gets the ground texture created by the helper.
  44451. */
  44452. readonly groundTexture: Nullable<BaseTexture>;
  44453. private _groundMirror;
  44454. /**
  44455. * Gets the ground mirror created by the helper.
  44456. */
  44457. readonly groundMirror: Nullable<MirrorTexture>;
  44458. /**
  44459. * Gets the ground mirror render list to helps pushing the meshes
  44460. * you wish in the ground reflection.
  44461. */
  44462. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44463. private _groundMaterial;
  44464. /**
  44465. * Gets the ground material created by the helper.
  44466. */
  44467. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44468. /**
  44469. * Stores the creation options.
  44470. */
  44471. private readonly _scene;
  44472. private _options;
  44473. /**
  44474. * This observable will be notified with any error during the creation of the environment,
  44475. * mainly texture creation errors.
  44476. */
  44477. onErrorObservable: Observable<{
  44478. message?: string;
  44479. exception?: any;
  44480. }>;
  44481. /**
  44482. * constructor
  44483. * @param options Defines the options we want to customize the helper
  44484. * @param scene The scene to add the material to
  44485. */
  44486. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44487. /**
  44488. * Updates the background according to the new options
  44489. * @param options
  44490. */
  44491. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44492. /**
  44493. * Sets the primary color of all the available elements.
  44494. * @param color the main color to affect to the ground and the background
  44495. */
  44496. setMainColor(color: Color3): void;
  44497. /**
  44498. * Setup the image processing according to the specified options.
  44499. */
  44500. private _setupImageProcessing;
  44501. /**
  44502. * Setup the environment texture according to the specified options.
  44503. */
  44504. private _setupEnvironmentTexture;
  44505. /**
  44506. * Setup the background according to the specified options.
  44507. */
  44508. private _setupBackground;
  44509. /**
  44510. * Get the scene sizes according to the setup.
  44511. */
  44512. private _getSceneSize;
  44513. /**
  44514. * Setup the ground according to the specified options.
  44515. */
  44516. private _setupGround;
  44517. /**
  44518. * Setup the ground material according to the specified options.
  44519. */
  44520. private _setupGroundMaterial;
  44521. /**
  44522. * Setup the ground diffuse texture according to the specified options.
  44523. */
  44524. private _setupGroundDiffuseTexture;
  44525. /**
  44526. * Setup the ground mirror texture according to the specified options.
  44527. */
  44528. private _setupGroundMirrorTexture;
  44529. /**
  44530. * Setup the ground to receive the mirror texture.
  44531. */
  44532. private _setupMirrorInGroundMaterial;
  44533. /**
  44534. * Setup the skybox according to the specified options.
  44535. */
  44536. private _setupSkybox;
  44537. /**
  44538. * Setup the skybox material according to the specified options.
  44539. */
  44540. private _setupSkyboxMaterial;
  44541. /**
  44542. * Setup the skybox reflection texture according to the specified options.
  44543. */
  44544. private _setupSkyboxReflectionTexture;
  44545. private _errorHandler;
  44546. /**
  44547. * Dispose all the elements created by the Helper.
  44548. */
  44549. dispose(): void;
  44550. }
  44551. }
  44552. declare module BABYLON {
  44553. /**
  44554. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44555. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44556. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44557. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44558. */
  44559. export class PhotoDome extends TransformNode {
  44560. /**
  44561. * Define the image as a Monoscopic panoramic 360 image.
  44562. */
  44563. static readonly MODE_MONOSCOPIC: number;
  44564. /**
  44565. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44566. */
  44567. static readonly MODE_TOPBOTTOM: number;
  44568. /**
  44569. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44570. */
  44571. static readonly MODE_SIDEBYSIDE: number;
  44572. private _useDirectMapping;
  44573. /**
  44574. * The texture being displayed on the sphere
  44575. */
  44576. protected _photoTexture: Texture;
  44577. /**
  44578. * Gets or sets the texture being displayed on the sphere
  44579. */
  44580. photoTexture: Texture;
  44581. /**
  44582. * Observable raised when an error occured while loading the 360 image
  44583. */
  44584. onLoadErrorObservable: Observable<string>;
  44585. /**
  44586. * The skybox material
  44587. */
  44588. protected _material: BackgroundMaterial;
  44589. /**
  44590. * The surface used for the skybox
  44591. */
  44592. protected _mesh: Mesh;
  44593. /**
  44594. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44595. * Also see the options.resolution property.
  44596. */
  44597. fovMultiplier: number;
  44598. private _imageMode;
  44599. /**
  44600. * Gets or set the current video mode for the video. It can be:
  44601. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  44602. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44603. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44604. */
  44605. imageMode: number;
  44606. /**
  44607. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44608. * @param name Element's name, child elements will append suffixes for their own names.
  44609. * @param urlsOfPhoto defines the url of the photo to display
  44610. * @param options defines an object containing optional or exposed sub element properties
  44611. * @param onError defines a callback called when an error occured while loading the texture
  44612. */
  44613. constructor(name: string, urlOfPhoto: string, options: {
  44614. resolution?: number;
  44615. size?: number;
  44616. useDirectMapping?: boolean;
  44617. faceForward?: boolean;
  44618. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44619. private _onBeforeCameraRenderObserver;
  44620. private _changeImageMode;
  44621. /**
  44622. * Releases resources associated with this node.
  44623. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44624. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44625. */
  44626. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44627. }
  44628. }
  44629. declare module BABYLON {
  44630. /** @hidden */
  44631. export var rgbdDecodePixelShader: {
  44632. name: string;
  44633. shader: string;
  44634. };
  44635. }
  44636. declare module BABYLON {
  44637. /**
  44638. * Class used to host texture specific utilities
  44639. */
  44640. export class BRDFTextureTools {
  44641. /**
  44642. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  44643. * @param texture the texture to expand.
  44644. */
  44645. private static _ExpandDefaultBRDFTexture;
  44646. /**
  44647. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44648. * @param scene defines the hosting scene
  44649. * @returns the environment BRDF texture
  44650. */
  44651. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44652. private static _environmentBRDFBase64Texture;
  44653. }
  44654. }
  44655. declare module BABYLON {
  44656. /**
  44657. * @hidden
  44658. */
  44659. export interface IMaterialClearCoatDefines {
  44660. CLEARCOAT: boolean;
  44661. CLEARCOAT_DEFAULTIOR: boolean;
  44662. CLEARCOAT_TEXTURE: boolean;
  44663. CLEARCOAT_TEXTUREDIRECTUV: number;
  44664. CLEARCOAT_BUMP: boolean;
  44665. CLEARCOAT_BUMPDIRECTUV: number;
  44666. CLEARCOAT_TINT: boolean;
  44667. CLEARCOAT_TINT_TEXTURE: boolean;
  44668. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44669. /** @hidden */
  44670. _areTexturesDirty: boolean;
  44671. }
  44672. /**
  44673. * Define the code related to the clear coat parameters of the pbr material.
  44674. */
  44675. export class PBRClearCoatConfiguration {
  44676. /**
  44677. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44678. * The default fits with a polyurethane material.
  44679. */
  44680. private static readonly _DefaultIndexOfRefraction;
  44681. private _isEnabled;
  44682. /**
  44683. * Defines if the clear coat is enabled in the material.
  44684. */
  44685. isEnabled: boolean;
  44686. /**
  44687. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44688. */
  44689. intensity: number;
  44690. /**
  44691. * Defines the clear coat layer roughness.
  44692. */
  44693. roughness: number;
  44694. private _indexOfRefraction;
  44695. /**
  44696. * Defines the index of refraction of the clear coat.
  44697. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44698. * The default fits with a polyurethane material.
  44699. * Changing the default value is more performance intensive.
  44700. */
  44701. indexOfRefraction: number;
  44702. private _texture;
  44703. /**
  44704. * Stores the clear coat values in a texture.
  44705. */
  44706. texture: Nullable<BaseTexture>;
  44707. private _bumpTexture;
  44708. /**
  44709. * Define the clear coat specific bump texture.
  44710. */
  44711. bumpTexture: Nullable<BaseTexture>;
  44712. private _isTintEnabled;
  44713. /**
  44714. * Defines if the clear coat tint is enabled in the material.
  44715. */
  44716. isTintEnabled: boolean;
  44717. /**
  44718. * Defines the clear coat tint of the material.
  44719. * This is only use if tint is enabled
  44720. */
  44721. tintColor: Color3;
  44722. /**
  44723. * Defines the distance at which the tint color should be found in the
  44724. * clear coat media.
  44725. * This is only use if tint is enabled
  44726. */
  44727. tintColorAtDistance: number;
  44728. /**
  44729. * Defines the clear coat layer thickness.
  44730. * This is only use if tint is enabled
  44731. */
  44732. tintThickness: number;
  44733. private _tintTexture;
  44734. /**
  44735. * Stores the clear tint values in a texture.
  44736. * rgb is tint
  44737. * a is a thickness factor
  44738. */
  44739. tintTexture: Nullable<BaseTexture>;
  44740. /** @hidden */
  44741. private _internalMarkAllSubMeshesAsTexturesDirty;
  44742. /** @hidden */
  44743. _markAllSubMeshesAsTexturesDirty(): void;
  44744. /**
  44745. * Instantiate a new istance of clear coat configuration.
  44746. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44747. */
  44748. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44749. /**
  44750. * Gets wehter the submesh is ready to be used or not.
  44751. * @param defines the list of "defines" to update.
  44752. * @param scene defines the scene the material belongs to.
  44753. * @param engine defines the engine the material belongs to.
  44754. * @param disableBumpMap defines wether the material disables bump or not.
  44755. * @returns - boolean indicating that the submesh is ready or not.
  44756. */
  44757. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44758. /**
  44759. * Checks to see if a texture is used in the material.
  44760. * @param defines the list of "defines" to update.
  44761. * @param scene defines the scene to the material belongs to.
  44762. */
  44763. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44764. /**
  44765. * Binds the material data.
  44766. * @param uniformBuffer defines the Uniform buffer to fill in.
  44767. * @param scene defines the scene the material belongs to.
  44768. * @param engine defines the engine the material belongs to.
  44769. * @param disableBumpMap defines wether the material disables bump or not.
  44770. * @param isFrozen defines wether the material is frozen or not.
  44771. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44772. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44773. */
  44774. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44775. /**
  44776. * Checks to see if a texture is used in the material.
  44777. * @param texture - Base texture to use.
  44778. * @returns - Boolean specifying if a texture is used in the material.
  44779. */
  44780. hasTexture(texture: BaseTexture): boolean;
  44781. /**
  44782. * Returns an array of the actively used textures.
  44783. * @param activeTextures Array of BaseTextures
  44784. */
  44785. getActiveTextures(activeTextures: BaseTexture[]): void;
  44786. /**
  44787. * Returns the animatable textures.
  44788. * @param animatables Array of animatable textures.
  44789. */
  44790. getAnimatables(animatables: IAnimatable[]): void;
  44791. /**
  44792. * Disposes the resources of the material.
  44793. * @param forceDisposeTextures - Forces the disposal of all textures.
  44794. */
  44795. dispose(forceDisposeTextures?: boolean): void;
  44796. /**
  44797. * Get the current class name of the texture useful for serialization or dynamic coding.
  44798. * @returns "PBRClearCoatConfiguration"
  44799. */
  44800. getClassName(): string;
  44801. /**
  44802. * Add fallbacks to the effect fallbacks list.
  44803. * @param defines defines the Base texture to use.
  44804. * @param fallbacks defines the current fallback list.
  44805. * @param currentRank defines the current fallback rank.
  44806. * @returns the new fallback rank.
  44807. */
  44808. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44809. /**
  44810. * Add the required uniforms to the current list.
  44811. * @param uniforms defines the current uniform list.
  44812. */
  44813. static AddUniforms(uniforms: string[]): void;
  44814. /**
  44815. * Add the required samplers to the current list.
  44816. * @param samplers defines the current sampler list.
  44817. */
  44818. static AddSamplers(samplers: string[]): void;
  44819. /**
  44820. * Add the required uniforms to the current buffer.
  44821. * @param uniformBuffer defines the current uniform buffer.
  44822. */
  44823. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44824. /**
  44825. * Makes a duplicate of the current configuration into another one.
  44826. * @param clearCoatConfiguration define the config where to copy the info
  44827. */
  44828. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44829. /**
  44830. * Serializes this clear coat configuration.
  44831. * @returns - An object with the serialized config.
  44832. */
  44833. serialize(): any;
  44834. /**
  44835. * Parses a anisotropy Configuration from a serialized object.
  44836. * @param source - Serialized object.
  44837. * @param scene Defines the scene we are parsing for
  44838. * @param rootUrl Defines the rootUrl to load from
  44839. */
  44840. parse(source: any, scene: Scene, rootUrl: string): void;
  44841. }
  44842. }
  44843. declare module BABYLON {
  44844. /**
  44845. * @hidden
  44846. */
  44847. export interface IMaterialAnisotropicDefines {
  44848. ANISOTROPIC: boolean;
  44849. ANISOTROPIC_TEXTURE: boolean;
  44850. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44851. MAINUV1: boolean;
  44852. _areTexturesDirty: boolean;
  44853. _needUVs: boolean;
  44854. }
  44855. /**
  44856. * Define the code related to the anisotropic parameters of the pbr material.
  44857. */
  44858. export class PBRAnisotropicConfiguration {
  44859. private _isEnabled;
  44860. /**
  44861. * Defines if the anisotropy is enabled in the material.
  44862. */
  44863. isEnabled: boolean;
  44864. /**
  44865. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44866. */
  44867. intensity: number;
  44868. /**
  44869. * Defines if the effect is along the tangents, bitangents or in between.
  44870. * By default, the effect is "strectching" the highlights along the tangents.
  44871. */
  44872. direction: Vector2;
  44873. private _texture;
  44874. /**
  44875. * Stores the anisotropy values in a texture.
  44876. * rg is direction (like normal from -1 to 1)
  44877. * b is a intensity
  44878. */
  44879. texture: Nullable<BaseTexture>;
  44880. /** @hidden */
  44881. private _internalMarkAllSubMeshesAsTexturesDirty;
  44882. /** @hidden */
  44883. _markAllSubMeshesAsTexturesDirty(): void;
  44884. /**
  44885. * Instantiate a new istance of anisotropy configuration.
  44886. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44887. */
  44888. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44889. /**
  44890. * Specifies that the submesh is ready to be used.
  44891. * @param defines the list of "defines" to update.
  44892. * @param scene defines the scene the material belongs to.
  44893. * @returns - boolean indicating that the submesh is ready or not.
  44894. */
  44895. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44896. /**
  44897. * Checks to see if a texture is used in the material.
  44898. * @param defines the list of "defines" to update.
  44899. * @param mesh the mesh we are preparing the defines for.
  44900. * @param scene defines the scene the material belongs to.
  44901. */
  44902. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44903. /**
  44904. * Binds the material data.
  44905. * @param uniformBuffer defines the Uniform buffer to fill in.
  44906. * @param scene defines the scene the material belongs to.
  44907. * @param isFrozen defines wether the material is frozen or not.
  44908. */
  44909. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44910. /**
  44911. * Checks to see if a texture is used in the material.
  44912. * @param texture - Base texture to use.
  44913. * @returns - Boolean specifying if a texture is used in the material.
  44914. */
  44915. hasTexture(texture: BaseTexture): boolean;
  44916. /**
  44917. * Returns an array of the actively used textures.
  44918. * @param activeTextures Array of BaseTextures
  44919. */
  44920. getActiveTextures(activeTextures: BaseTexture[]): void;
  44921. /**
  44922. * Returns the animatable textures.
  44923. * @param animatables Array of animatable textures.
  44924. */
  44925. getAnimatables(animatables: IAnimatable[]): void;
  44926. /**
  44927. * Disposes the resources of the material.
  44928. * @param forceDisposeTextures - Forces the disposal of all textures.
  44929. */
  44930. dispose(forceDisposeTextures?: boolean): void;
  44931. /**
  44932. * Get the current class name of the texture useful for serialization or dynamic coding.
  44933. * @returns "PBRAnisotropicConfiguration"
  44934. */
  44935. getClassName(): string;
  44936. /**
  44937. * Add fallbacks to the effect fallbacks list.
  44938. * @param defines defines the Base texture to use.
  44939. * @param fallbacks defines the current fallback list.
  44940. * @param currentRank defines the current fallback rank.
  44941. * @returns the new fallback rank.
  44942. */
  44943. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44944. /**
  44945. * Add the required uniforms to the current list.
  44946. * @param uniforms defines the current uniform list.
  44947. */
  44948. static AddUniforms(uniforms: string[]): void;
  44949. /**
  44950. * Add the required uniforms to the current buffer.
  44951. * @param uniformBuffer defines the current uniform buffer.
  44952. */
  44953. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44954. /**
  44955. * Add the required samplers to the current list.
  44956. * @param samplers defines the current sampler list.
  44957. */
  44958. static AddSamplers(samplers: string[]): void;
  44959. /**
  44960. * Makes a duplicate of the current configuration into another one.
  44961. * @param anisotropicConfiguration define the config where to copy the info
  44962. */
  44963. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44964. /**
  44965. * Serializes this anisotropy configuration.
  44966. * @returns - An object with the serialized config.
  44967. */
  44968. serialize(): any;
  44969. /**
  44970. * Parses a anisotropy Configuration from a serialized object.
  44971. * @param source - Serialized object.
  44972. * @param scene Defines the scene we are parsing for
  44973. * @param rootUrl Defines the rootUrl to load from
  44974. */
  44975. parse(source: any, scene: Scene, rootUrl: string): void;
  44976. }
  44977. }
  44978. declare module BABYLON {
  44979. /**
  44980. * @hidden
  44981. */
  44982. export interface IMaterialBRDFDefines {
  44983. BRDF_V_HEIGHT_CORRELATED: boolean;
  44984. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44985. SPHERICAL_HARMONICS: boolean;
  44986. /** @hidden */
  44987. _areMiscDirty: boolean;
  44988. }
  44989. /**
  44990. * Define the code related to the BRDF parameters of the pbr material.
  44991. */
  44992. export class PBRBRDFConfiguration {
  44993. /**
  44994. * Default value used for the energy conservation.
  44995. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44996. */
  44997. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  44998. /**
  44999. * Default value used for the Smith Visibility Height Correlated mode.
  45000. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45001. */
  45002. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45003. /**
  45004. * Default value used for the IBL diffuse part.
  45005. * This can help switching back to the polynomials mode globally which is a tiny bit
  45006. * less GPU intensive at the drawback of a lower quality.
  45007. */
  45008. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  45009. private _useEnergyConservation;
  45010. /**
  45011. * Defines if the material uses energy conservation.
  45012. */
  45013. useEnergyConservation: boolean;
  45014. private _useSmithVisibilityHeightCorrelated;
  45015. /**
  45016. * LEGACY Mode set to false
  45017. * Defines if the material uses height smith correlated visibility term.
  45018. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45019. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45020. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45021. * Not relying on height correlated will also disable energy conservation.
  45022. */
  45023. useSmithVisibilityHeightCorrelated: boolean;
  45024. private _useSphericalHarmonics;
  45025. /**
  45026. * LEGACY Mode set to false
  45027. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  45028. * diffuse part of the IBL.
  45029. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  45030. * to the ground truth.
  45031. */
  45032. useSphericalHarmonics: boolean;
  45033. /** @hidden */
  45034. private _internalMarkAllSubMeshesAsMiscDirty;
  45035. /** @hidden */
  45036. _markAllSubMeshesAsMiscDirty(): void;
  45037. /**
  45038. * Instantiate a new istance of clear coat configuration.
  45039. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45040. */
  45041. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45042. /**
  45043. * Checks to see if a texture is used in the material.
  45044. * @param defines the list of "defines" to update.
  45045. */
  45046. prepareDefines(defines: IMaterialBRDFDefines): void;
  45047. /**
  45048. * Get the current class name of the texture useful for serialization or dynamic coding.
  45049. * @returns "PBRClearCoatConfiguration"
  45050. */
  45051. getClassName(): string;
  45052. /**
  45053. * Makes a duplicate of the current configuration into another one.
  45054. * @param brdfConfiguration define the config where to copy the info
  45055. */
  45056. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45057. /**
  45058. * Serializes this BRDF configuration.
  45059. * @returns - An object with the serialized config.
  45060. */
  45061. serialize(): any;
  45062. /**
  45063. * Parses a anisotropy Configuration from a serialized object.
  45064. * @param source - Serialized object.
  45065. * @param scene Defines the scene we are parsing for
  45066. * @param rootUrl Defines the rootUrl to load from
  45067. */
  45068. parse(source: any, scene: Scene, rootUrl: string): void;
  45069. }
  45070. }
  45071. declare module BABYLON {
  45072. /**
  45073. * @hidden
  45074. */
  45075. export interface IMaterialSheenDefines {
  45076. SHEEN: boolean;
  45077. SHEEN_TEXTURE: boolean;
  45078. SHEEN_TEXTUREDIRECTUV: number;
  45079. SHEEN_LINKWITHALBEDO: boolean;
  45080. /** @hidden */
  45081. _areTexturesDirty: boolean;
  45082. }
  45083. /**
  45084. * Define the code related to the Sheen parameters of the pbr material.
  45085. */
  45086. export class PBRSheenConfiguration {
  45087. private _isEnabled;
  45088. /**
  45089. * Defines if the material uses sheen.
  45090. */
  45091. isEnabled: boolean;
  45092. private _linkSheenWithAlbedo;
  45093. /**
  45094. * Defines if the sheen is linked to the sheen color.
  45095. */
  45096. linkSheenWithAlbedo: boolean;
  45097. /**
  45098. * Defines the sheen intensity.
  45099. */
  45100. intensity: number;
  45101. /**
  45102. * Defines the sheen color.
  45103. */
  45104. color: Color3;
  45105. private _texture;
  45106. /**
  45107. * Stores the sheen tint values in a texture.
  45108. * rgb is tint
  45109. * a is a intensity
  45110. */
  45111. texture: Nullable<BaseTexture>;
  45112. /** @hidden */
  45113. private _internalMarkAllSubMeshesAsTexturesDirty;
  45114. /** @hidden */
  45115. _markAllSubMeshesAsTexturesDirty(): void;
  45116. /**
  45117. * Instantiate a new istance of clear coat configuration.
  45118. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45119. */
  45120. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45121. /**
  45122. * Specifies that the submesh is ready to be used.
  45123. * @param defines the list of "defines" to update.
  45124. * @param scene defines the scene the material belongs to.
  45125. * @returns - boolean indicating that the submesh is ready or not.
  45126. */
  45127. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45128. /**
  45129. * Checks to see if a texture is used in the material.
  45130. * @param defines the list of "defines" to update.
  45131. * @param scene defines the scene the material belongs to.
  45132. */
  45133. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45134. /**
  45135. * Binds the material data.
  45136. * @param uniformBuffer defines the Uniform buffer to fill in.
  45137. * @param scene defines the scene the material belongs to.
  45138. * @param isFrozen defines wether the material is frozen or not.
  45139. */
  45140. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45141. /**
  45142. * Checks to see if a texture is used in the material.
  45143. * @param texture - Base texture to use.
  45144. * @returns - Boolean specifying if a texture is used in the material.
  45145. */
  45146. hasTexture(texture: BaseTexture): boolean;
  45147. /**
  45148. * Returns an array of the actively used textures.
  45149. * @param activeTextures Array of BaseTextures
  45150. */
  45151. getActiveTextures(activeTextures: BaseTexture[]): void;
  45152. /**
  45153. * Returns the animatable textures.
  45154. * @param animatables Array of animatable textures.
  45155. */
  45156. getAnimatables(animatables: IAnimatable[]): void;
  45157. /**
  45158. * Disposes the resources of the material.
  45159. * @param forceDisposeTextures - Forces the disposal of all textures.
  45160. */
  45161. dispose(forceDisposeTextures?: boolean): void;
  45162. /**
  45163. * Get the current class name of the texture useful for serialization or dynamic coding.
  45164. * @returns "PBRSheenConfiguration"
  45165. */
  45166. getClassName(): string;
  45167. /**
  45168. * Add fallbacks to the effect fallbacks list.
  45169. * @param defines defines the Base texture to use.
  45170. * @param fallbacks defines the current fallback list.
  45171. * @param currentRank defines the current fallback rank.
  45172. * @returns the new fallback rank.
  45173. */
  45174. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45175. /**
  45176. * Add the required uniforms to the current list.
  45177. * @param uniforms defines the current uniform list.
  45178. */
  45179. static AddUniforms(uniforms: string[]): void;
  45180. /**
  45181. * Add the required uniforms to the current buffer.
  45182. * @param uniformBuffer defines the current uniform buffer.
  45183. */
  45184. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45185. /**
  45186. * Add the required samplers to the current list.
  45187. * @param samplers defines the current sampler list.
  45188. */
  45189. static AddSamplers(samplers: string[]): void;
  45190. /**
  45191. * Makes a duplicate of the current configuration into another one.
  45192. * @param sheenConfiguration define the config where to copy the info
  45193. */
  45194. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45195. /**
  45196. * Serializes this BRDF configuration.
  45197. * @returns - An object with the serialized config.
  45198. */
  45199. serialize(): any;
  45200. /**
  45201. * Parses a anisotropy Configuration from a serialized object.
  45202. * @param source - Serialized object.
  45203. * @param scene Defines the scene we are parsing for
  45204. * @param rootUrl Defines the rootUrl to load from
  45205. */
  45206. parse(source: any, scene: Scene, rootUrl: string): void;
  45207. }
  45208. }
  45209. declare module BABYLON {
  45210. /**
  45211. * @hidden
  45212. */
  45213. export interface IMaterialSubSurfaceDefines {
  45214. SUBSURFACE: boolean;
  45215. SS_REFRACTION: boolean;
  45216. SS_TRANSLUCENCY: boolean;
  45217. SS_SCATERRING: boolean;
  45218. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45219. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45220. SS_REFRACTIONMAP_3D: boolean;
  45221. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45222. SS_LODINREFRACTIONALPHA: boolean;
  45223. SS_GAMMAREFRACTION: boolean;
  45224. SS_RGBDREFRACTION: boolean;
  45225. SS_LINEARSPECULARREFRACTION: boolean;
  45226. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45227. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45228. /** @hidden */
  45229. _areTexturesDirty: boolean;
  45230. }
  45231. /**
  45232. * Define the code related to the sub surface parameters of the pbr material.
  45233. */
  45234. export class PBRSubSurfaceConfiguration {
  45235. private _isRefractionEnabled;
  45236. /**
  45237. * Defines if the refraction is enabled in the material.
  45238. */
  45239. isRefractionEnabled: boolean;
  45240. private _isTranslucencyEnabled;
  45241. /**
  45242. * Defines if the translucency is enabled in the material.
  45243. */
  45244. isTranslucencyEnabled: boolean;
  45245. private _isScatteringEnabled;
  45246. /**
  45247. * Defines the refraction intensity of the material.
  45248. * The refraction when enabled replaces the Diffuse part of the material.
  45249. * The intensity helps transitionning between diffuse and refraction.
  45250. */
  45251. refractionIntensity: number;
  45252. /**
  45253. * Defines the translucency intensity of the material.
  45254. * When translucency has been enabled, this defines how much of the "translucency"
  45255. * is addded to the diffuse part of the material.
  45256. */
  45257. translucencyIntensity: number;
  45258. /**
  45259. * Defines the scattering intensity of the material.
  45260. * When scattering has been enabled, this defines how much of the "scattered light"
  45261. * is addded to the diffuse part of the material.
  45262. */
  45263. scatteringIntensity: number;
  45264. private _thicknessTexture;
  45265. /**
  45266. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45267. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45268. * 0 would mean minimumThickness
  45269. * 1 would mean maximumThickness
  45270. * The other channels might be use as a mask to vary the different effects intensity.
  45271. */
  45272. thicknessTexture: Nullable<BaseTexture>;
  45273. private _refractionTexture;
  45274. /**
  45275. * Defines the texture to use for refraction.
  45276. */
  45277. refractionTexture: Nullable<BaseTexture>;
  45278. private _indexOfRefraction;
  45279. /**
  45280. * Defines the index of refraction used in the material.
  45281. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  45282. */
  45283. indexOfRefraction: number;
  45284. private _invertRefractionY;
  45285. /**
  45286. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45287. */
  45288. invertRefractionY: boolean;
  45289. private _linkRefractionWithTransparency;
  45290. /**
  45291. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45292. * Materials half opaque for instance using refraction could benefit from this control.
  45293. */
  45294. linkRefractionWithTransparency: boolean;
  45295. /**
  45296. * Defines the minimum thickness stored in the thickness map.
  45297. * If no thickness map is defined, this value will be used to simulate thickness.
  45298. */
  45299. minimumThickness: number;
  45300. /**
  45301. * Defines the maximum thickness stored in the thickness map.
  45302. */
  45303. maximumThickness: number;
  45304. /**
  45305. * Defines the volume tint of the material.
  45306. * This is used for both translucency and scattering.
  45307. */
  45308. tintColor: Color3;
  45309. /**
  45310. * Defines the distance at which the tint color should be found in the media.
  45311. * This is used for refraction only.
  45312. */
  45313. tintColorAtDistance: number;
  45314. /**
  45315. * Defines how far each channel transmit through the media.
  45316. * It is defined as a color to simplify it selection.
  45317. */
  45318. diffusionDistance: Color3;
  45319. private _useMaskFromThicknessTexture;
  45320. /**
  45321. * Stores the intensity of the different subsurface effects in the thickness texture.
  45322. * * the green channel is the translucency intensity.
  45323. * * the blue channel is the scattering intensity.
  45324. * * the alpha channel is the refraction intensity.
  45325. */
  45326. useMaskFromThicknessTexture: boolean;
  45327. /** @hidden */
  45328. private _internalMarkAllSubMeshesAsTexturesDirty;
  45329. /** @hidden */
  45330. _markAllSubMeshesAsTexturesDirty(): void;
  45331. /**
  45332. * Instantiate a new istance of sub surface configuration.
  45333. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45334. */
  45335. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45336. /**
  45337. * Gets wehter the submesh is ready to be used or not.
  45338. * @param defines the list of "defines" to update.
  45339. * @param scene defines the scene the material belongs to.
  45340. * @returns - boolean indicating that the submesh is ready or not.
  45341. */
  45342. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  45343. /**
  45344. * Checks to see if a texture is used in the material.
  45345. * @param defines the list of "defines" to update.
  45346. * @param scene defines the scene to the material belongs to.
  45347. */
  45348. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  45349. /**
  45350. * Binds the material data.
  45351. * @param uniformBuffer defines the Uniform buffer to fill in.
  45352. * @param scene defines the scene the material belongs to.
  45353. * @param engine defines the engine the material belongs to.
  45354. * @param isFrozen defines wether the material is frozen or not.
  45355. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  45356. */
  45357. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  45358. /**
  45359. * Unbinds the material from the mesh.
  45360. * @param activeEffect defines the effect that should be unbound from.
  45361. * @returns true if unbound, otherwise false
  45362. */
  45363. unbind(activeEffect: Effect): boolean;
  45364. /**
  45365. * Returns the texture used for refraction or null if none is used.
  45366. * @param scene defines the scene the material belongs to.
  45367. * @returns - Refraction texture if present. If no refraction texture and refraction
  45368. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45369. */
  45370. private _getRefractionTexture;
  45371. /**
  45372. * Returns true if alpha blending should be disabled.
  45373. */
  45374. readonly disableAlphaBlending: boolean;
  45375. /**
  45376. * Fills the list of render target textures.
  45377. * @param renderTargets the list of render targets to update
  45378. */
  45379. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  45380. /**
  45381. * Checks to see if a texture is used in the material.
  45382. * @param texture - Base texture to use.
  45383. * @returns - Boolean specifying if a texture is used in the material.
  45384. */
  45385. hasTexture(texture: BaseTexture): boolean;
  45386. /**
  45387. * Gets a boolean indicating that current material needs to register RTT
  45388. * @returns true if this uses a render target otherwise false.
  45389. */
  45390. hasRenderTargetTextures(): boolean;
  45391. /**
  45392. * Returns an array of the actively used textures.
  45393. * @param activeTextures Array of BaseTextures
  45394. */
  45395. getActiveTextures(activeTextures: BaseTexture[]): void;
  45396. /**
  45397. * Returns the animatable textures.
  45398. * @param animatables Array of animatable textures.
  45399. */
  45400. getAnimatables(animatables: IAnimatable[]): void;
  45401. /**
  45402. * Disposes the resources of the material.
  45403. * @param forceDisposeTextures - Forces the disposal of all textures.
  45404. */
  45405. dispose(forceDisposeTextures?: boolean): void;
  45406. /**
  45407. * Get the current class name of the texture useful for serialization or dynamic coding.
  45408. * @returns "PBRSubSurfaceConfiguration"
  45409. */
  45410. getClassName(): string;
  45411. /**
  45412. * Add fallbacks to the effect fallbacks list.
  45413. * @param defines defines the Base texture to use.
  45414. * @param fallbacks defines the current fallback list.
  45415. * @param currentRank defines the current fallback rank.
  45416. * @returns the new fallback rank.
  45417. */
  45418. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45419. /**
  45420. * Add the required uniforms to the current list.
  45421. * @param uniforms defines the current uniform list.
  45422. */
  45423. static AddUniforms(uniforms: string[]): void;
  45424. /**
  45425. * Add the required samplers to the current list.
  45426. * @param samplers defines the current sampler list.
  45427. */
  45428. static AddSamplers(samplers: string[]): void;
  45429. /**
  45430. * Add the required uniforms to the current buffer.
  45431. * @param uniformBuffer defines the current uniform buffer.
  45432. */
  45433. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45434. /**
  45435. * Makes a duplicate of the current configuration into another one.
  45436. * @param configuration define the config where to copy the info
  45437. */
  45438. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  45439. /**
  45440. * Serializes this Sub Surface configuration.
  45441. * @returns - An object with the serialized config.
  45442. */
  45443. serialize(): any;
  45444. /**
  45445. * Parses a anisotropy Configuration from a serialized object.
  45446. * @param source - Serialized object.
  45447. * @param scene Defines the scene we are parsing for
  45448. * @param rootUrl Defines the rootUrl to load from
  45449. */
  45450. parse(source: any, scene: Scene, rootUrl: string): void;
  45451. }
  45452. }
  45453. declare module BABYLON {
  45454. /** @hidden */
  45455. export var pbrFragmentDeclaration: {
  45456. name: string;
  45457. shader: string;
  45458. };
  45459. }
  45460. declare module BABYLON {
  45461. /** @hidden */
  45462. export var pbrUboDeclaration: {
  45463. name: string;
  45464. shader: string;
  45465. };
  45466. }
  45467. declare module BABYLON {
  45468. /** @hidden */
  45469. export var pbrFragmentExtraDeclaration: {
  45470. name: string;
  45471. shader: string;
  45472. };
  45473. }
  45474. declare module BABYLON {
  45475. /** @hidden */
  45476. export var pbrFragmentSamplersDeclaration: {
  45477. name: string;
  45478. shader: string;
  45479. };
  45480. }
  45481. declare module BABYLON {
  45482. /** @hidden */
  45483. export var pbrHelperFunctions: {
  45484. name: string;
  45485. shader: string;
  45486. };
  45487. }
  45488. declare module BABYLON {
  45489. /** @hidden */
  45490. export var harmonicsFunctions: {
  45491. name: string;
  45492. shader: string;
  45493. };
  45494. }
  45495. declare module BABYLON {
  45496. /** @hidden */
  45497. export var pbrDirectLightingSetupFunctions: {
  45498. name: string;
  45499. shader: string;
  45500. };
  45501. }
  45502. declare module BABYLON {
  45503. /** @hidden */
  45504. export var pbrDirectLightingFalloffFunctions: {
  45505. name: string;
  45506. shader: string;
  45507. };
  45508. }
  45509. declare module BABYLON {
  45510. /** @hidden */
  45511. export var pbrBRDFFunctions: {
  45512. name: string;
  45513. shader: string;
  45514. };
  45515. }
  45516. declare module BABYLON {
  45517. /** @hidden */
  45518. export var pbrDirectLightingFunctions: {
  45519. name: string;
  45520. shader: string;
  45521. };
  45522. }
  45523. declare module BABYLON {
  45524. /** @hidden */
  45525. export var pbrIBLFunctions: {
  45526. name: string;
  45527. shader: string;
  45528. };
  45529. }
  45530. declare module BABYLON {
  45531. /** @hidden */
  45532. export var pbrDebug: {
  45533. name: string;
  45534. shader: string;
  45535. };
  45536. }
  45537. declare module BABYLON {
  45538. /** @hidden */
  45539. export var pbrPixelShader: {
  45540. name: string;
  45541. shader: string;
  45542. };
  45543. }
  45544. declare module BABYLON {
  45545. /** @hidden */
  45546. export var pbrVertexDeclaration: {
  45547. name: string;
  45548. shader: string;
  45549. };
  45550. }
  45551. declare module BABYLON {
  45552. /** @hidden */
  45553. export var pbrVertexShader: {
  45554. name: string;
  45555. shader: string;
  45556. };
  45557. }
  45558. declare module BABYLON {
  45559. /**
  45560. * Manages the defines for the PBR Material.
  45561. * @hidden
  45562. */
  45563. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  45564. PBR: boolean;
  45565. MAINUV1: boolean;
  45566. MAINUV2: boolean;
  45567. UV1: boolean;
  45568. UV2: boolean;
  45569. ALBEDO: boolean;
  45570. ALBEDODIRECTUV: number;
  45571. VERTEXCOLOR: boolean;
  45572. AMBIENT: boolean;
  45573. AMBIENTDIRECTUV: number;
  45574. AMBIENTINGRAYSCALE: boolean;
  45575. OPACITY: boolean;
  45576. VERTEXALPHA: boolean;
  45577. OPACITYDIRECTUV: number;
  45578. OPACITYRGB: boolean;
  45579. ALPHATEST: boolean;
  45580. DEPTHPREPASS: boolean;
  45581. ALPHABLEND: boolean;
  45582. ALPHAFROMALBEDO: boolean;
  45583. ALPHATESTVALUE: string;
  45584. SPECULAROVERALPHA: boolean;
  45585. RADIANCEOVERALPHA: boolean;
  45586. ALPHAFRESNEL: boolean;
  45587. LINEARALPHAFRESNEL: boolean;
  45588. PREMULTIPLYALPHA: boolean;
  45589. EMISSIVE: boolean;
  45590. EMISSIVEDIRECTUV: number;
  45591. REFLECTIVITY: boolean;
  45592. REFLECTIVITYDIRECTUV: number;
  45593. SPECULARTERM: boolean;
  45594. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  45595. MICROSURFACEAUTOMATIC: boolean;
  45596. LODBASEDMICROSFURACE: boolean;
  45597. MICROSURFACEMAP: boolean;
  45598. MICROSURFACEMAPDIRECTUV: number;
  45599. METALLICWORKFLOW: boolean;
  45600. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  45601. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  45602. METALLNESSSTOREINMETALMAPBLUE: boolean;
  45603. AOSTOREINMETALMAPRED: boolean;
  45604. ENVIRONMENTBRDF: boolean;
  45605. ENVIRONMENTBRDF_RGBD: boolean;
  45606. NORMAL: boolean;
  45607. TANGENT: boolean;
  45608. BUMP: boolean;
  45609. BUMPDIRECTUV: number;
  45610. OBJECTSPACE_NORMALMAP: boolean;
  45611. PARALLAX: boolean;
  45612. PARALLAXOCCLUSION: boolean;
  45613. NORMALXYSCALE: boolean;
  45614. LIGHTMAP: boolean;
  45615. LIGHTMAPDIRECTUV: number;
  45616. USELIGHTMAPASSHADOWMAP: boolean;
  45617. GAMMALIGHTMAP: boolean;
  45618. REFLECTION: boolean;
  45619. REFLECTIONMAP_3D: boolean;
  45620. REFLECTIONMAP_SPHERICAL: boolean;
  45621. REFLECTIONMAP_PLANAR: boolean;
  45622. REFLECTIONMAP_CUBIC: boolean;
  45623. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  45624. REFLECTIONMAP_PROJECTION: boolean;
  45625. REFLECTIONMAP_SKYBOX: boolean;
  45626. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  45627. REFLECTIONMAP_EXPLICIT: boolean;
  45628. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  45629. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  45630. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  45631. INVERTCUBICMAP: boolean;
  45632. USESPHERICALFROMREFLECTIONMAP: boolean;
  45633. USEIRRADIANCEMAP: boolean;
  45634. SPHERICAL_HARMONICS: boolean;
  45635. USESPHERICALINVERTEX: boolean;
  45636. REFLECTIONMAP_OPPOSITEZ: boolean;
  45637. LODINREFLECTIONALPHA: boolean;
  45638. GAMMAREFLECTION: boolean;
  45639. RGBDREFLECTION: boolean;
  45640. LINEARSPECULARREFLECTION: boolean;
  45641. RADIANCEOCCLUSION: boolean;
  45642. HORIZONOCCLUSION: boolean;
  45643. INSTANCES: boolean;
  45644. NUM_BONE_INFLUENCERS: number;
  45645. BonesPerMesh: number;
  45646. BONETEXTURE: boolean;
  45647. NONUNIFORMSCALING: boolean;
  45648. MORPHTARGETS: boolean;
  45649. MORPHTARGETS_NORMAL: boolean;
  45650. MORPHTARGETS_TANGENT: boolean;
  45651. MORPHTARGETS_UV: boolean;
  45652. NUM_MORPH_INFLUENCERS: number;
  45653. IMAGEPROCESSING: boolean;
  45654. VIGNETTE: boolean;
  45655. VIGNETTEBLENDMODEMULTIPLY: boolean;
  45656. VIGNETTEBLENDMODEOPAQUE: boolean;
  45657. TONEMAPPING: boolean;
  45658. TONEMAPPING_ACES: boolean;
  45659. CONTRAST: boolean;
  45660. COLORCURVES: boolean;
  45661. COLORGRADING: boolean;
  45662. COLORGRADING3D: boolean;
  45663. SAMPLER3DGREENDEPTH: boolean;
  45664. SAMPLER3DBGRMAP: boolean;
  45665. IMAGEPROCESSINGPOSTPROCESS: boolean;
  45666. EXPOSURE: boolean;
  45667. MULTIVIEW: boolean;
  45668. USEPHYSICALLIGHTFALLOFF: boolean;
  45669. USEGLTFLIGHTFALLOFF: boolean;
  45670. TWOSIDEDLIGHTING: boolean;
  45671. SHADOWFLOAT: boolean;
  45672. CLIPPLANE: boolean;
  45673. CLIPPLANE2: boolean;
  45674. CLIPPLANE3: boolean;
  45675. CLIPPLANE4: boolean;
  45676. POINTSIZE: boolean;
  45677. FOG: boolean;
  45678. LOGARITHMICDEPTH: boolean;
  45679. FORCENORMALFORWARD: boolean;
  45680. SPECULARAA: boolean;
  45681. CLEARCOAT: boolean;
  45682. CLEARCOAT_DEFAULTIOR: boolean;
  45683. CLEARCOAT_TEXTURE: boolean;
  45684. CLEARCOAT_TEXTUREDIRECTUV: number;
  45685. CLEARCOAT_BUMP: boolean;
  45686. CLEARCOAT_BUMPDIRECTUV: number;
  45687. CLEARCOAT_TINT: boolean;
  45688. CLEARCOAT_TINT_TEXTURE: boolean;
  45689. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45690. ANISOTROPIC: boolean;
  45691. ANISOTROPIC_TEXTURE: boolean;
  45692. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45693. BRDF_V_HEIGHT_CORRELATED: boolean;
  45694. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45695. SHEEN: boolean;
  45696. SHEEN_TEXTURE: boolean;
  45697. SHEEN_TEXTUREDIRECTUV: number;
  45698. SHEEN_LINKWITHALBEDO: boolean;
  45699. SUBSURFACE: boolean;
  45700. SS_REFRACTION: boolean;
  45701. SS_TRANSLUCENCY: boolean;
  45702. SS_SCATERRING: boolean;
  45703. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45704. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45705. SS_REFRACTIONMAP_3D: boolean;
  45706. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45707. SS_LODINREFRACTIONALPHA: boolean;
  45708. SS_GAMMAREFRACTION: boolean;
  45709. SS_RGBDREFRACTION: boolean;
  45710. SS_LINEARSPECULARREFRACTION: boolean;
  45711. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45712. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45713. UNLIT: boolean;
  45714. DEBUGMODE: number;
  45715. /**
  45716. * Initializes the PBR Material defines.
  45717. */
  45718. constructor();
  45719. /**
  45720. * Resets the PBR Material defines.
  45721. */
  45722. reset(): void;
  45723. }
  45724. /**
  45725. * The Physically based material base class of BJS.
  45726. *
  45727. * This offers the main features of a standard PBR material.
  45728. * For more information, please refer to the documentation :
  45729. * https://doc.babylonjs.com/how_to/physically_based_rendering
  45730. */
  45731. export abstract class PBRBaseMaterial extends PushMaterial {
  45732. /**
  45733. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45734. */
  45735. static readonly PBRMATERIAL_OPAQUE: number;
  45736. /**
  45737. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45738. */
  45739. static readonly PBRMATERIAL_ALPHATEST: number;
  45740. /**
  45741. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45742. */
  45743. static readonly PBRMATERIAL_ALPHABLEND: number;
  45744. /**
  45745. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45746. * They are also discarded below the alpha cutoff threshold to improve performances.
  45747. */
  45748. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45749. /**
  45750. * Defines the default value of how much AO map is occluding the analytical lights
  45751. * (point spot...).
  45752. */
  45753. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45754. /**
  45755. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45756. */
  45757. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45758. /**
  45759. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45760. * to enhance interoperability with other engines.
  45761. */
  45762. static readonly LIGHTFALLOFF_GLTF: number;
  45763. /**
  45764. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45765. * to enhance interoperability with other materials.
  45766. */
  45767. static readonly LIGHTFALLOFF_STANDARD: number;
  45768. /**
  45769. * Intensity of the direct lights e.g. the four lights available in your scene.
  45770. * This impacts both the direct diffuse and specular highlights.
  45771. */
  45772. protected _directIntensity: number;
  45773. /**
  45774. * Intensity of the emissive part of the material.
  45775. * This helps controlling the emissive effect without modifying the emissive color.
  45776. */
  45777. protected _emissiveIntensity: number;
  45778. /**
  45779. * Intensity of the environment e.g. how much the environment will light the object
  45780. * either through harmonics for rough material or through the refelction for shiny ones.
  45781. */
  45782. protected _environmentIntensity: number;
  45783. /**
  45784. * This is a special control allowing the reduction of the specular highlights coming from the
  45785. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45786. */
  45787. protected _specularIntensity: number;
  45788. /**
  45789. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45790. */
  45791. private _lightingInfos;
  45792. /**
  45793. * Debug Control allowing disabling the bump map on this material.
  45794. */
  45795. protected _disableBumpMap: boolean;
  45796. /**
  45797. * AKA Diffuse Texture in standard nomenclature.
  45798. */
  45799. protected _albedoTexture: Nullable<BaseTexture>;
  45800. /**
  45801. * AKA Occlusion Texture in other nomenclature.
  45802. */
  45803. protected _ambientTexture: Nullable<BaseTexture>;
  45804. /**
  45805. * AKA Occlusion Texture Intensity in other nomenclature.
  45806. */
  45807. protected _ambientTextureStrength: number;
  45808. /**
  45809. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45810. * 1 means it completely occludes it
  45811. * 0 mean it has no impact
  45812. */
  45813. protected _ambientTextureImpactOnAnalyticalLights: number;
  45814. /**
  45815. * Stores the alpha values in a texture.
  45816. */
  45817. protected _opacityTexture: Nullable<BaseTexture>;
  45818. /**
  45819. * Stores the reflection values in a texture.
  45820. */
  45821. protected _reflectionTexture: Nullable<BaseTexture>;
  45822. /**
  45823. * Stores the emissive values in a texture.
  45824. */
  45825. protected _emissiveTexture: Nullable<BaseTexture>;
  45826. /**
  45827. * AKA Specular texture in other nomenclature.
  45828. */
  45829. protected _reflectivityTexture: Nullable<BaseTexture>;
  45830. /**
  45831. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45832. */
  45833. protected _metallicTexture: Nullable<BaseTexture>;
  45834. /**
  45835. * Specifies the metallic scalar of the metallic/roughness workflow.
  45836. * Can also be used to scale the metalness values of the metallic texture.
  45837. */
  45838. protected _metallic: Nullable<number>;
  45839. /**
  45840. * Specifies the roughness scalar of the metallic/roughness workflow.
  45841. * Can also be used to scale the roughness values of the metallic texture.
  45842. */
  45843. protected _roughness: Nullable<number>;
  45844. /**
  45845. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45846. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45847. */
  45848. protected _microSurfaceTexture: Nullable<BaseTexture>;
  45849. /**
  45850. * Stores surface normal data used to displace a mesh in a texture.
  45851. */
  45852. protected _bumpTexture: Nullable<BaseTexture>;
  45853. /**
  45854. * Stores the pre-calculated light information of a mesh in a texture.
  45855. */
  45856. protected _lightmapTexture: Nullable<BaseTexture>;
  45857. /**
  45858. * The color of a material in ambient lighting.
  45859. */
  45860. protected _ambientColor: Color3;
  45861. /**
  45862. * AKA Diffuse Color in other nomenclature.
  45863. */
  45864. protected _albedoColor: Color3;
  45865. /**
  45866. * AKA Specular Color in other nomenclature.
  45867. */
  45868. protected _reflectivityColor: Color3;
  45869. /**
  45870. * The color applied when light is reflected from a material.
  45871. */
  45872. protected _reflectionColor: Color3;
  45873. /**
  45874. * The color applied when light is emitted from a material.
  45875. */
  45876. protected _emissiveColor: Color3;
  45877. /**
  45878. * AKA Glossiness in other nomenclature.
  45879. */
  45880. protected _microSurface: number;
  45881. /**
  45882. * Specifies that the material will use the light map as a show map.
  45883. */
  45884. protected _useLightmapAsShadowmap: boolean;
  45885. /**
  45886. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45887. * makes the reflect vector face the model (under horizon).
  45888. */
  45889. protected _useHorizonOcclusion: boolean;
  45890. /**
  45891. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45892. * too much the area relying on ambient texture to define their ambient occlusion.
  45893. */
  45894. protected _useRadianceOcclusion: boolean;
  45895. /**
  45896. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45897. */
  45898. protected _useAlphaFromAlbedoTexture: boolean;
  45899. /**
  45900. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45901. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45902. */
  45903. protected _useSpecularOverAlpha: boolean;
  45904. /**
  45905. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45906. */
  45907. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45908. /**
  45909. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45910. */
  45911. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45912. /**
  45913. * Specifies if the metallic texture contains the roughness information in its green channel.
  45914. */
  45915. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45916. /**
  45917. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45918. */
  45919. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45920. /**
  45921. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45922. */
  45923. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45924. /**
  45925. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45926. */
  45927. protected _useAmbientInGrayScale: boolean;
  45928. /**
  45929. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45930. * The material will try to infer what glossiness each pixel should be.
  45931. */
  45932. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45933. /**
  45934. * Defines the falloff type used in this material.
  45935. * It by default is Physical.
  45936. */
  45937. protected _lightFalloff: number;
  45938. /**
  45939. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45940. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45941. */
  45942. protected _useRadianceOverAlpha: boolean;
  45943. /**
  45944. * Allows using an object space normal map (instead of tangent space).
  45945. */
  45946. protected _useObjectSpaceNormalMap: boolean;
  45947. /**
  45948. * Allows using the bump map in parallax mode.
  45949. */
  45950. protected _useParallax: boolean;
  45951. /**
  45952. * Allows using the bump map in parallax occlusion mode.
  45953. */
  45954. protected _useParallaxOcclusion: boolean;
  45955. /**
  45956. * Controls the scale bias of the parallax mode.
  45957. */
  45958. protected _parallaxScaleBias: number;
  45959. /**
  45960. * If sets to true, disables all the lights affecting the material.
  45961. */
  45962. protected _disableLighting: boolean;
  45963. /**
  45964. * Number of Simultaneous lights allowed on the material.
  45965. */
  45966. protected _maxSimultaneousLights: number;
  45967. /**
  45968. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45969. */
  45970. protected _invertNormalMapX: boolean;
  45971. /**
  45972. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45973. */
  45974. protected _invertNormalMapY: boolean;
  45975. /**
  45976. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45977. */
  45978. protected _twoSidedLighting: boolean;
  45979. /**
  45980. * Defines the alpha limits in alpha test mode.
  45981. */
  45982. protected _alphaCutOff: number;
  45983. /**
  45984. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45985. */
  45986. protected _forceAlphaTest: boolean;
  45987. /**
  45988. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45989. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45990. */
  45991. protected _useAlphaFresnel: boolean;
  45992. /**
  45993. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45994. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45995. */
  45996. protected _useLinearAlphaFresnel: boolean;
  45997. /**
  45998. * The transparency mode of the material.
  45999. */
  46000. protected _transparencyMode: Nullable<number>;
  46001. /**
  46002. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46003. * from cos thetav and roughness:
  46004. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46005. */
  46006. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46007. /**
  46008. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46009. */
  46010. protected _forceIrradianceInFragment: boolean;
  46011. /**
  46012. * Force normal to face away from face.
  46013. */
  46014. protected _forceNormalForward: boolean;
  46015. /**
  46016. * Enables specular anti aliasing in the PBR shader.
  46017. * It will both interacts on the Geometry for analytical and IBL lighting.
  46018. * It also prefilter the roughness map based on the bump values.
  46019. */
  46020. protected _enableSpecularAntiAliasing: boolean;
  46021. /**
  46022. * Default configuration related to image processing available in the PBR Material.
  46023. */
  46024. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46025. /**
  46026. * Keep track of the image processing observer to allow dispose and replace.
  46027. */
  46028. private _imageProcessingObserver;
  46029. /**
  46030. * Attaches a new image processing configuration to the PBR Material.
  46031. * @param configuration
  46032. */
  46033. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46034. /**
  46035. * Stores the available render targets.
  46036. */
  46037. private _renderTargets;
  46038. /**
  46039. * Sets the global ambient color for the material used in lighting calculations.
  46040. */
  46041. private _globalAmbientColor;
  46042. /**
  46043. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46044. */
  46045. private _useLogarithmicDepth;
  46046. /**
  46047. * If set to true, no lighting calculations will be applied.
  46048. */
  46049. private _unlit;
  46050. private _debugMode;
  46051. /**
  46052. * @hidden
  46053. * This is reserved for the inspector.
  46054. * Defines the material debug mode.
  46055. * It helps seeing only some components of the material while troubleshooting.
  46056. */
  46057. debugMode: number;
  46058. /**
  46059. * @hidden
  46060. * This is reserved for the inspector.
  46061. * Specify from where on screen the debug mode should start.
  46062. * The value goes from -1 (full screen) to 1 (not visible)
  46063. * It helps with side by side comparison against the final render
  46064. * This defaults to -1
  46065. */
  46066. private debugLimit;
  46067. /**
  46068. * @hidden
  46069. * This is reserved for the inspector.
  46070. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46071. * You can use the factor to better multiply the final value.
  46072. */
  46073. private debugFactor;
  46074. /**
  46075. * Defines the clear coat layer parameters for the material.
  46076. */
  46077. readonly clearCoat: PBRClearCoatConfiguration;
  46078. /**
  46079. * Defines the anisotropic parameters for the material.
  46080. */
  46081. readonly anisotropy: PBRAnisotropicConfiguration;
  46082. /**
  46083. * Defines the BRDF parameters for the material.
  46084. */
  46085. readonly brdf: PBRBRDFConfiguration;
  46086. /**
  46087. * Defines the Sheen parameters for the material.
  46088. */
  46089. readonly sheen: PBRSheenConfiguration;
  46090. /**
  46091. * Defines the SubSurface parameters for the material.
  46092. */
  46093. readonly subSurface: PBRSubSurfaceConfiguration;
  46094. /**
  46095. * Custom callback helping to override the default shader used in the material.
  46096. */
  46097. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46098. /**
  46099. * Instantiates a new PBRMaterial instance.
  46100. *
  46101. * @param name The material name
  46102. * @param scene The scene the material will be use in.
  46103. */
  46104. constructor(name: string, scene: Scene);
  46105. /**
  46106. * Gets a boolean indicating that current material needs to register RTT
  46107. */
  46108. readonly hasRenderTargetTextures: boolean;
  46109. /**
  46110. * Gets the name of the material class.
  46111. */
  46112. getClassName(): string;
  46113. /**
  46114. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46115. */
  46116. /**
  46117. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46118. */
  46119. useLogarithmicDepth: boolean;
  46120. /**
  46121. * Gets the current transparency mode.
  46122. */
  46123. /**
  46124. * Sets the transparency mode of the material.
  46125. *
  46126. * | Value | Type | Description |
  46127. * | ----- | ----------------------------------- | ----------- |
  46128. * | 0 | OPAQUE | |
  46129. * | 1 | ALPHATEST | |
  46130. * | 2 | ALPHABLEND | |
  46131. * | 3 | ALPHATESTANDBLEND | |
  46132. *
  46133. */
  46134. transparencyMode: Nullable<number>;
  46135. /**
  46136. * Returns true if alpha blending should be disabled.
  46137. */
  46138. private readonly _disableAlphaBlending;
  46139. /**
  46140. * Specifies whether or not this material should be rendered in alpha blend mode.
  46141. */
  46142. needAlphaBlending(): boolean;
  46143. /**
  46144. * Specifies if the mesh will require alpha blending.
  46145. * @param mesh - BJS mesh.
  46146. */
  46147. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46148. /**
  46149. * Specifies whether or not this material should be rendered in alpha test mode.
  46150. */
  46151. needAlphaTesting(): boolean;
  46152. /**
  46153. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46154. */
  46155. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46156. /**
  46157. * Gets the texture used for the alpha test.
  46158. */
  46159. getAlphaTestTexture(): Nullable<BaseTexture>;
  46160. /**
  46161. * Specifies that the submesh is ready to be used.
  46162. * @param mesh - BJS mesh.
  46163. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46164. * @param useInstances - Specifies that instances should be used.
  46165. * @returns - boolean indicating that the submesh is ready or not.
  46166. */
  46167. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46168. /**
  46169. * Specifies if the material uses metallic roughness workflow.
  46170. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46171. */
  46172. isMetallicWorkflow(): boolean;
  46173. private _prepareEffect;
  46174. private _prepareDefines;
  46175. /**
  46176. * Force shader compilation
  46177. */
  46178. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46179. clipPlane: boolean;
  46180. }>): void;
  46181. /**
  46182. * Initializes the uniform buffer layout for the shader.
  46183. */
  46184. buildUniformLayout(): void;
  46185. /**
  46186. * Unbinds the material from the mesh
  46187. */
  46188. unbind(): void;
  46189. /**
  46190. * Binds the submesh data.
  46191. * @param world - The world matrix.
  46192. * @param mesh - The BJS mesh.
  46193. * @param subMesh - A submesh of the BJS mesh.
  46194. */
  46195. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46196. /**
  46197. * Returns the animatable textures.
  46198. * @returns - Array of animatable textures.
  46199. */
  46200. getAnimatables(): IAnimatable[];
  46201. /**
  46202. * Returns the texture used for reflections.
  46203. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46204. */
  46205. private _getReflectionTexture;
  46206. /**
  46207. * Returns an array of the actively used textures.
  46208. * @returns - Array of BaseTextures
  46209. */
  46210. getActiveTextures(): BaseTexture[];
  46211. /**
  46212. * Checks to see if a texture is used in the material.
  46213. * @param texture - Base texture to use.
  46214. * @returns - Boolean specifying if a texture is used in the material.
  46215. */
  46216. hasTexture(texture: BaseTexture): boolean;
  46217. /**
  46218. * Disposes the resources of the material.
  46219. * @param forceDisposeEffect - Forces the disposal of effects.
  46220. * @param forceDisposeTextures - Forces the disposal of all textures.
  46221. */
  46222. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46223. }
  46224. }
  46225. declare module BABYLON {
  46226. /**
  46227. * The Physically based material of BJS.
  46228. *
  46229. * This offers the main features of a standard PBR material.
  46230. * For more information, please refer to the documentation :
  46231. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46232. */
  46233. export class PBRMaterial extends PBRBaseMaterial {
  46234. /**
  46235. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46236. */
  46237. static readonly PBRMATERIAL_OPAQUE: number;
  46238. /**
  46239. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46240. */
  46241. static readonly PBRMATERIAL_ALPHATEST: number;
  46242. /**
  46243. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46244. */
  46245. static readonly PBRMATERIAL_ALPHABLEND: number;
  46246. /**
  46247. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46248. * They are also discarded below the alpha cutoff threshold to improve performances.
  46249. */
  46250. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46251. /**
  46252. * Defines the default value of how much AO map is occluding the analytical lights
  46253. * (point spot...).
  46254. */
  46255. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46256. /**
  46257. * Intensity of the direct lights e.g. the four lights available in your scene.
  46258. * This impacts both the direct diffuse and specular highlights.
  46259. */
  46260. directIntensity: number;
  46261. /**
  46262. * Intensity of the emissive part of the material.
  46263. * This helps controlling the emissive effect without modifying the emissive color.
  46264. */
  46265. emissiveIntensity: number;
  46266. /**
  46267. * Intensity of the environment e.g. how much the environment will light the object
  46268. * either through harmonics for rough material or through the refelction for shiny ones.
  46269. */
  46270. environmentIntensity: number;
  46271. /**
  46272. * This is a special control allowing the reduction of the specular highlights coming from the
  46273. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46274. */
  46275. specularIntensity: number;
  46276. /**
  46277. * Debug Control allowing disabling the bump map on this material.
  46278. */
  46279. disableBumpMap: boolean;
  46280. /**
  46281. * AKA Diffuse Texture in standard nomenclature.
  46282. */
  46283. albedoTexture: BaseTexture;
  46284. /**
  46285. * AKA Occlusion Texture in other nomenclature.
  46286. */
  46287. ambientTexture: BaseTexture;
  46288. /**
  46289. * AKA Occlusion Texture Intensity in other nomenclature.
  46290. */
  46291. ambientTextureStrength: number;
  46292. /**
  46293. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46294. * 1 means it completely occludes it
  46295. * 0 mean it has no impact
  46296. */
  46297. ambientTextureImpactOnAnalyticalLights: number;
  46298. /**
  46299. * Stores the alpha values in a texture.
  46300. */
  46301. opacityTexture: BaseTexture;
  46302. /**
  46303. * Stores the reflection values in a texture.
  46304. */
  46305. reflectionTexture: Nullable<BaseTexture>;
  46306. /**
  46307. * Stores the emissive values in a texture.
  46308. */
  46309. emissiveTexture: BaseTexture;
  46310. /**
  46311. * AKA Specular texture in other nomenclature.
  46312. */
  46313. reflectivityTexture: BaseTexture;
  46314. /**
  46315. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46316. */
  46317. metallicTexture: BaseTexture;
  46318. /**
  46319. * Specifies the metallic scalar of the metallic/roughness workflow.
  46320. * Can also be used to scale the metalness values of the metallic texture.
  46321. */
  46322. metallic: Nullable<number>;
  46323. /**
  46324. * Specifies the roughness scalar of the metallic/roughness workflow.
  46325. * Can also be used to scale the roughness values of the metallic texture.
  46326. */
  46327. roughness: Nullable<number>;
  46328. /**
  46329. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46330. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46331. */
  46332. microSurfaceTexture: BaseTexture;
  46333. /**
  46334. * Stores surface normal data used to displace a mesh in a texture.
  46335. */
  46336. bumpTexture: BaseTexture;
  46337. /**
  46338. * Stores the pre-calculated light information of a mesh in a texture.
  46339. */
  46340. lightmapTexture: BaseTexture;
  46341. /**
  46342. * Stores the refracted light information in a texture.
  46343. */
  46344. refractionTexture: Nullable<BaseTexture>;
  46345. /**
  46346. * The color of a material in ambient lighting.
  46347. */
  46348. ambientColor: Color3;
  46349. /**
  46350. * AKA Diffuse Color in other nomenclature.
  46351. */
  46352. albedoColor: Color3;
  46353. /**
  46354. * AKA Specular Color in other nomenclature.
  46355. */
  46356. reflectivityColor: Color3;
  46357. /**
  46358. * The color reflected from the material.
  46359. */
  46360. reflectionColor: Color3;
  46361. /**
  46362. * The color emitted from the material.
  46363. */
  46364. emissiveColor: Color3;
  46365. /**
  46366. * AKA Glossiness in other nomenclature.
  46367. */
  46368. microSurface: number;
  46369. /**
  46370. * source material index of refraction (IOR)' / 'destination material IOR.
  46371. */
  46372. indexOfRefraction: number;
  46373. /**
  46374. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46375. */
  46376. invertRefractionY: boolean;
  46377. /**
  46378. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46379. * Materials half opaque for instance using refraction could benefit from this control.
  46380. */
  46381. linkRefractionWithTransparency: boolean;
  46382. /**
  46383. * If true, the light map contains occlusion information instead of lighting info.
  46384. */
  46385. useLightmapAsShadowmap: boolean;
  46386. /**
  46387. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46388. */
  46389. useAlphaFromAlbedoTexture: boolean;
  46390. /**
  46391. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46392. */
  46393. forceAlphaTest: boolean;
  46394. /**
  46395. * Defines the alpha limits in alpha test mode.
  46396. */
  46397. alphaCutOff: number;
  46398. /**
  46399. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46400. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46401. */
  46402. useSpecularOverAlpha: boolean;
  46403. /**
  46404. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46405. */
  46406. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46407. /**
  46408. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46409. */
  46410. useRoughnessFromMetallicTextureAlpha: boolean;
  46411. /**
  46412. * Specifies if the metallic texture contains the roughness information in its green channel.
  46413. */
  46414. useRoughnessFromMetallicTextureGreen: boolean;
  46415. /**
  46416. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46417. */
  46418. useMetallnessFromMetallicTextureBlue: boolean;
  46419. /**
  46420. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46421. */
  46422. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46423. /**
  46424. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46425. */
  46426. useAmbientInGrayScale: boolean;
  46427. /**
  46428. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46429. * The material will try to infer what glossiness each pixel should be.
  46430. */
  46431. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46432. /**
  46433. * BJS is using an harcoded light falloff based on a manually sets up range.
  46434. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46435. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46436. */
  46437. /**
  46438. * BJS is using an harcoded light falloff based on a manually sets up range.
  46439. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46440. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46441. */
  46442. usePhysicalLightFalloff: boolean;
  46443. /**
  46444. * In order to support the falloff compatibility with gltf, a special mode has been added
  46445. * to reproduce the gltf light falloff.
  46446. */
  46447. /**
  46448. * In order to support the falloff compatibility with gltf, a special mode has been added
  46449. * to reproduce the gltf light falloff.
  46450. */
  46451. useGLTFLightFalloff: boolean;
  46452. /**
  46453. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46454. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46455. */
  46456. useRadianceOverAlpha: boolean;
  46457. /**
  46458. * Allows using an object space normal map (instead of tangent space).
  46459. */
  46460. useObjectSpaceNormalMap: boolean;
  46461. /**
  46462. * Allows using the bump map in parallax mode.
  46463. */
  46464. useParallax: boolean;
  46465. /**
  46466. * Allows using the bump map in parallax occlusion mode.
  46467. */
  46468. useParallaxOcclusion: boolean;
  46469. /**
  46470. * Controls the scale bias of the parallax mode.
  46471. */
  46472. parallaxScaleBias: number;
  46473. /**
  46474. * If sets to true, disables all the lights affecting the material.
  46475. */
  46476. disableLighting: boolean;
  46477. /**
  46478. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46479. */
  46480. forceIrradianceInFragment: boolean;
  46481. /**
  46482. * Number of Simultaneous lights allowed on the material.
  46483. */
  46484. maxSimultaneousLights: number;
  46485. /**
  46486. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46487. */
  46488. invertNormalMapX: boolean;
  46489. /**
  46490. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46491. */
  46492. invertNormalMapY: boolean;
  46493. /**
  46494. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46495. */
  46496. twoSidedLighting: boolean;
  46497. /**
  46498. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46499. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46500. */
  46501. useAlphaFresnel: boolean;
  46502. /**
  46503. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46504. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46505. */
  46506. useLinearAlphaFresnel: boolean;
  46507. /**
  46508. * Let user defines the brdf lookup texture used for IBL.
  46509. * A default 8bit version is embedded but you could point at :
  46510. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  46511. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46512. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  46513. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46514. */
  46515. environmentBRDFTexture: Nullable<BaseTexture>;
  46516. /**
  46517. * Force normal to face away from face.
  46518. */
  46519. forceNormalForward: boolean;
  46520. /**
  46521. * Enables specular anti aliasing in the PBR shader.
  46522. * It will both interacts on the Geometry for analytical and IBL lighting.
  46523. * It also prefilter the roughness map based on the bump values.
  46524. */
  46525. enableSpecularAntiAliasing: boolean;
  46526. /**
  46527. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46528. * makes the reflect vector face the model (under horizon).
  46529. */
  46530. useHorizonOcclusion: boolean;
  46531. /**
  46532. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46533. * too much the area relying on ambient texture to define their ambient occlusion.
  46534. */
  46535. useRadianceOcclusion: boolean;
  46536. /**
  46537. * If set to true, no lighting calculations will be applied.
  46538. */
  46539. unlit: boolean;
  46540. /**
  46541. * Gets the image processing configuration used either in this material.
  46542. */
  46543. /**
  46544. * Sets the Default image processing configuration used either in the this material.
  46545. *
  46546. * If sets to null, the scene one is in use.
  46547. */
  46548. imageProcessingConfiguration: ImageProcessingConfiguration;
  46549. /**
  46550. * Gets wether the color curves effect is enabled.
  46551. */
  46552. /**
  46553. * Sets wether the color curves effect is enabled.
  46554. */
  46555. cameraColorCurvesEnabled: boolean;
  46556. /**
  46557. * Gets wether the color grading effect is enabled.
  46558. */
  46559. /**
  46560. * Gets wether the color grading effect is enabled.
  46561. */
  46562. cameraColorGradingEnabled: boolean;
  46563. /**
  46564. * Gets wether tonemapping is enabled or not.
  46565. */
  46566. /**
  46567. * Sets wether tonemapping is enabled or not
  46568. */
  46569. cameraToneMappingEnabled: boolean;
  46570. /**
  46571. * The camera exposure used on this material.
  46572. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46573. * This corresponds to a photographic exposure.
  46574. */
  46575. /**
  46576. * The camera exposure used on this material.
  46577. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46578. * This corresponds to a photographic exposure.
  46579. */
  46580. cameraExposure: number;
  46581. /**
  46582. * Gets The camera contrast used on this material.
  46583. */
  46584. /**
  46585. * Sets The camera contrast used on this material.
  46586. */
  46587. cameraContrast: number;
  46588. /**
  46589. * Gets the Color Grading 2D Lookup Texture.
  46590. */
  46591. /**
  46592. * Sets the Color Grading 2D Lookup Texture.
  46593. */
  46594. cameraColorGradingTexture: Nullable<BaseTexture>;
  46595. /**
  46596. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46597. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46598. * 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;
  46599. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46600. */
  46601. /**
  46602. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46603. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46604. * 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;
  46605. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46606. */
  46607. cameraColorCurves: Nullable<ColorCurves>;
  46608. /**
  46609. * Instantiates a new PBRMaterial instance.
  46610. *
  46611. * @param name The material name
  46612. * @param scene The scene the material will be use in.
  46613. */
  46614. constructor(name: string, scene: Scene);
  46615. /**
  46616. * Returns the name of this material class.
  46617. */
  46618. getClassName(): string;
  46619. /**
  46620. * Makes a duplicate of the current material.
  46621. * @param name - name to use for the new material.
  46622. */
  46623. clone(name: string): PBRMaterial;
  46624. /**
  46625. * Serializes this PBR Material.
  46626. * @returns - An object with the serialized material.
  46627. */
  46628. serialize(): any;
  46629. /**
  46630. * Parses a PBR Material from a serialized object.
  46631. * @param source - Serialized object.
  46632. * @param scene - BJS scene instance.
  46633. * @param rootUrl - url for the scene object
  46634. * @returns - PBRMaterial
  46635. */
  46636. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46637. }
  46638. }
  46639. declare module BABYLON {
  46640. /**
  46641. * Direct draw surface info
  46642. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46643. */
  46644. export interface DDSInfo {
  46645. /**
  46646. * Width of the texture
  46647. */
  46648. width: number;
  46649. /**
  46650. * Width of the texture
  46651. */
  46652. height: number;
  46653. /**
  46654. * Number of Mipmaps for the texture
  46655. * @see https://en.wikipedia.org/wiki/Mipmap
  46656. */
  46657. mipmapCount: number;
  46658. /**
  46659. * If the textures format is a known fourCC format
  46660. * @see https://www.fourcc.org/
  46661. */
  46662. isFourCC: boolean;
  46663. /**
  46664. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46665. */
  46666. isRGB: boolean;
  46667. /**
  46668. * If the texture is a lumincance format
  46669. */
  46670. isLuminance: boolean;
  46671. /**
  46672. * If this is a cube texture
  46673. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46674. */
  46675. isCube: boolean;
  46676. /**
  46677. * If the texture is a compressed format eg. FOURCC_DXT1
  46678. */
  46679. isCompressed: boolean;
  46680. /**
  46681. * The dxgiFormat of the texture
  46682. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46683. */
  46684. dxgiFormat: number;
  46685. /**
  46686. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46687. */
  46688. textureType: number;
  46689. /**
  46690. * Sphericle polynomial created for the dds texture
  46691. */
  46692. sphericalPolynomial?: SphericalPolynomial;
  46693. }
  46694. /**
  46695. * Class used to provide DDS decompression tools
  46696. */
  46697. export class DDSTools {
  46698. /**
  46699. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46700. */
  46701. static StoreLODInAlphaChannel: boolean;
  46702. /**
  46703. * Gets DDS information from an array buffer
  46704. * @param arrayBuffer defines the array buffer to read data from
  46705. * @returns the DDS information
  46706. */
  46707. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46708. private static _FloatView;
  46709. private static _Int32View;
  46710. private static _ToHalfFloat;
  46711. private static _FromHalfFloat;
  46712. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46713. private static _GetHalfFloatRGBAArrayBuffer;
  46714. private static _GetFloatRGBAArrayBuffer;
  46715. private static _GetFloatAsUIntRGBAArrayBuffer;
  46716. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46717. private static _GetRGBAArrayBuffer;
  46718. private static _ExtractLongWordOrder;
  46719. private static _GetRGBArrayBuffer;
  46720. private static _GetLuminanceArrayBuffer;
  46721. /**
  46722. * Uploads DDS Levels to a Babylon Texture
  46723. * @hidden
  46724. */
  46725. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46726. }
  46727. interface Engine {
  46728. /**
  46729. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46730. * @param rootUrl defines the url where the file to load is located
  46731. * @param scene defines the current scene
  46732. * @param lodScale defines scale to apply to the mip map selection
  46733. * @param lodOffset defines offset to apply to the mip map selection
  46734. * @param onLoad defines an optional callback raised when the texture is loaded
  46735. * @param onError defines an optional callback raised if there is an issue to load the texture
  46736. * @param format defines the format of the data
  46737. * @param forcedExtension defines the extension to use to pick the right loader
  46738. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46739. * @returns the cube texture as an InternalTexture
  46740. */
  46741. 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;
  46742. }
  46743. }
  46744. declare module BABYLON {
  46745. /**
  46746. * Implementation of the DDS Texture Loader.
  46747. * @hidden
  46748. */
  46749. export class _DDSTextureLoader implements IInternalTextureLoader {
  46750. /**
  46751. * Defines wether the loader supports cascade loading the different faces.
  46752. */
  46753. readonly supportCascades: boolean;
  46754. /**
  46755. * This returns if the loader support the current file information.
  46756. * @param extension defines the file extension of the file being loaded
  46757. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46758. * @param fallback defines the fallback internal texture if any
  46759. * @param isBase64 defines whether the texture is encoded as a base64
  46760. * @param isBuffer defines whether the texture data are stored as a buffer
  46761. * @returns true if the loader can load the specified file
  46762. */
  46763. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46764. /**
  46765. * Transform the url before loading if required.
  46766. * @param rootUrl the url of the texture
  46767. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46768. * @returns the transformed texture
  46769. */
  46770. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46771. /**
  46772. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46773. * @param rootUrl the url of the texture
  46774. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46775. * @returns the fallback texture
  46776. */
  46777. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46778. /**
  46779. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46780. * @param data contains the texture data
  46781. * @param texture defines the BabylonJS internal texture
  46782. * @param createPolynomials will be true if polynomials have been requested
  46783. * @param onLoad defines the callback to trigger once the texture is ready
  46784. * @param onError defines the callback to trigger in case of error
  46785. */
  46786. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46787. /**
  46788. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46789. * @param data contains the texture data
  46790. * @param texture defines the BabylonJS internal texture
  46791. * @param callback defines the method to call once ready to upload
  46792. */
  46793. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46794. }
  46795. }
  46796. declare module BABYLON {
  46797. /** @hidden */
  46798. export var rgbdEncodePixelShader: {
  46799. name: string;
  46800. shader: string;
  46801. };
  46802. }
  46803. declare module BABYLON {
  46804. /**
  46805. * Raw texture data and descriptor sufficient for WebGL texture upload
  46806. */
  46807. export interface EnvironmentTextureInfo {
  46808. /**
  46809. * Version of the environment map
  46810. */
  46811. version: number;
  46812. /**
  46813. * Width of image
  46814. */
  46815. width: number;
  46816. /**
  46817. * Irradiance information stored in the file.
  46818. */
  46819. irradiance: any;
  46820. /**
  46821. * Specular information stored in the file.
  46822. */
  46823. specular: any;
  46824. }
  46825. /**
  46826. * Sets of helpers addressing the serialization and deserialization of environment texture
  46827. * stored in a BabylonJS env file.
  46828. * Those files are usually stored as .env files.
  46829. */
  46830. export class EnvironmentTextureTools {
  46831. /**
  46832. * Magic number identifying the env file.
  46833. */
  46834. private static _MagicBytes;
  46835. /**
  46836. * Gets the environment info from an env file.
  46837. * @param data The array buffer containing the .env bytes.
  46838. * @returns the environment file info (the json header) if successfully parsed.
  46839. */
  46840. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46841. /**
  46842. * Creates an environment texture from a loaded cube texture.
  46843. * @param texture defines the cube texture to convert in env file
  46844. * @return a promise containing the environment data if succesfull.
  46845. */
  46846. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46847. /**
  46848. * Creates a JSON representation of the spherical data.
  46849. * @param texture defines the texture containing the polynomials
  46850. * @return the JSON representation of the spherical info
  46851. */
  46852. private static _CreateEnvTextureIrradiance;
  46853. /**
  46854. * Uploads the texture info contained in the env file to the GPU.
  46855. * @param texture defines the internal texture to upload to
  46856. * @param arrayBuffer defines the buffer cotaining the data to load
  46857. * @param info defines the texture info retrieved through the GetEnvInfo method
  46858. * @returns a promise
  46859. */
  46860. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46861. /**
  46862. * Uploads the levels of image data to the GPU.
  46863. * @param texture defines the internal texture to upload to
  46864. * @param imageData defines the array buffer views of image data [mipmap][face]
  46865. * @returns a promise
  46866. */
  46867. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46868. /**
  46869. * Uploads spherical polynomials information to the texture.
  46870. * @param texture defines the texture we are trying to upload the information to
  46871. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46872. */
  46873. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46874. /** @hidden */
  46875. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46876. }
  46877. }
  46878. declare module BABYLON {
  46879. /**
  46880. * Implementation of the ENV Texture Loader.
  46881. * @hidden
  46882. */
  46883. export class _ENVTextureLoader implements IInternalTextureLoader {
  46884. /**
  46885. * Defines wether the loader supports cascade loading the different faces.
  46886. */
  46887. readonly supportCascades: boolean;
  46888. /**
  46889. * This returns if the loader support the current file information.
  46890. * @param extension defines the file extension of the file being loaded
  46891. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46892. * @param fallback defines the fallback internal texture if any
  46893. * @param isBase64 defines whether the texture is encoded as a base64
  46894. * @param isBuffer defines whether the texture data are stored as a buffer
  46895. * @returns true if the loader can load the specified file
  46896. */
  46897. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46898. /**
  46899. * Transform the url before loading if required.
  46900. * @param rootUrl the url of the texture
  46901. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46902. * @returns the transformed texture
  46903. */
  46904. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46905. /**
  46906. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46907. * @param rootUrl the url of the texture
  46908. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46909. * @returns the fallback texture
  46910. */
  46911. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46912. /**
  46913. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46914. * @param data contains the texture data
  46915. * @param texture defines the BabylonJS internal texture
  46916. * @param createPolynomials will be true if polynomials have been requested
  46917. * @param onLoad defines the callback to trigger once the texture is ready
  46918. * @param onError defines the callback to trigger in case of error
  46919. */
  46920. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46921. /**
  46922. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46923. * @param data contains the texture data
  46924. * @param texture defines the BabylonJS internal texture
  46925. * @param callback defines the method to call once ready to upload
  46926. */
  46927. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46928. }
  46929. }
  46930. declare module BABYLON {
  46931. /**
  46932. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46933. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46934. */
  46935. export class KhronosTextureContainer {
  46936. /** contents of the KTX container file */
  46937. arrayBuffer: any;
  46938. private static HEADER_LEN;
  46939. private static COMPRESSED_2D;
  46940. private static COMPRESSED_3D;
  46941. private static TEX_2D;
  46942. private static TEX_3D;
  46943. /**
  46944. * Gets the openGL type
  46945. */
  46946. glType: number;
  46947. /**
  46948. * Gets the openGL type size
  46949. */
  46950. glTypeSize: number;
  46951. /**
  46952. * Gets the openGL format
  46953. */
  46954. glFormat: number;
  46955. /**
  46956. * Gets the openGL internal format
  46957. */
  46958. glInternalFormat: number;
  46959. /**
  46960. * Gets the base internal format
  46961. */
  46962. glBaseInternalFormat: number;
  46963. /**
  46964. * Gets image width in pixel
  46965. */
  46966. pixelWidth: number;
  46967. /**
  46968. * Gets image height in pixel
  46969. */
  46970. pixelHeight: number;
  46971. /**
  46972. * Gets image depth in pixels
  46973. */
  46974. pixelDepth: number;
  46975. /**
  46976. * Gets the number of array elements
  46977. */
  46978. numberOfArrayElements: number;
  46979. /**
  46980. * Gets the number of faces
  46981. */
  46982. numberOfFaces: number;
  46983. /**
  46984. * Gets the number of mipmap levels
  46985. */
  46986. numberOfMipmapLevels: number;
  46987. /**
  46988. * Gets the bytes of key value data
  46989. */
  46990. bytesOfKeyValueData: number;
  46991. /**
  46992. * Gets the load type
  46993. */
  46994. loadType: number;
  46995. /**
  46996. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46997. */
  46998. isInvalid: boolean;
  46999. /**
  47000. * Creates a new KhronosTextureContainer
  47001. * @param arrayBuffer contents of the KTX container file
  47002. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47003. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47004. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47005. */
  47006. constructor(
  47007. /** contents of the KTX container file */
  47008. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47009. /**
  47010. * Uploads KTX content to a Babylon Texture.
  47011. * It is assumed that the texture has already been created & is currently bound
  47012. * @hidden
  47013. */
  47014. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47015. private _upload2DCompressedLevels;
  47016. }
  47017. }
  47018. declare module BABYLON {
  47019. /**
  47020. * Implementation of the KTX Texture Loader.
  47021. * @hidden
  47022. */
  47023. export class _KTXTextureLoader implements IInternalTextureLoader {
  47024. /**
  47025. * Defines wether the loader supports cascade loading the different faces.
  47026. */
  47027. readonly supportCascades: boolean;
  47028. /**
  47029. * This returns if the loader support the current file information.
  47030. * @param extension defines the file extension of the file being loaded
  47031. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47032. * @param fallback defines the fallback internal texture if any
  47033. * @param isBase64 defines whether the texture is encoded as a base64
  47034. * @param isBuffer defines whether the texture data are stored as a buffer
  47035. * @returns true if the loader can load the specified file
  47036. */
  47037. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47038. /**
  47039. * Transform the url before loading if required.
  47040. * @param rootUrl the url of the texture
  47041. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47042. * @returns the transformed texture
  47043. */
  47044. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47045. /**
  47046. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47047. * @param rootUrl the url of the texture
  47048. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47049. * @returns the fallback texture
  47050. */
  47051. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47052. /**
  47053. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47054. * @param data contains the texture data
  47055. * @param texture defines the BabylonJS internal texture
  47056. * @param createPolynomials will be true if polynomials have been requested
  47057. * @param onLoad defines the callback to trigger once the texture is ready
  47058. * @param onError defines the callback to trigger in case of error
  47059. */
  47060. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47061. /**
  47062. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47063. * @param data contains the texture data
  47064. * @param texture defines the BabylonJS internal texture
  47065. * @param callback defines the method to call once ready to upload
  47066. */
  47067. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47068. }
  47069. }
  47070. declare module BABYLON {
  47071. /** @hidden */
  47072. export var _forceSceneHelpersToBundle: boolean;
  47073. interface Scene {
  47074. /**
  47075. * Creates a default light for the scene.
  47076. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47077. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47078. */
  47079. createDefaultLight(replace?: boolean): void;
  47080. /**
  47081. * Creates a default camera for the scene.
  47082. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47083. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47084. * @param replace has default false, when true replaces the active camera in the scene
  47085. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47086. */
  47087. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47088. /**
  47089. * Creates a default camera and a default light.
  47090. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47091. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47092. * @param replace has the default false, when true replaces the active camera/light in the scene
  47093. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47094. */
  47095. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47096. /**
  47097. * Creates a new sky box
  47098. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47099. * @param environmentTexture defines the texture to use as environment texture
  47100. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47101. * @param scale defines the overall scale of the skybox
  47102. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47103. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47104. * @returns a new mesh holding the sky box
  47105. */
  47106. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47107. /**
  47108. * Creates a new environment
  47109. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47110. * @param options defines the options you can use to configure the environment
  47111. * @returns the new EnvironmentHelper
  47112. */
  47113. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47114. /**
  47115. * Creates a new VREXperienceHelper
  47116. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47117. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47118. * @returns a new VREXperienceHelper
  47119. */
  47120. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47121. /**
  47122. * Creates a new XREXperienceHelper
  47123. * @see http://doc.babylonjs.com/how_to/webxr
  47124. * @returns a promise for a new XREXperienceHelper
  47125. */
  47126. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  47127. }
  47128. }
  47129. declare module BABYLON {
  47130. /**
  47131. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47132. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47133. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47134. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47135. */
  47136. export class VideoDome extends TransformNode {
  47137. /**
  47138. * Define the video source as a Monoscopic panoramic 360 video.
  47139. */
  47140. static readonly MODE_MONOSCOPIC: number;
  47141. /**
  47142. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47143. */
  47144. static readonly MODE_TOPBOTTOM: number;
  47145. /**
  47146. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47147. */
  47148. static readonly MODE_SIDEBYSIDE: number;
  47149. private _useDirectMapping;
  47150. /**
  47151. * The video texture being displayed on the sphere
  47152. */
  47153. protected _videoTexture: VideoTexture;
  47154. /**
  47155. * Gets the video texture being displayed on the sphere
  47156. */
  47157. readonly videoTexture: VideoTexture;
  47158. /**
  47159. * The skybox material
  47160. */
  47161. protected _material: BackgroundMaterial;
  47162. /**
  47163. * The surface used for the skybox
  47164. */
  47165. protected _mesh: Mesh;
  47166. /**
  47167. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47168. * Also see the options.resolution property.
  47169. */
  47170. fovMultiplier: number;
  47171. private _videoMode;
  47172. /**
  47173. * Gets or set the current video mode for the video. It can be:
  47174. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47175. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47176. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47177. */
  47178. videoMode: number;
  47179. /**
  47180. * Oberserver used in Stereoscopic VR Mode.
  47181. */
  47182. private _onBeforeCameraRenderObserver;
  47183. /**
  47184. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  47185. * @param name Element's name, child elements will append suffixes for their own names.
  47186. * @param urlsOrVideo defines the url(s) or the video element to use
  47187. * @param options An object containing optional or exposed sub element properties
  47188. */
  47189. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47190. resolution?: number;
  47191. clickToPlay?: boolean;
  47192. autoPlay?: boolean;
  47193. loop?: boolean;
  47194. size?: number;
  47195. poster?: string;
  47196. faceForward?: boolean;
  47197. useDirectMapping?: boolean;
  47198. }, scene: Scene);
  47199. private _changeVideoMode;
  47200. /**
  47201. * Releases resources associated with this node.
  47202. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47203. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47204. */
  47205. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47206. }
  47207. }
  47208. declare module BABYLON {
  47209. /**
  47210. * This class can be used to get instrumentation data from a Babylon engine
  47211. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47212. */
  47213. export class EngineInstrumentation implements IDisposable {
  47214. /**
  47215. * Define the instrumented engine.
  47216. */
  47217. engine: Engine;
  47218. private _captureGPUFrameTime;
  47219. private _gpuFrameTimeToken;
  47220. private _gpuFrameTime;
  47221. private _captureShaderCompilationTime;
  47222. private _shaderCompilationTime;
  47223. private _onBeginFrameObserver;
  47224. private _onEndFrameObserver;
  47225. private _onBeforeShaderCompilationObserver;
  47226. private _onAfterShaderCompilationObserver;
  47227. /**
  47228. * Gets the perf counter used for GPU frame time
  47229. */
  47230. readonly gpuFrameTimeCounter: PerfCounter;
  47231. /**
  47232. * Gets the GPU frame time capture status
  47233. */
  47234. /**
  47235. * Enable or disable the GPU frame time capture
  47236. */
  47237. captureGPUFrameTime: boolean;
  47238. /**
  47239. * Gets the perf counter used for shader compilation time
  47240. */
  47241. readonly shaderCompilationTimeCounter: PerfCounter;
  47242. /**
  47243. * Gets the shader compilation time capture status
  47244. */
  47245. /**
  47246. * Enable or disable the shader compilation time capture
  47247. */
  47248. captureShaderCompilationTime: boolean;
  47249. /**
  47250. * Instantiates a new engine instrumentation.
  47251. * This class can be used to get instrumentation data from a Babylon engine
  47252. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47253. * @param engine Defines the engine to instrument
  47254. */
  47255. constructor(
  47256. /**
  47257. * Define the instrumented engine.
  47258. */
  47259. engine: Engine);
  47260. /**
  47261. * Dispose and release associated resources.
  47262. */
  47263. dispose(): void;
  47264. }
  47265. }
  47266. declare module BABYLON {
  47267. /**
  47268. * This class can be used to get instrumentation data from a Babylon engine
  47269. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47270. */
  47271. export class SceneInstrumentation implements IDisposable {
  47272. /**
  47273. * Defines the scene to instrument
  47274. */
  47275. scene: Scene;
  47276. private _captureActiveMeshesEvaluationTime;
  47277. private _activeMeshesEvaluationTime;
  47278. private _captureRenderTargetsRenderTime;
  47279. private _renderTargetsRenderTime;
  47280. private _captureFrameTime;
  47281. private _frameTime;
  47282. private _captureRenderTime;
  47283. private _renderTime;
  47284. private _captureInterFrameTime;
  47285. private _interFrameTime;
  47286. private _captureParticlesRenderTime;
  47287. private _particlesRenderTime;
  47288. private _captureSpritesRenderTime;
  47289. private _spritesRenderTime;
  47290. private _capturePhysicsTime;
  47291. private _physicsTime;
  47292. private _captureAnimationsTime;
  47293. private _animationsTime;
  47294. private _captureCameraRenderTime;
  47295. private _cameraRenderTime;
  47296. private _onBeforeActiveMeshesEvaluationObserver;
  47297. private _onAfterActiveMeshesEvaluationObserver;
  47298. private _onBeforeRenderTargetsRenderObserver;
  47299. private _onAfterRenderTargetsRenderObserver;
  47300. private _onAfterRenderObserver;
  47301. private _onBeforeDrawPhaseObserver;
  47302. private _onAfterDrawPhaseObserver;
  47303. private _onBeforeAnimationsObserver;
  47304. private _onBeforeParticlesRenderingObserver;
  47305. private _onAfterParticlesRenderingObserver;
  47306. private _onBeforeSpritesRenderingObserver;
  47307. private _onAfterSpritesRenderingObserver;
  47308. private _onBeforePhysicsObserver;
  47309. private _onAfterPhysicsObserver;
  47310. private _onAfterAnimationsObserver;
  47311. private _onBeforeCameraRenderObserver;
  47312. private _onAfterCameraRenderObserver;
  47313. /**
  47314. * Gets the perf counter used for active meshes evaluation time
  47315. */
  47316. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47317. /**
  47318. * Gets the active meshes evaluation time capture status
  47319. */
  47320. /**
  47321. * Enable or disable the active meshes evaluation time capture
  47322. */
  47323. captureActiveMeshesEvaluationTime: boolean;
  47324. /**
  47325. * Gets the perf counter used for render targets render time
  47326. */
  47327. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47328. /**
  47329. * Gets the render targets render time capture status
  47330. */
  47331. /**
  47332. * Enable or disable the render targets render time capture
  47333. */
  47334. captureRenderTargetsRenderTime: boolean;
  47335. /**
  47336. * Gets the perf counter used for particles render time
  47337. */
  47338. readonly particlesRenderTimeCounter: PerfCounter;
  47339. /**
  47340. * Gets the particles render time capture status
  47341. */
  47342. /**
  47343. * Enable or disable the particles render time capture
  47344. */
  47345. captureParticlesRenderTime: boolean;
  47346. /**
  47347. * Gets the perf counter used for sprites render time
  47348. */
  47349. readonly spritesRenderTimeCounter: PerfCounter;
  47350. /**
  47351. * Gets the sprites render time capture status
  47352. */
  47353. /**
  47354. * Enable or disable the sprites render time capture
  47355. */
  47356. captureSpritesRenderTime: boolean;
  47357. /**
  47358. * Gets the perf counter used for physics time
  47359. */
  47360. readonly physicsTimeCounter: PerfCounter;
  47361. /**
  47362. * Gets the physics time capture status
  47363. */
  47364. /**
  47365. * Enable or disable the physics time capture
  47366. */
  47367. capturePhysicsTime: boolean;
  47368. /**
  47369. * Gets the perf counter used for animations time
  47370. */
  47371. readonly animationsTimeCounter: PerfCounter;
  47372. /**
  47373. * Gets the animations time capture status
  47374. */
  47375. /**
  47376. * Enable or disable the animations time capture
  47377. */
  47378. captureAnimationsTime: boolean;
  47379. /**
  47380. * Gets the perf counter used for frame time capture
  47381. */
  47382. readonly frameTimeCounter: PerfCounter;
  47383. /**
  47384. * Gets the frame time capture status
  47385. */
  47386. /**
  47387. * Enable or disable the frame time capture
  47388. */
  47389. captureFrameTime: boolean;
  47390. /**
  47391. * Gets the perf counter used for inter-frames time capture
  47392. */
  47393. readonly interFrameTimeCounter: PerfCounter;
  47394. /**
  47395. * Gets the inter-frames time capture status
  47396. */
  47397. /**
  47398. * Enable or disable the inter-frames time capture
  47399. */
  47400. captureInterFrameTime: boolean;
  47401. /**
  47402. * Gets the perf counter used for render time capture
  47403. */
  47404. readonly renderTimeCounter: PerfCounter;
  47405. /**
  47406. * Gets the render time capture status
  47407. */
  47408. /**
  47409. * Enable or disable the render time capture
  47410. */
  47411. captureRenderTime: boolean;
  47412. /**
  47413. * Gets the perf counter used for camera render time capture
  47414. */
  47415. readonly cameraRenderTimeCounter: PerfCounter;
  47416. /**
  47417. * Gets the camera render time capture status
  47418. */
  47419. /**
  47420. * Enable or disable the camera render time capture
  47421. */
  47422. captureCameraRenderTime: boolean;
  47423. /**
  47424. * Gets the perf counter used for draw calls
  47425. */
  47426. readonly drawCallsCounter: PerfCounter;
  47427. /**
  47428. * Instantiates a new scene instrumentation.
  47429. * This class can be used to get instrumentation data from a Babylon engine
  47430. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47431. * @param scene Defines the scene to instrument
  47432. */
  47433. constructor(
  47434. /**
  47435. * Defines the scene to instrument
  47436. */
  47437. scene: Scene);
  47438. /**
  47439. * Dispose and release associated resources.
  47440. */
  47441. dispose(): void;
  47442. }
  47443. }
  47444. declare module BABYLON {
  47445. /** @hidden */
  47446. export var glowMapGenerationPixelShader: {
  47447. name: string;
  47448. shader: string;
  47449. };
  47450. }
  47451. declare module BABYLON {
  47452. /** @hidden */
  47453. export var glowMapGenerationVertexShader: {
  47454. name: string;
  47455. shader: string;
  47456. };
  47457. }
  47458. declare module BABYLON {
  47459. /**
  47460. * Effect layer options. This helps customizing the behaviour
  47461. * of the effect layer.
  47462. */
  47463. export interface IEffectLayerOptions {
  47464. /**
  47465. * Multiplication factor apply to the canvas size to compute the render target size
  47466. * used to generated the objects (the smaller the faster).
  47467. */
  47468. mainTextureRatio: number;
  47469. /**
  47470. * Enforces a fixed size texture to ensure effect stability across devices.
  47471. */
  47472. mainTextureFixedSize?: number;
  47473. /**
  47474. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47475. */
  47476. alphaBlendingMode: number;
  47477. /**
  47478. * The camera attached to the layer.
  47479. */
  47480. camera: Nullable<Camera>;
  47481. /**
  47482. * The rendering group to draw the layer in.
  47483. */
  47484. renderingGroupId: number;
  47485. }
  47486. /**
  47487. * The effect layer Helps adding post process effect blended with the main pass.
  47488. *
  47489. * This can be for instance use to generate glow or higlight effects on the scene.
  47490. *
  47491. * The effect layer class can not be used directly and is intented to inherited from to be
  47492. * customized per effects.
  47493. */
  47494. export abstract class EffectLayer {
  47495. private _vertexBuffers;
  47496. private _indexBuffer;
  47497. private _cachedDefines;
  47498. private _effectLayerMapGenerationEffect;
  47499. private _effectLayerOptions;
  47500. private _mergeEffect;
  47501. protected _scene: Scene;
  47502. protected _engine: Engine;
  47503. protected _maxSize: number;
  47504. protected _mainTextureDesiredSize: ISize;
  47505. protected _mainTexture: RenderTargetTexture;
  47506. protected _shouldRender: boolean;
  47507. protected _postProcesses: PostProcess[];
  47508. protected _textures: BaseTexture[];
  47509. protected _emissiveTextureAndColor: {
  47510. texture: Nullable<BaseTexture>;
  47511. color: Color4;
  47512. };
  47513. /**
  47514. * The name of the layer
  47515. */
  47516. name: string;
  47517. /**
  47518. * The clear color of the texture used to generate the glow map.
  47519. */
  47520. neutralColor: Color4;
  47521. /**
  47522. * Specifies wether the highlight layer is enabled or not.
  47523. */
  47524. isEnabled: boolean;
  47525. /**
  47526. * Gets the camera attached to the layer.
  47527. */
  47528. readonly camera: Nullable<Camera>;
  47529. /**
  47530. * Gets the rendering group id the layer should render in.
  47531. */
  47532. renderingGroupId: number;
  47533. /**
  47534. * An event triggered when the effect layer has been disposed.
  47535. */
  47536. onDisposeObservable: Observable<EffectLayer>;
  47537. /**
  47538. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  47539. */
  47540. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  47541. /**
  47542. * An event triggered when the generated texture is being merged in the scene.
  47543. */
  47544. onBeforeComposeObservable: Observable<EffectLayer>;
  47545. /**
  47546. * An event triggered when the generated texture has been merged in the scene.
  47547. */
  47548. onAfterComposeObservable: Observable<EffectLayer>;
  47549. /**
  47550. * An event triggered when the efffect layer changes its size.
  47551. */
  47552. onSizeChangedObservable: Observable<EffectLayer>;
  47553. /** @hidden */
  47554. static _SceneComponentInitialization: (scene: Scene) => void;
  47555. /**
  47556. * Instantiates a new effect Layer and references it in the scene.
  47557. * @param name The name of the layer
  47558. * @param scene The scene to use the layer in
  47559. */
  47560. constructor(
  47561. /** The Friendly of the effect in the scene */
  47562. name: string, scene: Scene);
  47563. /**
  47564. * Get the effect name of the layer.
  47565. * @return The effect name
  47566. */
  47567. abstract getEffectName(): string;
  47568. /**
  47569. * Checks for the readiness of the element composing the layer.
  47570. * @param subMesh the mesh to check for
  47571. * @param useInstances specify wether or not to use instances to render the mesh
  47572. * @return true if ready otherwise, false
  47573. */
  47574. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47575. /**
  47576. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47577. * @returns true if the effect requires stencil during the main canvas render pass.
  47578. */
  47579. abstract needStencil(): boolean;
  47580. /**
  47581. * Create the merge effect. This is the shader use to blit the information back
  47582. * to the main canvas at the end of the scene rendering.
  47583. * @returns The effect containing the shader used to merge the effect on the main canvas
  47584. */
  47585. protected abstract _createMergeEffect(): Effect;
  47586. /**
  47587. * Creates the render target textures and post processes used in the effect layer.
  47588. */
  47589. protected abstract _createTextureAndPostProcesses(): void;
  47590. /**
  47591. * Implementation specific of rendering the generating effect on the main canvas.
  47592. * @param effect The effect used to render through
  47593. */
  47594. protected abstract _internalRender(effect: Effect): void;
  47595. /**
  47596. * Sets the required values for both the emissive texture and and the main color.
  47597. */
  47598. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47599. /**
  47600. * Free any resources and references associated to a mesh.
  47601. * Internal use
  47602. * @param mesh The mesh to free.
  47603. */
  47604. abstract _disposeMesh(mesh: Mesh): void;
  47605. /**
  47606. * Serializes this layer (Glow or Highlight for example)
  47607. * @returns a serialized layer object
  47608. */
  47609. abstract serialize?(): any;
  47610. /**
  47611. * Initializes the effect layer with the required options.
  47612. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47613. */
  47614. protected _init(options: Partial<IEffectLayerOptions>): void;
  47615. /**
  47616. * Generates the index buffer of the full screen quad blending to the main canvas.
  47617. */
  47618. private _generateIndexBuffer;
  47619. /**
  47620. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47621. */
  47622. private _generateVertexBuffer;
  47623. /**
  47624. * Sets the main texture desired size which is the closest power of two
  47625. * of the engine canvas size.
  47626. */
  47627. private _setMainTextureSize;
  47628. /**
  47629. * Creates the main texture for the effect layer.
  47630. */
  47631. protected _createMainTexture(): void;
  47632. /**
  47633. * Adds specific effects defines.
  47634. * @param defines The defines to add specifics to.
  47635. */
  47636. protected _addCustomEffectDefines(defines: string[]): void;
  47637. /**
  47638. * Checks for the readiness of the element composing the layer.
  47639. * @param subMesh the mesh to check for
  47640. * @param useInstances specify wether or not to use instances to render the mesh
  47641. * @param emissiveTexture the associated emissive texture used to generate the glow
  47642. * @return true if ready otherwise, false
  47643. */
  47644. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47645. /**
  47646. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47647. */
  47648. render(): void;
  47649. /**
  47650. * Determine if a given mesh will be used in the current effect.
  47651. * @param mesh mesh to test
  47652. * @returns true if the mesh will be used
  47653. */
  47654. hasMesh(mesh: AbstractMesh): boolean;
  47655. /**
  47656. * Returns true if the layer contains information to display, otherwise false.
  47657. * @returns true if the glow layer should be rendered
  47658. */
  47659. shouldRender(): boolean;
  47660. /**
  47661. * Returns true if the mesh should render, otherwise false.
  47662. * @param mesh The mesh to render
  47663. * @returns true if it should render otherwise false
  47664. */
  47665. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47666. /**
  47667. * Returns true if the mesh can be rendered, otherwise false.
  47668. * @param mesh The mesh to render
  47669. * @param material The material used on the mesh
  47670. * @returns true if it can be rendered otherwise false
  47671. */
  47672. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47673. /**
  47674. * Returns true if the mesh should render, otherwise false.
  47675. * @param mesh The mesh to render
  47676. * @returns true if it should render otherwise false
  47677. */
  47678. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47679. /**
  47680. * Renders the submesh passed in parameter to the generation map.
  47681. */
  47682. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  47683. /**
  47684. * Rebuild the required buffers.
  47685. * @hidden Internal use only.
  47686. */
  47687. _rebuild(): void;
  47688. /**
  47689. * Dispose only the render target textures and post process.
  47690. */
  47691. private _disposeTextureAndPostProcesses;
  47692. /**
  47693. * Dispose the highlight layer and free resources.
  47694. */
  47695. dispose(): void;
  47696. /**
  47697. * Gets the class name of the effect layer
  47698. * @returns the string with the class name of the effect layer
  47699. */
  47700. getClassName(): string;
  47701. /**
  47702. * Creates an effect layer from parsed effect layer data
  47703. * @param parsedEffectLayer defines effect layer data
  47704. * @param scene defines the current scene
  47705. * @param rootUrl defines the root URL containing the effect layer information
  47706. * @returns a parsed effect Layer
  47707. */
  47708. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47709. }
  47710. }
  47711. declare module BABYLON {
  47712. interface AbstractScene {
  47713. /**
  47714. * The list of effect layers (highlights/glow) added to the scene
  47715. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47716. * @see http://doc.babylonjs.com/how_to/glow_layer
  47717. */
  47718. effectLayers: Array<EffectLayer>;
  47719. /**
  47720. * Removes the given effect layer from this scene.
  47721. * @param toRemove defines the effect layer to remove
  47722. * @returns the index of the removed effect layer
  47723. */
  47724. removeEffectLayer(toRemove: EffectLayer): number;
  47725. /**
  47726. * Adds the given effect layer to this scene
  47727. * @param newEffectLayer defines the effect layer to add
  47728. */
  47729. addEffectLayer(newEffectLayer: EffectLayer): void;
  47730. }
  47731. /**
  47732. * Defines the layer scene component responsible to manage any effect layers
  47733. * in a given scene.
  47734. */
  47735. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47736. /**
  47737. * The component name helpfull to identify the component in the list of scene components.
  47738. */
  47739. readonly name: string;
  47740. /**
  47741. * The scene the component belongs to.
  47742. */
  47743. scene: Scene;
  47744. private _engine;
  47745. private _renderEffects;
  47746. private _needStencil;
  47747. private _previousStencilState;
  47748. /**
  47749. * Creates a new instance of the component for the given scene
  47750. * @param scene Defines the scene to register the component in
  47751. */
  47752. constructor(scene: Scene);
  47753. /**
  47754. * Registers the component in a given scene
  47755. */
  47756. register(): void;
  47757. /**
  47758. * Rebuilds the elements related to this component in case of
  47759. * context lost for instance.
  47760. */
  47761. rebuild(): void;
  47762. /**
  47763. * Serializes the component data to the specified json object
  47764. * @param serializationObject The object to serialize to
  47765. */
  47766. serialize(serializationObject: any): void;
  47767. /**
  47768. * Adds all the elements from the container to the scene
  47769. * @param container the container holding the elements
  47770. */
  47771. addFromContainer(container: AbstractScene): void;
  47772. /**
  47773. * Removes all the elements in the container from the scene
  47774. * @param container contains the elements to remove
  47775. * @param dispose if the removed element should be disposed (default: false)
  47776. */
  47777. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47778. /**
  47779. * Disposes the component and the associated ressources.
  47780. */
  47781. dispose(): void;
  47782. private _isReadyForMesh;
  47783. private _renderMainTexture;
  47784. private _setStencil;
  47785. private _setStencilBack;
  47786. private _draw;
  47787. private _drawCamera;
  47788. private _drawRenderingGroup;
  47789. }
  47790. }
  47791. declare module BABYLON {
  47792. /** @hidden */
  47793. export var glowMapMergePixelShader: {
  47794. name: string;
  47795. shader: string;
  47796. };
  47797. }
  47798. declare module BABYLON {
  47799. /** @hidden */
  47800. export var glowMapMergeVertexShader: {
  47801. name: string;
  47802. shader: string;
  47803. };
  47804. }
  47805. declare module BABYLON {
  47806. interface AbstractScene {
  47807. /**
  47808. * Return a the first highlight layer of the scene with a given name.
  47809. * @param name The name of the highlight layer to look for.
  47810. * @return The highlight layer if found otherwise null.
  47811. */
  47812. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47813. }
  47814. /**
  47815. * Glow layer options. This helps customizing the behaviour
  47816. * of the glow layer.
  47817. */
  47818. export interface IGlowLayerOptions {
  47819. /**
  47820. * Multiplication factor apply to the canvas size to compute the render target size
  47821. * used to generated the glowing objects (the smaller the faster).
  47822. */
  47823. mainTextureRatio: number;
  47824. /**
  47825. * Enforces a fixed size texture to ensure resize independant blur.
  47826. */
  47827. mainTextureFixedSize?: number;
  47828. /**
  47829. * How big is the kernel of the blur texture.
  47830. */
  47831. blurKernelSize: number;
  47832. /**
  47833. * The camera attached to the layer.
  47834. */
  47835. camera: Nullable<Camera>;
  47836. /**
  47837. * Enable MSAA by chosing the number of samples.
  47838. */
  47839. mainTextureSamples?: number;
  47840. /**
  47841. * The rendering group to draw the layer in.
  47842. */
  47843. renderingGroupId: number;
  47844. }
  47845. /**
  47846. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47847. *
  47848. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47849. * glowy meshes to your scene.
  47850. *
  47851. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47852. */
  47853. export class GlowLayer extends EffectLayer {
  47854. /**
  47855. * Effect Name of the layer.
  47856. */
  47857. static readonly EffectName: string;
  47858. /**
  47859. * The default blur kernel size used for the glow.
  47860. */
  47861. static DefaultBlurKernelSize: number;
  47862. /**
  47863. * The default texture size ratio used for the glow.
  47864. */
  47865. static DefaultTextureRatio: number;
  47866. /**
  47867. * Sets the kernel size of the blur.
  47868. */
  47869. /**
  47870. * Gets the kernel size of the blur.
  47871. */
  47872. blurKernelSize: number;
  47873. /**
  47874. * Sets the glow intensity.
  47875. */
  47876. /**
  47877. * Gets the glow intensity.
  47878. */
  47879. intensity: number;
  47880. private _options;
  47881. private _intensity;
  47882. private _horizontalBlurPostprocess1;
  47883. private _verticalBlurPostprocess1;
  47884. private _horizontalBlurPostprocess2;
  47885. private _verticalBlurPostprocess2;
  47886. private _blurTexture1;
  47887. private _blurTexture2;
  47888. private _postProcesses1;
  47889. private _postProcesses2;
  47890. private _includedOnlyMeshes;
  47891. private _excludedMeshes;
  47892. /**
  47893. * Callback used to let the user override the color selection on a per mesh basis
  47894. */
  47895. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47896. /**
  47897. * Callback used to let the user override the texture selection on a per mesh basis
  47898. */
  47899. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47900. /**
  47901. * Instantiates a new glow Layer and references it to the scene.
  47902. * @param name The name of the layer
  47903. * @param scene The scene to use the layer in
  47904. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47905. */
  47906. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47907. /**
  47908. * Get the effect name of the layer.
  47909. * @return The effect name
  47910. */
  47911. getEffectName(): string;
  47912. /**
  47913. * Create the merge effect. This is the shader use to blit the information back
  47914. * to the main canvas at the end of the scene rendering.
  47915. */
  47916. protected _createMergeEffect(): Effect;
  47917. /**
  47918. * Creates the render target textures and post processes used in the glow layer.
  47919. */
  47920. protected _createTextureAndPostProcesses(): void;
  47921. /**
  47922. * Checks for the readiness of the element composing the layer.
  47923. * @param subMesh the mesh to check for
  47924. * @param useInstances specify wether or not to use instances to render the mesh
  47925. * @param emissiveTexture the associated emissive texture used to generate the glow
  47926. * @return true if ready otherwise, false
  47927. */
  47928. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47929. /**
  47930. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47931. */
  47932. needStencil(): boolean;
  47933. /**
  47934. * Returns true if the mesh can be rendered, otherwise false.
  47935. * @param mesh The mesh to render
  47936. * @param material The material used on the mesh
  47937. * @returns true if it can be rendered otherwise false
  47938. */
  47939. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47940. /**
  47941. * Implementation specific of rendering the generating effect on the main canvas.
  47942. * @param effect The effect used to render through
  47943. */
  47944. protected _internalRender(effect: Effect): void;
  47945. /**
  47946. * Sets the required values for both the emissive texture and and the main color.
  47947. */
  47948. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47949. /**
  47950. * Returns true if the mesh should render, otherwise false.
  47951. * @param mesh The mesh to render
  47952. * @returns true if it should render otherwise false
  47953. */
  47954. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47955. /**
  47956. * Adds specific effects defines.
  47957. * @param defines The defines to add specifics to.
  47958. */
  47959. protected _addCustomEffectDefines(defines: string[]): void;
  47960. /**
  47961. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47962. * @param mesh The mesh to exclude from the glow layer
  47963. */
  47964. addExcludedMesh(mesh: Mesh): void;
  47965. /**
  47966. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47967. * @param mesh The mesh to remove
  47968. */
  47969. removeExcludedMesh(mesh: Mesh): void;
  47970. /**
  47971. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47972. * @param mesh The mesh to include in the glow layer
  47973. */
  47974. addIncludedOnlyMesh(mesh: Mesh): void;
  47975. /**
  47976. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47977. * @param mesh The mesh to remove
  47978. */
  47979. removeIncludedOnlyMesh(mesh: Mesh): void;
  47980. /**
  47981. * Determine if a given mesh will be used in the glow layer
  47982. * @param mesh The mesh to test
  47983. * @returns true if the mesh will be highlighted by the current glow layer
  47984. */
  47985. hasMesh(mesh: AbstractMesh): boolean;
  47986. /**
  47987. * Free any resources and references associated to a mesh.
  47988. * Internal use
  47989. * @param mesh The mesh to free.
  47990. * @hidden
  47991. */
  47992. _disposeMesh(mesh: Mesh): void;
  47993. /**
  47994. * Gets the class name of the effect layer
  47995. * @returns the string with the class name of the effect layer
  47996. */
  47997. getClassName(): string;
  47998. /**
  47999. * Serializes this glow layer
  48000. * @returns a serialized glow layer object
  48001. */
  48002. serialize(): any;
  48003. /**
  48004. * Creates a Glow Layer from parsed glow layer data
  48005. * @param parsedGlowLayer defines glow layer data
  48006. * @param scene defines the current scene
  48007. * @param rootUrl defines the root URL containing the glow layer information
  48008. * @returns a parsed Glow Layer
  48009. */
  48010. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48011. }
  48012. }
  48013. declare module BABYLON {
  48014. /** @hidden */
  48015. export var glowBlurPostProcessPixelShader: {
  48016. name: string;
  48017. shader: string;
  48018. };
  48019. }
  48020. declare module BABYLON {
  48021. interface AbstractScene {
  48022. /**
  48023. * Return a the first highlight layer of the scene with a given name.
  48024. * @param name The name of the highlight layer to look for.
  48025. * @return The highlight layer if found otherwise null.
  48026. */
  48027. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48028. }
  48029. /**
  48030. * Highlight layer options. This helps customizing the behaviour
  48031. * of the highlight layer.
  48032. */
  48033. export interface IHighlightLayerOptions {
  48034. /**
  48035. * Multiplication factor apply to the canvas size to compute the render target size
  48036. * used to generated the glowing objects (the smaller the faster).
  48037. */
  48038. mainTextureRatio: number;
  48039. /**
  48040. * Enforces a fixed size texture to ensure resize independant blur.
  48041. */
  48042. mainTextureFixedSize?: number;
  48043. /**
  48044. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48045. * of the picture to blur (the smaller the faster).
  48046. */
  48047. blurTextureSizeRatio: number;
  48048. /**
  48049. * How big in texel of the blur texture is the vertical blur.
  48050. */
  48051. blurVerticalSize: number;
  48052. /**
  48053. * How big in texel of the blur texture is the horizontal blur.
  48054. */
  48055. blurHorizontalSize: number;
  48056. /**
  48057. * Alpha blending mode used to apply the blur. Default is combine.
  48058. */
  48059. alphaBlendingMode: number;
  48060. /**
  48061. * The camera attached to the layer.
  48062. */
  48063. camera: Nullable<Camera>;
  48064. /**
  48065. * Should we display highlight as a solid stroke?
  48066. */
  48067. isStroke?: boolean;
  48068. /**
  48069. * The rendering group to draw the layer in.
  48070. */
  48071. renderingGroupId: number;
  48072. }
  48073. /**
  48074. * The highlight layer Helps adding a glow effect around a mesh.
  48075. *
  48076. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48077. * glowy meshes to your scene.
  48078. *
  48079. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48080. */
  48081. export class HighlightLayer extends EffectLayer {
  48082. name: string;
  48083. /**
  48084. * Effect Name of the highlight layer.
  48085. */
  48086. static readonly EffectName: string;
  48087. /**
  48088. * The neutral color used during the preparation of the glow effect.
  48089. * This is black by default as the blend operation is a blend operation.
  48090. */
  48091. static NeutralColor: Color4;
  48092. /**
  48093. * Stencil value used for glowing meshes.
  48094. */
  48095. static GlowingMeshStencilReference: number;
  48096. /**
  48097. * Stencil value used for the other meshes in the scene.
  48098. */
  48099. static NormalMeshStencilReference: number;
  48100. /**
  48101. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48102. */
  48103. innerGlow: boolean;
  48104. /**
  48105. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48106. */
  48107. outerGlow: boolean;
  48108. /**
  48109. * Specifies the horizontal size of the blur.
  48110. */
  48111. /**
  48112. * Gets the horizontal size of the blur.
  48113. */
  48114. blurHorizontalSize: number;
  48115. /**
  48116. * Specifies the vertical size of the blur.
  48117. */
  48118. /**
  48119. * Gets the vertical size of the blur.
  48120. */
  48121. blurVerticalSize: number;
  48122. /**
  48123. * An event triggered when the highlight layer is being blurred.
  48124. */
  48125. onBeforeBlurObservable: Observable<HighlightLayer>;
  48126. /**
  48127. * An event triggered when the highlight layer has been blurred.
  48128. */
  48129. onAfterBlurObservable: Observable<HighlightLayer>;
  48130. private _instanceGlowingMeshStencilReference;
  48131. private _options;
  48132. private _downSamplePostprocess;
  48133. private _horizontalBlurPostprocess;
  48134. private _verticalBlurPostprocess;
  48135. private _blurTexture;
  48136. private _meshes;
  48137. private _excludedMeshes;
  48138. /**
  48139. * Instantiates a new highlight Layer and references it to the scene..
  48140. * @param name The name of the layer
  48141. * @param scene The scene to use the layer in
  48142. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48143. */
  48144. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48145. /**
  48146. * Get the effect name of the layer.
  48147. * @return The effect name
  48148. */
  48149. getEffectName(): string;
  48150. /**
  48151. * Create the merge effect. This is the shader use to blit the information back
  48152. * to the main canvas at the end of the scene rendering.
  48153. */
  48154. protected _createMergeEffect(): Effect;
  48155. /**
  48156. * Creates the render target textures and post processes used in the highlight layer.
  48157. */
  48158. protected _createTextureAndPostProcesses(): void;
  48159. /**
  48160. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48161. */
  48162. needStencil(): boolean;
  48163. /**
  48164. * Checks for the readiness of the element composing the layer.
  48165. * @param subMesh the mesh to check for
  48166. * @param useInstances specify wether or not to use instances to render the mesh
  48167. * @param emissiveTexture the associated emissive texture used to generate the glow
  48168. * @return true if ready otherwise, false
  48169. */
  48170. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48171. /**
  48172. * Implementation specific of rendering the generating effect on the main canvas.
  48173. * @param effect The effect used to render through
  48174. */
  48175. protected _internalRender(effect: Effect): void;
  48176. /**
  48177. * Returns true if the layer contains information to display, otherwise false.
  48178. */
  48179. shouldRender(): boolean;
  48180. /**
  48181. * Returns true if the mesh should render, otherwise false.
  48182. * @param mesh The mesh to render
  48183. * @returns true if it should render otherwise false
  48184. */
  48185. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48186. /**
  48187. * Sets the required values for both the emissive texture and and the main color.
  48188. */
  48189. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48190. /**
  48191. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  48192. * @param mesh The mesh to exclude from the highlight layer
  48193. */
  48194. addExcludedMesh(mesh: Mesh): void;
  48195. /**
  48196. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  48197. * @param mesh The mesh to highlight
  48198. */
  48199. removeExcludedMesh(mesh: Mesh): void;
  48200. /**
  48201. * Determine if a given mesh will be highlighted by the current HighlightLayer
  48202. * @param mesh mesh to test
  48203. * @returns true if the mesh will be highlighted by the current HighlightLayer
  48204. */
  48205. hasMesh(mesh: AbstractMesh): boolean;
  48206. /**
  48207. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  48208. * @param mesh The mesh to highlight
  48209. * @param color The color of the highlight
  48210. * @param glowEmissiveOnly Extract the glow from the emissive texture
  48211. */
  48212. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48213. /**
  48214. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48215. * @param mesh The mesh to highlight
  48216. */
  48217. removeMesh(mesh: Mesh): void;
  48218. /**
  48219. * Force the stencil to the normal expected value for none glowing parts
  48220. */
  48221. private _defaultStencilReference;
  48222. /**
  48223. * Free any resources and references associated to a mesh.
  48224. * Internal use
  48225. * @param mesh The mesh to free.
  48226. * @hidden
  48227. */
  48228. _disposeMesh(mesh: Mesh): void;
  48229. /**
  48230. * Dispose the highlight layer and free resources.
  48231. */
  48232. dispose(): void;
  48233. /**
  48234. * Gets the class name of the effect layer
  48235. * @returns the string with the class name of the effect layer
  48236. */
  48237. getClassName(): string;
  48238. /**
  48239. * Serializes this Highlight layer
  48240. * @returns a serialized Highlight layer object
  48241. */
  48242. serialize(): any;
  48243. /**
  48244. * Creates a Highlight layer from parsed Highlight layer data
  48245. * @param parsedHightlightLayer defines the Highlight layer data
  48246. * @param scene defines the current scene
  48247. * @param rootUrl defines the root URL containing the Highlight layer information
  48248. * @returns a parsed Highlight layer
  48249. */
  48250. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48251. }
  48252. }
  48253. declare module BABYLON {
  48254. interface AbstractScene {
  48255. /**
  48256. * The list of layers (background and foreground) of the scene
  48257. */
  48258. layers: Array<Layer>;
  48259. }
  48260. /**
  48261. * Defines the layer scene component responsible to manage any layers
  48262. * in a given scene.
  48263. */
  48264. export class LayerSceneComponent implements ISceneComponent {
  48265. /**
  48266. * The component name helpfull to identify the component in the list of scene components.
  48267. */
  48268. readonly name: string;
  48269. /**
  48270. * The scene the component belongs to.
  48271. */
  48272. scene: Scene;
  48273. private _engine;
  48274. /**
  48275. * Creates a new instance of the component for the given scene
  48276. * @param scene Defines the scene to register the component in
  48277. */
  48278. constructor(scene: Scene);
  48279. /**
  48280. * Registers the component in a given scene
  48281. */
  48282. register(): void;
  48283. /**
  48284. * Rebuilds the elements related to this component in case of
  48285. * context lost for instance.
  48286. */
  48287. rebuild(): void;
  48288. /**
  48289. * Disposes the component and the associated ressources.
  48290. */
  48291. dispose(): void;
  48292. private _draw;
  48293. private _drawCameraPredicate;
  48294. private _drawCameraBackground;
  48295. private _drawCameraForeground;
  48296. private _drawRenderTargetPredicate;
  48297. private _drawRenderTargetBackground;
  48298. private _drawRenderTargetForeground;
  48299. /**
  48300. * Adds all the elements from the container to the scene
  48301. * @param container the container holding the elements
  48302. */
  48303. addFromContainer(container: AbstractScene): void;
  48304. /**
  48305. * Removes all the elements in the container from the scene
  48306. * @param container contains the elements to remove
  48307. * @param dispose if the removed element should be disposed (default: false)
  48308. */
  48309. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48310. }
  48311. }
  48312. declare module BABYLON {
  48313. /** @hidden */
  48314. export var layerPixelShader: {
  48315. name: string;
  48316. shader: string;
  48317. };
  48318. }
  48319. declare module BABYLON {
  48320. /** @hidden */
  48321. export var layerVertexShader: {
  48322. name: string;
  48323. shader: string;
  48324. };
  48325. }
  48326. declare module BABYLON {
  48327. /**
  48328. * This represents a full screen 2d layer.
  48329. * This can be useful to display a picture in the background of your scene for instance.
  48330. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48331. */
  48332. export class Layer {
  48333. /**
  48334. * Define the name of the layer.
  48335. */
  48336. name: string;
  48337. /**
  48338. * Define the texture the layer should display.
  48339. */
  48340. texture: Nullable<Texture>;
  48341. /**
  48342. * Is the layer in background or foreground.
  48343. */
  48344. isBackground: boolean;
  48345. /**
  48346. * Define the color of the layer (instead of texture).
  48347. */
  48348. color: Color4;
  48349. /**
  48350. * Define the scale of the layer in order to zoom in out of the texture.
  48351. */
  48352. scale: Vector2;
  48353. /**
  48354. * Define an offset for the layer in order to shift the texture.
  48355. */
  48356. offset: Vector2;
  48357. /**
  48358. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  48359. */
  48360. alphaBlendingMode: number;
  48361. /**
  48362. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  48363. * Alpha test will not mix with the background color in case of transparency.
  48364. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  48365. */
  48366. alphaTest: boolean;
  48367. /**
  48368. * Define a mask to restrict the layer to only some of the scene cameras.
  48369. */
  48370. layerMask: number;
  48371. /**
  48372. * Define the list of render target the layer is visible into.
  48373. */
  48374. renderTargetTextures: RenderTargetTexture[];
  48375. /**
  48376. * Define if the layer is only used in renderTarget or if it also
  48377. * renders in the main frame buffer of the canvas.
  48378. */
  48379. renderOnlyInRenderTargetTextures: boolean;
  48380. private _scene;
  48381. private _vertexBuffers;
  48382. private _indexBuffer;
  48383. private _effect;
  48384. private _alphaTestEffect;
  48385. /**
  48386. * An event triggered when the layer is disposed.
  48387. */
  48388. onDisposeObservable: Observable<Layer>;
  48389. private _onDisposeObserver;
  48390. /**
  48391. * Back compatibility with callback before the onDisposeObservable existed.
  48392. * The set callback will be triggered when the layer has been disposed.
  48393. */
  48394. onDispose: () => void;
  48395. /**
  48396. * An event triggered before rendering the scene
  48397. */
  48398. onBeforeRenderObservable: Observable<Layer>;
  48399. private _onBeforeRenderObserver;
  48400. /**
  48401. * Back compatibility with callback before the onBeforeRenderObservable existed.
  48402. * The set callback will be triggered just before rendering the layer.
  48403. */
  48404. onBeforeRender: () => void;
  48405. /**
  48406. * An event triggered after rendering the scene
  48407. */
  48408. onAfterRenderObservable: Observable<Layer>;
  48409. private _onAfterRenderObserver;
  48410. /**
  48411. * Back compatibility with callback before the onAfterRenderObservable existed.
  48412. * The set callback will be triggered just after rendering the layer.
  48413. */
  48414. onAfterRender: () => void;
  48415. /**
  48416. * Instantiates a new layer.
  48417. * This represents a full screen 2d layer.
  48418. * This can be useful to display a picture in the background of your scene for instance.
  48419. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48420. * @param name Define the name of the layer in the scene
  48421. * @param imgUrl Define the url of the texture to display in the layer
  48422. * @param scene Define the scene the layer belongs to
  48423. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  48424. * @param color Defines a color for the layer
  48425. */
  48426. constructor(
  48427. /**
  48428. * Define the name of the layer.
  48429. */
  48430. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  48431. private _createIndexBuffer;
  48432. /** @hidden */
  48433. _rebuild(): void;
  48434. /**
  48435. * Renders the layer in the scene.
  48436. */
  48437. render(): void;
  48438. /**
  48439. * Disposes and releases the associated ressources.
  48440. */
  48441. dispose(): void;
  48442. }
  48443. }
  48444. declare module BABYLON {
  48445. /** @hidden */
  48446. export var lensFlarePixelShader: {
  48447. name: string;
  48448. shader: string;
  48449. };
  48450. }
  48451. declare module BABYLON {
  48452. /** @hidden */
  48453. export var lensFlareVertexShader: {
  48454. name: string;
  48455. shader: string;
  48456. };
  48457. }
  48458. declare module BABYLON {
  48459. /**
  48460. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48461. * It is usually composed of several `lensFlare`.
  48462. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48463. */
  48464. export class LensFlareSystem {
  48465. /**
  48466. * Define the name of the lens flare system
  48467. */
  48468. name: string;
  48469. /**
  48470. * List of lens flares used in this system.
  48471. */
  48472. lensFlares: LensFlare[];
  48473. /**
  48474. * Define a limit from the border the lens flare can be visible.
  48475. */
  48476. borderLimit: number;
  48477. /**
  48478. * Define a viewport border we do not want to see the lens flare in.
  48479. */
  48480. viewportBorder: number;
  48481. /**
  48482. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48483. */
  48484. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48485. /**
  48486. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48487. */
  48488. layerMask: number;
  48489. /**
  48490. * Define the id of the lens flare system in the scene.
  48491. * (equal to name by default)
  48492. */
  48493. id: string;
  48494. private _scene;
  48495. private _emitter;
  48496. private _vertexBuffers;
  48497. private _indexBuffer;
  48498. private _effect;
  48499. private _positionX;
  48500. private _positionY;
  48501. private _isEnabled;
  48502. /** @hidden */
  48503. static _SceneComponentInitialization: (scene: Scene) => void;
  48504. /**
  48505. * Instantiates a lens flare system.
  48506. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48507. * It is usually composed of several `lensFlare`.
  48508. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48509. * @param name Define the name of the lens flare system in the scene
  48510. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48511. * @param scene Define the scene the lens flare system belongs to
  48512. */
  48513. constructor(
  48514. /**
  48515. * Define the name of the lens flare system
  48516. */
  48517. name: string, emitter: any, scene: Scene);
  48518. /**
  48519. * Define if the lens flare system is enabled.
  48520. */
  48521. isEnabled: boolean;
  48522. /**
  48523. * Get the scene the effects belongs to.
  48524. * @returns the scene holding the lens flare system
  48525. */
  48526. getScene(): Scene;
  48527. /**
  48528. * Get the emitter of the lens flare system.
  48529. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48530. * @returns the emitter of the lens flare system
  48531. */
  48532. getEmitter(): any;
  48533. /**
  48534. * Set the emitter of the lens flare system.
  48535. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48536. * @param newEmitter Define the new emitter of the system
  48537. */
  48538. setEmitter(newEmitter: any): void;
  48539. /**
  48540. * Get the lens flare system emitter position.
  48541. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48542. * @returns the position
  48543. */
  48544. getEmitterPosition(): Vector3;
  48545. /**
  48546. * @hidden
  48547. */
  48548. computeEffectivePosition(globalViewport: Viewport): boolean;
  48549. /** @hidden */
  48550. _isVisible(): boolean;
  48551. /**
  48552. * @hidden
  48553. */
  48554. render(): boolean;
  48555. /**
  48556. * Dispose and release the lens flare with its associated resources.
  48557. */
  48558. dispose(): void;
  48559. /**
  48560. * Parse a lens flare system from a JSON repressentation
  48561. * @param parsedLensFlareSystem Define the JSON to parse
  48562. * @param scene Define the scene the parsed system should be instantiated in
  48563. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48564. * @returns the parsed system
  48565. */
  48566. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  48567. /**
  48568. * Serialize the current Lens Flare System into a JSON representation.
  48569. * @returns the serialized JSON
  48570. */
  48571. serialize(): any;
  48572. }
  48573. }
  48574. declare module BABYLON {
  48575. /**
  48576. * This represents one of the lens effect in a `lensFlareSystem`.
  48577. * It controls one of the indiviual texture used in the effect.
  48578. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48579. */
  48580. export class LensFlare {
  48581. /**
  48582. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48583. */
  48584. size: number;
  48585. /**
  48586. * 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.
  48587. */
  48588. position: number;
  48589. /**
  48590. * Define the lens color.
  48591. */
  48592. color: Color3;
  48593. /**
  48594. * Define the lens texture.
  48595. */
  48596. texture: Nullable<Texture>;
  48597. /**
  48598. * Define the alpha mode to render this particular lens.
  48599. */
  48600. alphaMode: number;
  48601. private _system;
  48602. /**
  48603. * Creates a new Lens Flare.
  48604. * This represents one of the lens effect in a `lensFlareSystem`.
  48605. * It controls one of the indiviual texture used in the effect.
  48606. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48607. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  48608. * @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.
  48609. * @param color Define the lens color
  48610. * @param imgUrl Define the lens texture url
  48611. * @param system Define the `lensFlareSystem` this flare is part of
  48612. * @returns The newly created Lens Flare
  48613. */
  48614. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  48615. /**
  48616. * Instantiates a new Lens Flare.
  48617. * This represents one of the lens effect in a `lensFlareSystem`.
  48618. * It controls one of the indiviual texture used in the effect.
  48619. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48620. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  48621. * @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.
  48622. * @param color Define the lens color
  48623. * @param imgUrl Define the lens texture url
  48624. * @param system Define the `lensFlareSystem` this flare is part of
  48625. */
  48626. constructor(
  48627. /**
  48628. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48629. */
  48630. size: number,
  48631. /**
  48632. * 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.
  48633. */
  48634. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  48635. /**
  48636. * Dispose and release the lens flare with its associated resources.
  48637. */
  48638. dispose(): void;
  48639. }
  48640. }
  48641. declare module BABYLON {
  48642. interface AbstractScene {
  48643. /**
  48644. * The list of lens flare system added to the scene
  48645. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48646. */
  48647. lensFlareSystems: Array<LensFlareSystem>;
  48648. /**
  48649. * Removes the given lens flare system from this scene.
  48650. * @param toRemove The lens flare system to remove
  48651. * @returns The index of the removed lens flare system
  48652. */
  48653. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  48654. /**
  48655. * Adds the given lens flare system to this scene
  48656. * @param newLensFlareSystem The lens flare system to add
  48657. */
  48658. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  48659. /**
  48660. * Gets a lens flare system using its name
  48661. * @param name defines the name to look for
  48662. * @returns the lens flare system or null if not found
  48663. */
  48664. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  48665. /**
  48666. * Gets a lens flare system using its id
  48667. * @param id defines the id to look for
  48668. * @returns the lens flare system or null if not found
  48669. */
  48670. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  48671. }
  48672. /**
  48673. * Defines the lens flare scene component responsible to manage any lens flares
  48674. * in a given scene.
  48675. */
  48676. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48677. /**
  48678. * The component name helpfull to identify the component in the list of scene components.
  48679. */
  48680. readonly name: string;
  48681. /**
  48682. * The scene the component belongs to.
  48683. */
  48684. scene: Scene;
  48685. /**
  48686. * Creates a new instance of the component for the given scene
  48687. * @param scene Defines the scene to register the component in
  48688. */
  48689. constructor(scene: Scene);
  48690. /**
  48691. * Registers the component in a given scene
  48692. */
  48693. register(): void;
  48694. /**
  48695. * Rebuilds the elements related to this component in case of
  48696. * context lost for instance.
  48697. */
  48698. rebuild(): void;
  48699. /**
  48700. * Adds all the elements from the container to the scene
  48701. * @param container the container holding the elements
  48702. */
  48703. addFromContainer(container: AbstractScene): void;
  48704. /**
  48705. * Removes all the elements in the container from the scene
  48706. * @param container contains the elements to remove
  48707. * @param dispose if the removed element should be disposed (default: false)
  48708. */
  48709. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48710. /**
  48711. * Serializes the component data to the specified json object
  48712. * @param serializationObject The object to serialize to
  48713. */
  48714. serialize(serializationObject: any): void;
  48715. /**
  48716. * Disposes the component and the associated ressources.
  48717. */
  48718. dispose(): void;
  48719. private _draw;
  48720. }
  48721. }
  48722. declare module BABYLON {
  48723. /**
  48724. * Defines the shadow generator component responsible to manage any shadow generators
  48725. * in a given scene.
  48726. */
  48727. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48728. /**
  48729. * The component name helpfull to identify the component in the list of scene components.
  48730. */
  48731. readonly name: string;
  48732. /**
  48733. * The scene the component belongs to.
  48734. */
  48735. scene: Scene;
  48736. /**
  48737. * Creates a new instance of the component for the given scene
  48738. * @param scene Defines the scene to register the component in
  48739. */
  48740. constructor(scene: Scene);
  48741. /**
  48742. * Registers the component in a given scene
  48743. */
  48744. register(): void;
  48745. /**
  48746. * Rebuilds the elements related to this component in case of
  48747. * context lost for instance.
  48748. */
  48749. rebuild(): void;
  48750. /**
  48751. * Serializes the component data to the specified json object
  48752. * @param serializationObject The object to serialize to
  48753. */
  48754. serialize(serializationObject: any): void;
  48755. /**
  48756. * Adds all the elements from the container to the scene
  48757. * @param container the container holding the elements
  48758. */
  48759. addFromContainer(container: AbstractScene): void;
  48760. /**
  48761. * Removes all the elements in the container from the scene
  48762. * @param container contains the elements to remove
  48763. * @param dispose if the removed element should be disposed (default: false)
  48764. */
  48765. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48766. /**
  48767. * Rebuilds the elements related to this component in case of
  48768. * context lost for instance.
  48769. */
  48770. dispose(): void;
  48771. private _gatherRenderTargets;
  48772. }
  48773. }
  48774. declare module BABYLON {
  48775. /**
  48776. * A point light is a light defined by an unique point in world space.
  48777. * The light is emitted in every direction from this point.
  48778. * A good example of a point light is a standard light bulb.
  48779. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48780. */
  48781. export class PointLight extends ShadowLight {
  48782. private _shadowAngle;
  48783. /**
  48784. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48785. * This specifies what angle the shadow will use to be created.
  48786. *
  48787. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48788. */
  48789. /**
  48790. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48791. * This specifies what angle the shadow will use to be created.
  48792. *
  48793. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48794. */
  48795. shadowAngle: number;
  48796. /**
  48797. * Gets the direction if it has been set.
  48798. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48799. */
  48800. /**
  48801. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48802. */
  48803. direction: Vector3;
  48804. /**
  48805. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48806. * A PointLight emits the light in every direction.
  48807. * It can cast shadows.
  48808. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48809. * ```javascript
  48810. * var pointLight = new PointLight("pl", camera.position, scene);
  48811. * ```
  48812. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48813. * @param name The light friendly name
  48814. * @param position The position of the point light in the scene
  48815. * @param scene The scene the lights belongs to
  48816. */
  48817. constructor(name: string, position: Vector3, scene: Scene);
  48818. /**
  48819. * Returns the string "PointLight"
  48820. * @returns the class name
  48821. */
  48822. getClassName(): string;
  48823. /**
  48824. * Returns the integer 0.
  48825. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48826. */
  48827. getTypeID(): number;
  48828. /**
  48829. * Specifies wether or not the shadowmap should be a cube texture.
  48830. * @returns true if the shadowmap needs to be a cube texture.
  48831. */
  48832. needCube(): boolean;
  48833. /**
  48834. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48835. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48836. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48837. */
  48838. getShadowDirection(faceIndex?: number): Vector3;
  48839. /**
  48840. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48841. * - fov = PI / 2
  48842. * - aspect ratio : 1.0
  48843. * - z-near and far equal to the active camera minZ and maxZ.
  48844. * Returns the PointLight.
  48845. */
  48846. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48847. protected _buildUniformLayout(): void;
  48848. /**
  48849. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48850. * @param effect The effect to update
  48851. * @param lightIndex The index of the light in the effect to update
  48852. * @returns The point light
  48853. */
  48854. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48855. /**
  48856. * Prepares the list of defines specific to the light type.
  48857. * @param defines the list of defines
  48858. * @param lightIndex defines the index of the light for the effect
  48859. */
  48860. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48861. }
  48862. }
  48863. declare module BABYLON {
  48864. /**
  48865. * Header information of HDR texture files.
  48866. */
  48867. export interface HDRInfo {
  48868. /**
  48869. * The height of the texture in pixels.
  48870. */
  48871. height: number;
  48872. /**
  48873. * The width of the texture in pixels.
  48874. */
  48875. width: number;
  48876. /**
  48877. * The index of the beginning of the data in the binary file.
  48878. */
  48879. dataPosition: number;
  48880. }
  48881. /**
  48882. * This groups tools to convert HDR texture to native colors array.
  48883. */
  48884. export class HDRTools {
  48885. private static Ldexp;
  48886. private static Rgbe2float;
  48887. private static readStringLine;
  48888. /**
  48889. * Reads header information from an RGBE texture stored in a native array.
  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 native array.
  48894. * @return The header information.
  48895. */
  48896. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48897. /**
  48898. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48899. * This RGBE texture needs to store the information as a panorama.
  48900. *
  48901. * More information on this format are available here:
  48902. * https://en.wikipedia.org/wiki/RGBE_image_format
  48903. *
  48904. * @param buffer The binary file stored in an array buffer.
  48905. * @param size The expected size of the extracted cubemap.
  48906. * @return The Cube Map information.
  48907. */
  48908. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48909. /**
  48910. * Returns the pixels data extracted from an RGBE texture.
  48911. * This pixels will be stored left to right up to down in the R G B order in one array.
  48912. *
  48913. * More information on this format are available here:
  48914. * https://en.wikipedia.org/wiki/RGBE_image_format
  48915. *
  48916. * @param uint8array The binary file stored in an array buffer.
  48917. * @param hdrInfo The header information of the file.
  48918. * @return The pixels data in RGB right to left up to down order.
  48919. */
  48920. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48921. private static RGBE_ReadPixels_RLE;
  48922. }
  48923. }
  48924. declare module BABYLON {
  48925. /**
  48926. * This represents a texture coming from an HDR input.
  48927. *
  48928. * The only supported format is currently panorama picture stored in RGBE format.
  48929. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48930. */
  48931. export class HDRCubeTexture extends BaseTexture {
  48932. private static _facesMapping;
  48933. private _generateHarmonics;
  48934. private _noMipmap;
  48935. private _textureMatrix;
  48936. private _size;
  48937. private _onLoad;
  48938. private _onError;
  48939. /**
  48940. * The texture URL.
  48941. */
  48942. url: string;
  48943. /**
  48944. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48945. */
  48946. coordinatesMode: number;
  48947. protected _isBlocking: boolean;
  48948. /**
  48949. * Sets wether or not the texture is blocking during loading.
  48950. */
  48951. /**
  48952. * Gets wether or not the texture is blocking during loading.
  48953. */
  48954. isBlocking: boolean;
  48955. protected _rotationY: number;
  48956. /**
  48957. * Sets texture matrix rotation angle around Y axis in radians.
  48958. */
  48959. /**
  48960. * Gets texture matrix rotation angle around Y axis radians.
  48961. */
  48962. rotationY: number;
  48963. /**
  48964. * Gets or sets the center of the bounding box associated with the cube texture
  48965. * It must define where the camera used to render the texture was set
  48966. */
  48967. boundingBoxPosition: Vector3;
  48968. private _boundingBoxSize;
  48969. /**
  48970. * Gets or sets the size of the bounding box associated with the cube texture
  48971. * When defined, the cubemap will switch to local mode
  48972. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48973. * @example https://www.babylonjs-playground.com/#RNASML
  48974. */
  48975. boundingBoxSize: Vector3;
  48976. /**
  48977. * Instantiates an HDRTexture from the following parameters.
  48978. *
  48979. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48980. * @param scene The scene the texture will be used in
  48981. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48982. * @param noMipmap Forces to not generate the mipmap if true
  48983. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48984. * @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)
  48985. * @param reserved Reserved flag for internal use.
  48986. */
  48987. 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>);
  48988. /**
  48989. * Get the current class name of the texture useful for serialization or dynamic coding.
  48990. * @returns "HDRCubeTexture"
  48991. */
  48992. getClassName(): string;
  48993. /**
  48994. * Occurs when the file is raw .hdr file.
  48995. */
  48996. private loadTexture;
  48997. clone(): HDRCubeTexture;
  48998. delayLoad(): void;
  48999. /**
  49000. * Get the texture reflection matrix used to rotate/transform the reflection.
  49001. * @returns the reflection matrix
  49002. */
  49003. getReflectionTextureMatrix(): Matrix;
  49004. /**
  49005. * Set the texture reflection matrix used to rotate/transform the reflection.
  49006. * @param value Define the reflection matrix to set
  49007. */
  49008. setReflectionTextureMatrix(value: Matrix): void;
  49009. /**
  49010. * Parses a JSON representation of an HDR Texture in order to create the texture
  49011. * @param parsedTexture Define the JSON representation
  49012. * @param scene Define the scene the texture should be created in
  49013. * @param rootUrl Define the root url in case we need to load relative dependencies
  49014. * @returns the newly created texture after parsing
  49015. */
  49016. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49017. serialize(): any;
  49018. }
  49019. }
  49020. declare module BABYLON {
  49021. /**
  49022. * Class used to control physics engine
  49023. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49024. */
  49025. export class PhysicsEngine implements IPhysicsEngine {
  49026. private _physicsPlugin;
  49027. /**
  49028. * Global value used to control the smallest number supported by the simulation
  49029. */
  49030. static Epsilon: number;
  49031. private _impostors;
  49032. private _joints;
  49033. /**
  49034. * Gets the gravity vector used by the simulation
  49035. */
  49036. gravity: Vector3;
  49037. /**
  49038. * Factory used to create the default physics plugin.
  49039. * @returns The default physics plugin
  49040. */
  49041. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49042. /**
  49043. * Creates a new Physics Engine
  49044. * @param gravity defines the gravity vector used by the simulation
  49045. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49046. */
  49047. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49048. /**
  49049. * Sets the gravity vector used by the simulation
  49050. * @param gravity defines the gravity vector to use
  49051. */
  49052. setGravity(gravity: Vector3): void;
  49053. /**
  49054. * Set the time step of the physics engine.
  49055. * Default is 1/60.
  49056. * To slow it down, enter 1/600 for example.
  49057. * To speed it up, 1/30
  49058. * @param newTimeStep defines the new timestep to apply to this world.
  49059. */
  49060. setTimeStep(newTimeStep?: number): void;
  49061. /**
  49062. * Get the time step of the physics engine.
  49063. * @returns the current time step
  49064. */
  49065. getTimeStep(): number;
  49066. /**
  49067. * Release all resources
  49068. */
  49069. dispose(): void;
  49070. /**
  49071. * Gets the name of the current physics plugin
  49072. * @returns the name of the plugin
  49073. */
  49074. getPhysicsPluginName(): string;
  49075. /**
  49076. * Adding a new impostor for the impostor tracking.
  49077. * This will be done by the impostor itself.
  49078. * @param impostor the impostor to add
  49079. */
  49080. addImpostor(impostor: PhysicsImpostor): void;
  49081. /**
  49082. * Remove an impostor from the engine.
  49083. * This impostor and its mesh will not longer be updated by the physics engine.
  49084. * @param impostor the impostor to remove
  49085. */
  49086. removeImpostor(impostor: PhysicsImpostor): void;
  49087. /**
  49088. * Add a joint to the physics engine
  49089. * @param mainImpostor defines the main impostor to which the joint is added.
  49090. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49091. * @param joint defines the joint that will connect both impostors.
  49092. */
  49093. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49094. /**
  49095. * Removes a joint from the simulation
  49096. * @param mainImpostor defines the impostor used with the joint
  49097. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49098. * @param joint defines the joint to remove
  49099. */
  49100. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49101. /**
  49102. * Called by the scene. No need to call it.
  49103. * @param delta defines the timespam between frames
  49104. */
  49105. _step(delta: number): void;
  49106. /**
  49107. * Gets the current plugin used to run the simulation
  49108. * @returns current plugin
  49109. */
  49110. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49111. /**
  49112. * Gets the list of physic impostors
  49113. * @returns an array of PhysicsImpostor
  49114. */
  49115. getImpostors(): Array<PhysicsImpostor>;
  49116. /**
  49117. * Gets the impostor for a physics enabled object
  49118. * @param object defines the object impersonated by the impostor
  49119. * @returns the PhysicsImpostor or null if not found
  49120. */
  49121. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49122. /**
  49123. * Gets the impostor for a physics body object
  49124. * @param body defines physics body used by the impostor
  49125. * @returns the PhysicsImpostor or null if not found
  49126. */
  49127. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49128. /**
  49129. * Does a raycast in the physics world
  49130. * @param from when should the ray start?
  49131. * @param to when should the ray end?
  49132. * @returns PhysicsRaycastResult
  49133. */
  49134. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49135. }
  49136. }
  49137. declare module BABYLON {
  49138. /** @hidden */
  49139. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49140. private _useDeltaForWorldStep;
  49141. world: any;
  49142. name: string;
  49143. private _physicsMaterials;
  49144. private _fixedTimeStep;
  49145. private _cannonRaycastResult;
  49146. private _raycastResult;
  49147. private _physicsBodysToRemoveAfterStep;
  49148. BJSCANNON: any;
  49149. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49150. setGravity(gravity: Vector3): void;
  49151. setTimeStep(timeStep: number): void;
  49152. getTimeStep(): number;
  49153. executeStep(delta: number): void;
  49154. private _removeMarkedPhysicsBodiesFromWorld;
  49155. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49156. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49157. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49158. private _processChildMeshes;
  49159. removePhysicsBody(impostor: PhysicsImpostor): void;
  49160. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49161. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49162. private _addMaterial;
  49163. private _checkWithEpsilon;
  49164. private _createShape;
  49165. private _createHeightmap;
  49166. private _minus90X;
  49167. private _plus90X;
  49168. private _tmpPosition;
  49169. private _tmpDeltaPosition;
  49170. private _tmpUnityRotation;
  49171. private _updatePhysicsBodyTransformation;
  49172. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49173. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49174. isSupported(): boolean;
  49175. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49176. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49177. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49178. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49179. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49180. getBodyMass(impostor: PhysicsImpostor): number;
  49181. getBodyFriction(impostor: PhysicsImpostor): number;
  49182. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49183. getBodyRestitution(impostor: PhysicsImpostor): number;
  49184. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49185. sleepBody(impostor: PhysicsImpostor): void;
  49186. wakeUpBody(impostor: PhysicsImpostor): void;
  49187. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49188. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49189. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49190. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49191. getRadius(impostor: PhysicsImpostor): number;
  49192. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49193. dispose(): void;
  49194. private _extendNamespace;
  49195. /**
  49196. * Does a raycast in the physics world
  49197. * @param from when should the ray start?
  49198. * @param to when should the ray end?
  49199. * @returns PhysicsRaycastResult
  49200. */
  49201. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49202. }
  49203. }
  49204. declare module BABYLON {
  49205. /** @hidden */
  49206. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49207. world: any;
  49208. name: string;
  49209. BJSOIMO: any;
  49210. private _raycastResult;
  49211. constructor(iterations?: number, oimoInjection?: any);
  49212. setGravity(gravity: Vector3): void;
  49213. setTimeStep(timeStep: number): void;
  49214. getTimeStep(): number;
  49215. private _tmpImpostorsArray;
  49216. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49217. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49218. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49219. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49220. private _tmpPositionVector;
  49221. removePhysicsBody(impostor: PhysicsImpostor): void;
  49222. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49223. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49224. isSupported(): boolean;
  49225. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49226. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49227. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49228. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49229. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49230. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49231. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49232. getBodyMass(impostor: PhysicsImpostor): number;
  49233. getBodyFriction(impostor: PhysicsImpostor): number;
  49234. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49235. getBodyRestitution(impostor: PhysicsImpostor): number;
  49236. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49237. sleepBody(impostor: PhysicsImpostor): void;
  49238. wakeUpBody(impostor: PhysicsImpostor): void;
  49239. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49240. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49241. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49242. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49243. getRadius(impostor: PhysicsImpostor): number;
  49244. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49245. dispose(): void;
  49246. /**
  49247. * Does a raycast in the physics world
  49248. * @param from when should the ray start?
  49249. * @param to when should the ray end?
  49250. * @returns PhysicsRaycastResult
  49251. */
  49252. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49253. }
  49254. }
  49255. declare module BABYLON {
  49256. /**
  49257. * Class containing static functions to help procedurally build meshes
  49258. */
  49259. export class RibbonBuilder {
  49260. /**
  49261. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49262. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49263. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49264. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49265. * * 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
  49266. * * 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
  49267. * * 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
  49268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49269. * * 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
  49270. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49271. * * 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
  49272. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49273. * * 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
  49274. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49276. * @param name defines the name of the mesh
  49277. * @param options defines the options used to create the mesh
  49278. * @param scene defines the hosting scene
  49279. * @returns the ribbon mesh
  49280. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49281. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49282. */
  49283. static CreateRibbon(name: string, options: {
  49284. pathArray: Vector3[][];
  49285. closeArray?: boolean;
  49286. closePath?: boolean;
  49287. offset?: number;
  49288. updatable?: boolean;
  49289. sideOrientation?: number;
  49290. frontUVs?: Vector4;
  49291. backUVs?: Vector4;
  49292. instance?: Mesh;
  49293. invertUV?: boolean;
  49294. uvs?: Vector2[];
  49295. colors?: Color4[];
  49296. }, scene?: Nullable<Scene>): Mesh;
  49297. }
  49298. }
  49299. declare module BABYLON {
  49300. /**
  49301. * Class containing static functions to help procedurally build meshes
  49302. */
  49303. export class ShapeBuilder {
  49304. /**
  49305. * 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.
  49306. * * 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.
  49307. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49308. * * 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.
  49309. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49310. * * 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
  49311. * * 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
  49312. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49313. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49314. * * 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
  49315. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49317. * @param name defines the name of the mesh
  49318. * @param options defines the options used to create the mesh
  49319. * @param scene defines the hosting scene
  49320. * @returns the extruded shape mesh
  49321. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49322. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49323. */
  49324. static ExtrudeShape(name: string, options: {
  49325. shape: Vector3[];
  49326. path: Vector3[];
  49327. scale?: number;
  49328. rotation?: number;
  49329. cap?: number;
  49330. updatable?: boolean;
  49331. sideOrientation?: number;
  49332. frontUVs?: Vector4;
  49333. backUVs?: Vector4;
  49334. instance?: Mesh;
  49335. invertUV?: boolean;
  49336. }, scene?: Nullable<Scene>): Mesh;
  49337. /**
  49338. * Creates an custom extruded shape mesh.
  49339. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49340. * * 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.
  49341. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49342. * * 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
  49343. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49344. * * 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
  49345. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49346. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49347. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49348. * * 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
  49349. * * 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
  49350. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49352. * * 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
  49353. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49355. * @param name defines the name of the mesh
  49356. * @param options defines the options used to create the mesh
  49357. * @param scene defines the hosting scene
  49358. * @returns the custom extruded shape mesh
  49359. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49360. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49361. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49362. */
  49363. static ExtrudeShapeCustom(name: string, options: {
  49364. shape: Vector3[];
  49365. path: Vector3[];
  49366. scaleFunction?: any;
  49367. rotationFunction?: any;
  49368. ribbonCloseArray?: boolean;
  49369. ribbonClosePath?: boolean;
  49370. cap?: number;
  49371. updatable?: boolean;
  49372. sideOrientation?: number;
  49373. frontUVs?: Vector4;
  49374. backUVs?: Vector4;
  49375. instance?: Mesh;
  49376. invertUV?: boolean;
  49377. }, scene?: Nullable<Scene>): Mesh;
  49378. private static _ExtrudeShapeGeneric;
  49379. }
  49380. }
  49381. declare module BABYLON {
  49382. /**
  49383. * AmmoJS Physics plugin
  49384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49385. * @see https://github.com/kripken/ammo.js/
  49386. */
  49387. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49388. private _useDeltaForWorldStep;
  49389. /**
  49390. * Reference to the Ammo library
  49391. */
  49392. bjsAMMO: any;
  49393. /**
  49394. * Created ammoJS world which physics bodies are added to
  49395. */
  49396. world: any;
  49397. /**
  49398. * Name of the plugin
  49399. */
  49400. name: string;
  49401. private _timeStep;
  49402. private _fixedTimeStep;
  49403. private _maxSteps;
  49404. private _tmpQuaternion;
  49405. private _tmpAmmoTransform;
  49406. private _tmpAmmoQuaternion;
  49407. private _tmpAmmoConcreteContactResultCallback;
  49408. private _collisionConfiguration;
  49409. private _dispatcher;
  49410. private _overlappingPairCache;
  49411. private _solver;
  49412. private _softBodySolver;
  49413. private _tmpAmmoVectorA;
  49414. private _tmpAmmoVectorB;
  49415. private _tmpAmmoVectorC;
  49416. private _tmpAmmoVectorD;
  49417. private _tmpContactCallbackResult;
  49418. private _tmpAmmoVectorRCA;
  49419. private _tmpAmmoVectorRCB;
  49420. private _raycastResult;
  49421. private static readonly DISABLE_COLLISION_FLAG;
  49422. private static readonly KINEMATIC_FLAG;
  49423. private static readonly DISABLE_DEACTIVATION_FLAG;
  49424. /**
  49425. * Initializes the ammoJS plugin
  49426. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49427. * @param ammoInjection can be used to inject your own ammo reference
  49428. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  49429. */
  49430. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  49431. /**
  49432. * Sets the gravity of the physics world (m/(s^2))
  49433. * @param gravity Gravity to set
  49434. */
  49435. setGravity(gravity: Vector3): void;
  49436. /**
  49437. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49438. * @param timeStep timestep to use in seconds
  49439. */
  49440. setTimeStep(timeStep: number): void;
  49441. /**
  49442. * 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)
  49443. * @param fixedTimeStep fixedTimeStep to use in seconds
  49444. */
  49445. setFixedTimeStep(fixedTimeStep: number): void;
  49446. /**
  49447. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49448. * @param maxSteps the maximum number of steps by the physics engine per frame
  49449. */
  49450. setMaxSteps(maxSteps: number): void;
  49451. /**
  49452. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49453. * @returns the current timestep in seconds
  49454. */
  49455. getTimeStep(): number;
  49456. private _isImpostorInContact;
  49457. private _isImpostorPairInContact;
  49458. private _stepSimulation;
  49459. /**
  49460. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49461. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49462. * After the step the babylon meshes are set to the position of the physics imposters
  49463. * @param delta amount of time to step forward
  49464. * @param impostors array of imposters to update before/after the step
  49465. */
  49466. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49467. /**
  49468. * Update babylon mesh to match physics world object
  49469. * @param impostor imposter to match
  49470. */
  49471. private _afterSoftStep;
  49472. /**
  49473. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49474. * @param impostor imposter to match
  49475. */
  49476. private _ropeStep;
  49477. /**
  49478. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49479. * @param impostor imposter to match
  49480. */
  49481. private _softbodyOrClothStep;
  49482. private _tmpVector;
  49483. private _tmpMatrix;
  49484. /**
  49485. * Applies an impulse on the imposter
  49486. * @param impostor imposter to apply impulse to
  49487. * @param force amount of force to be applied to the imposter
  49488. * @param contactPoint the location to apply the impulse on the imposter
  49489. */
  49490. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49491. /**
  49492. * Applies a force on the imposter
  49493. * @param impostor imposter to apply force
  49494. * @param force amount of force to be applied to the imposter
  49495. * @param contactPoint the location to apply the force on the imposter
  49496. */
  49497. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49498. /**
  49499. * Creates a physics body using the plugin
  49500. * @param impostor the imposter to create the physics body on
  49501. */
  49502. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49503. /**
  49504. * Removes the physics body from the imposter and disposes of the body's memory
  49505. * @param impostor imposter to remove the physics body from
  49506. */
  49507. removePhysicsBody(impostor: PhysicsImpostor): void;
  49508. /**
  49509. * Generates a joint
  49510. * @param impostorJoint the imposter joint to create the joint with
  49511. */
  49512. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49513. /**
  49514. * Removes a joint
  49515. * @param impostorJoint the imposter joint to remove the joint from
  49516. */
  49517. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49518. private _addMeshVerts;
  49519. /**
  49520. * Initialise the soft body vertices to match its object's (mesh) vertices
  49521. * Softbody vertices (nodes) are in world space and to match this
  49522. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  49523. * @param impostor to create the softbody for
  49524. */
  49525. private _softVertexData;
  49526. /**
  49527. * Create an impostor's soft body
  49528. * @param impostor to create the softbody for
  49529. */
  49530. private _createSoftbody;
  49531. /**
  49532. * Create cloth for an impostor
  49533. * @param impostor to create the softbody for
  49534. */
  49535. private _createCloth;
  49536. /**
  49537. * Create rope for an impostor
  49538. * @param impostor to create the softbody for
  49539. */
  49540. private _createRope;
  49541. private _addHullVerts;
  49542. private _createShape;
  49543. /**
  49544. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49545. * @param impostor imposter containing the physics body and babylon object
  49546. */
  49547. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49548. /**
  49549. * Sets the babylon object's position/rotation from the physics body's position/rotation
  49550. * @param impostor imposter containing the physics body and babylon object
  49551. * @param newPosition new position
  49552. * @param newRotation new rotation
  49553. */
  49554. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49555. /**
  49556. * If this plugin is supported
  49557. * @returns true if its supported
  49558. */
  49559. isSupported(): boolean;
  49560. /**
  49561. * Sets the linear velocity of the physics body
  49562. * @param impostor imposter to set the velocity on
  49563. * @param velocity velocity to set
  49564. */
  49565. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49566. /**
  49567. * Sets the angular velocity of the physics body
  49568. * @param impostor imposter to set the velocity on
  49569. * @param velocity velocity to set
  49570. */
  49571. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49572. /**
  49573. * gets the linear velocity
  49574. * @param impostor imposter to get linear velocity from
  49575. * @returns linear velocity
  49576. */
  49577. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49578. /**
  49579. * gets the angular velocity
  49580. * @param impostor imposter to get angular velocity from
  49581. * @returns angular velocity
  49582. */
  49583. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49584. /**
  49585. * Sets the mass of physics body
  49586. * @param impostor imposter to set the mass on
  49587. * @param mass mass to set
  49588. */
  49589. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49590. /**
  49591. * Gets the mass of the physics body
  49592. * @param impostor imposter to get the mass from
  49593. * @returns mass
  49594. */
  49595. getBodyMass(impostor: PhysicsImpostor): number;
  49596. /**
  49597. * Gets friction of the impostor
  49598. * @param impostor impostor to get friction from
  49599. * @returns friction value
  49600. */
  49601. getBodyFriction(impostor: PhysicsImpostor): number;
  49602. /**
  49603. * Sets friction of the impostor
  49604. * @param impostor impostor to set friction on
  49605. * @param friction friction value
  49606. */
  49607. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49608. /**
  49609. * Gets restitution of the impostor
  49610. * @param impostor impostor to get restitution from
  49611. * @returns restitution value
  49612. */
  49613. getBodyRestitution(impostor: PhysicsImpostor): number;
  49614. /**
  49615. * Sets resitution of the impostor
  49616. * @param impostor impostor to set resitution on
  49617. * @param restitution resitution value
  49618. */
  49619. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49620. /**
  49621. * Gets pressure inside the impostor
  49622. * @param impostor impostor to get pressure from
  49623. * @returns pressure value
  49624. */
  49625. getBodyPressure(impostor: PhysicsImpostor): number;
  49626. /**
  49627. * Sets pressure inside a soft body impostor
  49628. * Cloth and rope must remain 0 pressure
  49629. * @param impostor impostor to set pressure on
  49630. * @param pressure pressure value
  49631. */
  49632. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  49633. /**
  49634. * Gets stiffness of the impostor
  49635. * @param impostor impostor to get stiffness from
  49636. * @returns pressure value
  49637. */
  49638. getBodyStiffness(impostor: PhysicsImpostor): number;
  49639. /**
  49640. * Sets stiffness of the impostor
  49641. * @param impostor impostor to set stiffness on
  49642. * @param stiffness stiffness value from 0 to 1
  49643. */
  49644. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  49645. /**
  49646. * Gets velocityIterations of the impostor
  49647. * @param impostor impostor to get velocity iterations from
  49648. * @returns velocityIterations value
  49649. */
  49650. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  49651. /**
  49652. * Sets velocityIterations of the impostor
  49653. * @param impostor impostor to set velocity iterations on
  49654. * @param velocityIterations velocityIterations value
  49655. */
  49656. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  49657. /**
  49658. * Gets positionIterations of the impostor
  49659. * @param impostor impostor to get position iterations from
  49660. * @returns positionIterations value
  49661. */
  49662. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  49663. /**
  49664. * Sets positionIterations of the impostor
  49665. * @param impostor impostor to set position on
  49666. * @param positionIterations positionIterations value
  49667. */
  49668. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  49669. /**
  49670. * Append an anchor to a cloth object
  49671. * @param impostor is the cloth impostor to add anchor to
  49672. * @param otherImpostor is the rigid impostor to anchor to
  49673. * @param width ratio across width from 0 to 1
  49674. * @param height ratio up height from 0 to 1
  49675. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  49676. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49677. */
  49678. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49679. /**
  49680. * Append an hook to a rope object
  49681. * @param impostor is the rope impostor to add hook to
  49682. * @param otherImpostor is the rigid impostor to hook to
  49683. * @param length ratio along the rope from 0 to 1
  49684. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  49685. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49686. */
  49687. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49688. /**
  49689. * Sleeps the physics body and stops it from being active
  49690. * @param impostor impostor to sleep
  49691. */
  49692. sleepBody(impostor: PhysicsImpostor): void;
  49693. /**
  49694. * Activates the physics body
  49695. * @param impostor impostor to activate
  49696. */
  49697. wakeUpBody(impostor: PhysicsImpostor): void;
  49698. /**
  49699. * Updates the distance parameters of the joint
  49700. * @param joint joint to update
  49701. * @param maxDistance maximum distance of the joint
  49702. * @param minDistance minimum distance of the joint
  49703. */
  49704. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49705. /**
  49706. * Sets a motor on the joint
  49707. * @param joint joint to set motor on
  49708. * @param speed speed of the motor
  49709. * @param maxForce maximum force of the motor
  49710. * @param motorIndex index of the motor
  49711. */
  49712. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49713. /**
  49714. * Sets the motors limit
  49715. * @param joint joint to set limit on
  49716. * @param upperLimit upper limit
  49717. * @param lowerLimit lower limit
  49718. */
  49719. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49720. /**
  49721. * Syncs the position and rotation of a mesh with the impostor
  49722. * @param mesh mesh to sync
  49723. * @param impostor impostor to update the mesh with
  49724. */
  49725. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49726. /**
  49727. * Gets the radius of the impostor
  49728. * @param impostor impostor to get radius from
  49729. * @returns the radius
  49730. */
  49731. getRadius(impostor: PhysicsImpostor): number;
  49732. /**
  49733. * Gets the box size of the impostor
  49734. * @param impostor impostor to get box size from
  49735. * @param result the resulting box size
  49736. */
  49737. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49738. /**
  49739. * Disposes of the impostor
  49740. */
  49741. dispose(): void;
  49742. /**
  49743. * Does a raycast in the physics world
  49744. * @param from when should the ray start?
  49745. * @param to when should the ray end?
  49746. * @returns PhysicsRaycastResult
  49747. */
  49748. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49749. }
  49750. }
  49751. declare module BABYLON {
  49752. interface AbstractScene {
  49753. /**
  49754. * The list of reflection probes added to the scene
  49755. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49756. */
  49757. reflectionProbes: Array<ReflectionProbe>;
  49758. /**
  49759. * Removes the given reflection probe from this scene.
  49760. * @param toRemove The reflection probe to remove
  49761. * @returns The index of the removed reflection probe
  49762. */
  49763. removeReflectionProbe(toRemove: ReflectionProbe): number;
  49764. /**
  49765. * Adds the given reflection probe to this scene.
  49766. * @param newReflectionProbe The reflection probe to add
  49767. */
  49768. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  49769. }
  49770. /**
  49771. * Class used to generate realtime reflection / refraction cube textures
  49772. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49773. */
  49774. export class ReflectionProbe {
  49775. /** defines the name of the probe */
  49776. name: string;
  49777. private _scene;
  49778. private _renderTargetTexture;
  49779. private _projectionMatrix;
  49780. private _viewMatrix;
  49781. private _target;
  49782. private _add;
  49783. private _attachedMesh;
  49784. private _invertYAxis;
  49785. /** Gets or sets probe position (center of the cube map) */
  49786. position: Vector3;
  49787. /**
  49788. * Creates a new reflection probe
  49789. * @param name defines the name of the probe
  49790. * @param size defines the texture resolution (for each face)
  49791. * @param scene defines the hosting scene
  49792. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49793. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49794. */
  49795. constructor(
  49796. /** defines the name of the probe */
  49797. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49798. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49799. samples: number;
  49800. /** Gets or sets the refresh rate to use (on every frame by default) */
  49801. refreshRate: number;
  49802. /**
  49803. * Gets the hosting scene
  49804. * @returns a Scene
  49805. */
  49806. getScene(): Scene;
  49807. /** Gets the internal CubeTexture used to render to */
  49808. readonly cubeTexture: RenderTargetTexture;
  49809. /** Gets the list of meshes to render */
  49810. readonly renderList: Nullable<AbstractMesh[]>;
  49811. /**
  49812. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49813. * @param mesh defines the mesh to attach to
  49814. */
  49815. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49816. /**
  49817. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49818. * @param renderingGroupId The rendering group id corresponding to its index
  49819. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49820. */
  49821. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49822. /**
  49823. * Clean all associated resources
  49824. */
  49825. dispose(): void;
  49826. /**
  49827. * Converts the reflection probe information to a readable string for debug purpose.
  49828. * @param fullDetails Supports for multiple levels of logging within scene loading
  49829. * @returns the human readable reflection probe info
  49830. */
  49831. toString(fullDetails?: boolean): string;
  49832. /**
  49833. * Get the class name of the relfection probe.
  49834. * @returns "ReflectionProbe"
  49835. */
  49836. getClassName(): string;
  49837. /**
  49838. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49839. * @returns The JSON representation of the texture
  49840. */
  49841. serialize(): any;
  49842. /**
  49843. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49844. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49845. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49846. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49847. * @returns The parsed reflection probe if successful
  49848. */
  49849. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49850. }
  49851. }
  49852. declare module BABYLON {
  49853. /** @hidden */
  49854. export var _BabylonLoaderRegistered: boolean;
  49855. }
  49856. declare module BABYLON {
  49857. /**
  49858. * The Physically based simple base material of BJS.
  49859. *
  49860. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49861. * It is used as the base class for both the specGloss and metalRough conventions.
  49862. */
  49863. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49864. /**
  49865. * Number of Simultaneous lights allowed on the material.
  49866. */
  49867. maxSimultaneousLights: number;
  49868. /**
  49869. * If sets to true, disables all the lights affecting the material.
  49870. */
  49871. disableLighting: boolean;
  49872. /**
  49873. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49874. */
  49875. environmentTexture: BaseTexture;
  49876. /**
  49877. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49878. */
  49879. invertNormalMapX: boolean;
  49880. /**
  49881. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49882. */
  49883. invertNormalMapY: boolean;
  49884. /**
  49885. * Normal map used in the model.
  49886. */
  49887. normalTexture: BaseTexture;
  49888. /**
  49889. * Emissivie color used to self-illuminate the model.
  49890. */
  49891. emissiveColor: Color3;
  49892. /**
  49893. * Emissivie texture used to self-illuminate the model.
  49894. */
  49895. emissiveTexture: BaseTexture;
  49896. /**
  49897. * Occlusion Channel Strenght.
  49898. */
  49899. occlusionStrength: number;
  49900. /**
  49901. * Occlusion Texture of the material (adding extra occlusion effects).
  49902. */
  49903. occlusionTexture: BaseTexture;
  49904. /**
  49905. * Defines the alpha limits in alpha test mode.
  49906. */
  49907. alphaCutOff: number;
  49908. /**
  49909. * Gets the current double sided mode.
  49910. */
  49911. /**
  49912. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49913. */
  49914. doubleSided: boolean;
  49915. /**
  49916. * Stores the pre-calculated light information of a mesh in a texture.
  49917. */
  49918. lightmapTexture: BaseTexture;
  49919. /**
  49920. * If true, the light map contains occlusion information instead of lighting info.
  49921. */
  49922. useLightmapAsShadowmap: boolean;
  49923. /**
  49924. * Instantiates a new PBRMaterial instance.
  49925. *
  49926. * @param name The material name
  49927. * @param scene The scene the material will be use in.
  49928. */
  49929. constructor(name: string, scene: Scene);
  49930. getClassName(): string;
  49931. }
  49932. }
  49933. declare module BABYLON {
  49934. /**
  49935. * The PBR material of BJS following the metal roughness convention.
  49936. *
  49937. * This fits to the PBR convention in the GLTF definition:
  49938. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49939. */
  49940. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49941. /**
  49942. * The base color has two different interpretations depending on the value of metalness.
  49943. * When the material is a metal, the base color is the specific measured reflectance value
  49944. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49945. * of the material.
  49946. */
  49947. baseColor: Color3;
  49948. /**
  49949. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49950. * well as opacity information in the alpha channel.
  49951. */
  49952. baseTexture: BaseTexture;
  49953. /**
  49954. * Specifies the metallic scalar value of the material.
  49955. * Can also be used to scale the metalness values of the metallic texture.
  49956. */
  49957. metallic: number;
  49958. /**
  49959. * Specifies the roughness scalar value of the material.
  49960. * Can also be used to scale the roughness values of the metallic texture.
  49961. */
  49962. roughness: number;
  49963. /**
  49964. * Texture containing both the metallic value in the B channel and the
  49965. * roughness value in the G channel to keep better precision.
  49966. */
  49967. metallicRoughnessTexture: BaseTexture;
  49968. /**
  49969. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49970. *
  49971. * @param name The material name
  49972. * @param scene The scene the material will be use in.
  49973. */
  49974. constructor(name: string, scene: Scene);
  49975. /**
  49976. * Return the currrent class name of the material.
  49977. */
  49978. getClassName(): string;
  49979. /**
  49980. * Makes a duplicate of the current material.
  49981. * @param name - name to use for the new material.
  49982. */
  49983. clone(name: string): PBRMetallicRoughnessMaterial;
  49984. /**
  49985. * Serialize the material to a parsable JSON object.
  49986. */
  49987. serialize(): any;
  49988. /**
  49989. * Parses a JSON object correponding to the serialize function.
  49990. */
  49991. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49992. }
  49993. }
  49994. declare module BABYLON {
  49995. /**
  49996. * The PBR material of BJS following the specular glossiness convention.
  49997. *
  49998. * This fits to the PBR convention in the GLTF definition:
  49999. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50000. */
  50001. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50002. /**
  50003. * Specifies the diffuse color of the material.
  50004. */
  50005. diffuseColor: Color3;
  50006. /**
  50007. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50008. * channel.
  50009. */
  50010. diffuseTexture: BaseTexture;
  50011. /**
  50012. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50013. */
  50014. specularColor: Color3;
  50015. /**
  50016. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50017. */
  50018. glossiness: number;
  50019. /**
  50020. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50021. */
  50022. specularGlossinessTexture: BaseTexture;
  50023. /**
  50024. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50025. *
  50026. * @param name The material name
  50027. * @param scene The scene the material will be use in.
  50028. */
  50029. constructor(name: string, scene: Scene);
  50030. /**
  50031. * Return the currrent class name of the material.
  50032. */
  50033. getClassName(): string;
  50034. /**
  50035. * Makes a duplicate of the current material.
  50036. * @param name - name to use for the new material.
  50037. */
  50038. clone(name: string): PBRSpecularGlossinessMaterial;
  50039. /**
  50040. * Serialize the material to a parsable JSON object.
  50041. */
  50042. serialize(): any;
  50043. /**
  50044. * Parses a JSON object correponding to the serialize function.
  50045. */
  50046. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50047. }
  50048. }
  50049. declare module BABYLON {
  50050. /**
  50051. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50052. * It can help converting any input color in a desired output one. This can then be used to create effects
  50053. * from sepia, black and white to sixties or futuristic rendering...
  50054. *
  50055. * The only supported format is currently 3dl.
  50056. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50057. */
  50058. export class ColorGradingTexture extends BaseTexture {
  50059. /**
  50060. * The current texture matrix. (will always be identity in color grading texture)
  50061. */
  50062. private _textureMatrix;
  50063. /**
  50064. * The texture URL.
  50065. */
  50066. url: string;
  50067. /**
  50068. * Empty line regex stored for GC.
  50069. */
  50070. private static _noneEmptyLineRegex;
  50071. private _engine;
  50072. /**
  50073. * Instantiates a ColorGradingTexture from the following parameters.
  50074. *
  50075. * @param url The location of the color gradind data (currently only supporting 3dl)
  50076. * @param scene The scene the texture will be used in
  50077. */
  50078. constructor(url: string, scene: Scene);
  50079. /**
  50080. * Returns the texture matrix used in most of the material.
  50081. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50082. */
  50083. getTextureMatrix(): Matrix;
  50084. /**
  50085. * Occurs when the file being loaded is a .3dl LUT file.
  50086. */
  50087. private load3dlTexture;
  50088. /**
  50089. * Starts the loading process of the texture.
  50090. */
  50091. private loadTexture;
  50092. /**
  50093. * Clones the color gradind texture.
  50094. */
  50095. clone(): ColorGradingTexture;
  50096. /**
  50097. * Called during delayed load for textures.
  50098. */
  50099. delayLoad(): void;
  50100. /**
  50101. * Parses a color grading texture serialized by Babylon.
  50102. * @param parsedTexture The texture information being parsedTexture
  50103. * @param scene The scene to load the texture in
  50104. * @param rootUrl The root url of the data assets to load
  50105. * @return A color gradind texture
  50106. */
  50107. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50108. /**
  50109. * Serializes the LUT texture to json format.
  50110. */
  50111. serialize(): any;
  50112. }
  50113. }
  50114. declare module BABYLON {
  50115. /**
  50116. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50117. */
  50118. export class EquiRectangularCubeTexture extends BaseTexture {
  50119. /** The six faces of the cube. */
  50120. private static _FacesMapping;
  50121. private _noMipmap;
  50122. private _onLoad;
  50123. private _onError;
  50124. /** The size of the cubemap. */
  50125. private _size;
  50126. /** The buffer of the image. */
  50127. private _buffer;
  50128. /** The width of the input image. */
  50129. private _width;
  50130. /** The height of the input image. */
  50131. private _height;
  50132. /** The URL to the image. */
  50133. url: string;
  50134. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50135. coordinatesMode: number;
  50136. /**
  50137. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50138. * @param url The location of the image
  50139. * @param scene The scene the texture will be used in
  50140. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50141. * @param noMipmap Forces to not generate the mipmap if true
  50142. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50143. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50144. * @param onLoad — defines a callback called when texture is loaded
  50145. * @param onError — defines a callback called if there is an error
  50146. */
  50147. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50148. /**
  50149. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50150. */
  50151. private loadImage;
  50152. /**
  50153. * Convert the image buffer into a cubemap and create a CubeTexture.
  50154. */
  50155. private loadTexture;
  50156. /**
  50157. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  50158. * @param buffer The ArrayBuffer that should be converted.
  50159. * @returns The buffer as Float32Array.
  50160. */
  50161. private getFloat32ArrayFromArrayBuffer;
  50162. /**
  50163. * Get the current class name of the texture useful for serialization or dynamic coding.
  50164. * @returns "EquiRectangularCubeTexture"
  50165. */
  50166. getClassName(): string;
  50167. /**
  50168. * Create a clone of the current EquiRectangularCubeTexture and return it.
  50169. * @returns A clone of the current EquiRectangularCubeTexture.
  50170. */
  50171. clone(): EquiRectangularCubeTexture;
  50172. }
  50173. }
  50174. declare module BABYLON {
  50175. /**
  50176. * Based on jsTGALoader - Javascript loader for TGA file
  50177. * By Vincent Thibault
  50178. * @see http://blog.robrowser.com/javascript-tga-loader.html
  50179. */
  50180. export class TGATools {
  50181. private static _TYPE_INDEXED;
  50182. private static _TYPE_RGB;
  50183. private static _TYPE_GREY;
  50184. private static _TYPE_RLE_INDEXED;
  50185. private static _TYPE_RLE_RGB;
  50186. private static _TYPE_RLE_GREY;
  50187. private static _ORIGIN_MASK;
  50188. private static _ORIGIN_SHIFT;
  50189. private static _ORIGIN_BL;
  50190. private static _ORIGIN_BR;
  50191. private static _ORIGIN_UL;
  50192. private static _ORIGIN_UR;
  50193. /**
  50194. * Gets the header of a TGA file
  50195. * @param data defines the TGA data
  50196. * @returns the header
  50197. */
  50198. static GetTGAHeader(data: Uint8Array): any;
  50199. /**
  50200. * Uploads TGA content to a Babylon Texture
  50201. * @hidden
  50202. */
  50203. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  50204. /** @hidden */
  50205. 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;
  50206. /** @hidden */
  50207. 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;
  50208. /** @hidden */
  50209. 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;
  50210. /** @hidden */
  50211. 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;
  50212. /** @hidden */
  50213. 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;
  50214. /** @hidden */
  50215. 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;
  50216. }
  50217. }
  50218. declare module BABYLON {
  50219. /**
  50220. * Implementation of the TGA Texture Loader.
  50221. * @hidden
  50222. */
  50223. export class _TGATextureLoader implements IInternalTextureLoader {
  50224. /**
  50225. * Defines wether the loader supports cascade loading the different faces.
  50226. */
  50227. readonly supportCascades: boolean;
  50228. /**
  50229. * This returns if the loader support the current file information.
  50230. * @param extension defines the file extension of the file being loaded
  50231. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50232. * @param fallback defines the fallback internal texture if any
  50233. * @param isBase64 defines whether the texture is encoded as a base64
  50234. * @param isBuffer defines whether the texture data are stored as a buffer
  50235. * @returns true if the loader can load the specified file
  50236. */
  50237. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50238. /**
  50239. * Transform the url before loading if required.
  50240. * @param rootUrl the url of the texture
  50241. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50242. * @returns the transformed texture
  50243. */
  50244. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50245. /**
  50246. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50247. * @param rootUrl the url of the texture
  50248. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50249. * @returns the fallback texture
  50250. */
  50251. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50252. /**
  50253. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50254. * @param data contains the texture data
  50255. * @param texture defines the BabylonJS internal texture
  50256. * @param createPolynomials will be true if polynomials have been requested
  50257. * @param onLoad defines the callback to trigger once the texture is ready
  50258. * @param onError defines the callback to trigger in case of error
  50259. */
  50260. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50261. /**
  50262. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50263. * @param data contains the texture data
  50264. * @param texture defines the BabylonJS internal texture
  50265. * @param callback defines the method to call once ready to upload
  50266. */
  50267. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50268. }
  50269. }
  50270. declare module BABYLON {
  50271. /**
  50272. * Info about the .basis files
  50273. */
  50274. class BasisFileInfo {
  50275. /**
  50276. * If the file has alpha
  50277. */
  50278. hasAlpha: boolean;
  50279. /**
  50280. * Info about each image of the basis file
  50281. */
  50282. images: Array<{
  50283. levels: Array<{
  50284. width: number;
  50285. height: number;
  50286. transcodedPixels: ArrayBufferView;
  50287. }>;
  50288. }>;
  50289. }
  50290. /**
  50291. * Result of transcoding a basis file
  50292. */
  50293. class TranscodeResult {
  50294. /**
  50295. * Info about the .basis file
  50296. */
  50297. fileInfo: BasisFileInfo;
  50298. /**
  50299. * Format to use when loading the file
  50300. */
  50301. format: number;
  50302. }
  50303. /**
  50304. * Configuration options for the Basis transcoder
  50305. */
  50306. export class BasisTranscodeConfiguration {
  50307. /**
  50308. * Supported compression formats used to determine the supported output format of the transcoder
  50309. */
  50310. supportedCompressionFormats?: {
  50311. /**
  50312. * etc1 compression format
  50313. */
  50314. etc1?: boolean;
  50315. /**
  50316. * s3tc compression format
  50317. */
  50318. s3tc?: boolean;
  50319. /**
  50320. * pvrtc compression format
  50321. */
  50322. pvrtc?: boolean;
  50323. /**
  50324. * etc2 compression format
  50325. */
  50326. etc2?: boolean;
  50327. };
  50328. /**
  50329. * If mipmap levels should be loaded for transcoded images (Default: true)
  50330. */
  50331. loadMipmapLevels?: boolean;
  50332. /**
  50333. * Index of a single image to load (Default: all images)
  50334. */
  50335. loadSingleImage?: number;
  50336. }
  50337. /**
  50338. * Used to load .Basis files
  50339. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  50340. */
  50341. export class BasisTools {
  50342. private static _IgnoreSupportedFormats;
  50343. /**
  50344. * URL to use when loading the basis transcoder
  50345. */
  50346. static JSModuleURL: string;
  50347. /**
  50348. * URL to use when loading the wasm module for the transcoder
  50349. */
  50350. static WasmModuleURL: string;
  50351. /**
  50352. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  50353. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  50354. * @returns internal format corresponding to the Basis format
  50355. */
  50356. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  50357. private static _WorkerPromise;
  50358. private static _Worker;
  50359. private static _actionId;
  50360. private static _CreateWorkerAsync;
  50361. /**
  50362. * Transcodes a loaded image file to compressed pixel data
  50363. * @param imageData image data to transcode
  50364. * @param config configuration options for the transcoding
  50365. * @returns a promise resulting in the transcoded image
  50366. */
  50367. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  50368. /**
  50369. * Loads a texture from the transcode result
  50370. * @param texture texture load to
  50371. * @param transcodeResult the result of transcoding the basis file to load from
  50372. */
  50373. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  50374. }
  50375. }
  50376. declare module BABYLON {
  50377. /**
  50378. * Loader for .basis file format
  50379. */
  50380. export class _BasisTextureLoader implements IInternalTextureLoader {
  50381. /**
  50382. * Defines whether the loader supports cascade loading the different faces.
  50383. */
  50384. readonly supportCascades: boolean;
  50385. /**
  50386. * This returns if the loader support the current file information.
  50387. * @param extension defines the file extension of the file being loaded
  50388. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50389. * @param fallback defines the fallback internal texture if any
  50390. * @param isBase64 defines whether the texture is encoded as a base64
  50391. * @param isBuffer defines whether the texture data are stored as a buffer
  50392. * @returns true if the loader can load the specified file
  50393. */
  50394. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50395. /**
  50396. * Transform the url before loading if required.
  50397. * @param rootUrl the url of the texture
  50398. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50399. * @returns the transformed texture
  50400. */
  50401. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50402. /**
  50403. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50404. * @param rootUrl the url of the texture
  50405. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50406. * @returns the fallback texture
  50407. */
  50408. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50409. /**
  50410. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  50411. * @param data contains the texture data
  50412. * @param texture defines the BabylonJS internal texture
  50413. * @param createPolynomials will be true if polynomials have been requested
  50414. * @param onLoad defines the callback to trigger once the texture is ready
  50415. * @param onError defines the callback to trigger in case of error
  50416. */
  50417. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50418. /**
  50419. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50420. * @param data contains the texture data
  50421. * @param texture defines the BabylonJS internal texture
  50422. * @param callback defines the method to call once ready to upload
  50423. */
  50424. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50425. }
  50426. }
  50427. declare module BABYLON {
  50428. /**
  50429. * 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.
  50430. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50431. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50432. */
  50433. export class CustomProceduralTexture extends ProceduralTexture {
  50434. private _animate;
  50435. private _time;
  50436. private _config;
  50437. private _texturePath;
  50438. /**
  50439. * Instantiates a new Custom Procedural Texture.
  50440. * 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.
  50441. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50442. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50443. * @param name Define the name of the texture
  50444. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50445. * @param size Define the size of the texture to create
  50446. * @param scene Define the scene the texture belongs to
  50447. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50448. * @param generateMipMaps Define if the texture should creates mip maps or not
  50449. */
  50450. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50451. private _loadJson;
  50452. /**
  50453. * Is the texture ready to be used ? (rendered at least once)
  50454. * @returns true if ready, otherwise, false.
  50455. */
  50456. isReady(): boolean;
  50457. /**
  50458. * Render the texture to its associated render target.
  50459. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50460. */
  50461. render(useCameraPostProcess?: boolean): void;
  50462. /**
  50463. * Update the list of dependant textures samplers in the shader.
  50464. */
  50465. updateTextures(): void;
  50466. /**
  50467. * Update the uniform values of the procedural texture in the shader.
  50468. */
  50469. updateShaderUniforms(): void;
  50470. /**
  50471. * Define if the texture animates or not.
  50472. */
  50473. animate: boolean;
  50474. }
  50475. }
  50476. declare module BABYLON {
  50477. /** @hidden */
  50478. export var noisePixelShader: {
  50479. name: string;
  50480. shader: string;
  50481. };
  50482. }
  50483. declare module BABYLON {
  50484. /**
  50485. * Class used to generate noise procedural textures
  50486. */
  50487. export class NoiseProceduralTexture extends ProceduralTexture {
  50488. private _time;
  50489. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50490. brightness: number;
  50491. /** Defines the number of octaves to process */
  50492. octaves: number;
  50493. /** Defines the level of persistence (0.8 by default) */
  50494. persistence: number;
  50495. /** Gets or sets animation speed factor (default is 1) */
  50496. animationSpeedFactor: number;
  50497. /**
  50498. * Creates a new NoiseProceduralTexture
  50499. * @param name defines the name fo the texture
  50500. * @param size defines the size of the texture (default is 256)
  50501. * @param scene defines the hosting scene
  50502. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50503. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50504. */
  50505. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50506. private _updateShaderUniforms;
  50507. protected _getDefines(): string;
  50508. /** Generate the current state of the procedural texture */
  50509. render(useCameraPostProcess?: boolean): void;
  50510. /**
  50511. * Serializes this noise procedural texture
  50512. * @returns a serialized noise procedural texture object
  50513. */
  50514. serialize(): any;
  50515. /**
  50516. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50517. * @param parsedTexture defines parsed texture data
  50518. * @param scene defines the current scene
  50519. * @param rootUrl defines the root URL containing noise procedural texture information
  50520. * @returns a parsed NoiseProceduralTexture
  50521. */
  50522. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  50523. }
  50524. }
  50525. declare module BABYLON {
  50526. /**
  50527. * Raw cube texture where the raw buffers are passed in
  50528. */
  50529. export class RawCubeTexture extends CubeTexture {
  50530. /**
  50531. * Creates a cube texture where the raw buffers are passed in.
  50532. * @param scene defines the scene the texture is attached to
  50533. * @param data defines the array of data to use to create each face
  50534. * @param size defines the size of the textures
  50535. * @param format defines the format of the data
  50536. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  50537. * @param generateMipMaps defines if the engine should generate the mip levels
  50538. * @param invertY defines if data must be stored with Y axis inverted
  50539. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  50540. * @param compression defines the compression used (null by default)
  50541. */
  50542. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  50543. /**
  50544. * Updates the raw cube texture.
  50545. * @param data defines the data to store
  50546. * @param format defines the data format
  50547. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50548. * @param invertY defines if data must be stored with Y axis inverted
  50549. * @param compression defines the compression used (null by default)
  50550. * @param level defines which level of the texture to update
  50551. */
  50552. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  50553. /**
  50554. * Updates a raw cube texture with RGBD encoded data.
  50555. * @param data defines the array of data [mipmap][face] to use to create each face
  50556. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  50557. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50558. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50559. * @returns a promsie that resolves when the operation is complete
  50560. */
  50561. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  50562. /**
  50563. * Clones the raw cube texture.
  50564. * @return a new cube texture
  50565. */
  50566. clone(): CubeTexture;
  50567. /** @hidden */
  50568. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50569. }
  50570. }
  50571. declare module BABYLON {
  50572. /**
  50573. * Class used to store 3D textures containing user data
  50574. */
  50575. export class RawTexture3D extends Texture {
  50576. /** Gets or sets the texture format to use */
  50577. format: number;
  50578. private _engine;
  50579. /**
  50580. * Create a new RawTexture3D
  50581. * @param data defines the data of the texture
  50582. * @param width defines the width of the texture
  50583. * @param height defines the height of the texture
  50584. * @param depth defines the depth of the texture
  50585. * @param format defines the texture format to use
  50586. * @param scene defines the hosting scene
  50587. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  50588. * @param invertY defines if texture must be stored with Y axis inverted
  50589. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  50590. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  50591. */
  50592. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  50593. /** Gets or sets the texture format to use */
  50594. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  50595. /**
  50596. * Update the texture with new data
  50597. * @param data defines the data to store in the texture
  50598. */
  50599. update(data: ArrayBufferView): void;
  50600. }
  50601. }
  50602. declare module BABYLON {
  50603. /**
  50604. * Creates a refraction texture used by refraction channel of the standard material.
  50605. * It is like a mirror but to see through a material.
  50606. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50607. */
  50608. export class RefractionTexture extends RenderTargetTexture {
  50609. /**
  50610. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  50611. * 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.
  50612. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50613. */
  50614. refractionPlane: Plane;
  50615. /**
  50616. * Define how deep under the surface we should see.
  50617. */
  50618. depth: number;
  50619. /**
  50620. * Creates a refraction texture used by refraction channel of the standard material.
  50621. * It is like a mirror but to see through a material.
  50622. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50623. * @param name Define the texture name
  50624. * @param size Define the size of the underlying texture
  50625. * @param scene Define the scene the refraction belongs to
  50626. * @param generateMipMaps Define if we need to generate mips level for the refraction
  50627. */
  50628. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  50629. /**
  50630. * Clone the refraction texture.
  50631. * @returns the cloned texture
  50632. */
  50633. clone(): RefractionTexture;
  50634. /**
  50635. * Serialize the texture to a JSON representation you could use in Parse later on
  50636. * @returns the serialized JSON representation
  50637. */
  50638. serialize(): any;
  50639. }
  50640. }
  50641. declare module BABYLON {
  50642. /**
  50643. * Defines the options related to the creation of an HtmlElementTexture
  50644. */
  50645. export interface IHtmlElementTextureOptions {
  50646. /**
  50647. * Defines wether mip maps should be created or not.
  50648. */
  50649. generateMipMaps?: boolean;
  50650. /**
  50651. * Defines the sampling mode of the texture.
  50652. */
  50653. samplingMode?: number;
  50654. /**
  50655. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  50656. */
  50657. engine: Nullable<Engine>;
  50658. /**
  50659. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  50660. */
  50661. scene: Nullable<Scene>;
  50662. }
  50663. /**
  50664. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  50665. * To be as efficient as possible depending on your constraints nothing aside the first upload
  50666. * is automatically managed.
  50667. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  50668. * in your application.
  50669. *
  50670. * As the update is not automatic, you need to call them manually.
  50671. */
  50672. export class HtmlElementTexture extends BaseTexture {
  50673. /**
  50674. * The texture URL.
  50675. */
  50676. element: HTMLVideoElement | HTMLCanvasElement;
  50677. private static readonly DefaultOptions;
  50678. private _textureMatrix;
  50679. private _engine;
  50680. private _isVideo;
  50681. private _generateMipMaps;
  50682. private _samplingMode;
  50683. /**
  50684. * Instantiates a HtmlElementTexture from the following parameters.
  50685. *
  50686. * @param name Defines the name of the texture
  50687. * @param element Defines the video or canvas the texture is filled with
  50688. * @param options Defines the other none mandatory texture creation options
  50689. */
  50690. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  50691. private _createInternalTexture;
  50692. /**
  50693. * Returns the texture matrix used in most of the material.
  50694. */
  50695. getTextureMatrix(): Matrix;
  50696. /**
  50697. * Updates the content of the texture.
  50698. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  50699. */
  50700. update(invertY?: Nullable<boolean>): void;
  50701. }
  50702. }
  50703. declare module BABYLON {
  50704. /**
  50705. * Enum used to define the target of a block
  50706. */
  50707. export enum NodeMaterialBlockTargets {
  50708. /** Vertex shader */
  50709. Vertex = 1,
  50710. /** Fragment shader */
  50711. Fragment = 2,
  50712. /** Vertex and Fragment */
  50713. VertexAndFragment = 3
  50714. }
  50715. }
  50716. declare module BABYLON {
  50717. /**
  50718. * Defines the kind of connection point for node based material
  50719. */
  50720. export enum NodeMaterialBlockConnectionPointTypes {
  50721. /** Float */
  50722. Float = 1,
  50723. /** Int */
  50724. Int = 2,
  50725. /** Vector2 */
  50726. Vector2 = 4,
  50727. /** Vector3 */
  50728. Vector3 = 8,
  50729. /** Vector4 */
  50730. Vector4 = 16,
  50731. /** Color3 */
  50732. Color3 = 32,
  50733. /** Color4 */
  50734. Color4 = 64,
  50735. /** Matrix */
  50736. Matrix = 128,
  50737. /** Texture */
  50738. Texture = 256,
  50739. /** Texture3D */
  50740. Texture3D = 512,
  50741. /** Vector3 or Color3 */
  50742. Vector3OrColor3 = 40,
  50743. /** Vector3 or Vector4 */
  50744. Vector3OrVector4 = 24,
  50745. /** Vector4 or Color4 */
  50746. Vector4OrColor4 = 80,
  50747. /** Color3 or Color4 */
  50748. Color3OrColor4 = 96,
  50749. /** Vector3 or Color3 */
  50750. Vector3OrColor3OrVector4OrColor4 = 120,
  50751. /** Detect type based on connection */
  50752. AutoDetect = 1024,
  50753. /** Output type that will be defined by input type */
  50754. BasedOnInput = 2048,
  50755. /** Light */
  50756. Light = 4096
  50757. }
  50758. }
  50759. declare module BABYLON {
  50760. /**
  50761. * Enum used to define well known values e.g. values automatically provided by the system
  50762. */
  50763. export enum NodeMaterialWellKnownValues {
  50764. /** World */
  50765. World = 1,
  50766. /** View */
  50767. View = 2,
  50768. /** Projection */
  50769. Projection = 3,
  50770. /** ViewProjection */
  50771. ViewProjection = 4,
  50772. /** WorldView */
  50773. WorldView = 5,
  50774. /** WorldViewProjection */
  50775. WorldViewProjection = 6,
  50776. /** CameraPosition */
  50777. CameraPosition = 7,
  50778. /** Will be filled by the block itself */
  50779. Automatic = 8
  50780. }
  50781. }
  50782. declare module BABYLON {
  50783. /**
  50784. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  50785. */
  50786. export enum NodeMaterialBlockConnectionPointMode {
  50787. /** Value is an uniform */
  50788. Uniform = 0,
  50789. /** Value is a mesh attribute */
  50790. Attribute = 1,
  50791. /** Value is a varying between vertex and fragment shaders */
  50792. Varying = 2,
  50793. /** Mode is undefined */
  50794. Undefined = 3
  50795. }
  50796. }
  50797. declare module BABYLON {
  50798. /**
  50799. * Class used to store shared data between 2 NodeMaterialBuildState
  50800. */
  50801. export class NodeMaterialBuildStateSharedData {
  50802. /**
  50803. * Gets the list of emitted varyings
  50804. */
  50805. varyings: string[];
  50806. /**
  50807. * Gets the varying declaration string
  50808. */
  50809. varyingDeclaration: string;
  50810. /**
  50811. * Uniform connection points
  50812. */
  50813. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  50814. /**
  50815. * Bindable blocks (Blocks that need to set data to the effect)
  50816. */
  50817. bindableBlocks: NodeMaterialBlock[];
  50818. /**
  50819. * List of blocks that can provide a compilation fallback
  50820. */
  50821. blocksWithFallbacks: NodeMaterialBlock[];
  50822. /**
  50823. * List of blocks that can provide a define update
  50824. */
  50825. blocksWithDefines: NodeMaterialBlock[];
  50826. /**
  50827. * List of blocks that can provide a repeatable content
  50828. */
  50829. repeatableContentBlocks: NodeMaterialBlock[];
  50830. /**
  50831. * List of blocks that can provide a dynamic list of uniforms
  50832. */
  50833. dynamicUniformBlocks: NodeMaterialBlock[];
  50834. /**
  50835. * List of blocks that can block the isReady function for the material
  50836. */
  50837. blockingBlocks: NodeMaterialBlock[];
  50838. /**
  50839. * Build Id used to avoid multiple recompilations
  50840. */
  50841. buildId: number;
  50842. /** List of emitted variables */
  50843. variableNames: {
  50844. [key: string]: number;
  50845. };
  50846. /** List of emitted defines */
  50847. defineNames: {
  50848. [key: string]: number;
  50849. };
  50850. /** Should emit comments? */
  50851. emitComments: boolean;
  50852. /** Emit build activity */
  50853. verbose: boolean;
  50854. /**
  50855. * Gets the compilation hints emitted at compilation time
  50856. */
  50857. hints: {
  50858. needWorldViewMatrix: boolean;
  50859. needWorldViewProjectionMatrix: boolean;
  50860. needAlphaBlending: boolean;
  50861. needAlphaTesting: boolean;
  50862. };
  50863. /**
  50864. * List of compilation checks
  50865. */
  50866. checks: {
  50867. emitVertex: boolean;
  50868. emitFragment: boolean;
  50869. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  50870. };
  50871. /** Creates a new shared data */
  50872. constructor();
  50873. /**
  50874. * Emits console errors and exceptions if there is a failing check
  50875. */
  50876. emitErrors(): void;
  50877. }
  50878. }
  50879. declare module BABYLON {
  50880. /**
  50881. * Class used to store node based material build state
  50882. */
  50883. export class NodeMaterialBuildState {
  50884. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  50885. supportUniformBuffers: boolean;
  50886. /**
  50887. * Gets the list of emitted attributes
  50888. */
  50889. attributes: string[];
  50890. /**
  50891. * Gets the list of emitted uniforms
  50892. */
  50893. uniforms: string[];
  50894. /**
  50895. * Gets the list of emitted uniform buffers
  50896. */
  50897. uniformBuffers: string[];
  50898. /**
  50899. * Gets the list of emitted samplers
  50900. */
  50901. samplers: string[];
  50902. /**
  50903. * Gets the list of emitted functions
  50904. */
  50905. functions: {
  50906. [key: string]: string;
  50907. };
  50908. /**
  50909. * Gets the target of the compilation state
  50910. */
  50911. target: NodeMaterialBlockTargets;
  50912. /**
  50913. * Gets the list of emitted counters
  50914. */
  50915. counters: {
  50916. [key: string]: number;
  50917. };
  50918. /**
  50919. * Shared data between multiple NodeMaterialBuildState instances
  50920. */
  50921. sharedData: NodeMaterialBuildStateSharedData;
  50922. /** @hidden */
  50923. _vertexState: NodeMaterialBuildState;
  50924. private _attributeDeclaration;
  50925. private _uniformDeclaration;
  50926. private _samplerDeclaration;
  50927. private _varyingTransfer;
  50928. private _repeatableContentAnchorIndex;
  50929. /** @hidden */
  50930. _builtCompilationString: string;
  50931. /**
  50932. * Gets the emitted compilation strings
  50933. */
  50934. compilationString: string;
  50935. /**
  50936. * Finalize the compilation strings
  50937. * @param state defines the current compilation state
  50938. */
  50939. finalize(state: NodeMaterialBuildState): void;
  50940. /** @hidden */
  50941. readonly _repeatableContentAnchor: string;
  50942. /** @hidden */
  50943. _getFreeVariableName(prefix: string): string;
  50944. /** @hidden */
  50945. _getFreeDefineName(prefix: string): string;
  50946. /** @hidden */
  50947. _excludeVariableName(name: string): void;
  50948. /** @hidden */
  50949. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  50950. /** @hidden */
  50951. _emitFunction(name: string, code: string, comments: string): void;
  50952. /** @hidden */
  50953. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  50954. replaceStrings?: {
  50955. search: RegExp;
  50956. replace: string;
  50957. }[];
  50958. repeatKey?: string;
  50959. }): string;
  50960. /** @hidden */
  50961. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  50962. repeatKey?: string;
  50963. removeAttributes?: boolean;
  50964. removeUniforms?: boolean;
  50965. removeVaryings?: boolean;
  50966. removeIfDef?: boolean;
  50967. replaceStrings?: {
  50968. search: RegExp;
  50969. replace: string;
  50970. }[];
  50971. }, storeKey?: string): void;
  50972. /** @hidden */
  50973. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string, type?: Nullable<NodeMaterialBlockConnectionPointTypes>): void;
  50974. private _emitDefine;
  50975. /** @hidden */
  50976. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  50977. }
  50978. }
  50979. declare module BABYLON {
  50980. /**
  50981. * Root class for all node material optimizers
  50982. */
  50983. export class NodeMaterialOptimizer {
  50984. /**
  50985. * Function used to optimize a NodeMaterial graph
  50986. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  50987. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  50988. */
  50989. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  50990. }
  50991. }
  50992. declare module BABYLON {
  50993. /**
  50994. * Block used to transform a vector4 with a matrix
  50995. */
  50996. export class Vector4TransformBlock extends NodeMaterialBlock {
  50997. /**
  50998. * Defines the value to use to complement Vector3 to transform it to a Vector4
  50999. */
  51000. complementW: number;
  51001. /**
  51002. * Creates a new Vector4TransformBlock
  51003. * @param name defines the block name
  51004. */
  51005. constructor(name: string);
  51006. /**
  51007. * Gets the current class name
  51008. * @returns the class name
  51009. */
  51010. getClassName(): string;
  51011. /**
  51012. * Gets the vector input
  51013. */
  51014. readonly vector: NodeMaterialConnectionPoint;
  51015. /**
  51016. * Gets the output component
  51017. */
  51018. readonly output: NodeMaterialConnectionPoint;
  51019. /**
  51020. * Gets the matrix transform input
  51021. */
  51022. readonly transform: NodeMaterialConnectionPoint;
  51023. protected _buildBlock(state: NodeMaterialBuildState): this;
  51024. }
  51025. }
  51026. declare module BABYLON {
  51027. /**
  51028. * Block used to output the vertex position
  51029. */
  51030. export class VertexOutputBlock extends NodeMaterialBlock {
  51031. /**
  51032. * Creates a new VertexOutputBlock
  51033. * @param name defines the block name
  51034. */
  51035. constructor(name: string);
  51036. /**
  51037. * Gets the current class name
  51038. * @returns the class name
  51039. */
  51040. getClassName(): string;
  51041. /**
  51042. * Gets the vector input component
  51043. */
  51044. readonly vector: NodeMaterialConnectionPoint;
  51045. protected _buildBlock(state: NodeMaterialBuildState): this;
  51046. }
  51047. }
  51048. declare module BABYLON {
  51049. /**
  51050. * Block used to output the final color
  51051. */
  51052. export class FragmentOutputBlock extends NodeMaterialBlock {
  51053. /**
  51054. * Gets or sets a boolean indicating if this block will output an alpha value
  51055. */
  51056. alphaBlendingEnabled: boolean;
  51057. /**
  51058. * Create a new FragmentOutputBlock
  51059. * @param name defines the block name
  51060. */
  51061. constructor(name: string);
  51062. /**
  51063. * Gets the current class name
  51064. * @returns the class name
  51065. */
  51066. getClassName(): string;
  51067. /**
  51068. * Gets the color input component
  51069. */
  51070. readonly color: NodeMaterialConnectionPoint;
  51071. protected _buildBlock(state: NodeMaterialBuildState): this;
  51072. }
  51073. }
  51074. declare module BABYLON {
  51075. /**
  51076. * Interface used to configure the node material editor
  51077. */
  51078. export interface INodeMaterialEditorOptions {
  51079. /** Define the URl to load node editor script */
  51080. editorURL?: string;
  51081. }
  51082. /** @hidden */
  51083. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  51084. /** BONES */
  51085. NUM_BONE_INFLUENCERS: number;
  51086. BonesPerMesh: number;
  51087. BONETEXTURE: boolean;
  51088. /** MORPH TARGETS */
  51089. MORPHTARGETS: boolean;
  51090. MORPHTARGETS_NORMAL: boolean;
  51091. MORPHTARGETS_TANGENT: boolean;
  51092. MORPHTARGETS_UV: boolean;
  51093. NUM_MORPH_INFLUENCERS: number;
  51094. /** IMAGE PROCESSING */
  51095. IMAGEPROCESSING: boolean;
  51096. VIGNETTE: boolean;
  51097. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51098. VIGNETTEBLENDMODEOPAQUE: boolean;
  51099. TONEMAPPING: boolean;
  51100. TONEMAPPING_ACES: boolean;
  51101. CONTRAST: boolean;
  51102. EXPOSURE: boolean;
  51103. COLORCURVES: boolean;
  51104. COLORGRADING: boolean;
  51105. COLORGRADING3D: boolean;
  51106. SAMPLER3DGREENDEPTH: boolean;
  51107. SAMPLER3DBGRMAP: boolean;
  51108. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51109. constructor();
  51110. setValue(name: string, value: boolean): void;
  51111. }
  51112. /**
  51113. * Class used to configure NodeMaterial
  51114. */
  51115. export interface INodeMaterialOptions {
  51116. /**
  51117. * Defines if blocks should emit comments
  51118. */
  51119. emitComments: boolean;
  51120. }
  51121. /**
  51122. * Class used to create a node based material built by assembling shader blocks
  51123. */
  51124. export class NodeMaterial extends PushMaterial {
  51125. private _options;
  51126. private _vertexCompilationState;
  51127. private _fragmentCompilationState;
  51128. private _sharedData;
  51129. private _buildId;
  51130. private _buildWasSuccessful;
  51131. private _cachedWorldViewMatrix;
  51132. private _cachedWorldViewProjectionMatrix;
  51133. private _textureConnectionPoints;
  51134. private _optimizers;
  51135. /** Define the URl to load node editor script */
  51136. static EditorURL: string;
  51137. private BJSNODEMATERIALEDITOR;
  51138. /** Get the inspector from bundle or global */
  51139. private _getGlobalNodeMaterialEditor;
  51140. /**
  51141. * Defines the maximum number of lights that can be used in the material
  51142. */
  51143. maxSimultaneousLights: number;
  51144. /**
  51145. * Observable raised when the material is built
  51146. */
  51147. onBuildObservable: Observable<NodeMaterial>;
  51148. /**
  51149. * Gets or sets the root nodes of the material vertex shader
  51150. */
  51151. _vertexOutputNodes: NodeMaterialBlock[];
  51152. /**
  51153. * Gets or sets the root nodes of the material fragment (pixel) shader
  51154. */
  51155. _fragmentOutputNodes: NodeMaterialBlock[];
  51156. /** Gets or sets options to control the node material overall behavior */
  51157. options: INodeMaterialOptions;
  51158. /**
  51159. * Default configuration related to image processing available in the standard Material.
  51160. */
  51161. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51162. /**
  51163. * Gets the image processing configuration used either in this material.
  51164. */
  51165. /**
  51166. * Sets the Default image processing configuration used either in the this material.
  51167. *
  51168. * If sets to null, the scene one is in use.
  51169. */
  51170. imageProcessingConfiguration: ImageProcessingConfiguration;
  51171. /**
  51172. * Create a new node based material
  51173. * @param name defines the material name
  51174. * @param scene defines the hosting scene
  51175. * @param options defines creation option
  51176. */
  51177. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  51178. /**
  51179. * Gets the current class name of the material e.g. "NodeMaterial"
  51180. * @returns the class name
  51181. */
  51182. getClassName(): string;
  51183. /**
  51184. * Keep track of the image processing observer to allow dispose and replace.
  51185. */
  51186. private _imageProcessingObserver;
  51187. /**
  51188. * Attaches a new image processing configuration to the Standard Material.
  51189. * @param configuration
  51190. */
  51191. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51192. /**
  51193. * Adds a new optimizer to the list of optimizers
  51194. * @param optimizer defines the optimizers to add
  51195. * @returns the current material
  51196. */
  51197. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51198. /**
  51199. * Remove an optimizer from the list of optimizers
  51200. * @param optimizer defines the optimizers to remove
  51201. * @returns the current material
  51202. */
  51203. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51204. /**
  51205. * Add a new block to the list of output nodes
  51206. * @param node defines the node to add
  51207. * @returns the current material
  51208. */
  51209. addOutputNode(node: NodeMaterialBlock): this;
  51210. /**
  51211. * Remove a block from the list of root nodes
  51212. * @param node defines the node to remove
  51213. * @returns the current material
  51214. */
  51215. removeOutputNode(node: NodeMaterialBlock): this;
  51216. private _addVertexOutputNode;
  51217. private _removeVertexOutputNode;
  51218. private _addFragmentOutputNode;
  51219. private _removeFragmentOutputNode;
  51220. /**
  51221. * Specifies if the material will require alpha blending
  51222. * @returns a boolean specifying if alpha blending is needed
  51223. */
  51224. needAlphaBlending(): boolean;
  51225. /**
  51226. * Specifies if this material should be rendered in alpha test mode
  51227. * @returns a boolean specifying if an alpha test is needed.
  51228. */
  51229. needAlphaTesting(): boolean;
  51230. private _initializeBlock;
  51231. private _resetDualBlocks;
  51232. /**
  51233. * Build the material and generates the inner effect
  51234. * @param verbose defines if the build should log activity
  51235. */
  51236. build(verbose?: boolean): void;
  51237. /**
  51238. * Runs an otpimization phase to try to improve the shader code
  51239. */
  51240. optimize(): void;
  51241. private _prepareDefinesForAttributes;
  51242. /**
  51243. * Get if the submesh is ready to be used and all its information available.
  51244. * Child classes can use it to update shaders
  51245. * @param mesh defines the mesh to check
  51246. * @param subMesh defines which submesh to check
  51247. * @param useInstances specifies that instances should be used
  51248. * @returns a boolean indicating that the submesh is ready or not
  51249. */
  51250. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51251. /**
  51252. * Binds the world matrix to the material
  51253. * @param world defines the world transformation matrix
  51254. */
  51255. bindOnlyWorldMatrix(world: Matrix): void;
  51256. /**
  51257. * Binds the submesh to this material by preparing the effect and shader to draw
  51258. * @param world defines the world transformation matrix
  51259. * @param mesh defines the mesh containing the submesh
  51260. * @param subMesh defines the submesh to bind the material to
  51261. */
  51262. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51263. /**
  51264. * Gets the active textures from the material
  51265. * @returns an array of textures
  51266. */
  51267. getActiveTextures(): BaseTexture[];
  51268. /**
  51269. * Specifies if the material uses a texture
  51270. * @param texture defines the texture to check against the material
  51271. * @returns a boolean specifying if the material uses the texture
  51272. */
  51273. hasTexture(texture: BaseTexture): boolean;
  51274. /**
  51275. * Disposes the material
  51276. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  51277. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  51278. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  51279. */
  51280. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  51281. /** Creates the node editor window. */
  51282. private _createNodeEditor;
  51283. /**
  51284. * Launch the node material editor
  51285. * @param config Define the configuration of the editor
  51286. * @return a promise fulfilled when the node editor is visible
  51287. */
  51288. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  51289. /**
  51290. * Clear the current material
  51291. */
  51292. clear(): void;
  51293. /**
  51294. * Clear the current material and set it to a default state
  51295. */
  51296. setToDefault(): void;
  51297. }
  51298. }
  51299. declare module BABYLON {
  51300. /**
  51301. * Defines a block that can be used inside a node based material
  51302. */
  51303. export class NodeMaterialBlock {
  51304. private _buildId;
  51305. private _target;
  51306. private _isFinalMerger;
  51307. /** @hidden */
  51308. _inputs: NodeMaterialConnectionPoint[];
  51309. /** @hidden */
  51310. _outputs: NodeMaterialConnectionPoint[];
  51311. /**
  51312. * Gets or sets the name of the block
  51313. */
  51314. name: string;
  51315. /**
  51316. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  51317. */
  51318. readonly isFinalMerger: boolean;
  51319. /**
  51320. * Gets or sets the build Id
  51321. */
  51322. buildId: number;
  51323. /**
  51324. * Gets or sets the target of the block
  51325. */
  51326. target: NodeMaterialBlockTargets;
  51327. /**
  51328. * Gets the list of input points
  51329. */
  51330. readonly inputs: NodeMaterialConnectionPoint[];
  51331. /** Gets the list of output points */
  51332. readonly outputs: NodeMaterialConnectionPoint[];
  51333. /**
  51334. * Find an input by its name
  51335. * @param name defines the name of the input to look for
  51336. * @returns the input or null if not found
  51337. */
  51338. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51339. /**
  51340. * Find an output by its name
  51341. * @param name defines the name of the outputto look for
  51342. * @returns the output or null if not found
  51343. */
  51344. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51345. /**
  51346. * Creates a new NodeMaterialBlock
  51347. * @param name defines the block name
  51348. * @param target defines the target of that block (Vertex by default)
  51349. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  51350. */
  51351. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  51352. /**
  51353. * Initialize the block and prepare the context for build
  51354. * @param state defines the state that will be used for the build
  51355. */
  51356. initialize(state: NodeMaterialBuildState): void;
  51357. /**
  51358. * Bind data to effect. Will only be called for blocks with isBindable === true
  51359. * @param effect defines the effect to bind data to
  51360. * @param nodeMaterial defines the hosting NodeMaterial
  51361. * @param mesh defines the mesh that will be rendered
  51362. */
  51363. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51364. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  51365. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  51366. protected _writeFloat(value: number): string;
  51367. /**
  51368. * Gets the current class name e.g. "NodeMaterialBlock"
  51369. * @returns the class name
  51370. */
  51371. getClassName(): string;
  51372. /**
  51373. * Register a new input. Must be called inside a block constructor
  51374. * @param name defines the connection point name
  51375. * @param type defines the connection point type
  51376. * @param isOptional defines a boolean indicating that this input can be omitted
  51377. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51378. * @returns the current block
  51379. */
  51380. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  51381. /**
  51382. * Register a new output. Must be called inside a block constructor
  51383. * @param name defines the connection point name
  51384. * @param type defines the connection point type
  51385. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51386. * @returns the current block
  51387. */
  51388. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  51389. /**
  51390. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  51391. * @param forOutput defines an optional connection point to check compatibility with
  51392. * @returns the first available input or null
  51393. */
  51394. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  51395. /**
  51396. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  51397. * @param forBlock defines an optional block to check compatibility with
  51398. * @returns the first available input or null
  51399. */
  51400. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  51401. /**
  51402. * Connect current block with another block
  51403. * @param other defines the block to connect with
  51404. * @param options define the various options to help pick the right connections
  51405. * @returns the current block
  51406. */
  51407. connectTo(other: NodeMaterialBlock, options?: {
  51408. input?: string;
  51409. output?: string;
  51410. outputSwizzle?: string;
  51411. }): this | undefined;
  51412. protected _buildBlock(state: NodeMaterialBuildState): void;
  51413. /**
  51414. * Add uniforms, samplers and uniform buffers at compilation time
  51415. * @param state defines the state to update
  51416. * @param nodeMaterial defines the node material requesting the update
  51417. * @param defines defines the material defines to update
  51418. */
  51419. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51420. /**
  51421. * Add potential fallbacks if shader compilation fails
  51422. * @param mesh defines the mesh to be rendered
  51423. * @param fallbacks defines the current prioritized list of fallbacks
  51424. */
  51425. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  51426. /**
  51427. * Update defines for shader compilation
  51428. * @param mesh defines the mesh to be rendered
  51429. * @param nodeMaterial defines the node material requesting the update
  51430. * @param defines defines the material defines to update
  51431. * @param useInstances specifies that instances should be used
  51432. */
  51433. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51434. /**
  51435. * Lets the block try to connect some inputs automatically
  51436. */
  51437. autoConfigure(): void;
  51438. /**
  51439. * Function called when a block is declared as repeatable content generator
  51440. * @param vertexShaderState defines the current compilation state for the vertex shader
  51441. * @param fragmentShaderState defines the current compilation state for the fragment shader
  51442. * @param mesh defines the mesh to be rendered
  51443. * @param defines defines the material defines to update
  51444. */
  51445. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  51446. /**
  51447. * Checks if the block is ready
  51448. * @param mesh defines the mesh to be rendered
  51449. * @param nodeMaterial defines the node material requesting the update
  51450. * @param defines defines the material defines to update
  51451. * @param useInstances specifies that instances should be used
  51452. * @returns true if the block is ready
  51453. */
  51454. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  51455. /**
  51456. * Compile the current node and generate the shader code
  51457. * @param state defines the current compilation state (uniforms, samplers, current string)
  51458. * @returns the current block
  51459. */
  51460. build(state: NodeMaterialBuildState): this | undefined;
  51461. }
  51462. }
  51463. declare module BABYLON {
  51464. /**
  51465. * Defines a connection point for a block
  51466. */
  51467. export class NodeMaterialConnectionPoint {
  51468. /** @hidden */
  51469. _ownerBlock: NodeMaterialBlock;
  51470. /** @hidden */
  51471. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  51472. private _associatedVariableName;
  51473. private _endpoints;
  51474. private _storedValue;
  51475. private _valueCallback;
  51476. private _mode;
  51477. /** @hidden */
  51478. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51479. /** @hidden */
  51480. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  51481. /** @hidden */
  51482. _needToEmitVarying: boolean;
  51483. /** @hidden */
  51484. _forceUniformInVertexShaderOnly: boolean;
  51485. private _type;
  51486. /**
  51487. * Gets or sets the connection point type (default is float)
  51488. */
  51489. type: NodeMaterialBlockConnectionPointTypes;
  51490. /**
  51491. * Gets or sets the connection point name
  51492. */
  51493. name: string;
  51494. /**
  51495. * Gets or sets the swizzle to apply to this connection point when reading or writing
  51496. */
  51497. swizzle: string;
  51498. /**
  51499. * Gets or sets a boolean indicating that this connection point can be omitted
  51500. */
  51501. isOptional: boolean;
  51502. /**
  51503. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  51504. */
  51505. define: string;
  51506. /** Gets or sets the target of that connection point */
  51507. target: NodeMaterialBlockTargets;
  51508. /**
  51509. * Gets or sets the value of that point.
  51510. * Please note that this value will be ignored if valueCallback is defined
  51511. */
  51512. value: any;
  51513. /**
  51514. * Gets or sets a callback used to get the value of that point.
  51515. * Please note that setting this value will force the connection point to ignore the value property
  51516. */
  51517. valueCallback: () => any;
  51518. /**
  51519. * Gets or sets the associated variable name in the shader
  51520. */
  51521. associatedVariableName: string;
  51522. /**
  51523. * Gets a boolean indicating that this connection point not defined yet
  51524. */
  51525. readonly isUndefined: boolean;
  51526. /**
  51527. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  51528. * In this case the connection point name must be the name of the uniform to use.
  51529. * Can only be set on inputs
  51530. */
  51531. isUniform: boolean;
  51532. /**
  51533. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  51534. * In this case the connection point name must be the name of the attribute to use
  51535. * Can only be set on inputs
  51536. */
  51537. isAttribute: boolean;
  51538. /**
  51539. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  51540. * Can only be set on exit points
  51541. */
  51542. isVarying: boolean;
  51543. /** Get the other side of the connection (if any) */
  51544. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  51545. /** Get the block that owns this connection point */
  51546. readonly ownerBlock: NodeMaterialBlock;
  51547. /** Get the block connected on the other side of this connection (if any) */
  51548. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  51549. /** Get the block connected on the endpoints of this connection (if any) */
  51550. readonly connectedBlocks: Array<NodeMaterialBlock>;
  51551. /**
  51552. * Creates a new connection point
  51553. * @param name defines the connection point name
  51554. * @param ownerBlock defines the block hosting this connection point
  51555. */
  51556. constructor(name: string, ownerBlock: NodeMaterialBlock);
  51557. /**
  51558. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  51559. * @returns the class name
  51560. */
  51561. getClassName(): string;
  51562. /**
  51563. * Set the source of this connection point to a vertex attribute
  51564. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  51565. * @returns the current connection point
  51566. */
  51567. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  51568. /**
  51569. * Set the source of this connection point to a well known value
  51570. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  51571. * @returns the current connection point
  51572. */
  51573. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  51574. /**
  51575. * Gets a boolean indicating that the current connection point is a well known value
  51576. */
  51577. readonly isWellKnownValue: boolean;
  51578. /**
  51579. * Gets or sets the current well known value or null if not defined as well know value
  51580. */
  51581. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51582. private _getTypeLength;
  51583. /**
  51584. * Gets an boolean indicating if the current point can be connected to another point
  51585. * @param connectionPoint defines the other connection point
  51586. * @returns true if the connection is possible
  51587. */
  51588. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  51589. /**
  51590. * Connect this point to another connection point
  51591. * @param connectionPoint defines the other connection point
  51592. * @returns the current connection point
  51593. */
  51594. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  51595. /**
  51596. * Disconnect this point from one of his endpoint
  51597. * @param endpoint defines the other connection point
  51598. * @returns the current connection point
  51599. */
  51600. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  51601. /**
  51602. * When connection point is an uniform, this function will send its value to the effect
  51603. * @param effect defines the effect to transmit value to
  51604. * @param world defines the world matrix
  51605. * @param worldView defines the worldxview matrix
  51606. * @param worldViewProjection defines the worldxviewxprojection matrix
  51607. */
  51608. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  51609. /**
  51610. * When connection point is an uniform, this function will send its value to the effect
  51611. * @param effect defines the effect to transmit value to
  51612. * @param scene defines the hosting scene
  51613. */
  51614. transmit(effect: Effect, scene: Scene): void;
  51615. }
  51616. }
  51617. declare module BABYLON {
  51618. /**
  51619. * Block used to add support for vertex skinning (bones)
  51620. */
  51621. export class BonesBlock extends NodeMaterialBlock {
  51622. /**
  51623. * Creates a new BonesBlock
  51624. * @param name defines the block name
  51625. */
  51626. constructor(name: string);
  51627. /**
  51628. * Initialize the block and prepare the context for build
  51629. * @param state defines the state that will be used for the build
  51630. */
  51631. initialize(state: NodeMaterialBuildState): void;
  51632. /**
  51633. * Gets the current class name
  51634. * @returns the class name
  51635. */
  51636. getClassName(): string;
  51637. /**
  51638. * Gets the matrix indices input component
  51639. */
  51640. readonly matricesIndices: NodeMaterialConnectionPoint;
  51641. /**
  51642. * Gets the matrix weights input component
  51643. */
  51644. readonly matricesWeights: NodeMaterialConnectionPoint;
  51645. /**
  51646. * Gets the extra matrix indices input component
  51647. */
  51648. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  51649. /**
  51650. * Gets the extra matrix weights input component
  51651. */
  51652. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  51653. /**
  51654. * Gets the world input component
  51655. */
  51656. readonly world: NodeMaterialConnectionPoint;
  51657. /**
  51658. * Gets the output component
  51659. */
  51660. readonly output: NodeMaterialConnectionPoint;
  51661. autoConfigure(): void;
  51662. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  51663. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51664. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51665. protected _buildBlock(state: NodeMaterialBuildState): this;
  51666. }
  51667. }
  51668. declare module BABYLON {
  51669. /**
  51670. * Block used to add support for instances
  51671. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  51672. */
  51673. export class InstancesBlock extends NodeMaterialBlock {
  51674. /**
  51675. * Creates a new InstancesBlock
  51676. * @param name defines the block name
  51677. */
  51678. constructor(name: string);
  51679. /**
  51680. * Gets the current class name
  51681. * @returns the class name
  51682. */
  51683. getClassName(): string;
  51684. /**
  51685. * Gets the first world row input component
  51686. */
  51687. readonly world0: NodeMaterialConnectionPoint;
  51688. /**
  51689. * Gets the second world row input component
  51690. */
  51691. readonly world1: NodeMaterialConnectionPoint;
  51692. /**
  51693. * Gets the third world row input component
  51694. */
  51695. readonly world2: NodeMaterialConnectionPoint;
  51696. /**
  51697. * Gets the forth world row input component
  51698. */
  51699. readonly world3: NodeMaterialConnectionPoint;
  51700. /**
  51701. * Gets the world input component
  51702. */
  51703. readonly world: NodeMaterialConnectionPoint;
  51704. /**
  51705. * Gets the output component
  51706. */
  51707. readonly output: NodeMaterialConnectionPoint;
  51708. autoConfigure(): void;
  51709. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51710. protected _buildBlock(state: NodeMaterialBuildState): this;
  51711. }
  51712. }
  51713. declare module BABYLON {
  51714. /**
  51715. * Block used to add morph targets support to vertex shader
  51716. */
  51717. export class MorphTargetsBlock extends NodeMaterialBlock {
  51718. private _repeatableContentAnchor;
  51719. private _repeatebleContentGenerated;
  51720. /**
  51721. * Create a new MorphTargetsBlock
  51722. * @param name defines the block name
  51723. */
  51724. constructor(name: string);
  51725. /**
  51726. * Gets the current class name
  51727. * @returns the class name
  51728. */
  51729. getClassName(): string;
  51730. /**
  51731. * Gets the position input component
  51732. */
  51733. readonly position: NodeMaterialConnectionPoint;
  51734. /**
  51735. * Gets the normal input component
  51736. */
  51737. readonly normal: NodeMaterialConnectionPoint;
  51738. /**
  51739. * Gets the tangent input component
  51740. */
  51741. readonly tangent: NodeMaterialConnectionPoint;
  51742. /**
  51743. * Gets the tangent input component
  51744. */
  51745. readonly uv: NodeMaterialConnectionPoint;
  51746. /**
  51747. * Gets the position output component
  51748. */
  51749. readonly positionOutput: NodeMaterialConnectionPoint;
  51750. /**
  51751. * Gets the normal output component
  51752. */
  51753. readonly normalOutput: NodeMaterialConnectionPoint;
  51754. /**
  51755. * Gets the tangent output component
  51756. */
  51757. readonly tangentOutput: NodeMaterialConnectionPoint;
  51758. /**
  51759. * Gets the tangent output component
  51760. */
  51761. readonly uvOutput: NodeMaterialConnectionPoint;
  51762. initialize(state: NodeMaterialBuildState): void;
  51763. autoConfigure(): void;
  51764. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51765. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51766. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  51767. protected _buildBlock(state: NodeMaterialBuildState): this;
  51768. }
  51769. }
  51770. declare module BABYLON {
  51771. /**
  51772. * Block used to add an alpha test in the fragment shader
  51773. */
  51774. export class AlphaTestBlock extends NodeMaterialBlock {
  51775. /**
  51776. * Gets or sets the alpha value where alpha testing happens
  51777. */
  51778. alphaCutOff: number;
  51779. /**
  51780. * Create a new AlphaTestBlock
  51781. * @param name defines the block name
  51782. */
  51783. constructor(name: string);
  51784. /**
  51785. * Gets the current class name
  51786. * @returns the class name
  51787. */
  51788. getClassName(): string;
  51789. /**
  51790. * Gets the color input component
  51791. */
  51792. readonly color: NodeMaterialConnectionPoint;
  51793. protected _buildBlock(state: NodeMaterialBuildState): this;
  51794. }
  51795. }
  51796. declare module BABYLON {
  51797. /**
  51798. * Block used to create a Color4 out of 4 inputs (one for each component)
  51799. */
  51800. export class RGBAMergerBlock extends NodeMaterialBlock {
  51801. /**
  51802. * Create a new RGBAMergerBlock
  51803. * @param name defines the block name
  51804. */
  51805. constructor(name: string);
  51806. /**
  51807. * Gets the current class name
  51808. * @returns the class name
  51809. */
  51810. getClassName(): string;
  51811. /**
  51812. * Gets the R input component
  51813. */
  51814. readonly r: NodeMaterialConnectionPoint;
  51815. /**
  51816. * Gets the G input component
  51817. */
  51818. readonly g: NodeMaterialConnectionPoint;
  51819. /**
  51820. * Gets the B input component
  51821. */
  51822. readonly b: NodeMaterialConnectionPoint;
  51823. /**
  51824. * Gets the RGB input component
  51825. */
  51826. readonly rgb: NodeMaterialConnectionPoint;
  51827. /**
  51828. * Gets the R input component
  51829. */
  51830. readonly a: NodeMaterialConnectionPoint;
  51831. /**
  51832. * Gets the output component
  51833. */
  51834. readonly output: NodeMaterialConnectionPoint;
  51835. protected _buildBlock(state: NodeMaterialBuildState): this;
  51836. }
  51837. }
  51838. declare module BABYLON {
  51839. /**
  51840. * Block used to create a Color3 out of 3 inputs (one for each component)
  51841. */
  51842. export class RGBMergerBlock extends NodeMaterialBlock {
  51843. /**
  51844. * Create a new RGBMergerBlock
  51845. * @param name defines the block name
  51846. */
  51847. constructor(name: string);
  51848. /**
  51849. * Gets the current class name
  51850. * @returns the class name
  51851. */
  51852. getClassName(): string;
  51853. /**
  51854. * Gets the R component input
  51855. */
  51856. readonly r: NodeMaterialConnectionPoint;
  51857. /**
  51858. * Gets the G component input
  51859. */
  51860. readonly g: NodeMaterialConnectionPoint;
  51861. /**
  51862. * Gets the B component input
  51863. */
  51864. readonly b: NodeMaterialConnectionPoint;
  51865. /**
  51866. * Gets the output component
  51867. */
  51868. readonly output: NodeMaterialConnectionPoint;
  51869. protected _buildBlock(state: NodeMaterialBuildState): this;
  51870. }
  51871. }
  51872. declare module BABYLON {
  51873. /**
  51874. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  51875. */
  51876. export class RGBASplitterBlock extends NodeMaterialBlock {
  51877. /**
  51878. * Create a new RGBASplitterBlock
  51879. * @param name defines the block name
  51880. */
  51881. constructor(name: string);
  51882. /**
  51883. * Gets the current class name
  51884. * @returns the class name
  51885. */
  51886. getClassName(): string;
  51887. /**
  51888. * Gets the input component
  51889. */
  51890. readonly input: NodeMaterialConnectionPoint;
  51891. protected _buildBlock(state: NodeMaterialBuildState): this;
  51892. }
  51893. }
  51894. declare module BABYLON {
  51895. /**
  51896. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  51897. */
  51898. export class RGBSplitterBlock extends NodeMaterialBlock {
  51899. /**
  51900. * Create a new RGBSplitterBlock
  51901. * @param name defines the block name
  51902. */
  51903. constructor(name: string);
  51904. /**
  51905. * Gets the current class name
  51906. * @returns the class name
  51907. */
  51908. getClassName(): string;
  51909. /**
  51910. * Gets the input component
  51911. */
  51912. readonly input: NodeMaterialConnectionPoint;
  51913. protected _buildBlock(state: NodeMaterialBuildState): this;
  51914. }
  51915. }
  51916. declare module BABYLON {
  51917. /**
  51918. * Block used to read a texture from a sampler
  51919. */
  51920. export class TextureBlock extends NodeMaterialBlock {
  51921. private _defineName;
  51922. /**
  51923. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  51924. */
  51925. autoConnectTextureMatrix: boolean;
  51926. /**
  51927. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  51928. */
  51929. autoSelectUV: boolean;
  51930. /**
  51931. * Create a new TextureBlock
  51932. * @param name defines the block name
  51933. */
  51934. constructor(name: string);
  51935. /**
  51936. * Gets the current class name
  51937. * @returns the class name
  51938. */
  51939. getClassName(): string;
  51940. /**
  51941. * Gets the uv input component
  51942. */
  51943. readonly uv: NodeMaterialConnectionPoint;
  51944. /**
  51945. * Gets the texture information input component
  51946. */
  51947. readonly textureInfo: NodeMaterialConnectionPoint;
  51948. /**
  51949. * Gets the transformed uv input component
  51950. */
  51951. readonly transformedUV: NodeMaterialConnectionPoint;
  51952. /**
  51953. * Gets the texture input component
  51954. */
  51955. readonly texture: NodeMaterialConnectionPoint;
  51956. /**
  51957. * Gets the texture transform input component
  51958. */
  51959. readonly textureTransform: NodeMaterialConnectionPoint;
  51960. /**
  51961. * Gets the output component
  51962. */
  51963. readonly output: NodeMaterialConnectionPoint;
  51964. autoConfigure(): void;
  51965. initialize(state: NodeMaterialBuildState): void;
  51966. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51967. isReady(): boolean;
  51968. private _injectVertexCode;
  51969. protected _buildBlock(state: NodeMaterialBuildState): this;
  51970. }
  51971. }
  51972. declare module BABYLON {
  51973. /**
  51974. * Block used to add image processing support to fragment shader
  51975. */
  51976. export class ImageProcessingBlock extends NodeMaterialBlock {
  51977. /**
  51978. * Create a new ImageProcessingBlock
  51979. * @param name defines the block name
  51980. */
  51981. constructor(name: string);
  51982. /**
  51983. * Gets the current class name
  51984. * @returns the class name
  51985. */
  51986. getClassName(): string;
  51987. /**
  51988. * Gets the color input component
  51989. */
  51990. readonly color: NodeMaterialConnectionPoint;
  51991. /**
  51992. * Gets the output component
  51993. */
  51994. readonly output: NodeMaterialConnectionPoint;
  51995. /**
  51996. * Initialize the block and prepare the context for build
  51997. * @param state defines the state that will be used for the build
  51998. */
  51999. initialize(state: NodeMaterialBuildState): void;
  52000. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  52001. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52002. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52003. protected _buildBlock(state: NodeMaterialBuildState): this;
  52004. }
  52005. }
  52006. declare module BABYLON {
  52007. /**
  52008. * Block used to add support for scene fog
  52009. */
  52010. export class FogBlock extends NodeMaterialBlock {
  52011. /**
  52012. * Create a new FogBlock
  52013. * @param name defines the block name
  52014. */
  52015. constructor(name: string);
  52016. /**
  52017. * Gets the current class name
  52018. * @returns the class name
  52019. */
  52020. getClassName(): string;
  52021. /**
  52022. * Gets the world position input component
  52023. */
  52024. readonly worldPosition: NodeMaterialConnectionPoint;
  52025. /**
  52026. * Gets the view input component
  52027. */
  52028. readonly view: NodeMaterialConnectionPoint;
  52029. /**
  52030. * Gets the color input component
  52031. */
  52032. readonly color: NodeMaterialConnectionPoint;
  52033. /**
  52034. * Gets the fog color input component
  52035. */
  52036. readonly fogColor: NodeMaterialConnectionPoint;
  52037. /**
  52038. * Gets the for parameter input component
  52039. */
  52040. readonly fogParameters: NodeMaterialConnectionPoint;
  52041. /**
  52042. * Gets the output component
  52043. */
  52044. readonly output: NodeMaterialConnectionPoint;
  52045. autoConfigure(): void;
  52046. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52047. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52048. protected _buildBlock(state: NodeMaterialBuildState): this;
  52049. }
  52050. }
  52051. declare module BABYLON {
  52052. /**
  52053. * Block used to add light in the fragment shader
  52054. */
  52055. export class LightBlock extends NodeMaterialBlock {
  52056. private _lightId;
  52057. /**
  52058. * Create a new LightBlock
  52059. * @param name defines the block name
  52060. */
  52061. constructor(name: string);
  52062. /**
  52063. * Gets the current class name
  52064. * @returns the class name
  52065. */
  52066. getClassName(): string;
  52067. /**
  52068. * Gets the world position input component
  52069. */
  52070. readonly worldPosition: NodeMaterialConnectionPoint;
  52071. /**
  52072. * Gets the world normal input component
  52073. */
  52074. readonly worldNormal: NodeMaterialConnectionPoint;
  52075. /**
  52076. * Gets the light input component.
  52077. * If not defined, all lights will be considered
  52078. */
  52079. readonly light: NodeMaterialConnectionPoint;
  52080. /**
  52081. * Gets the camera (or eye) position component
  52082. */
  52083. readonly cameraPosition: NodeMaterialConnectionPoint;
  52084. /**
  52085. * Gets the diffuse output component
  52086. */
  52087. readonly diffuseOutput: NodeMaterialConnectionPoint;
  52088. /**
  52089. * Gets the specular output component
  52090. */
  52091. readonly specularOutput: NodeMaterialConnectionPoint;
  52092. autoConfigure(): void;
  52093. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52094. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52095. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52096. private _injectVertexCode;
  52097. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52098. }
  52099. }
  52100. declare module BABYLON {
  52101. /**
  52102. * Block used to multiply 2 vector4
  52103. */
  52104. export class MultiplyBlock extends NodeMaterialBlock {
  52105. /**
  52106. * Creates a new MultiplyBlock
  52107. * @param name defines the block name
  52108. */
  52109. constructor(name: string);
  52110. /**
  52111. * Gets the current class name
  52112. * @returns the class name
  52113. */
  52114. getClassName(): string;
  52115. /**
  52116. * Gets the left operand input component
  52117. */
  52118. readonly left: NodeMaterialConnectionPoint;
  52119. /**
  52120. * Gets the right operand input component
  52121. */
  52122. readonly right: NodeMaterialConnectionPoint;
  52123. /**
  52124. * Gets the output component
  52125. */
  52126. readonly output: NodeMaterialConnectionPoint;
  52127. protected _buildBlock(state: NodeMaterialBuildState): this;
  52128. }
  52129. }
  52130. declare module BABYLON {
  52131. /**
  52132. * Block used to add 2 vector4
  52133. */
  52134. export class AddBlock extends NodeMaterialBlock {
  52135. /**
  52136. * Creates a new AddBlock
  52137. * @param name defines the block name
  52138. */
  52139. constructor(name: string);
  52140. /**
  52141. * Gets the current class name
  52142. * @returns the class name
  52143. */
  52144. getClassName(): string;
  52145. /**
  52146. * Gets the left operand input component
  52147. */
  52148. readonly left: NodeMaterialConnectionPoint;
  52149. /**
  52150. * Gets the right operand input component
  52151. */
  52152. readonly right: NodeMaterialConnectionPoint;
  52153. /**
  52154. * Gets the output component
  52155. */
  52156. readonly output: NodeMaterialConnectionPoint;
  52157. protected _buildBlock(state: NodeMaterialBuildState): this;
  52158. }
  52159. }
  52160. declare module BABYLON {
  52161. /**
  52162. * Block used to clamp a float
  52163. */
  52164. export class ClampBlock extends NodeMaterialBlock {
  52165. /** Gets or sets the minimum range */
  52166. minimum: number;
  52167. /** Gets or sets the maximum range */
  52168. maximum: number;
  52169. /**
  52170. * Creates a new ClampBlock
  52171. * @param name defines the block name
  52172. */
  52173. constructor(name: string);
  52174. /**
  52175. * Gets the current class name
  52176. * @returns the class name
  52177. */
  52178. getClassName(): string;
  52179. /**
  52180. * Gets the value input component
  52181. */
  52182. readonly value: NodeMaterialConnectionPoint;
  52183. /**
  52184. * Gets the output component
  52185. */
  52186. readonly output: NodeMaterialConnectionPoint;
  52187. protected _buildBlock(state: NodeMaterialBuildState): this;
  52188. }
  52189. }
  52190. declare module BABYLON {
  52191. /**
  52192. * Block used to scale a value
  52193. */
  52194. export class ScaleBlock extends NodeMaterialBlock {
  52195. /**
  52196. * Creates a new ScaleBlock
  52197. * @param name defines the block name
  52198. */
  52199. constructor(name: string);
  52200. /**
  52201. * Gets the current class name
  52202. * @returns the class name
  52203. */
  52204. getClassName(): string;
  52205. /**
  52206. * Gets the value operand input component
  52207. */
  52208. readonly value: NodeMaterialConnectionPoint;
  52209. /**
  52210. * Gets the scale operand input component
  52211. */
  52212. readonly scale: NodeMaterialConnectionPoint;
  52213. /**
  52214. * Gets the output component
  52215. */
  52216. readonly output: NodeMaterialConnectionPoint;
  52217. protected _buildBlock(state: NodeMaterialBuildState): this;
  52218. }
  52219. }
  52220. declare module BABYLON {
  52221. /**
  52222. * Block used to transform a vector2 with a matrix
  52223. */
  52224. export class Vector2TransformBlock extends NodeMaterialBlock {
  52225. /**
  52226. * Defines the value to use to complement Vector2 to transform it to a Vector4
  52227. */
  52228. complementZ: number;
  52229. /**
  52230. * Defines the value to use to complement Vector2 to transform it to a Vector4
  52231. */
  52232. complementW: number;
  52233. /**
  52234. * Creates a new Vector2TransformBlock
  52235. * @param name defines the block name
  52236. */
  52237. constructor(name: string);
  52238. /**
  52239. * Gets the vector input
  52240. */
  52241. readonly vector: NodeMaterialConnectionPoint;
  52242. /**
  52243. * Gets the matrix transform input
  52244. */
  52245. readonly transform: NodeMaterialConnectionPoint;
  52246. /**
  52247. * Gets the output component
  52248. */
  52249. readonly output: NodeMaterialConnectionPoint;
  52250. /**
  52251. * Gets the current class name
  52252. * @returns the class name
  52253. */
  52254. getClassName(): string;
  52255. protected _buildBlock(state: NodeMaterialBuildState): this;
  52256. }
  52257. }
  52258. declare module BABYLON {
  52259. /**
  52260. * Block used to transform a vector3 with a matrix
  52261. */
  52262. export class Vector3TransformBlock extends NodeMaterialBlock {
  52263. /**
  52264. * Defines the value to use to complement Vector3 to transform it to a Vector4
  52265. */
  52266. complement: number;
  52267. /**
  52268. * Creates a new Vector3TransformBlock
  52269. * @param name defines the block name
  52270. */
  52271. constructor(name: string);
  52272. /**
  52273. * Gets the vector input
  52274. */
  52275. readonly vector: NodeMaterialConnectionPoint;
  52276. /**
  52277. * Gets the matrix transform input
  52278. */
  52279. readonly transform: NodeMaterialConnectionPoint;
  52280. /**
  52281. * Gets the output component
  52282. */
  52283. readonly output: NodeMaterialConnectionPoint;
  52284. /**
  52285. * Gets the current class name
  52286. * @returns the class name
  52287. */
  52288. getClassName(): string;
  52289. protected _buildBlock(state: NodeMaterialBuildState): this;
  52290. }
  52291. }
  52292. declare module BABYLON {
  52293. /**
  52294. * Block used to multiply two matrices
  52295. */
  52296. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  52297. /**
  52298. * Creates a new MatrixMultiplicationBlock
  52299. * @param name defines the block name
  52300. */
  52301. constructor(name: string);
  52302. /**
  52303. * Gets the left operand
  52304. */
  52305. readonly left: NodeMaterialConnectionPoint;
  52306. /**
  52307. * Gets the right operand
  52308. */
  52309. readonly right: NodeMaterialConnectionPoint;
  52310. /**
  52311. * Gets the output component
  52312. */
  52313. readonly output: NodeMaterialConnectionPoint;
  52314. /**
  52315. * Gets the current class name
  52316. * @returns the class name
  52317. */
  52318. getClassName(): string;
  52319. protected _buildBlock(state: NodeMaterialBuildState): this;
  52320. }
  52321. }
  52322. declare module BABYLON {
  52323. /**
  52324. * Helper class to push actions to a pool of workers.
  52325. */
  52326. export class WorkerPool implements IDisposable {
  52327. private _workerInfos;
  52328. private _pendingActions;
  52329. /**
  52330. * Constructor
  52331. * @param workers Array of workers to use for actions
  52332. */
  52333. constructor(workers: Array<Worker>);
  52334. /**
  52335. * Terminates all workers and clears any pending actions.
  52336. */
  52337. dispose(): void;
  52338. /**
  52339. * Pushes an action to the worker pool. If all the workers are active, the action will be
  52340. * pended until a worker has completed its action.
  52341. * @param action The action to perform. Call onComplete when the action is complete.
  52342. */
  52343. push(action: (worker: Worker, onComplete: () => void) => void): void;
  52344. private _execute;
  52345. }
  52346. }
  52347. declare module BABYLON {
  52348. /**
  52349. * Configuration for Draco compression
  52350. */
  52351. export interface IDracoCompressionConfiguration {
  52352. /**
  52353. * Configuration for the decoder.
  52354. */
  52355. decoder: {
  52356. /**
  52357. * The url to the WebAssembly module.
  52358. */
  52359. wasmUrl?: string;
  52360. /**
  52361. * The url to the WebAssembly binary.
  52362. */
  52363. wasmBinaryUrl?: string;
  52364. /**
  52365. * The url to the fallback JavaScript module.
  52366. */
  52367. fallbackUrl?: string;
  52368. };
  52369. }
  52370. /**
  52371. * Draco compression (https://google.github.io/draco/)
  52372. *
  52373. * This class wraps the Draco module.
  52374. *
  52375. * **Encoder**
  52376. *
  52377. * The encoder is not currently implemented.
  52378. *
  52379. * **Decoder**
  52380. *
  52381. * 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.
  52382. *
  52383. * To update the configuration, use the following code:
  52384. * ```javascript
  52385. * DracoCompression.Configuration = {
  52386. * decoder: {
  52387. * wasmUrl: "<url to the WebAssembly library>",
  52388. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  52389. * fallbackUrl: "<url to the fallback JavaScript library>",
  52390. * }
  52391. * };
  52392. * ```
  52393. *
  52394. * 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.
  52395. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  52396. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  52397. *
  52398. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  52399. * ```javascript
  52400. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  52401. * ```
  52402. *
  52403. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  52404. */
  52405. export class DracoCompression implements IDisposable {
  52406. private _workerPoolPromise?;
  52407. private _decoderModulePromise?;
  52408. /**
  52409. * The configuration. Defaults to the following urls:
  52410. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  52411. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  52412. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  52413. */
  52414. static Configuration: IDracoCompressionConfiguration;
  52415. /**
  52416. * Returns true if the decoder configuration is available.
  52417. */
  52418. static readonly DecoderAvailable: boolean;
  52419. /**
  52420. * Default number of workers to create when creating the draco compression object.
  52421. */
  52422. static DefaultNumWorkers: number;
  52423. private static GetDefaultNumWorkers;
  52424. private static _Default;
  52425. /**
  52426. * Default instance for the draco compression object.
  52427. */
  52428. static readonly Default: DracoCompression;
  52429. /**
  52430. * Constructor
  52431. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  52432. */
  52433. constructor(numWorkers?: number);
  52434. /**
  52435. * Stop all async operations and release resources.
  52436. */
  52437. dispose(): void;
  52438. /**
  52439. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  52440. * @returns a promise that resolves when ready
  52441. */
  52442. whenReadyAsync(): Promise<void>;
  52443. /**
  52444. * Decode Draco compressed mesh data to vertex data.
  52445. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  52446. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  52447. * @returns A promise that resolves with the decoded vertex data
  52448. */
  52449. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  52450. [kind: string]: number;
  52451. }): Promise<VertexData>;
  52452. }
  52453. }
  52454. declare module BABYLON {
  52455. /**
  52456. * Class for building Constructive Solid Geometry
  52457. */
  52458. export class CSG {
  52459. private polygons;
  52460. /**
  52461. * The world matrix
  52462. */
  52463. matrix: Matrix;
  52464. /**
  52465. * Stores the position
  52466. */
  52467. position: Vector3;
  52468. /**
  52469. * Stores the rotation
  52470. */
  52471. rotation: Vector3;
  52472. /**
  52473. * Stores the rotation quaternion
  52474. */
  52475. rotationQuaternion: Nullable<Quaternion>;
  52476. /**
  52477. * Stores the scaling vector
  52478. */
  52479. scaling: Vector3;
  52480. /**
  52481. * Convert the Mesh to CSG
  52482. * @param mesh The Mesh to convert to CSG
  52483. * @returns A new CSG from the Mesh
  52484. */
  52485. static FromMesh(mesh: Mesh): CSG;
  52486. /**
  52487. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  52488. * @param polygons Polygons used to construct a CSG solid
  52489. */
  52490. private static FromPolygons;
  52491. /**
  52492. * Clones, or makes a deep copy, of the CSG
  52493. * @returns A new CSG
  52494. */
  52495. clone(): CSG;
  52496. /**
  52497. * Unions this CSG with another CSG
  52498. * @param csg The CSG to union against this CSG
  52499. * @returns The unioned CSG
  52500. */
  52501. union(csg: CSG): CSG;
  52502. /**
  52503. * Unions this CSG with another CSG in place
  52504. * @param csg The CSG to union against this CSG
  52505. */
  52506. unionInPlace(csg: CSG): void;
  52507. /**
  52508. * Subtracts this CSG with another CSG
  52509. * @param csg The CSG to subtract against this CSG
  52510. * @returns A new CSG
  52511. */
  52512. subtract(csg: CSG): CSG;
  52513. /**
  52514. * Subtracts this CSG with another CSG in place
  52515. * @param csg The CSG to subtact against this CSG
  52516. */
  52517. subtractInPlace(csg: CSG): void;
  52518. /**
  52519. * Intersect this CSG with another CSG
  52520. * @param csg The CSG to intersect against this CSG
  52521. * @returns A new CSG
  52522. */
  52523. intersect(csg: CSG): CSG;
  52524. /**
  52525. * Intersects this CSG with another CSG in place
  52526. * @param csg The CSG to intersect against this CSG
  52527. */
  52528. intersectInPlace(csg: CSG): void;
  52529. /**
  52530. * Return a new CSG solid with solid and empty space switched. This solid is
  52531. * not modified.
  52532. * @returns A new CSG solid with solid and empty space switched
  52533. */
  52534. inverse(): CSG;
  52535. /**
  52536. * Inverses the CSG in place
  52537. */
  52538. inverseInPlace(): void;
  52539. /**
  52540. * This is used to keep meshes transformations so they can be restored
  52541. * when we build back a Babylon Mesh
  52542. * NB : All CSG operations are performed in world coordinates
  52543. * @param csg The CSG to copy the transform attributes from
  52544. * @returns This CSG
  52545. */
  52546. copyTransformAttributes(csg: CSG): CSG;
  52547. /**
  52548. * Build Raw mesh from CSG
  52549. * Coordinates here are in world space
  52550. * @param name The name of the mesh geometry
  52551. * @param scene The Scene
  52552. * @param keepSubMeshes Specifies if the submeshes should be kept
  52553. * @returns A new Mesh
  52554. */
  52555. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  52556. /**
  52557. * Build Mesh from CSG taking material and transforms into account
  52558. * @param name The name of the Mesh
  52559. * @param material The material of the Mesh
  52560. * @param scene The Scene
  52561. * @param keepSubMeshes Specifies if submeshes should be kept
  52562. * @returns The new Mesh
  52563. */
  52564. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  52565. }
  52566. }
  52567. declare module BABYLON {
  52568. /**
  52569. * Class used to create a trail following a mesh
  52570. */
  52571. export class TrailMesh extends Mesh {
  52572. private _generator;
  52573. private _autoStart;
  52574. private _running;
  52575. private _diameter;
  52576. private _length;
  52577. private _sectionPolygonPointsCount;
  52578. private _sectionVectors;
  52579. private _sectionNormalVectors;
  52580. private _beforeRenderObserver;
  52581. /**
  52582. * @constructor
  52583. * @param name The value used by scene.getMeshByName() to do a lookup.
  52584. * @param generator The mesh to generate a trail.
  52585. * @param scene The scene to add this mesh to.
  52586. * @param diameter Diameter of trailing mesh. Default is 1.
  52587. * @param length Length of trailing mesh. Default is 60.
  52588. * @param autoStart Automatically start trailing mesh. Default true.
  52589. */
  52590. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  52591. /**
  52592. * "TrailMesh"
  52593. * @returns "TrailMesh"
  52594. */
  52595. getClassName(): string;
  52596. private _createMesh;
  52597. /**
  52598. * Start trailing mesh.
  52599. */
  52600. start(): void;
  52601. /**
  52602. * Stop trailing mesh.
  52603. */
  52604. stop(): void;
  52605. /**
  52606. * Update trailing mesh geometry.
  52607. */
  52608. update(): void;
  52609. /**
  52610. * Returns a new TrailMesh object.
  52611. * @param name is a string, the name given to the new mesh
  52612. * @param newGenerator use new generator object for cloned trail mesh
  52613. * @returns a new mesh
  52614. */
  52615. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  52616. /**
  52617. * Serializes this trail mesh
  52618. * @param serializationObject object to write serialization to
  52619. */
  52620. serialize(serializationObject: any): void;
  52621. /**
  52622. * Parses a serialized trail mesh
  52623. * @param parsedMesh the serialized mesh
  52624. * @param scene the scene to create the trail mesh in
  52625. * @returns the created trail mesh
  52626. */
  52627. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  52628. }
  52629. }
  52630. declare module BABYLON {
  52631. /**
  52632. * Class containing static functions to help procedurally build meshes
  52633. */
  52634. export class TiledBoxBuilder {
  52635. /**
  52636. * Creates a box mesh
  52637. * 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)
  52638. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52639. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52640. * * 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
  52641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52642. * @param name defines the name of the mesh
  52643. * @param options defines the options used to create the mesh
  52644. * @param scene defines the hosting scene
  52645. * @returns the box mesh
  52646. */
  52647. static CreateTiledBox(name: string, options: {
  52648. pattern?: number;
  52649. width?: number;
  52650. height?: number;
  52651. depth?: number;
  52652. tileSize?: number;
  52653. tileWidth?: number;
  52654. tileHeight?: number;
  52655. alignHorizontal?: number;
  52656. alignVertical?: number;
  52657. faceUV?: Vector4[];
  52658. faceColors?: Color4[];
  52659. sideOrientation?: number;
  52660. updatable?: boolean;
  52661. }, scene?: Nullable<Scene>): Mesh;
  52662. }
  52663. }
  52664. declare module BABYLON {
  52665. /**
  52666. * Class containing static functions to help procedurally build meshes
  52667. */
  52668. export class TorusKnotBuilder {
  52669. /**
  52670. * Creates a torus knot mesh
  52671. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52672. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52673. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52674. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52676. * * 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
  52677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52678. * @param name defines the name of the mesh
  52679. * @param options defines the options used to create the mesh
  52680. * @param scene defines the hosting scene
  52681. * @returns the torus knot mesh
  52682. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52683. */
  52684. static CreateTorusKnot(name: string, options: {
  52685. radius?: number;
  52686. tube?: number;
  52687. radialSegments?: number;
  52688. tubularSegments?: number;
  52689. p?: number;
  52690. q?: number;
  52691. updatable?: boolean;
  52692. sideOrientation?: number;
  52693. frontUVs?: Vector4;
  52694. backUVs?: Vector4;
  52695. }, scene: any): Mesh;
  52696. }
  52697. }
  52698. declare module BABYLON {
  52699. /**
  52700. * Polygon
  52701. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  52702. */
  52703. export class Polygon {
  52704. /**
  52705. * Creates a rectangle
  52706. * @param xmin bottom X coord
  52707. * @param ymin bottom Y coord
  52708. * @param xmax top X coord
  52709. * @param ymax top Y coord
  52710. * @returns points that make the resulting rectation
  52711. */
  52712. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  52713. /**
  52714. * Creates a circle
  52715. * @param radius radius of circle
  52716. * @param cx scale in x
  52717. * @param cy scale in y
  52718. * @param numberOfSides number of sides that make up the circle
  52719. * @returns points that make the resulting circle
  52720. */
  52721. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  52722. /**
  52723. * Creates a polygon from input string
  52724. * @param input Input polygon data
  52725. * @returns the parsed points
  52726. */
  52727. static Parse(input: string): Vector2[];
  52728. /**
  52729. * Starts building a polygon from x and y coordinates
  52730. * @param x x coordinate
  52731. * @param y y coordinate
  52732. * @returns the started path2
  52733. */
  52734. static StartingAt(x: number, y: number): Path2;
  52735. }
  52736. /**
  52737. * Builds a polygon
  52738. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  52739. */
  52740. export class PolygonMeshBuilder {
  52741. private _points;
  52742. private _outlinepoints;
  52743. private _holes;
  52744. private _name;
  52745. private _scene;
  52746. private _epoints;
  52747. private _eholes;
  52748. private _addToepoint;
  52749. /**
  52750. * Babylon reference to the earcut plugin.
  52751. */
  52752. bjsEarcut: any;
  52753. /**
  52754. * Creates a PolygonMeshBuilder
  52755. * @param name name of the builder
  52756. * @param contours Path of the polygon
  52757. * @param scene scene to add to when creating the mesh
  52758. * @param earcutInjection can be used to inject your own earcut reference
  52759. */
  52760. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  52761. /**
  52762. * Adds a whole within the polygon
  52763. * @param hole Array of points defining the hole
  52764. * @returns this
  52765. */
  52766. addHole(hole: Vector2[]): PolygonMeshBuilder;
  52767. /**
  52768. * Creates the polygon
  52769. * @param updatable If the mesh should be updatable
  52770. * @param depth The depth of the mesh created
  52771. * @returns the created mesh
  52772. */
  52773. build(updatable?: boolean, depth?: number): Mesh;
  52774. /**
  52775. * Creates the polygon
  52776. * @param depth The depth of the mesh created
  52777. * @returns the created VertexData
  52778. */
  52779. buildVertexData(depth?: number): VertexData;
  52780. /**
  52781. * Adds a side to the polygon
  52782. * @param positions points that make the polygon
  52783. * @param normals normals of the polygon
  52784. * @param uvs uvs of the polygon
  52785. * @param indices indices of the polygon
  52786. * @param bounds bounds of the polygon
  52787. * @param points points of the polygon
  52788. * @param depth depth of the polygon
  52789. * @param flip flip of the polygon
  52790. */
  52791. private addSide;
  52792. }
  52793. }
  52794. declare module BABYLON {
  52795. /**
  52796. * Class containing static functions to help procedurally build meshes
  52797. */
  52798. export class PolygonBuilder {
  52799. /**
  52800. * Creates a polygon mesh
  52801. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52802. * * 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
  52803. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52805. * * 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)
  52806. * * Remember you can only change the shape positions, not their number when updating a polygon
  52807. * @param name defines the name of the mesh
  52808. * @param options defines the options used to create the mesh
  52809. * @param scene defines the hosting scene
  52810. * @param earcutInjection can be used to inject your own earcut reference
  52811. * @returns the polygon mesh
  52812. */
  52813. static CreatePolygon(name: string, options: {
  52814. shape: Vector3[];
  52815. holes?: Vector3[][];
  52816. depth?: number;
  52817. faceUV?: Vector4[];
  52818. faceColors?: Color4[];
  52819. updatable?: boolean;
  52820. sideOrientation?: number;
  52821. frontUVs?: Vector4;
  52822. backUVs?: Vector4;
  52823. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52824. /**
  52825. * Creates an extruded polygon mesh, with depth in the Y direction.
  52826. * * 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)
  52827. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52828. * @param name defines the name of the mesh
  52829. * @param options defines the options used to create the mesh
  52830. * @param scene defines the hosting scene
  52831. * @param earcutInjection can be used to inject your own earcut reference
  52832. * @returns the polygon mesh
  52833. */
  52834. static ExtrudePolygon(name: string, options: {
  52835. shape: Vector3[];
  52836. holes?: Vector3[][];
  52837. depth?: number;
  52838. faceUV?: Vector4[];
  52839. faceColors?: Color4[];
  52840. updatable?: boolean;
  52841. sideOrientation?: number;
  52842. frontUVs?: Vector4;
  52843. backUVs?: Vector4;
  52844. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52845. }
  52846. }
  52847. declare module BABYLON {
  52848. /**
  52849. * Class containing static functions to help procedurally build meshes
  52850. */
  52851. export class LatheBuilder {
  52852. /**
  52853. * Creates lathe mesh.
  52854. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52855. * * 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
  52856. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52857. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52858. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52859. * * 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
  52860. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52861. * * 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
  52862. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52863. * * 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
  52864. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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 lathe mesh
  52870. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52871. */
  52872. static CreateLathe(name: string, options: {
  52873. shape: Vector3[];
  52874. radius?: number;
  52875. tessellation?: number;
  52876. clip?: number;
  52877. arc?: number;
  52878. closed?: boolean;
  52879. updatable?: boolean;
  52880. sideOrientation?: number;
  52881. frontUVs?: Vector4;
  52882. backUVs?: Vector4;
  52883. cap?: number;
  52884. invertUV?: 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 TiledPlaneBuilder {
  52893. /**
  52894. * Creates a tiled plane mesh
  52895. * * The parameter `pattern` will, depending on value, do nothing or
  52896. * * * flip (reflect about central vertical) alternate tiles across and up
  52897. * * * flip every tile on alternate rows
  52898. * * * rotate (180 degs) alternate tiles across and up
  52899. * * * rotate every tile on alternate rows
  52900. * * * flip and rotate alternate tiles across and up
  52901. * * * flip and rotate every tile on alternate rows
  52902. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  52903. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  52904. * * 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
  52905. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52906. * * 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)
  52907. * * 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)
  52908. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52909. * @param name defines the name of the mesh
  52910. * @param options defines the options used to create the mesh
  52911. * @param scene defines the hosting scene
  52912. * @returns the box mesh
  52913. */
  52914. static CreateTiledPlane(name: string, options: {
  52915. pattern?: number;
  52916. tileSize?: number;
  52917. tileWidth?: number;
  52918. tileHeight?: number;
  52919. size?: number;
  52920. width?: number;
  52921. height?: number;
  52922. alignHorizontal?: number;
  52923. alignVertical?: number;
  52924. sideOrientation?: number;
  52925. frontUVs?: Vector4;
  52926. backUVs?: Vector4;
  52927. updatable?: boolean;
  52928. }, scene?: Nullable<Scene>): Mesh;
  52929. }
  52930. }
  52931. declare module BABYLON {
  52932. /**
  52933. * Class containing static functions to help procedurally build meshes
  52934. */
  52935. export class TubeBuilder {
  52936. /**
  52937. * Creates a tube mesh.
  52938. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52939. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52940. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52941. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52942. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52943. * * 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)
  52944. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52945. * * 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
  52946. * * 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
  52947. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52948. * * 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
  52949. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52951. * @param name defines the name of the mesh
  52952. * @param options defines the options used to create the mesh
  52953. * @param scene defines the hosting scene
  52954. * @returns the tube mesh
  52955. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52956. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52957. */
  52958. static CreateTube(name: string, options: {
  52959. path: Vector3[];
  52960. radius?: number;
  52961. tessellation?: number;
  52962. radiusFunction?: {
  52963. (i: number, distance: number): number;
  52964. };
  52965. cap?: number;
  52966. arc?: number;
  52967. updatable?: boolean;
  52968. sideOrientation?: number;
  52969. frontUVs?: Vector4;
  52970. backUVs?: Vector4;
  52971. instance?: Mesh;
  52972. invertUV?: boolean;
  52973. }, scene?: Nullable<Scene>): Mesh;
  52974. }
  52975. }
  52976. declare module BABYLON {
  52977. /**
  52978. * Class containing static functions to help procedurally build meshes
  52979. */
  52980. export class IcoSphereBuilder {
  52981. /**
  52982. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52983. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52984. * * 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`)
  52985. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52986. * * 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
  52987. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52988. * * 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
  52989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52990. * @param name defines the name of the mesh
  52991. * @param options defines the options used to create the mesh
  52992. * @param scene defines the hosting scene
  52993. * @returns the icosahedron mesh
  52994. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52995. */
  52996. static CreateIcoSphere(name: string, options: {
  52997. radius?: number;
  52998. radiusX?: number;
  52999. radiusY?: number;
  53000. radiusZ?: number;
  53001. flat?: boolean;
  53002. subdivisions?: number;
  53003. sideOrientation?: number;
  53004. frontUVs?: Vector4;
  53005. backUVs?: Vector4;
  53006. updatable?: boolean;
  53007. }, scene?: Nullable<Scene>): Mesh;
  53008. }
  53009. }
  53010. declare module BABYLON {
  53011. /**
  53012. * Class containing static functions to help procedurally build meshes
  53013. */
  53014. export class DecalBuilder {
  53015. /**
  53016. * Creates a decal mesh.
  53017. * 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
  53018. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53019. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53020. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53021. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53022. * @param name defines the name of the mesh
  53023. * @param sourceMesh defines the mesh where the decal must be applied
  53024. * @param options defines the options used to create the mesh
  53025. * @param scene defines the hosting scene
  53026. * @returns the decal mesh
  53027. * @see https://doc.babylonjs.com/how_to/decals
  53028. */
  53029. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53030. position?: Vector3;
  53031. normal?: Vector3;
  53032. size?: Vector3;
  53033. angle?: number;
  53034. }): Mesh;
  53035. }
  53036. }
  53037. declare module BABYLON {
  53038. /**
  53039. * Class containing static functions to help procedurally build meshes
  53040. */
  53041. export class MeshBuilder {
  53042. /**
  53043. * Creates a box mesh
  53044. * * The parameter `size` sets the size (float) of each box side (default 1)
  53045. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53046. * * 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)
  53047. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53048. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53049. * * 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
  53050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53051. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53052. * @param name defines the name of the mesh
  53053. * @param options defines the options used to create the mesh
  53054. * @param scene defines the hosting scene
  53055. * @returns the box mesh
  53056. */
  53057. static CreateBox(name: string, options: {
  53058. size?: number;
  53059. width?: number;
  53060. height?: number;
  53061. depth?: number;
  53062. faceUV?: Vector4[];
  53063. faceColors?: Color4[];
  53064. sideOrientation?: number;
  53065. frontUVs?: Vector4;
  53066. backUVs?: Vector4;
  53067. updatable?: boolean;
  53068. }, scene?: Nullable<Scene>): Mesh;
  53069. /**
  53070. * Creates a tiled box mesh
  53071. * * faceTiles sets the pattern, tile size and number of tiles for a face
  53072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53073. * @param name defines the name of the mesh
  53074. * @param options defines the options used to create the mesh
  53075. * @param scene defines the hosting scene
  53076. * @returns the tiled box mesh
  53077. */
  53078. static CreateTiledBox(name: string, options: {
  53079. pattern?: number;
  53080. size?: number;
  53081. width?: number;
  53082. height?: number;
  53083. depth: number;
  53084. tileSize?: number;
  53085. tileWidth?: number;
  53086. tileHeight?: number;
  53087. faceUV?: Vector4[];
  53088. faceColors?: Color4[];
  53089. alignHorizontal?: number;
  53090. alignVertical?: number;
  53091. sideOrientation?: number;
  53092. updatable?: boolean;
  53093. }, scene?: Nullable<Scene>): Mesh;
  53094. /**
  53095. * Creates a sphere mesh
  53096. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53097. * * 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`)
  53098. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53099. * * 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
  53100. * * 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)
  53101. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53102. * * 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
  53103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53104. * @param name defines the name of the mesh
  53105. * @param options defines the options used to create the mesh
  53106. * @param scene defines the hosting scene
  53107. * @returns the sphere mesh
  53108. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53109. */
  53110. static CreateSphere(name: string, options: {
  53111. segments?: number;
  53112. diameter?: number;
  53113. diameterX?: number;
  53114. diameterY?: number;
  53115. diameterZ?: number;
  53116. arc?: number;
  53117. slice?: number;
  53118. sideOrientation?: number;
  53119. frontUVs?: Vector4;
  53120. backUVs?: Vector4;
  53121. updatable?: boolean;
  53122. }, scene?: Nullable<Scene>): Mesh;
  53123. /**
  53124. * Creates a plane polygonal mesh. By default, this is a disc
  53125. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  53126. * * 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
  53127. * * 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
  53128. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53129. * * 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
  53130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53131. * @param name defines the name of the mesh
  53132. * @param options defines the options used to create the mesh
  53133. * @param scene defines the hosting scene
  53134. * @returns the plane polygonal mesh
  53135. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  53136. */
  53137. static CreateDisc(name: string, options: {
  53138. radius?: number;
  53139. tessellation?: number;
  53140. arc?: number;
  53141. updatable?: boolean;
  53142. sideOrientation?: number;
  53143. frontUVs?: Vector4;
  53144. backUVs?: Vector4;
  53145. }, scene?: Nullable<Scene>): Mesh;
  53146. /**
  53147. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  53148. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  53149. * * 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`)
  53150. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  53151. * * 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
  53152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53153. * * 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
  53154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53155. * @param name defines the name of the mesh
  53156. * @param options defines the options used to create the mesh
  53157. * @param scene defines the hosting scene
  53158. * @returns the icosahedron mesh
  53159. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  53160. */
  53161. static CreateIcoSphere(name: string, options: {
  53162. radius?: number;
  53163. radiusX?: number;
  53164. radiusY?: number;
  53165. radiusZ?: number;
  53166. flat?: boolean;
  53167. subdivisions?: number;
  53168. sideOrientation?: number;
  53169. frontUVs?: Vector4;
  53170. backUVs?: Vector4;
  53171. updatable?: boolean;
  53172. }, scene?: Nullable<Scene>): Mesh;
  53173. /**
  53174. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53175. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53176. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53177. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53178. * * 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
  53179. * * 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
  53180. * * 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
  53181. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53182. * * 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
  53183. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53184. * * 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
  53185. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53186. * * 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
  53187. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  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 ribbon mesh
  53193. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53194. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53195. */
  53196. static CreateRibbon(name: string, options: {
  53197. pathArray: Vector3[][];
  53198. closeArray?: boolean;
  53199. closePath?: boolean;
  53200. offset?: number;
  53201. updatable?: boolean;
  53202. sideOrientation?: number;
  53203. frontUVs?: Vector4;
  53204. backUVs?: Vector4;
  53205. instance?: Mesh;
  53206. invertUV?: boolean;
  53207. uvs?: Vector2[];
  53208. colors?: Color4[];
  53209. }, scene?: Nullable<Scene>): Mesh;
  53210. /**
  53211. * Creates a cylinder or a cone mesh
  53212. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53213. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53214. * * 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.
  53215. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53216. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53217. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53218. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53219. * * 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).
  53220. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53221. * * 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).
  53222. * * 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
  53223. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53224. * * 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
  53225. * * 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.
  53226. * * If `enclose` is false, a ring surface is one element.
  53227. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53228. * * 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
  53229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53230. * * 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
  53231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53232. * @param name defines the name of the mesh
  53233. * @param options defines the options used to create the mesh
  53234. * @param scene defines the hosting scene
  53235. * @returns the cylinder mesh
  53236. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53237. */
  53238. static CreateCylinder(name: string, options: {
  53239. height?: number;
  53240. diameterTop?: number;
  53241. diameterBottom?: number;
  53242. diameter?: number;
  53243. tessellation?: number;
  53244. subdivisions?: number;
  53245. arc?: number;
  53246. faceColors?: Color4[];
  53247. faceUV?: Vector4[];
  53248. updatable?: boolean;
  53249. hasRings?: boolean;
  53250. enclose?: boolean;
  53251. cap?: number;
  53252. sideOrientation?: number;
  53253. frontUVs?: Vector4;
  53254. backUVs?: Vector4;
  53255. }, scene?: Nullable<Scene>): Mesh;
  53256. /**
  53257. * Creates a torus mesh
  53258. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53259. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53260. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  53261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53262. * * 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
  53263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53264. * @param name defines the name of the mesh
  53265. * @param options defines the options used to create the mesh
  53266. * @param scene defines the hosting scene
  53267. * @returns the torus mesh
  53268. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53269. */
  53270. static CreateTorus(name: string, options: {
  53271. diameter?: number;
  53272. thickness?: number;
  53273. tessellation?: number;
  53274. updatable?: boolean;
  53275. sideOrientation?: number;
  53276. frontUVs?: Vector4;
  53277. backUVs?: Vector4;
  53278. }, scene?: Nullable<Scene>): Mesh;
  53279. /**
  53280. * Creates a torus knot mesh
  53281. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  53282. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  53283. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  53284. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  53285. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53286. * * 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
  53287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53288. * @param name defines the name of the mesh
  53289. * @param options defines the options used to create the mesh
  53290. * @param scene defines the hosting scene
  53291. * @returns the torus knot mesh
  53292. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  53293. */
  53294. static CreateTorusKnot(name: string, options: {
  53295. radius?: number;
  53296. tube?: number;
  53297. radialSegments?: number;
  53298. tubularSegments?: number;
  53299. p?: number;
  53300. q?: number;
  53301. updatable?: boolean;
  53302. sideOrientation?: number;
  53303. frontUVs?: Vector4;
  53304. backUVs?: Vector4;
  53305. }, scene?: Nullable<Scene>): Mesh;
  53306. /**
  53307. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  53308. * * 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
  53309. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  53310. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  53311. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  53312. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  53313. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  53314. * * 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
  53315. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  53316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53317. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  53318. * @param name defines the name of the new line system
  53319. * @param options defines the options used to create the line system
  53320. * @param scene defines the hosting scene
  53321. * @returns a new line system mesh
  53322. */
  53323. static CreateLineSystem(name: string, options: {
  53324. lines: Vector3[][];
  53325. updatable?: boolean;
  53326. instance?: Nullable<LinesMesh>;
  53327. colors?: Nullable<Color4[][]>;
  53328. useVertexAlpha?: boolean;
  53329. }, scene: Nullable<Scene>): LinesMesh;
  53330. /**
  53331. * Creates a line mesh
  53332. * 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
  53333. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  53334. * * The parameter `points` is an array successive Vector3
  53335. * * 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
  53336. * * The optional parameter `colors` is an array of successive Color4, one per line point
  53337. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  53338. * * When updating an instance, remember that only point positions can change, not the number of points
  53339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53340. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  53341. * @param name defines the name of the new line system
  53342. * @param options defines the options used to create the line system
  53343. * @param scene defines the hosting scene
  53344. * @returns a new line mesh
  53345. */
  53346. static CreateLines(name: string, options: {
  53347. points: Vector3[];
  53348. updatable?: boolean;
  53349. instance?: Nullable<LinesMesh>;
  53350. colors?: Color4[];
  53351. useVertexAlpha?: boolean;
  53352. }, scene?: Nullable<Scene>): LinesMesh;
  53353. /**
  53354. * Creates a dashed line mesh
  53355. * * 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
  53356. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  53357. * * The parameter `points` is an array successive Vector3
  53358. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  53359. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  53360. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  53361. * * 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
  53362. * * When updating an instance, remember that only point positions can change, not the number of points
  53363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53364. * @param name defines the name of the mesh
  53365. * @param options defines the options used to create the mesh
  53366. * @param scene defines the hosting scene
  53367. * @returns the dashed line mesh
  53368. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  53369. */
  53370. static CreateDashedLines(name: string, options: {
  53371. points: Vector3[];
  53372. dashSize?: number;
  53373. gapSize?: number;
  53374. dashNb?: number;
  53375. updatable?: boolean;
  53376. instance?: LinesMesh;
  53377. }, scene?: Nullable<Scene>): LinesMesh;
  53378. /**
  53379. * 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.
  53380. * * 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.
  53381. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53382. * * 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.
  53383. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53384. * * 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
  53385. * * 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
  53386. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53387. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53388. * * 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
  53389. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53391. * @param name defines the name of the mesh
  53392. * @param options defines the options used to create the mesh
  53393. * @param scene defines the hosting scene
  53394. * @returns the extruded shape mesh
  53395. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53396. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53397. */
  53398. static ExtrudeShape(name: string, options: {
  53399. shape: Vector3[];
  53400. path: Vector3[];
  53401. scale?: number;
  53402. rotation?: number;
  53403. cap?: number;
  53404. updatable?: boolean;
  53405. sideOrientation?: number;
  53406. frontUVs?: Vector4;
  53407. backUVs?: Vector4;
  53408. instance?: Mesh;
  53409. invertUV?: boolean;
  53410. }, scene?: Nullable<Scene>): Mesh;
  53411. /**
  53412. * Creates an custom extruded shape mesh.
  53413. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53414. * * 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.
  53415. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53416. * * 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
  53417. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53418. * * 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
  53419. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53420. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53421. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53422. * * 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
  53423. * * 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
  53424. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53425. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53426. * * 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
  53427. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53429. * @param name defines the name of the mesh
  53430. * @param options defines the options used to create the mesh
  53431. * @param scene defines the hosting scene
  53432. * @returns the custom extruded shape mesh
  53433. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53434. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53435. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53436. */
  53437. static ExtrudeShapeCustom(name: string, options: {
  53438. shape: Vector3[];
  53439. path: Vector3[];
  53440. scaleFunction?: any;
  53441. rotationFunction?: any;
  53442. ribbonCloseArray?: boolean;
  53443. ribbonClosePath?: boolean;
  53444. cap?: number;
  53445. updatable?: boolean;
  53446. sideOrientation?: number;
  53447. frontUVs?: Vector4;
  53448. backUVs?: Vector4;
  53449. instance?: Mesh;
  53450. invertUV?: boolean;
  53451. }, scene?: Nullable<Scene>): Mesh;
  53452. /**
  53453. * Creates lathe mesh.
  53454. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  53455. * * 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
  53456. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  53457. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  53458. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  53459. * * 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
  53460. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53461. * * 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
  53462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53463. * * 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
  53464. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53466. * @param name defines the name of the mesh
  53467. * @param options defines the options used to create the mesh
  53468. * @param scene defines the hosting scene
  53469. * @returns the lathe mesh
  53470. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53471. */
  53472. static CreateLathe(name: string, options: {
  53473. shape: Vector3[];
  53474. radius?: number;
  53475. tessellation?: number;
  53476. clip?: number;
  53477. arc?: number;
  53478. closed?: boolean;
  53479. updatable?: boolean;
  53480. sideOrientation?: number;
  53481. frontUVs?: Vector4;
  53482. backUVs?: Vector4;
  53483. cap?: number;
  53484. invertUV?: boolean;
  53485. }, scene?: Nullable<Scene>): Mesh;
  53486. /**
  53487. * Creates a tiled plane mesh
  53488. * * You can set a limited pattern arrangement with the tiles
  53489. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53490. * * 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
  53491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53492. * @param name defines the name of the mesh
  53493. * @param options defines the options used to create the mesh
  53494. * @param scene defines the hosting scene
  53495. * @returns the plane mesh
  53496. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53497. */
  53498. static CreateTiledPlane(name: string, options: {
  53499. pattern?: number;
  53500. tileSize?: number;
  53501. tileWidth?: number;
  53502. tileHeight?: number;
  53503. size?: number;
  53504. width?: number;
  53505. height?: number;
  53506. alignHorizontal?: number;
  53507. alignVertical?: number;
  53508. sideOrientation?: number;
  53509. frontUVs?: Vector4;
  53510. backUVs?: Vector4;
  53511. updatable?: boolean;
  53512. }, scene?: Nullable<Scene>): Mesh;
  53513. /**
  53514. * Creates a plane mesh
  53515. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  53516. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  53517. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  53518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53519. * * 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
  53520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53521. * @param name defines the name of the mesh
  53522. * @param options defines the options used to create the mesh
  53523. * @param scene defines the hosting scene
  53524. * @returns the plane mesh
  53525. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53526. */
  53527. static CreatePlane(name: string, options: {
  53528. size?: number;
  53529. width?: number;
  53530. height?: number;
  53531. sideOrientation?: number;
  53532. frontUVs?: Vector4;
  53533. backUVs?: Vector4;
  53534. updatable?: boolean;
  53535. sourcePlane?: Plane;
  53536. }, scene?: Nullable<Scene>): Mesh;
  53537. /**
  53538. * Creates a ground mesh
  53539. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53540. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53542. * @param name defines the name of the mesh
  53543. * @param options defines the options used to create the mesh
  53544. * @param scene defines the hosting scene
  53545. * @returns the ground mesh
  53546. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53547. */
  53548. static CreateGround(name: string, options: {
  53549. width?: number;
  53550. height?: number;
  53551. subdivisions?: number;
  53552. subdivisionsX?: number;
  53553. subdivisionsY?: number;
  53554. updatable?: boolean;
  53555. }, scene?: Nullable<Scene>): Mesh;
  53556. /**
  53557. * Creates a tiled ground mesh
  53558. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53559. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53560. * * 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
  53561. * * 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
  53562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53563. * @param name defines the name of the mesh
  53564. * @param options defines the options used to create the mesh
  53565. * @param scene defines the hosting scene
  53566. * @returns the tiled ground mesh
  53567. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53568. */
  53569. static CreateTiledGround(name: string, options: {
  53570. xmin: number;
  53571. zmin: number;
  53572. xmax: number;
  53573. zmax: number;
  53574. subdivisions?: {
  53575. w: number;
  53576. h: number;
  53577. };
  53578. precision?: {
  53579. w: number;
  53580. h: number;
  53581. };
  53582. updatable?: boolean;
  53583. }, scene?: Nullable<Scene>): Mesh;
  53584. /**
  53585. * Creates a ground mesh from a height map
  53586. * * The parameter `url` sets the URL of the height map image resource.
  53587. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53588. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53589. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53590. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53591. * * 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.
  53592. * * 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).
  53593. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53595. * @param name defines the name of the mesh
  53596. * @param url defines the url to the height map
  53597. * @param options defines the options used to create the mesh
  53598. * @param scene defines the hosting scene
  53599. * @returns the ground mesh
  53600. * @see https://doc.babylonjs.com/babylon101/height_map
  53601. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53602. */
  53603. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53604. width?: number;
  53605. height?: number;
  53606. subdivisions?: number;
  53607. minHeight?: number;
  53608. maxHeight?: number;
  53609. colorFilter?: Color3;
  53610. alphaFilter?: number;
  53611. updatable?: boolean;
  53612. onReady?: (mesh: GroundMesh) => void;
  53613. }, scene?: Nullable<Scene>): GroundMesh;
  53614. /**
  53615. * Creates a polygon mesh
  53616. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53617. * * 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
  53618. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53620. * * 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)
  53621. * * Remember you can only change the shape positions, not their number when updating a polygon
  53622. * @param name defines the name of the mesh
  53623. * @param options defines the options used to create the mesh
  53624. * @param scene defines the hosting scene
  53625. * @param earcutInjection can be used to inject your own earcut reference
  53626. * @returns the polygon mesh
  53627. */
  53628. static CreatePolygon(name: string, options: {
  53629. shape: Vector3[];
  53630. holes?: Vector3[][];
  53631. depth?: number;
  53632. faceUV?: Vector4[];
  53633. faceColors?: Color4[];
  53634. updatable?: boolean;
  53635. sideOrientation?: number;
  53636. frontUVs?: Vector4;
  53637. backUVs?: Vector4;
  53638. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53639. /**
  53640. * Creates an extruded polygon mesh, with depth in the Y direction.
  53641. * * 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)
  53642. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53643. * @param name defines the name of the mesh
  53644. * @param options defines the options used to create the mesh
  53645. * @param scene defines the hosting scene
  53646. * @param earcutInjection can be used to inject your own earcut reference
  53647. * @returns the polygon mesh
  53648. */
  53649. static ExtrudePolygon(name: string, options: {
  53650. shape: Vector3[];
  53651. holes?: Vector3[][];
  53652. depth?: number;
  53653. faceUV?: Vector4[];
  53654. faceColors?: Color4[];
  53655. updatable?: boolean;
  53656. sideOrientation?: number;
  53657. frontUVs?: Vector4;
  53658. backUVs?: Vector4;
  53659. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53660. /**
  53661. * Creates a tube mesh.
  53662. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53663. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53664. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53665. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53666. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53667. * * 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)
  53668. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53669. * * 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
  53670. * * 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
  53671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53672. * * 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
  53673. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53674. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53675. * @param name defines the name of the mesh
  53676. * @param options defines the options used to create the mesh
  53677. * @param scene defines the hosting scene
  53678. * @returns the tube mesh
  53679. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53680. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53681. */
  53682. static CreateTube(name: string, options: {
  53683. path: Vector3[];
  53684. radius?: number;
  53685. tessellation?: number;
  53686. radiusFunction?: {
  53687. (i: number, distance: number): number;
  53688. };
  53689. cap?: number;
  53690. arc?: number;
  53691. updatable?: boolean;
  53692. sideOrientation?: number;
  53693. frontUVs?: Vector4;
  53694. backUVs?: Vector4;
  53695. instance?: Mesh;
  53696. invertUV?: boolean;
  53697. }, scene?: Nullable<Scene>): Mesh;
  53698. /**
  53699. * Creates a polyhedron mesh
  53700. * * 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
  53701. * * The parameter `size` (positive float, default 1) sets the polygon size
  53702. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53703. * * 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`
  53704. * * 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
  53705. * * 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)`)
  53706. * * 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
  53707. * * 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
  53708. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53709. * * 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
  53710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53711. * @param name defines the name of the mesh
  53712. * @param options defines the options used to create the mesh
  53713. * @param scene defines the hosting scene
  53714. * @returns the polyhedron mesh
  53715. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53716. */
  53717. static CreatePolyhedron(name: string, options: {
  53718. type?: number;
  53719. size?: number;
  53720. sizeX?: number;
  53721. sizeY?: number;
  53722. sizeZ?: number;
  53723. custom?: any;
  53724. faceUV?: Vector4[];
  53725. faceColors?: Color4[];
  53726. flat?: boolean;
  53727. updatable?: boolean;
  53728. sideOrientation?: number;
  53729. frontUVs?: Vector4;
  53730. backUVs?: Vector4;
  53731. }, scene?: Nullable<Scene>): Mesh;
  53732. /**
  53733. * Creates a decal mesh.
  53734. * 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
  53735. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53736. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53737. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53738. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53739. * @param name defines the name of the mesh
  53740. * @param sourceMesh defines the mesh where the decal must be applied
  53741. * @param options defines the options used to create the mesh
  53742. * @param scene defines the hosting scene
  53743. * @returns the decal mesh
  53744. * @see https://doc.babylonjs.com/how_to/decals
  53745. */
  53746. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53747. position?: Vector3;
  53748. normal?: Vector3;
  53749. size?: Vector3;
  53750. angle?: number;
  53751. }): Mesh;
  53752. }
  53753. }
  53754. declare module BABYLON {
  53755. /**
  53756. * A simplifier interface for future simplification implementations
  53757. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53758. */
  53759. export interface ISimplifier {
  53760. /**
  53761. * Simplification of a given mesh according to the given settings.
  53762. * Since this requires computation, it is assumed that the function runs async.
  53763. * @param settings The settings of the simplification, including quality and distance
  53764. * @param successCallback A callback that will be called after the mesh was simplified.
  53765. * @param errorCallback in case of an error, this callback will be called. optional.
  53766. */
  53767. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  53768. }
  53769. /**
  53770. * Expected simplification settings.
  53771. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  53772. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53773. */
  53774. export interface ISimplificationSettings {
  53775. /**
  53776. * Gets or sets the expected quality
  53777. */
  53778. quality: number;
  53779. /**
  53780. * Gets or sets the distance when this optimized version should be used
  53781. */
  53782. distance: number;
  53783. /**
  53784. * Gets an already optimized mesh
  53785. */
  53786. optimizeMesh?: boolean;
  53787. }
  53788. /**
  53789. * Class used to specify simplification options
  53790. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53791. */
  53792. export class SimplificationSettings implements ISimplificationSettings {
  53793. /** expected quality */
  53794. quality: number;
  53795. /** distance when this optimized version should be used */
  53796. distance: number;
  53797. /** already optimized mesh */
  53798. optimizeMesh?: boolean | undefined;
  53799. /**
  53800. * Creates a SimplificationSettings
  53801. * @param quality expected quality
  53802. * @param distance distance when this optimized version should be used
  53803. * @param optimizeMesh already optimized mesh
  53804. */
  53805. constructor(
  53806. /** expected quality */
  53807. quality: number,
  53808. /** distance when this optimized version should be used */
  53809. distance: number,
  53810. /** already optimized mesh */
  53811. optimizeMesh?: boolean | undefined);
  53812. }
  53813. /**
  53814. * Interface used to define a simplification task
  53815. */
  53816. export interface ISimplificationTask {
  53817. /**
  53818. * Array of settings
  53819. */
  53820. settings: Array<ISimplificationSettings>;
  53821. /**
  53822. * Simplification type
  53823. */
  53824. simplificationType: SimplificationType;
  53825. /**
  53826. * Mesh to simplify
  53827. */
  53828. mesh: Mesh;
  53829. /**
  53830. * Callback called on success
  53831. */
  53832. successCallback?: () => void;
  53833. /**
  53834. * Defines if parallel processing can be used
  53835. */
  53836. parallelProcessing: boolean;
  53837. }
  53838. /**
  53839. * Queue used to order the simplification tasks
  53840. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53841. */
  53842. export class SimplificationQueue {
  53843. private _simplificationArray;
  53844. /**
  53845. * Gets a boolean indicating that the process is still running
  53846. */
  53847. running: boolean;
  53848. /**
  53849. * Creates a new queue
  53850. */
  53851. constructor();
  53852. /**
  53853. * Adds a new simplification task
  53854. * @param task defines a task to add
  53855. */
  53856. addTask(task: ISimplificationTask): void;
  53857. /**
  53858. * Execute next task
  53859. */
  53860. executeNext(): void;
  53861. /**
  53862. * Execute a simplification task
  53863. * @param task defines the task to run
  53864. */
  53865. runSimplification(task: ISimplificationTask): void;
  53866. private getSimplifier;
  53867. }
  53868. /**
  53869. * The implemented types of simplification
  53870. * At the moment only Quadratic Error Decimation is implemented
  53871. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53872. */
  53873. export enum SimplificationType {
  53874. /** Quadratic error decimation */
  53875. QUADRATIC = 0
  53876. }
  53877. }
  53878. declare module BABYLON {
  53879. interface Scene {
  53880. /** @hidden (Backing field) */
  53881. _simplificationQueue: SimplificationQueue;
  53882. /**
  53883. * Gets or sets the simplification queue attached to the scene
  53884. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53885. */
  53886. simplificationQueue: SimplificationQueue;
  53887. }
  53888. interface Mesh {
  53889. /**
  53890. * Simplify the mesh according to the given array of settings.
  53891. * Function will return immediately and will simplify async
  53892. * @param settings a collection of simplification settings
  53893. * @param parallelProcessing should all levels calculate parallel or one after the other
  53894. * @param simplificationType the type of simplification to run
  53895. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  53896. * @returns the current mesh
  53897. */
  53898. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  53899. }
  53900. /**
  53901. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  53902. * created in a scene
  53903. */
  53904. export class SimplicationQueueSceneComponent implements ISceneComponent {
  53905. /**
  53906. * The component name helpfull to identify the component in the list of scene components.
  53907. */
  53908. readonly name: string;
  53909. /**
  53910. * The scene the component belongs to.
  53911. */
  53912. scene: Scene;
  53913. /**
  53914. * Creates a new instance of the component for the given scene
  53915. * @param scene Defines the scene to register the component in
  53916. */
  53917. constructor(scene: Scene);
  53918. /**
  53919. * Registers the component in a given scene
  53920. */
  53921. register(): void;
  53922. /**
  53923. * Rebuilds the elements related to this component in case of
  53924. * context lost for instance.
  53925. */
  53926. rebuild(): void;
  53927. /**
  53928. * Disposes the component and the associated ressources
  53929. */
  53930. dispose(): void;
  53931. private _beforeCameraUpdate;
  53932. }
  53933. }
  53934. declare module BABYLON {
  53935. /**
  53936. * Class used to enable access to IndexedDB
  53937. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  53938. */
  53939. export class Database implements IOfflineProvider {
  53940. private _callbackManifestChecked;
  53941. private _currentSceneUrl;
  53942. private _db;
  53943. private _enableSceneOffline;
  53944. private _enableTexturesOffline;
  53945. private _manifestVersionFound;
  53946. private _mustUpdateRessources;
  53947. private _hasReachedQuota;
  53948. private _isSupported;
  53949. private _idbFactory;
  53950. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53951. private static IsUASupportingBlobStorage;
  53952. /**
  53953. * Gets a boolean indicating if Database storate is enabled (off by default)
  53954. */
  53955. static IDBStorageEnabled: boolean;
  53956. /**
  53957. * Gets a boolean indicating if scene must be saved in the database
  53958. */
  53959. readonly enableSceneOffline: boolean;
  53960. /**
  53961. * Gets a boolean indicating if textures must be saved in the database
  53962. */
  53963. readonly enableTexturesOffline: boolean;
  53964. /**
  53965. * Creates a new Database
  53966. * @param urlToScene defines the url to load the scene
  53967. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53968. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53969. */
  53970. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53971. private static _ParseURL;
  53972. private static _ReturnFullUrlLocation;
  53973. private _checkManifestFile;
  53974. /**
  53975. * Open the database and make it available
  53976. * @param successCallback defines the callback to call on success
  53977. * @param errorCallback defines the callback to call on error
  53978. */
  53979. open(successCallback: () => void, errorCallback: () => void): void;
  53980. /**
  53981. * Loads an image from the database
  53982. * @param url defines the url to load from
  53983. * @param image defines the target DOM image
  53984. */
  53985. loadImage(url: string, image: HTMLImageElement): void;
  53986. private _loadImageFromDBAsync;
  53987. private _saveImageIntoDBAsync;
  53988. private _checkVersionFromDB;
  53989. private _loadVersionFromDBAsync;
  53990. private _saveVersionIntoDBAsync;
  53991. /**
  53992. * Loads a file from database
  53993. * @param url defines the URL to load from
  53994. * @param sceneLoaded defines a callback to call on success
  53995. * @param progressCallBack defines a callback to call when progress changed
  53996. * @param errorCallback defines a callback to call on error
  53997. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53998. */
  53999. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  54000. private _loadFileAsync;
  54001. private _saveFileAsync;
  54002. /**
  54003. * Validates if xhr data is correct
  54004. * @param xhr defines the request to validate
  54005. * @param dataType defines the expected data type
  54006. * @returns true if data is correct
  54007. */
  54008. private static _ValidateXHRData;
  54009. }
  54010. }
  54011. declare module BABYLON {
  54012. /** @hidden */
  54013. export var gpuUpdateParticlesPixelShader: {
  54014. name: string;
  54015. shader: string;
  54016. };
  54017. }
  54018. declare module BABYLON {
  54019. /** @hidden */
  54020. export var gpuUpdateParticlesVertexShader: {
  54021. name: string;
  54022. shader: string;
  54023. };
  54024. }
  54025. declare module BABYLON {
  54026. /** @hidden */
  54027. export var clipPlaneFragmentDeclaration2: {
  54028. name: string;
  54029. shader: string;
  54030. };
  54031. }
  54032. declare module BABYLON {
  54033. /** @hidden */
  54034. export var gpuRenderParticlesPixelShader: {
  54035. name: string;
  54036. shader: string;
  54037. };
  54038. }
  54039. declare module BABYLON {
  54040. /** @hidden */
  54041. export var clipPlaneVertexDeclaration2: {
  54042. name: string;
  54043. shader: string;
  54044. };
  54045. }
  54046. declare module BABYLON {
  54047. /** @hidden */
  54048. export var gpuRenderParticlesVertexShader: {
  54049. name: string;
  54050. shader: string;
  54051. };
  54052. }
  54053. declare module BABYLON {
  54054. /**
  54055. * This represents a GPU particle system in Babylon
  54056. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  54057. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  54058. */
  54059. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  54060. /**
  54061. * The layer mask we are rendering the particles through.
  54062. */
  54063. layerMask: number;
  54064. private _capacity;
  54065. private _activeCount;
  54066. private _currentActiveCount;
  54067. private _accumulatedCount;
  54068. private _renderEffect;
  54069. private _updateEffect;
  54070. private _buffer0;
  54071. private _buffer1;
  54072. private _spriteBuffer;
  54073. private _updateVAO;
  54074. private _renderVAO;
  54075. private _targetIndex;
  54076. private _sourceBuffer;
  54077. private _targetBuffer;
  54078. private _engine;
  54079. private _currentRenderId;
  54080. private _started;
  54081. private _stopped;
  54082. private _timeDelta;
  54083. private _randomTexture;
  54084. private _randomTexture2;
  54085. private _attributesStrideSize;
  54086. private _updateEffectOptions;
  54087. private _randomTextureSize;
  54088. private _actualFrame;
  54089. private readonly _rawTextureWidth;
  54090. /**
  54091. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  54092. */
  54093. static readonly IsSupported: boolean;
  54094. /**
  54095. * An event triggered when the system is disposed.
  54096. */
  54097. onDisposeObservable: Observable<GPUParticleSystem>;
  54098. /**
  54099. * Gets the maximum number of particles active at the same time.
  54100. * @returns The max number of active particles.
  54101. */
  54102. getCapacity(): number;
  54103. /**
  54104. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  54105. * to override the particles.
  54106. */
  54107. forceDepthWrite: boolean;
  54108. /**
  54109. * Gets or set the number of active particles
  54110. */
  54111. activeParticleCount: number;
  54112. private _preWarmDone;
  54113. /**
  54114. * Is this system ready to be used/rendered
  54115. * @return true if the system is ready
  54116. */
  54117. isReady(): boolean;
  54118. /**
  54119. * Gets if the system has been started. (Note: this will still be true after stop is called)
  54120. * @returns True if it has been started, otherwise false.
  54121. */
  54122. isStarted(): boolean;
  54123. /**
  54124. * Starts the particle system and begins to emit
  54125. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  54126. */
  54127. start(delay?: number): void;
  54128. /**
  54129. * Stops the particle system.
  54130. */
  54131. stop(): void;
  54132. /**
  54133. * Remove all active particles
  54134. */
  54135. reset(): void;
  54136. /**
  54137. * Returns the string "GPUParticleSystem"
  54138. * @returns a string containing the class name
  54139. */
  54140. getClassName(): string;
  54141. private _colorGradientsTexture;
  54142. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  54143. /**
  54144. * Adds a new color gradient
  54145. * @param gradient defines the gradient to use (between 0 and 1)
  54146. * @param color1 defines the color to affect to the specified gradient
  54147. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  54148. * @returns the current particle system
  54149. */
  54150. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  54151. /**
  54152. * Remove a specific color gradient
  54153. * @param gradient defines the gradient to remove
  54154. * @returns the current particle system
  54155. */
  54156. removeColorGradient(gradient: number): GPUParticleSystem;
  54157. private _angularSpeedGradientsTexture;
  54158. private _sizeGradientsTexture;
  54159. private _velocityGradientsTexture;
  54160. private _limitVelocityGradientsTexture;
  54161. private _dragGradientsTexture;
  54162. private _addFactorGradient;
  54163. /**
  54164. * Adds a new size gradient
  54165. * @param gradient defines the gradient to use (between 0 and 1)
  54166. * @param factor defines the size factor to affect to the specified gradient
  54167. * @returns the current particle system
  54168. */
  54169. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  54170. /**
  54171. * Remove a specific size gradient
  54172. * @param gradient defines the gradient to remove
  54173. * @returns the current particle system
  54174. */
  54175. removeSizeGradient(gradient: number): GPUParticleSystem;
  54176. /**
  54177. * Adds a new angular speed gradient
  54178. * @param gradient defines the gradient to use (between 0 and 1)
  54179. * @param factor defines the angular speed to affect to the specified gradient
  54180. * @returns the current particle system
  54181. */
  54182. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  54183. /**
  54184. * Remove a specific angular speed gradient
  54185. * @param gradient defines the gradient to remove
  54186. * @returns the current particle system
  54187. */
  54188. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  54189. /**
  54190. * Adds a new velocity gradient
  54191. * @param gradient defines the gradient to use (between 0 and 1)
  54192. * @param factor defines the velocity to affect to the specified gradient
  54193. * @returns the current particle system
  54194. */
  54195. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  54196. /**
  54197. * Remove a specific velocity gradient
  54198. * @param gradient defines the gradient to remove
  54199. * @returns the current particle system
  54200. */
  54201. removeVelocityGradient(gradient: number): GPUParticleSystem;
  54202. /**
  54203. * Adds a new limit velocity gradient
  54204. * @param gradient defines the gradient to use (between 0 and 1)
  54205. * @param factor defines the limit velocity value to affect to the specified gradient
  54206. * @returns the current particle system
  54207. */
  54208. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  54209. /**
  54210. * Remove a specific limit velocity gradient
  54211. * @param gradient defines the gradient to remove
  54212. * @returns the current particle system
  54213. */
  54214. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  54215. /**
  54216. * Adds a new drag gradient
  54217. * @param gradient defines the gradient to use (between 0 and 1)
  54218. * @param factor defines the drag value to affect to the specified gradient
  54219. * @returns the current particle system
  54220. */
  54221. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  54222. /**
  54223. * Remove a specific drag gradient
  54224. * @param gradient defines the gradient to remove
  54225. * @returns the current particle system
  54226. */
  54227. removeDragGradient(gradient: number): GPUParticleSystem;
  54228. /**
  54229. * Not supported by GPUParticleSystem
  54230. * @param gradient defines the gradient to use (between 0 and 1)
  54231. * @param factor defines the emit rate value to affect to the specified gradient
  54232. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54233. * @returns the current particle system
  54234. */
  54235. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54236. /**
  54237. * Not supported by GPUParticleSystem
  54238. * @param gradient defines the gradient to remove
  54239. * @returns the current particle system
  54240. */
  54241. removeEmitRateGradient(gradient: number): IParticleSystem;
  54242. /**
  54243. * Not supported by GPUParticleSystem
  54244. * @param gradient defines the gradient to use (between 0 and 1)
  54245. * @param factor defines the start size value to affect to the specified gradient
  54246. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54247. * @returns the current particle system
  54248. */
  54249. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54250. /**
  54251. * Not supported by GPUParticleSystem
  54252. * @param gradient defines the gradient to remove
  54253. * @returns the current particle system
  54254. */
  54255. removeStartSizeGradient(gradient: number): IParticleSystem;
  54256. /**
  54257. * Not supported by GPUParticleSystem
  54258. * @param gradient defines the gradient to use (between 0 and 1)
  54259. * @param min defines the color remap minimal range
  54260. * @param max defines the color remap maximal range
  54261. * @returns the current particle system
  54262. */
  54263. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  54264. /**
  54265. * Not supported by GPUParticleSystem
  54266. * @param gradient defines the gradient to remove
  54267. * @returns the current particle system
  54268. */
  54269. removeColorRemapGradient(): IParticleSystem;
  54270. /**
  54271. * Not supported by GPUParticleSystem
  54272. * @param gradient defines the gradient to use (between 0 and 1)
  54273. * @param min defines the alpha remap minimal range
  54274. * @param max defines the alpha remap maximal range
  54275. * @returns the current particle system
  54276. */
  54277. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  54278. /**
  54279. * Not supported by GPUParticleSystem
  54280. * @param gradient defines the gradient to remove
  54281. * @returns the current particle system
  54282. */
  54283. removeAlphaRemapGradient(): IParticleSystem;
  54284. /**
  54285. * Not supported by GPUParticleSystem
  54286. * @param gradient defines the gradient to use (between 0 and 1)
  54287. * @param color defines the color to affect to the specified gradient
  54288. * @returns the current particle system
  54289. */
  54290. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  54291. /**
  54292. * Not supported by GPUParticleSystem
  54293. * @param gradient defines the gradient to remove
  54294. * @returns the current particle system
  54295. */
  54296. removeRampGradient(): IParticleSystem;
  54297. /**
  54298. * Not supported by GPUParticleSystem
  54299. * @returns the list of ramp gradients
  54300. */
  54301. getRampGradients(): Nullable<Array<Color3Gradient>>;
  54302. /**
  54303. * Not supported by GPUParticleSystem
  54304. * Gets or sets a boolean indicating that ramp gradients must be used
  54305. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  54306. */
  54307. useRampGradients: boolean;
  54308. /**
  54309. * Not supported by GPUParticleSystem
  54310. * @param gradient defines the gradient to use (between 0 and 1)
  54311. * @param factor defines the life time factor to affect to the specified gradient
  54312. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54313. * @returns the current particle system
  54314. */
  54315. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54316. /**
  54317. * Not supported by GPUParticleSystem
  54318. * @param gradient defines the gradient to remove
  54319. * @returns the current particle system
  54320. */
  54321. removeLifeTimeGradient(gradient: number): IParticleSystem;
  54322. /**
  54323. * Instantiates a GPU particle system.
  54324. * 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.
  54325. * @param name The name of the particle system
  54326. * @param options The options used to create the system
  54327. * @param scene The scene the particle system belongs to
  54328. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  54329. */
  54330. constructor(name: string, options: Partial<{
  54331. capacity: number;
  54332. randomTextureSize: number;
  54333. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  54334. protected _reset(): void;
  54335. private _createUpdateVAO;
  54336. private _createRenderVAO;
  54337. private _initialize;
  54338. /** @hidden */
  54339. _recreateUpdateEffect(): void;
  54340. /** @hidden */
  54341. _recreateRenderEffect(): void;
  54342. /**
  54343. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  54344. * @param preWarm defines if we are in the pre-warmimg phase
  54345. */
  54346. animate(preWarm?: boolean): void;
  54347. private _createFactorGradientTexture;
  54348. private _createSizeGradientTexture;
  54349. private _createAngularSpeedGradientTexture;
  54350. private _createVelocityGradientTexture;
  54351. private _createLimitVelocityGradientTexture;
  54352. private _createDragGradientTexture;
  54353. private _createColorGradientTexture;
  54354. /**
  54355. * Renders the particle system in its current state
  54356. * @param preWarm defines if the system should only update the particles but not render them
  54357. * @returns the current number of particles
  54358. */
  54359. render(preWarm?: boolean): number;
  54360. /**
  54361. * Rebuilds the particle system
  54362. */
  54363. rebuild(): void;
  54364. private _releaseBuffers;
  54365. private _releaseVAOs;
  54366. /**
  54367. * Disposes the particle system and free the associated resources
  54368. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  54369. */
  54370. dispose(disposeTexture?: boolean): void;
  54371. /**
  54372. * Clones the particle system.
  54373. * @param name The name of the cloned object
  54374. * @param newEmitter The new emitter to use
  54375. * @returns the cloned particle system
  54376. */
  54377. clone(name: string, newEmitter: any): GPUParticleSystem;
  54378. /**
  54379. * Serializes the particle system to a JSON object.
  54380. * @returns the JSON object
  54381. */
  54382. serialize(): any;
  54383. /**
  54384. * Parses a JSON object to create a GPU particle system.
  54385. * @param parsedParticleSystem The JSON object to parse
  54386. * @param scene The scene to create the particle system in
  54387. * @param rootUrl The root url to use to load external dependencies like texture
  54388. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  54389. * @returns the parsed GPU particle system
  54390. */
  54391. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  54392. }
  54393. }
  54394. declare module BABYLON {
  54395. /**
  54396. * Represents a set of particle systems working together to create a specific effect
  54397. */
  54398. export class ParticleSystemSet implements IDisposable {
  54399. private _emitterCreationOptions;
  54400. private _emitterNode;
  54401. /**
  54402. * Gets the particle system list
  54403. */
  54404. systems: IParticleSystem[];
  54405. /**
  54406. * Gets the emitter node used with this set
  54407. */
  54408. readonly emitterNode: Nullable<TransformNode>;
  54409. /**
  54410. * Creates a new emitter mesh as a sphere
  54411. * @param options defines the options used to create the sphere
  54412. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  54413. * @param scene defines the hosting scene
  54414. */
  54415. setEmitterAsSphere(options: {
  54416. diameter: number;
  54417. segments: number;
  54418. color: Color3;
  54419. }, renderingGroupId: number, scene: Scene): void;
  54420. /**
  54421. * Starts all particle systems of the set
  54422. * @param emitter defines an optional mesh to use as emitter for the particle systems
  54423. */
  54424. start(emitter?: AbstractMesh): void;
  54425. /**
  54426. * Release all associated resources
  54427. */
  54428. dispose(): void;
  54429. /**
  54430. * Serialize the set into a JSON compatible object
  54431. * @returns a JSON compatible representation of the set
  54432. */
  54433. serialize(): any;
  54434. /**
  54435. * Parse a new ParticleSystemSet from a serialized source
  54436. * @param data defines a JSON compatible representation of the set
  54437. * @param scene defines the hosting scene
  54438. * @param gpu defines if we want GPU particles or CPU particles
  54439. * @returns a new ParticleSystemSet
  54440. */
  54441. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  54442. }
  54443. }
  54444. declare module BABYLON {
  54445. /**
  54446. * This class is made for on one-liner static method to help creating particle system set.
  54447. */
  54448. export class ParticleHelper {
  54449. /**
  54450. * Gets or sets base Assets URL
  54451. */
  54452. static BaseAssetsUrl: string;
  54453. /**
  54454. * Create a default particle system that you can tweak
  54455. * @param emitter defines the emitter to use
  54456. * @param capacity defines the system capacity (default is 500 particles)
  54457. * @param scene defines the hosting scene
  54458. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  54459. * @returns the new Particle system
  54460. */
  54461. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  54462. /**
  54463. * This is the main static method (one-liner) of this helper to create different particle systems
  54464. * @param type This string represents the type to the particle system to create
  54465. * @param scene The scene where the particle system should live
  54466. * @param gpu If the system will use gpu
  54467. * @returns the ParticleSystemSet created
  54468. */
  54469. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  54470. /**
  54471. * Static function used to export a particle system to a ParticleSystemSet variable.
  54472. * Please note that the emitter shape is not exported
  54473. * @param systems defines the particle systems to export
  54474. * @returns the created particle system set
  54475. */
  54476. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  54477. }
  54478. }
  54479. declare module BABYLON {
  54480. interface Engine {
  54481. /**
  54482. * Create an effect to use with particle systems.
  54483. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  54484. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  54485. * @param uniformsNames defines a list of attribute names
  54486. * @param samplers defines an array of string used to represent textures
  54487. * @param defines defines the string containing the defines to use to compile the shaders
  54488. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  54489. * @param onCompiled defines a function to call when the effect creation is successful
  54490. * @param onError defines a function to call when the effect creation has failed
  54491. * @returns the new Effect
  54492. */
  54493. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  54494. }
  54495. interface Mesh {
  54496. /**
  54497. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  54498. * @returns an array of IParticleSystem
  54499. */
  54500. getEmittedParticleSystems(): IParticleSystem[];
  54501. /**
  54502. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  54503. * @returns an array of IParticleSystem
  54504. */
  54505. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  54506. }
  54507. /**
  54508. * @hidden
  54509. */
  54510. export var _IDoNeedToBeInTheBuild: number;
  54511. }
  54512. declare module BABYLON {
  54513. interface Scene {
  54514. /** @hidden (Backing field) */
  54515. _physicsEngine: Nullable<IPhysicsEngine>;
  54516. /**
  54517. * Gets the current physics engine
  54518. * @returns a IPhysicsEngine or null if none attached
  54519. */
  54520. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  54521. /**
  54522. * Enables physics to the current scene
  54523. * @param gravity defines the scene's gravity for the physics engine
  54524. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  54525. * @return a boolean indicating if the physics engine was initialized
  54526. */
  54527. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  54528. /**
  54529. * Disables and disposes the physics engine associated with the scene
  54530. */
  54531. disablePhysicsEngine(): void;
  54532. /**
  54533. * Gets a boolean indicating if there is an active physics engine
  54534. * @returns a boolean indicating if there is an active physics engine
  54535. */
  54536. isPhysicsEnabled(): boolean;
  54537. /**
  54538. * Deletes a physics compound impostor
  54539. * @param compound defines the compound to delete
  54540. */
  54541. deleteCompoundImpostor(compound: any): void;
  54542. /**
  54543. * An event triggered when physic simulation is about to be run
  54544. */
  54545. onBeforePhysicsObservable: Observable<Scene>;
  54546. /**
  54547. * An event triggered when physic simulation has been done
  54548. */
  54549. onAfterPhysicsObservable: Observable<Scene>;
  54550. }
  54551. interface AbstractMesh {
  54552. /** @hidden */
  54553. _physicsImpostor: Nullable<PhysicsImpostor>;
  54554. /**
  54555. * Gets or sets impostor used for physic simulation
  54556. * @see http://doc.babylonjs.com/features/physics_engine
  54557. */
  54558. physicsImpostor: Nullable<PhysicsImpostor>;
  54559. /**
  54560. * Gets the current physics impostor
  54561. * @see http://doc.babylonjs.com/features/physics_engine
  54562. * @returns a physics impostor or null
  54563. */
  54564. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  54565. /** Apply a physic impulse to the mesh
  54566. * @param force defines the force to apply
  54567. * @param contactPoint defines where to apply the force
  54568. * @returns the current mesh
  54569. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54570. */
  54571. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  54572. /**
  54573. * Creates a physic joint between two meshes
  54574. * @param otherMesh defines the other mesh to use
  54575. * @param pivot1 defines the pivot to use on this mesh
  54576. * @param pivot2 defines the pivot to use on the other mesh
  54577. * @param options defines additional options (can be plugin dependent)
  54578. * @returns the current mesh
  54579. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  54580. */
  54581. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  54582. /** @hidden */
  54583. _disposePhysicsObserver: Nullable<Observer<Node>>;
  54584. }
  54585. /**
  54586. * Defines the physics engine scene component responsible to manage a physics engine
  54587. */
  54588. export class PhysicsEngineSceneComponent implements ISceneComponent {
  54589. /**
  54590. * The component name helpful to identify the component in the list of scene components.
  54591. */
  54592. readonly name: string;
  54593. /**
  54594. * The scene the component belongs to.
  54595. */
  54596. scene: Scene;
  54597. /**
  54598. * Creates a new instance of the component for the given scene
  54599. * @param scene Defines the scene to register the component in
  54600. */
  54601. constructor(scene: Scene);
  54602. /**
  54603. * Registers the component in a given scene
  54604. */
  54605. register(): void;
  54606. /**
  54607. * Rebuilds the elements related to this component in case of
  54608. * context lost for instance.
  54609. */
  54610. rebuild(): void;
  54611. /**
  54612. * Disposes the component and the associated ressources
  54613. */
  54614. dispose(): void;
  54615. }
  54616. }
  54617. declare module BABYLON {
  54618. /**
  54619. * A helper for physics simulations
  54620. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54621. */
  54622. export class PhysicsHelper {
  54623. private _scene;
  54624. private _physicsEngine;
  54625. /**
  54626. * Initializes the Physics helper
  54627. * @param scene Babylon.js scene
  54628. */
  54629. constructor(scene: Scene);
  54630. /**
  54631. * Applies a radial explosion impulse
  54632. * @param origin the origin of the explosion
  54633. * @param radiusOrEventOptions the radius or the options of radial explosion
  54634. * @param strength the explosion strength
  54635. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54636. * @returns A physics radial explosion event, or null
  54637. */
  54638. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54639. /**
  54640. * Applies a radial explosion force
  54641. * @param origin the origin of the explosion
  54642. * @param radiusOrEventOptions the radius or the options of radial explosion
  54643. * @param strength the explosion strength
  54644. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54645. * @returns A physics radial explosion event, or null
  54646. */
  54647. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54648. /**
  54649. * Creates a gravitational field
  54650. * @param origin the origin of the explosion
  54651. * @param radiusOrEventOptions the radius or the options of radial explosion
  54652. * @param strength the explosion strength
  54653. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54654. * @returns A physics gravitational field event, or null
  54655. */
  54656. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  54657. /**
  54658. * Creates a physics updraft event
  54659. * @param origin the origin of the updraft
  54660. * @param radiusOrEventOptions the radius or the options of the updraft
  54661. * @param strength the strength of the updraft
  54662. * @param height the height of the updraft
  54663. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  54664. * @returns A physics updraft event, or null
  54665. */
  54666. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  54667. /**
  54668. * Creates a physics vortex event
  54669. * @param origin the of the vortex
  54670. * @param radiusOrEventOptions the radius or the options of the vortex
  54671. * @param strength the strength of the vortex
  54672. * @param height the height of the vortex
  54673. * @returns a Physics vortex event, or null
  54674. * A physics vortex event or null
  54675. */
  54676. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  54677. }
  54678. /**
  54679. * Represents a physics radial explosion event
  54680. */
  54681. class PhysicsRadialExplosionEvent {
  54682. private _scene;
  54683. private _options;
  54684. private _sphere;
  54685. private _dataFetched;
  54686. /**
  54687. * Initializes a radial explosioin event
  54688. * @param _scene BabylonJS scene
  54689. * @param _options The options for the vortex event
  54690. */
  54691. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  54692. /**
  54693. * Returns the data related to the radial explosion event (sphere).
  54694. * @returns The radial explosion event data
  54695. */
  54696. getData(): PhysicsRadialExplosionEventData;
  54697. /**
  54698. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  54699. * @param impostor A physics imposter
  54700. * @param origin the origin of the explosion
  54701. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  54702. */
  54703. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  54704. /**
  54705. * Triggers affecterd impostors callbacks
  54706. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  54707. */
  54708. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  54709. /**
  54710. * Disposes the sphere.
  54711. * @param force Specifies if the sphere should be disposed by force
  54712. */
  54713. dispose(force?: boolean): void;
  54714. /*** Helpers ***/
  54715. private _prepareSphere;
  54716. private _intersectsWithSphere;
  54717. }
  54718. /**
  54719. * Represents a gravitational field event
  54720. */
  54721. class PhysicsGravitationalFieldEvent {
  54722. private _physicsHelper;
  54723. private _scene;
  54724. private _origin;
  54725. private _options;
  54726. private _tickCallback;
  54727. private _sphere;
  54728. private _dataFetched;
  54729. /**
  54730. * Initializes the physics gravitational field event
  54731. * @param _physicsHelper A physics helper
  54732. * @param _scene BabylonJS scene
  54733. * @param _origin The origin position of the gravitational field event
  54734. * @param _options The options for the vortex event
  54735. */
  54736. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  54737. /**
  54738. * Returns the data related to the gravitational field event (sphere).
  54739. * @returns A gravitational field event
  54740. */
  54741. getData(): PhysicsGravitationalFieldEventData;
  54742. /**
  54743. * Enables the gravitational field.
  54744. */
  54745. enable(): void;
  54746. /**
  54747. * Disables the gravitational field.
  54748. */
  54749. disable(): void;
  54750. /**
  54751. * Disposes the sphere.
  54752. * @param force The force to dispose from the gravitational field event
  54753. */
  54754. dispose(force?: boolean): void;
  54755. private _tick;
  54756. }
  54757. /**
  54758. * Represents a physics updraft event
  54759. */
  54760. class PhysicsUpdraftEvent {
  54761. private _scene;
  54762. private _origin;
  54763. private _options;
  54764. private _physicsEngine;
  54765. private _originTop;
  54766. private _originDirection;
  54767. private _tickCallback;
  54768. private _cylinder;
  54769. private _cylinderPosition;
  54770. private _dataFetched;
  54771. /**
  54772. * Initializes the physics updraft event
  54773. * @param _scene BabylonJS scene
  54774. * @param _origin The origin position of the updraft
  54775. * @param _options The options for the updraft event
  54776. */
  54777. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  54778. /**
  54779. * Returns the data related to the updraft event (cylinder).
  54780. * @returns A physics updraft event
  54781. */
  54782. getData(): PhysicsUpdraftEventData;
  54783. /**
  54784. * Enables the updraft.
  54785. */
  54786. enable(): void;
  54787. /**
  54788. * Disables the updraft.
  54789. */
  54790. disable(): void;
  54791. /**
  54792. * Disposes the cylinder.
  54793. * @param force Specifies if the updraft should be disposed by force
  54794. */
  54795. dispose(force?: boolean): void;
  54796. private getImpostorHitData;
  54797. private _tick;
  54798. /*** Helpers ***/
  54799. private _prepareCylinder;
  54800. private _intersectsWithCylinder;
  54801. }
  54802. /**
  54803. * Represents a physics vortex event
  54804. */
  54805. class PhysicsVortexEvent {
  54806. private _scene;
  54807. private _origin;
  54808. private _options;
  54809. private _physicsEngine;
  54810. private _originTop;
  54811. private _tickCallback;
  54812. private _cylinder;
  54813. private _cylinderPosition;
  54814. private _dataFetched;
  54815. /**
  54816. * Initializes the physics vortex event
  54817. * @param _scene The BabylonJS scene
  54818. * @param _origin The origin position of the vortex
  54819. * @param _options The options for the vortex event
  54820. */
  54821. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  54822. /**
  54823. * Returns the data related to the vortex event (cylinder).
  54824. * @returns The physics vortex event data
  54825. */
  54826. getData(): PhysicsVortexEventData;
  54827. /**
  54828. * Enables the vortex.
  54829. */
  54830. enable(): void;
  54831. /**
  54832. * Disables the cortex.
  54833. */
  54834. disable(): void;
  54835. /**
  54836. * Disposes the sphere.
  54837. * @param force
  54838. */
  54839. dispose(force?: boolean): void;
  54840. private getImpostorHitData;
  54841. private _tick;
  54842. /*** Helpers ***/
  54843. private _prepareCylinder;
  54844. private _intersectsWithCylinder;
  54845. }
  54846. /**
  54847. * Options fot the radial explosion event
  54848. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54849. */
  54850. export class PhysicsRadialExplosionEventOptions {
  54851. /**
  54852. * The radius of the sphere for the radial explosion.
  54853. */
  54854. radius: number;
  54855. /**
  54856. * The strenth of the explosion.
  54857. */
  54858. strength: number;
  54859. /**
  54860. * The strenght of the force in correspondence to the distance of the affected object
  54861. */
  54862. falloff: PhysicsRadialImpulseFalloff;
  54863. /**
  54864. * Sphere options for the radial explosion.
  54865. */
  54866. sphere: {
  54867. segments: number;
  54868. diameter: number;
  54869. };
  54870. /**
  54871. * Sphere options for the radial explosion.
  54872. */
  54873. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54874. }
  54875. /**
  54876. * Options fot the updraft event
  54877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54878. */
  54879. export class PhysicsUpdraftEventOptions {
  54880. /**
  54881. * The radius of the cylinder for the vortex
  54882. */
  54883. radius: number;
  54884. /**
  54885. * The strenth of the updraft.
  54886. */
  54887. strength: number;
  54888. /**
  54889. * The height of the cylinder for the updraft.
  54890. */
  54891. height: number;
  54892. /**
  54893. * The mode for the the updraft.
  54894. */
  54895. updraftMode: PhysicsUpdraftMode;
  54896. }
  54897. /**
  54898. * Options fot the vortex event
  54899. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54900. */
  54901. export class PhysicsVortexEventOptions {
  54902. /**
  54903. * The radius of the cylinder for the vortex
  54904. */
  54905. radius: number;
  54906. /**
  54907. * The strenth of the vortex.
  54908. */
  54909. strength: number;
  54910. /**
  54911. * The height of the cylinder for the vortex.
  54912. */
  54913. height: number;
  54914. /**
  54915. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54916. */
  54917. centripetalForceThreshold: number;
  54918. /**
  54919. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54920. */
  54921. centripetalForceMultiplier: number;
  54922. /**
  54923. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54924. */
  54925. centrifugalForceMultiplier: number;
  54926. /**
  54927. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54928. */
  54929. updraftForceMultiplier: number;
  54930. }
  54931. /**
  54932. * The strenght of the force in correspondence to the distance of the affected object
  54933. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54934. */
  54935. export enum PhysicsRadialImpulseFalloff {
  54936. /** Defines that impulse is constant in strength across it's whole radius */
  54937. Constant = 0,
  54938. /** Defines that impulse gets weaker if it's further from the origin */
  54939. Linear = 1
  54940. }
  54941. /**
  54942. * The strength of the force in correspondence to the distance of the affected object
  54943. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54944. */
  54945. export enum PhysicsUpdraftMode {
  54946. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54947. Center = 0,
  54948. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54949. Perpendicular = 1
  54950. }
  54951. /**
  54952. * Interface for a physics hit data
  54953. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54954. */
  54955. export interface PhysicsHitData {
  54956. /**
  54957. * The force applied at the contact point
  54958. */
  54959. force: Vector3;
  54960. /**
  54961. * The contact point
  54962. */
  54963. contactPoint: Vector3;
  54964. /**
  54965. * The distance from the origin to the contact point
  54966. */
  54967. distanceFromOrigin: number;
  54968. }
  54969. /**
  54970. * Interface for radial explosion event data
  54971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54972. */
  54973. export interface PhysicsRadialExplosionEventData {
  54974. /**
  54975. * A sphere used for the radial explosion event
  54976. */
  54977. sphere: Mesh;
  54978. }
  54979. /**
  54980. * Interface for gravitational field event data
  54981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54982. */
  54983. export interface PhysicsGravitationalFieldEventData {
  54984. /**
  54985. * A sphere mesh used for the gravitational field event
  54986. */
  54987. sphere: Mesh;
  54988. }
  54989. /**
  54990. * Interface for updraft event data
  54991. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54992. */
  54993. export interface PhysicsUpdraftEventData {
  54994. /**
  54995. * A cylinder used for the updraft event
  54996. */
  54997. cylinder: Mesh;
  54998. }
  54999. /**
  55000. * Interface for vortex event data
  55001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55002. */
  55003. export interface PhysicsVortexEventData {
  55004. /**
  55005. * A cylinder used for the vortex event
  55006. */
  55007. cylinder: Mesh;
  55008. }
  55009. /**
  55010. * Interface for an affected physics impostor
  55011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55012. */
  55013. export interface PhysicsAffectedImpostorWithData {
  55014. /**
  55015. * The impostor affected by the effect
  55016. */
  55017. impostor: PhysicsImpostor;
  55018. /**
  55019. * The data about the hit/horce from the explosion
  55020. */
  55021. hitData: PhysicsHitData;
  55022. }
  55023. }
  55024. declare module BABYLON {
  55025. /** @hidden */
  55026. export var blackAndWhitePixelShader: {
  55027. name: string;
  55028. shader: string;
  55029. };
  55030. }
  55031. declare module BABYLON {
  55032. /**
  55033. * Post process used to render in black and white
  55034. */
  55035. export class BlackAndWhitePostProcess extends PostProcess {
  55036. /**
  55037. * Linear about to convert he result to black and white (default: 1)
  55038. */
  55039. degree: number;
  55040. /**
  55041. * Creates a black and white post process
  55042. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  55043. * @param name The name of the effect.
  55044. * @param options The required width/height ratio to downsize to before computing the render pass.
  55045. * @param camera The camera to apply the render pass to.
  55046. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55047. * @param engine The engine which the post process will be applied. (default: current engine)
  55048. * @param reusable If the post process can be reused on the same frame. (default: false)
  55049. */
  55050. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55051. }
  55052. }
  55053. declare module BABYLON {
  55054. /**
  55055. * This represents a set of one or more post processes in Babylon.
  55056. * A post process can be used to apply a shader to a texture after it is rendered.
  55057. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55058. */
  55059. export class PostProcessRenderEffect {
  55060. private _postProcesses;
  55061. private _getPostProcesses;
  55062. private _singleInstance;
  55063. private _cameras;
  55064. private _indicesForCamera;
  55065. /**
  55066. * Name of the effect
  55067. * @hidden
  55068. */
  55069. _name: string;
  55070. /**
  55071. * Instantiates a post process render effect.
  55072. * A post process can be used to apply a shader to a texture after it is rendered.
  55073. * @param engine The engine the effect is tied to
  55074. * @param name The name of the effect
  55075. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  55076. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  55077. */
  55078. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  55079. /**
  55080. * Checks if all the post processes in the effect are supported.
  55081. */
  55082. readonly isSupported: boolean;
  55083. /**
  55084. * Updates the current state of the effect
  55085. * @hidden
  55086. */
  55087. _update(): void;
  55088. /**
  55089. * Attaches the effect on cameras
  55090. * @param cameras The camera to attach to.
  55091. * @hidden
  55092. */
  55093. _attachCameras(cameras: Camera): void;
  55094. /**
  55095. * Attaches the effect on cameras
  55096. * @param cameras The camera to attach to.
  55097. * @hidden
  55098. */
  55099. _attachCameras(cameras: Camera[]): void;
  55100. /**
  55101. * Detaches the effect on cameras
  55102. * @param cameras The camera to detatch from.
  55103. * @hidden
  55104. */
  55105. _detachCameras(cameras: Camera): void;
  55106. /**
  55107. * Detatches the effect on cameras
  55108. * @param cameras The camera to detatch from.
  55109. * @hidden
  55110. */
  55111. _detachCameras(cameras: Camera[]): void;
  55112. /**
  55113. * Enables the effect on given cameras
  55114. * @param cameras The camera to enable.
  55115. * @hidden
  55116. */
  55117. _enable(cameras: Camera): void;
  55118. /**
  55119. * Enables the effect on given cameras
  55120. * @param cameras The camera to enable.
  55121. * @hidden
  55122. */
  55123. _enable(cameras: Nullable<Camera[]>): void;
  55124. /**
  55125. * Disables the effect on the given cameras
  55126. * @param cameras The camera to disable.
  55127. * @hidden
  55128. */
  55129. _disable(cameras: Camera): void;
  55130. /**
  55131. * Disables the effect on the given cameras
  55132. * @param cameras The camera to disable.
  55133. * @hidden
  55134. */
  55135. _disable(cameras: Nullable<Camera[]>): void;
  55136. /**
  55137. * Gets a list of the post processes contained in the effect.
  55138. * @param camera The camera to get the post processes on.
  55139. * @returns The list of the post processes in the effect.
  55140. */
  55141. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  55142. }
  55143. }
  55144. declare module BABYLON {
  55145. /** @hidden */
  55146. export var extractHighlightsPixelShader: {
  55147. name: string;
  55148. shader: string;
  55149. };
  55150. }
  55151. declare module BABYLON {
  55152. /**
  55153. * 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.
  55154. */
  55155. export class ExtractHighlightsPostProcess extends PostProcess {
  55156. /**
  55157. * The luminance threshold, pixels below this value will be set to black.
  55158. */
  55159. threshold: number;
  55160. /** @hidden */
  55161. _exposure: number;
  55162. /**
  55163. * Post process which has the input texture to be used when performing highlight extraction
  55164. * @hidden
  55165. */
  55166. _inputPostProcess: Nullable<PostProcess>;
  55167. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55168. }
  55169. }
  55170. declare module BABYLON {
  55171. /** @hidden */
  55172. export var bloomMergePixelShader: {
  55173. name: string;
  55174. shader: string;
  55175. };
  55176. }
  55177. declare module BABYLON {
  55178. /**
  55179. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55180. */
  55181. export class BloomMergePostProcess extends PostProcess {
  55182. /** Weight of the bloom to be added to the original input. */
  55183. weight: number;
  55184. /**
  55185. * Creates a new instance of @see BloomMergePostProcess
  55186. * @param name The name of the effect.
  55187. * @param originalFromInput Post process which's input will be used for the merge.
  55188. * @param blurred Blurred highlights post process which's output will be used.
  55189. * @param weight Weight of the bloom to be added to the original input.
  55190. * @param options The required width/height ratio to downsize to before computing the render pass.
  55191. * @param camera The camera to apply the render pass to.
  55192. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55193. * @param engine The engine which the post process will be applied. (default: current engine)
  55194. * @param reusable If the post process can be reused on the same frame. (default: false)
  55195. * @param textureType Type of textures used when performing the post process. (default: 0)
  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(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  55199. /** Weight of the bloom to be added to the original input. */
  55200. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55201. }
  55202. }
  55203. declare module BABYLON {
  55204. /**
  55205. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  55206. */
  55207. export class BloomEffect extends PostProcessRenderEffect {
  55208. private bloomScale;
  55209. /**
  55210. * @hidden Internal
  55211. */
  55212. _effects: Array<PostProcess>;
  55213. /**
  55214. * @hidden Internal
  55215. */
  55216. _downscale: ExtractHighlightsPostProcess;
  55217. private _blurX;
  55218. private _blurY;
  55219. private _merge;
  55220. /**
  55221. * The luminance threshold to find bright areas of the image to bloom.
  55222. */
  55223. threshold: number;
  55224. /**
  55225. * The strength of the bloom.
  55226. */
  55227. weight: number;
  55228. /**
  55229. * Specifies the size of the bloom blur kernel, relative to the final output size
  55230. */
  55231. kernel: number;
  55232. /**
  55233. * Creates a new instance of @see BloomEffect
  55234. * @param scene The scene the effect belongs to.
  55235. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  55236. * @param bloomKernel The size of the kernel to be used when applying the blur.
  55237. * @param bloomWeight The the strength of bloom.
  55238. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55239. * @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)
  55240. */
  55241. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  55242. /**
  55243. * Disposes each of the internal effects for a given camera.
  55244. * @param camera The camera to dispose the effect on.
  55245. */
  55246. disposeEffects(camera: Camera): void;
  55247. /**
  55248. * @hidden Internal
  55249. */
  55250. _updateEffects(): void;
  55251. /**
  55252. * Internal
  55253. * @returns if all the contained post processes are ready.
  55254. * @hidden
  55255. */
  55256. _isReady(): boolean;
  55257. }
  55258. }
  55259. declare module BABYLON {
  55260. /** @hidden */
  55261. export var chromaticAberrationPixelShader: {
  55262. name: string;
  55263. shader: string;
  55264. };
  55265. }
  55266. declare module BABYLON {
  55267. /**
  55268. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  55269. */
  55270. export class ChromaticAberrationPostProcess extends PostProcess {
  55271. /**
  55272. * The amount of seperation of rgb channels (default: 30)
  55273. */
  55274. aberrationAmount: number;
  55275. /**
  55276. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  55277. */
  55278. radialIntensity: number;
  55279. /**
  55280. * 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))
  55281. */
  55282. direction: Vector2;
  55283. /**
  55284. * 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))
  55285. */
  55286. centerPosition: Vector2;
  55287. /**
  55288. * Creates a new instance ChromaticAberrationPostProcess
  55289. * @param name The name of the effect.
  55290. * @param screenWidth The width of the screen to apply the effect on.
  55291. * @param screenHeight The height of the screen to apply the effect on.
  55292. * @param options The required width/height ratio to downsize to before computing the render pass.
  55293. * @param camera The camera to apply the render pass to.
  55294. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55295. * @param engine The engine which the post process will be applied. (default: current engine)
  55296. * @param reusable If the post process can be reused on the same frame. (default: false)
  55297. * @param textureType Type of textures used when performing the post process. (default: 0)
  55298. * @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)
  55299. */
  55300. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55301. }
  55302. }
  55303. declare module BABYLON {
  55304. /** @hidden */
  55305. export var circleOfConfusionPixelShader: {
  55306. name: string;
  55307. shader: string;
  55308. };
  55309. }
  55310. declare module BABYLON {
  55311. /**
  55312. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  55313. */
  55314. export class CircleOfConfusionPostProcess extends PostProcess {
  55315. /**
  55316. * 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.
  55317. */
  55318. lensSize: number;
  55319. /**
  55320. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55321. */
  55322. fStop: number;
  55323. /**
  55324. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55325. */
  55326. focusDistance: number;
  55327. /**
  55328. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  55329. */
  55330. focalLength: number;
  55331. private _depthTexture;
  55332. /**
  55333. * Creates a new instance CircleOfConfusionPostProcess
  55334. * @param name The name of the effect.
  55335. * @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.
  55336. * @param options The required width/height ratio to downsize to before computing the render pass.
  55337. * @param camera The camera to apply the render pass to.
  55338. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55339. * @param engine The engine which the post process will be applied. (default: current engine)
  55340. * @param reusable If the post process can be reused on the same frame. (default: false)
  55341. * @param textureType Type of textures used when performing the post process. (default: 0)
  55342. * @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)
  55343. */
  55344. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55345. /**
  55346. * 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.
  55347. */
  55348. depthTexture: RenderTargetTexture;
  55349. }
  55350. }
  55351. declare module BABYLON {
  55352. /** @hidden */
  55353. export var colorCorrectionPixelShader: {
  55354. name: string;
  55355. shader: string;
  55356. };
  55357. }
  55358. declare module BABYLON {
  55359. /**
  55360. *
  55361. * This post-process allows the modification of rendered colors by using
  55362. * a 'look-up table' (LUT). This effect is also called Color Grading.
  55363. *
  55364. * The object needs to be provided an url to a texture containing the color
  55365. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  55366. * Use an image editing software to tweak the LUT to match your needs.
  55367. *
  55368. * For an example of a color LUT, see here:
  55369. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  55370. * For explanations on color grading, see here:
  55371. * @see http://udn.epicgames.com/Three/ColorGrading.html
  55372. *
  55373. */
  55374. export class ColorCorrectionPostProcess extends PostProcess {
  55375. private _colorTableTexture;
  55376. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55377. }
  55378. }
  55379. declare module BABYLON {
  55380. /** @hidden */
  55381. export var convolutionPixelShader: {
  55382. name: string;
  55383. shader: string;
  55384. };
  55385. }
  55386. declare module BABYLON {
  55387. /**
  55388. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  55389. * input texture to perform effects such as edge detection or sharpening
  55390. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55391. */
  55392. export class ConvolutionPostProcess extends PostProcess {
  55393. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  55394. kernel: number[];
  55395. /**
  55396. * Creates a new instance ConvolutionPostProcess
  55397. * @param name The name of the effect.
  55398. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  55399. * @param options The required width/height ratio to downsize to before computing the render pass.
  55400. * @param camera The camera to apply the render pass to.
  55401. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55402. * @param engine The engine which the post process will be applied. (default: current engine)
  55403. * @param reusable If the post process can be reused on the same frame. (default: false)
  55404. * @param textureType Type of textures used when performing the post process. (default: 0)
  55405. */
  55406. constructor(name: string,
  55407. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  55408. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55409. /**
  55410. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55411. */
  55412. static EdgeDetect0Kernel: number[];
  55413. /**
  55414. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55415. */
  55416. static EdgeDetect1Kernel: number[];
  55417. /**
  55418. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55419. */
  55420. static EdgeDetect2Kernel: number[];
  55421. /**
  55422. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55423. */
  55424. static SharpenKernel: number[];
  55425. /**
  55426. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55427. */
  55428. static EmbossKernel: number[];
  55429. /**
  55430. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55431. */
  55432. static GaussianKernel: number[];
  55433. }
  55434. }
  55435. declare module BABYLON {
  55436. /**
  55437. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  55438. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  55439. * based on samples that have a large difference in distance than the center pixel.
  55440. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  55441. */
  55442. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  55443. direction: Vector2;
  55444. /**
  55445. * Creates a new instance CircleOfConfusionPostProcess
  55446. * @param name The name of the effect.
  55447. * @param scene The scene the effect belongs to.
  55448. * @param direction The direction the blur should be applied.
  55449. * @param kernel The size of the kernel used to blur.
  55450. * @param options The required width/height ratio to downsize to before computing the render pass.
  55451. * @param camera The camera to apply the render pass to.
  55452. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  55453. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  55454. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55455. * @param engine The engine which the post process will be applied. (default: current engine)
  55456. * @param reusable If the post process can be reused on the same frame. (default: false)
  55457. * @param textureType Type of textures used when performing the post process. (default: 0)
  55458. * @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)
  55459. */
  55460. 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);
  55461. }
  55462. }
  55463. declare module BABYLON {
  55464. /** @hidden */
  55465. export var depthOfFieldMergePixelShader: {
  55466. name: string;
  55467. shader: string;
  55468. };
  55469. }
  55470. declare module BABYLON {
  55471. /**
  55472. * Options to be set when merging outputs from the default pipeline.
  55473. */
  55474. export class DepthOfFieldMergePostProcessOptions {
  55475. /**
  55476. * The original image to merge on top of
  55477. */
  55478. originalFromInput: PostProcess;
  55479. /**
  55480. * Parameters to perform the merge of the depth of field effect
  55481. */
  55482. depthOfField?: {
  55483. circleOfConfusion: PostProcess;
  55484. blurSteps: Array<PostProcess>;
  55485. };
  55486. /**
  55487. * Parameters to perform the merge of bloom effect
  55488. */
  55489. bloom?: {
  55490. blurred: PostProcess;
  55491. weight: number;
  55492. };
  55493. }
  55494. /**
  55495. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55496. */
  55497. export class DepthOfFieldMergePostProcess extends PostProcess {
  55498. private blurSteps;
  55499. /**
  55500. * Creates a new instance of DepthOfFieldMergePostProcess
  55501. * @param name The name of the effect.
  55502. * @param originalFromInput Post process which's input will be used for the merge.
  55503. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  55504. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  55505. * @param options The required width/height ratio to downsize to before computing the render pass.
  55506. * @param camera The camera to apply the render pass to.
  55507. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55508. * @param engine The engine which the post process will be applied. (default: current engine)
  55509. * @param reusable If the post process can be reused on the same frame. (default: false)
  55510. * @param textureType Type of textures used when performing the post process. (default: 0)
  55511. * @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)
  55512. */
  55513. 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);
  55514. /**
  55515. * Updates the effect with the current post process compile time values and recompiles the shader.
  55516. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  55517. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  55518. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  55519. * @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
  55520. * @param onCompiled Called when the shader has been compiled.
  55521. * @param onError Called if there is an error when compiling a shader.
  55522. */
  55523. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  55524. }
  55525. }
  55526. declare module BABYLON {
  55527. /**
  55528. * Specifies the level of max blur that should be applied when using the depth of field effect
  55529. */
  55530. export enum DepthOfFieldEffectBlurLevel {
  55531. /**
  55532. * Subtle blur
  55533. */
  55534. Low = 0,
  55535. /**
  55536. * Medium blur
  55537. */
  55538. Medium = 1,
  55539. /**
  55540. * Large blur
  55541. */
  55542. High = 2
  55543. }
  55544. /**
  55545. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  55546. */
  55547. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  55548. private _circleOfConfusion;
  55549. /**
  55550. * @hidden Internal, blurs from high to low
  55551. */
  55552. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  55553. private _depthOfFieldBlurY;
  55554. private _dofMerge;
  55555. /**
  55556. * @hidden Internal post processes in depth of field effect
  55557. */
  55558. _effects: Array<PostProcess>;
  55559. /**
  55560. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  55561. */
  55562. focalLength: number;
  55563. /**
  55564. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55565. */
  55566. fStop: number;
  55567. /**
  55568. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55569. */
  55570. focusDistance: number;
  55571. /**
  55572. * 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.
  55573. */
  55574. lensSize: number;
  55575. /**
  55576. * Creates a new instance DepthOfFieldEffect
  55577. * @param scene The scene the effect belongs to.
  55578. * @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.
  55579. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55580. * @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)
  55581. */
  55582. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  55583. /**
  55584. * Get the current class name of the current effet
  55585. * @returns "DepthOfFieldEffect"
  55586. */
  55587. getClassName(): string;
  55588. /**
  55589. * 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.
  55590. */
  55591. depthTexture: RenderTargetTexture;
  55592. /**
  55593. * Disposes each of the internal effects for a given camera.
  55594. * @param camera The camera to dispose the effect on.
  55595. */
  55596. disposeEffects(camera: Camera): void;
  55597. /**
  55598. * @hidden Internal
  55599. */
  55600. _updateEffects(): void;
  55601. /**
  55602. * Internal
  55603. * @returns if all the contained post processes are ready.
  55604. * @hidden
  55605. */
  55606. _isReady(): boolean;
  55607. }
  55608. }
  55609. declare module BABYLON {
  55610. /** @hidden */
  55611. export var displayPassPixelShader: {
  55612. name: string;
  55613. shader: string;
  55614. };
  55615. }
  55616. declare module BABYLON {
  55617. /**
  55618. * DisplayPassPostProcess which produces an output the same as it's input
  55619. */
  55620. export class DisplayPassPostProcess extends PostProcess {
  55621. /**
  55622. * Creates the DisplayPassPostProcess
  55623. * @param name The name of the effect.
  55624. * @param options The required width/height ratio to downsize to before computing the render pass.
  55625. * @param camera The camera to apply the render pass to.
  55626. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55627. * @param engine The engine which the post process will be applied. (default: current engine)
  55628. * @param reusable If the post process can be reused on the same frame. (default: false)
  55629. */
  55630. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55631. }
  55632. }
  55633. declare module BABYLON {
  55634. /** @hidden */
  55635. export var filterPixelShader: {
  55636. name: string;
  55637. shader: string;
  55638. };
  55639. }
  55640. declare module BABYLON {
  55641. /**
  55642. * Applies a kernel filter to the image
  55643. */
  55644. export class FilterPostProcess extends PostProcess {
  55645. /** The matrix to be applied to the image */
  55646. kernelMatrix: Matrix;
  55647. /**
  55648. *
  55649. * @param name The name of the effect.
  55650. * @param kernelMatrix The matrix to be applied to the image
  55651. * @param options The required width/height ratio to downsize to before computing the render pass.
  55652. * @param camera The camera to apply the render pass to.
  55653. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55654. * @param engine The engine which the post process will be applied. (default: current engine)
  55655. * @param reusable If the post process can be reused on the same frame. (default: false)
  55656. */
  55657. constructor(name: string,
  55658. /** The matrix to be applied to the image */
  55659. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55660. }
  55661. }
  55662. declare module BABYLON {
  55663. /** @hidden */
  55664. export var fxaaPixelShader: {
  55665. name: string;
  55666. shader: string;
  55667. };
  55668. }
  55669. declare module BABYLON {
  55670. /** @hidden */
  55671. export var fxaaVertexShader: {
  55672. name: string;
  55673. shader: string;
  55674. };
  55675. }
  55676. declare module BABYLON {
  55677. /**
  55678. * Fxaa post process
  55679. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  55680. */
  55681. export class FxaaPostProcess extends PostProcess {
  55682. /** @hidden */
  55683. texelWidth: number;
  55684. /** @hidden */
  55685. texelHeight: number;
  55686. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55687. private _getDefines;
  55688. }
  55689. }
  55690. declare module BABYLON {
  55691. /** @hidden */
  55692. export var grainPixelShader: {
  55693. name: string;
  55694. shader: string;
  55695. };
  55696. }
  55697. declare module BABYLON {
  55698. /**
  55699. * The GrainPostProcess adds noise to the image at mid luminance levels
  55700. */
  55701. export class GrainPostProcess extends PostProcess {
  55702. /**
  55703. * The intensity of the grain added (default: 30)
  55704. */
  55705. intensity: number;
  55706. /**
  55707. * If the grain should be randomized on every frame
  55708. */
  55709. animated: boolean;
  55710. /**
  55711. * Creates a new instance of @see GrainPostProcess
  55712. * @param name The name of the effect.
  55713. * @param options The required width/height ratio to downsize to before computing the render pass.
  55714. * @param camera The camera to apply the render pass to.
  55715. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55716. * @param engine The engine which the post process will be applied. (default: current engine)
  55717. * @param reusable If the post process can be reused on the same frame. (default: false)
  55718. * @param textureType Type of textures used when performing the post process. (default: 0)
  55719. * @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)
  55720. */
  55721. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55722. }
  55723. }
  55724. declare module BABYLON {
  55725. /** @hidden */
  55726. export var highlightsPixelShader: {
  55727. name: string;
  55728. shader: string;
  55729. };
  55730. }
  55731. declare module BABYLON {
  55732. /**
  55733. * Extracts highlights from the image
  55734. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55735. */
  55736. export class HighlightsPostProcess extends PostProcess {
  55737. /**
  55738. * Extracts highlights from the image
  55739. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55740. * @param name The name of the effect.
  55741. * @param options The required width/height ratio to downsize to before computing the render pass.
  55742. * @param camera The camera to apply the render pass to.
  55743. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55744. * @param engine The engine which the post process will be applied. (default: current engine)
  55745. * @param reusable If the post process can be reused on the same frame. (default: false)
  55746. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  55747. */
  55748. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55749. }
  55750. }
  55751. declare module BABYLON {
  55752. /** @hidden */
  55753. export var mrtFragmentDeclaration: {
  55754. name: string;
  55755. shader: string;
  55756. };
  55757. }
  55758. declare module BABYLON {
  55759. /** @hidden */
  55760. export var geometryPixelShader: {
  55761. name: string;
  55762. shader: string;
  55763. };
  55764. }
  55765. declare module BABYLON {
  55766. /** @hidden */
  55767. export var geometryVertexShader: {
  55768. name: string;
  55769. shader: string;
  55770. };
  55771. }
  55772. declare module BABYLON {
  55773. /** @hidden */
  55774. interface ISavedTransformationMatrix {
  55775. world: Matrix;
  55776. viewProjection: Matrix;
  55777. }
  55778. /**
  55779. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55780. */
  55781. export class GeometryBufferRenderer {
  55782. /**
  55783. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55784. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55785. */
  55786. static readonly POSITION_TEXTURE_TYPE: number;
  55787. /**
  55788. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55789. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55790. */
  55791. static readonly VELOCITY_TEXTURE_TYPE: number;
  55792. /**
  55793. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55794. * in order to compute objects velocities when enableVelocity is set to "true"
  55795. * @hidden
  55796. */
  55797. _previousTransformationMatrices: {
  55798. [index: number]: ISavedTransformationMatrix;
  55799. };
  55800. /**
  55801. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  55802. * in order to compute objects velocities when enableVelocity is set to "true"
  55803. * @hidden
  55804. */
  55805. _previousBonesTransformationMatrices: {
  55806. [index: number]: Float32Array;
  55807. };
  55808. /**
  55809. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  55810. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  55811. */
  55812. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  55813. private _scene;
  55814. private _multiRenderTarget;
  55815. private _ratio;
  55816. private _enablePosition;
  55817. private _enableVelocity;
  55818. private _positionIndex;
  55819. private _velocityIndex;
  55820. protected _effect: Effect;
  55821. protected _cachedDefines: string;
  55822. /**
  55823. * Set the render list (meshes to be rendered) used in the G buffer.
  55824. */
  55825. renderList: Mesh[];
  55826. /**
  55827. * Gets wether or not G buffer are supported by the running hardware.
  55828. * This requires draw buffer supports
  55829. */
  55830. readonly isSupported: boolean;
  55831. /**
  55832. * Returns the index of the given texture type in the G-Buffer textures array
  55833. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55834. * @returns the index of the given texture type in the G-Buffer textures array
  55835. */
  55836. getTextureIndex(textureType: number): number;
  55837. /**
  55838. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55839. */
  55840. /**
  55841. * Sets whether or not objects positions are enabled for the G buffer.
  55842. */
  55843. enablePosition: boolean;
  55844. /**
  55845. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55846. */
  55847. /**
  55848. * Sets wether or not objects velocities are enabled for the G buffer.
  55849. */
  55850. enableVelocity: boolean;
  55851. /**
  55852. * Gets the scene associated with the buffer.
  55853. */
  55854. readonly scene: Scene;
  55855. /**
  55856. * Gets the ratio used by the buffer during its creation.
  55857. * How big is the buffer related to the main canvas.
  55858. */
  55859. readonly ratio: number;
  55860. /** @hidden */
  55861. static _SceneComponentInitialization: (scene: Scene) => void;
  55862. /**
  55863. * Creates a new G Buffer for the scene
  55864. * @param scene The scene the buffer belongs to
  55865. * @param ratio How big is the buffer related to the main canvas.
  55866. */
  55867. constructor(scene: Scene, ratio?: number);
  55868. /**
  55869. * Checks wether everything is ready to render a submesh to the G buffer.
  55870. * @param subMesh the submesh to check readiness for
  55871. * @param useInstances is the mesh drawn using instance or not
  55872. * @returns true if ready otherwise false
  55873. */
  55874. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55875. /**
  55876. * Gets the current underlying G Buffer.
  55877. * @returns the buffer
  55878. */
  55879. getGBuffer(): MultiRenderTarget;
  55880. /**
  55881. * Gets the number of samples used to render the buffer (anti aliasing).
  55882. */
  55883. /**
  55884. * Sets the number of samples used to render the buffer (anti aliasing).
  55885. */
  55886. samples: number;
  55887. /**
  55888. * Disposes the renderer and frees up associated resources.
  55889. */
  55890. dispose(): void;
  55891. protected _createRenderTargets(): void;
  55892. private _copyBonesTransformationMatrices;
  55893. }
  55894. }
  55895. declare module BABYLON {
  55896. interface Scene {
  55897. /** @hidden (Backing field) */
  55898. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55899. /**
  55900. * Gets or Sets the current geometry buffer associated to the scene.
  55901. */
  55902. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55903. /**
  55904. * Enables a GeometryBufferRender and associates it with the scene
  55905. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55906. * @returns the GeometryBufferRenderer
  55907. */
  55908. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55909. /**
  55910. * Disables the GeometryBufferRender associated with the scene
  55911. */
  55912. disableGeometryBufferRenderer(): void;
  55913. }
  55914. /**
  55915. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55916. * in several rendering techniques.
  55917. */
  55918. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55919. /**
  55920. * The component name helpful to identify the component in the list of scene components.
  55921. */
  55922. readonly name: string;
  55923. /**
  55924. * The scene the component belongs to.
  55925. */
  55926. scene: Scene;
  55927. /**
  55928. * Creates a new instance of the component for the given scene
  55929. * @param scene Defines the scene to register the component in
  55930. */
  55931. constructor(scene: Scene);
  55932. /**
  55933. * Registers the component in a given scene
  55934. */
  55935. register(): void;
  55936. /**
  55937. * Rebuilds the elements related to this component in case of
  55938. * context lost for instance.
  55939. */
  55940. rebuild(): void;
  55941. /**
  55942. * Disposes the component and the associated ressources
  55943. */
  55944. dispose(): void;
  55945. private _gatherRenderTargets;
  55946. }
  55947. }
  55948. declare module BABYLON {
  55949. /** @hidden */
  55950. export var motionBlurPixelShader: {
  55951. name: string;
  55952. shader: string;
  55953. };
  55954. }
  55955. declare module BABYLON {
  55956. /**
  55957. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55958. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55959. * As an example, all you have to do is to create the post-process:
  55960. * var mb = new BABYLON.MotionBlurPostProcess(
  55961. * 'mb', // The name of the effect.
  55962. * scene, // The scene containing the objects to blur according to their velocity.
  55963. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55964. * camera // The camera to apply the render pass to.
  55965. * );
  55966. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55967. */
  55968. export class MotionBlurPostProcess extends PostProcess {
  55969. /**
  55970. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55971. */
  55972. motionStrength: number;
  55973. /**
  55974. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55975. */
  55976. /**
  55977. * Sets the number of iterations to be used for motion blur quality
  55978. */
  55979. motionBlurSamples: number;
  55980. private _motionBlurSamples;
  55981. private _geometryBufferRenderer;
  55982. /**
  55983. * Creates a new instance MotionBlurPostProcess
  55984. * @param name The name of the effect.
  55985. * @param scene The scene containing the objects to blur according to their velocity.
  55986. * @param options The required width/height ratio to downsize to before computing the render pass.
  55987. * @param camera The camera to apply the render pass to.
  55988. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55989. * @param engine The engine which the post process will be applied. (default: current engine)
  55990. * @param reusable If the post process can be reused on the same frame. (default: false)
  55991. * @param textureType Type of textures used when performing the post process. (default: 0)
  55992. * @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)
  55993. */
  55994. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55995. /**
  55996. * Excludes the given skinned mesh from computing bones velocities.
  55997. * 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.
  55998. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  55999. */
  56000. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  56001. /**
  56002. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  56003. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  56004. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  56005. */
  56006. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  56007. /**
  56008. * Disposes the post process.
  56009. * @param camera The camera to dispose the post process on.
  56010. */
  56011. dispose(camera?: Camera): void;
  56012. }
  56013. }
  56014. declare module BABYLON {
  56015. /** @hidden */
  56016. export var refractionPixelShader: {
  56017. name: string;
  56018. shader: string;
  56019. };
  56020. }
  56021. declare module BABYLON {
  56022. /**
  56023. * Post process which applies a refractin texture
  56024. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  56025. */
  56026. export class RefractionPostProcess extends PostProcess {
  56027. /** the base color of the refraction (used to taint the rendering) */
  56028. color: Color3;
  56029. /** simulated refraction depth */
  56030. depth: number;
  56031. /** the coefficient of the base color (0 to remove base color tainting) */
  56032. colorLevel: number;
  56033. private _refTexture;
  56034. private _ownRefractionTexture;
  56035. /**
  56036. * Gets or sets the refraction texture
  56037. * Please note that you are responsible for disposing the texture if you set it manually
  56038. */
  56039. refractionTexture: Texture;
  56040. /**
  56041. * Initializes the RefractionPostProcess
  56042. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  56043. * @param name The name of the effect.
  56044. * @param refractionTextureUrl Url of the refraction texture to use
  56045. * @param color the base color of the refraction (used to taint the rendering)
  56046. * @param depth simulated refraction depth
  56047. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  56048. * @param camera The camera to apply the render pass to.
  56049. * @param options The required width/height ratio to downsize to before computing the render pass.
  56050. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56051. * @param engine The engine which the post process will be applied. (default: current engine)
  56052. * @param reusable If the post process can be reused on the same frame. (default: false)
  56053. */
  56054. constructor(name: string, refractionTextureUrl: string,
  56055. /** the base color of the refraction (used to taint the rendering) */
  56056. color: Color3,
  56057. /** simulated refraction depth */
  56058. depth: number,
  56059. /** the coefficient of the base color (0 to remove base color tainting) */
  56060. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56061. /**
  56062. * Disposes of the post process
  56063. * @param camera Camera to dispose post process on
  56064. */
  56065. dispose(camera: Camera): void;
  56066. }
  56067. }
  56068. declare module BABYLON {
  56069. /** @hidden */
  56070. export var sharpenPixelShader: {
  56071. name: string;
  56072. shader: string;
  56073. };
  56074. }
  56075. declare module BABYLON {
  56076. /**
  56077. * The SharpenPostProcess applies a sharpen kernel to every pixel
  56078. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  56079. */
  56080. export class SharpenPostProcess extends PostProcess {
  56081. /**
  56082. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  56083. */
  56084. colorAmount: number;
  56085. /**
  56086. * How much sharpness should be applied (default: 0.3)
  56087. */
  56088. edgeAmount: number;
  56089. /**
  56090. * Creates a new instance ConvolutionPostProcess
  56091. * @param name The name of the effect.
  56092. * @param options The required width/height ratio to downsize to before computing the render pass.
  56093. * @param camera The camera to apply the render pass to.
  56094. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56095. * @param engine The engine which the post process will be applied. (default: current engine)
  56096. * @param reusable If the post process can be reused on the same frame. (default: false)
  56097. * @param textureType Type of textures used when performing the post process. (default: 0)
  56098. * @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)
  56099. */
  56100. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56101. }
  56102. }
  56103. declare module BABYLON {
  56104. /**
  56105. * PostProcessRenderPipeline
  56106. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56107. */
  56108. export class PostProcessRenderPipeline {
  56109. private engine;
  56110. private _renderEffects;
  56111. private _renderEffectsForIsolatedPass;
  56112. /**
  56113. * List of inspectable custom properties (used by the Inspector)
  56114. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  56115. */
  56116. inspectableCustomProperties: IInspectable[];
  56117. /**
  56118. * @hidden
  56119. */
  56120. protected _cameras: Camera[];
  56121. /** @hidden */
  56122. _name: string;
  56123. /**
  56124. * Gets pipeline name
  56125. */
  56126. readonly name: string;
  56127. /**
  56128. * Initializes a PostProcessRenderPipeline
  56129. * @param engine engine to add the pipeline to
  56130. * @param name name of the pipeline
  56131. */
  56132. constructor(engine: Engine, name: string);
  56133. /**
  56134. * Gets the class name
  56135. * @returns "PostProcessRenderPipeline"
  56136. */
  56137. getClassName(): string;
  56138. /**
  56139. * If all the render effects in the pipeline are supported
  56140. */
  56141. readonly isSupported: boolean;
  56142. /**
  56143. * Adds an effect to the pipeline
  56144. * @param renderEffect the effect to add
  56145. */
  56146. addEffect(renderEffect: PostProcessRenderEffect): void;
  56147. /** @hidden */
  56148. _rebuild(): void;
  56149. /** @hidden */
  56150. _enableEffect(renderEffectName: string, cameras: Camera): void;
  56151. /** @hidden */
  56152. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  56153. /** @hidden */
  56154. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  56155. /** @hidden */
  56156. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  56157. /** @hidden */
  56158. _attachCameras(cameras: Camera, unique: boolean): void;
  56159. /** @hidden */
  56160. _attachCameras(cameras: Camera[], unique: boolean): void;
  56161. /** @hidden */
  56162. _detachCameras(cameras: Camera): void;
  56163. /** @hidden */
  56164. _detachCameras(cameras: Nullable<Camera[]>): void;
  56165. /** @hidden */
  56166. _update(): void;
  56167. /** @hidden */
  56168. _reset(): void;
  56169. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  56170. /**
  56171. * Disposes of the pipeline
  56172. */
  56173. dispose(): void;
  56174. }
  56175. }
  56176. declare module BABYLON {
  56177. /**
  56178. * PostProcessRenderPipelineManager class
  56179. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56180. */
  56181. export class PostProcessRenderPipelineManager {
  56182. private _renderPipelines;
  56183. /**
  56184. * Initializes a PostProcessRenderPipelineManager
  56185. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56186. */
  56187. constructor();
  56188. /**
  56189. * Gets the list of supported render pipelines
  56190. */
  56191. readonly supportedPipelines: PostProcessRenderPipeline[];
  56192. /**
  56193. * Adds a pipeline to the manager
  56194. * @param renderPipeline The pipeline to add
  56195. */
  56196. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  56197. /**
  56198. * Attaches a camera to the pipeline
  56199. * @param renderPipelineName The name of the pipeline to attach to
  56200. * @param cameras the camera to attach
  56201. * @param unique if the camera can be attached multiple times to the pipeline
  56202. */
  56203. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  56204. /**
  56205. * Detaches a camera from the pipeline
  56206. * @param renderPipelineName The name of the pipeline to detach from
  56207. * @param cameras the camera to detach
  56208. */
  56209. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  56210. /**
  56211. * Enables an effect by name on a pipeline
  56212. * @param renderPipelineName the name of the pipeline to enable the effect in
  56213. * @param renderEffectName the name of the effect to enable
  56214. * @param cameras the cameras that the effect should be enabled on
  56215. */
  56216. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  56217. /**
  56218. * Disables an effect by name on a pipeline
  56219. * @param renderPipelineName the name of the pipeline to disable the effect in
  56220. * @param renderEffectName the name of the effect to disable
  56221. * @param cameras the cameras that the effect should be disabled on
  56222. */
  56223. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  56224. /**
  56225. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  56226. */
  56227. update(): void;
  56228. /** @hidden */
  56229. _rebuild(): void;
  56230. /**
  56231. * Disposes of the manager and pipelines
  56232. */
  56233. dispose(): void;
  56234. }
  56235. }
  56236. declare module BABYLON {
  56237. interface Scene {
  56238. /** @hidden (Backing field) */
  56239. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56240. /**
  56241. * Gets the postprocess render pipeline manager
  56242. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56243. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56244. */
  56245. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56246. }
  56247. /**
  56248. * Defines the Render Pipeline scene component responsible to rendering pipelines
  56249. */
  56250. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  56251. /**
  56252. * The component name helpfull to identify the component in the list of scene components.
  56253. */
  56254. readonly name: string;
  56255. /**
  56256. * The scene the component belongs to.
  56257. */
  56258. scene: Scene;
  56259. /**
  56260. * Creates a new instance of the component for the given scene
  56261. * @param scene Defines the scene to register the component in
  56262. */
  56263. constructor(scene: Scene);
  56264. /**
  56265. * Registers the component in a given scene
  56266. */
  56267. register(): void;
  56268. /**
  56269. * Rebuilds the elements related to this component in case of
  56270. * context lost for instance.
  56271. */
  56272. rebuild(): void;
  56273. /**
  56274. * Disposes the component and the associated ressources
  56275. */
  56276. dispose(): void;
  56277. private _gatherRenderTargets;
  56278. }
  56279. }
  56280. declare module BABYLON {
  56281. /**
  56282. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  56283. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56284. */
  56285. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56286. private _scene;
  56287. private _camerasToBeAttached;
  56288. /**
  56289. * ID of the sharpen post process,
  56290. */
  56291. private readonly SharpenPostProcessId;
  56292. /**
  56293. * @ignore
  56294. * ID of the image processing post process;
  56295. */
  56296. readonly ImageProcessingPostProcessId: string;
  56297. /**
  56298. * @ignore
  56299. * ID of the Fast Approximate Anti-Aliasing post process;
  56300. */
  56301. readonly FxaaPostProcessId: string;
  56302. /**
  56303. * ID of the chromatic aberration post process,
  56304. */
  56305. private readonly ChromaticAberrationPostProcessId;
  56306. /**
  56307. * ID of the grain post process
  56308. */
  56309. private readonly GrainPostProcessId;
  56310. /**
  56311. * Sharpen post process which will apply a sharpen convolution to enhance edges
  56312. */
  56313. sharpen: SharpenPostProcess;
  56314. private _sharpenEffect;
  56315. private bloom;
  56316. /**
  56317. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  56318. */
  56319. depthOfField: DepthOfFieldEffect;
  56320. /**
  56321. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56322. */
  56323. fxaa: FxaaPostProcess;
  56324. /**
  56325. * Image post processing pass used to perform operations such as tone mapping or color grading.
  56326. */
  56327. imageProcessing: ImageProcessingPostProcess;
  56328. /**
  56329. * Chromatic aberration post process which will shift rgb colors in the image
  56330. */
  56331. chromaticAberration: ChromaticAberrationPostProcess;
  56332. private _chromaticAberrationEffect;
  56333. /**
  56334. * Grain post process which add noise to the image
  56335. */
  56336. grain: GrainPostProcess;
  56337. private _grainEffect;
  56338. /**
  56339. * Glow post process which adds a glow to emissive areas of the image
  56340. */
  56341. private _glowLayer;
  56342. /**
  56343. * Animations which can be used to tweak settings over a period of time
  56344. */
  56345. animations: Animation[];
  56346. private _imageProcessingConfigurationObserver;
  56347. private _sharpenEnabled;
  56348. private _bloomEnabled;
  56349. private _depthOfFieldEnabled;
  56350. private _depthOfFieldBlurLevel;
  56351. private _fxaaEnabled;
  56352. private _imageProcessingEnabled;
  56353. private _defaultPipelineTextureType;
  56354. private _bloomScale;
  56355. private _chromaticAberrationEnabled;
  56356. private _grainEnabled;
  56357. private _buildAllowed;
  56358. /**
  56359. * Gets active scene
  56360. */
  56361. readonly scene: Scene;
  56362. /**
  56363. * Enable or disable the sharpen process from the pipeline
  56364. */
  56365. sharpenEnabled: boolean;
  56366. private _resizeObserver;
  56367. private _hardwareScaleLevel;
  56368. private _bloomKernel;
  56369. /**
  56370. * Specifies the size of the bloom blur kernel, relative to the final output size
  56371. */
  56372. bloomKernel: number;
  56373. /**
  56374. * Specifies the weight of the bloom in the final rendering
  56375. */
  56376. private _bloomWeight;
  56377. /**
  56378. * Specifies the luma threshold for the area that will be blurred by the bloom
  56379. */
  56380. private _bloomThreshold;
  56381. private _hdr;
  56382. /**
  56383. * The strength of the bloom.
  56384. */
  56385. bloomWeight: number;
  56386. /**
  56387. * The strength of the bloom.
  56388. */
  56389. bloomThreshold: number;
  56390. /**
  56391. * The scale of the bloom, lower value will provide better performance.
  56392. */
  56393. bloomScale: number;
  56394. /**
  56395. * Enable or disable the bloom from the pipeline
  56396. */
  56397. bloomEnabled: boolean;
  56398. private _rebuildBloom;
  56399. /**
  56400. * If the depth of field is enabled.
  56401. */
  56402. depthOfFieldEnabled: boolean;
  56403. /**
  56404. * Blur level of the depth of field effect. (Higher blur will effect performance)
  56405. */
  56406. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  56407. /**
  56408. * If the anti aliasing is enabled.
  56409. */
  56410. fxaaEnabled: boolean;
  56411. private _samples;
  56412. /**
  56413. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56414. */
  56415. samples: number;
  56416. /**
  56417. * If image processing is enabled.
  56418. */
  56419. imageProcessingEnabled: boolean;
  56420. /**
  56421. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  56422. */
  56423. glowLayerEnabled: boolean;
  56424. /**
  56425. * Gets the glow layer (or null if not defined)
  56426. */
  56427. readonly glowLayer: Nullable<GlowLayer>;
  56428. /**
  56429. * Enable or disable the chromaticAberration process from the pipeline
  56430. */
  56431. chromaticAberrationEnabled: boolean;
  56432. /**
  56433. * Enable or disable the grain process from the pipeline
  56434. */
  56435. grainEnabled: boolean;
  56436. /**
  56437. * @constructor
  56438. * @param name - The rendering pipeline name (default: "")
  56439. * @param hdr - If high dynamic range textures should be used (default: true)
  56440. * @param scene - The scene linked to this pipeline (default: the last created scene)
  56441. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  56442. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  56443. */
  56444. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  56445. /**
  56446. * Get the class name
  56447. * @returns "DefaultRenderingPipeline"
  56448. */
  56449. getClassName(): string;
  56450. /**
  56451. * Force the compilation of the entire pipeline.
  56452. */
  56453. prepare(): void;
  56454. private _hasCleared;
  56455. private _prevPostProcess;
  56456. private _prevPrevPostProcess;
  56457. private _setAutoClearAndTextureSharing;
  56458. private _depthOfFieldSceneObserver;
  56459. private _buildPipeline;
  56460. private _disposePostProcesses;
  56461. /**
  56462. * Adds a camera to the pipeline
  56463. * @param camera the camera to be added
  56464. */
  56465. addCamera(camera: Camera): void;
  56466. /**
  56467. * Removes a camera from the pipeline
  56468. * @param camera the camera to remove
  56469. */
  56470. removeCamera(camera: Camera): void;
  56471. /**
  56472. * Dispose of the pipeline and stop all post processes
  56473. */
  56474. dispose(): void;
  56475. /**
  56476. * Serialize the rendering pipeline (Used when exporting)
  56477. * @returns the serialized object
  56478. */
  56479. serialize(): any;
  56480. /**
  56481. * Parse the serialized pipeline
  56482. * @param source Source pipeline.
  56483. * @param scene The scene to load the pipeline to.
  56484. * @param rootUrl The URL of the serialized pipeline.
  56485. * @returns An instantiated pipeline from the serialized object.
  56486. */
  56487. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  56488. }
  56489. }
  56490. declare module BABYLON {
  56491. /** @hidden */
  56492. export var lensHighlightsPixelShader: {
  56493. name: string;
  56494. shader: string;
  56495. };
  56496. }
  56497. declare module BABYLON {
  56498. /** @hidden */
  56499. export var depthOfFieldPixelShader: {
  56500. name: string;
  56501. shader: string;
  56502. };
  56503. }
  56504. declare module BABYLON {
  56505. /**
  56506. * BABYLON.JS Chromatic Aberration GLSL Shader
  56507. * Author: Olivier Guyot
  56508. * Separates very slightly R, G and B colors on the edges of the screen
  56509. * Inspired by Francois Tarlier & Martins Upitis
  56510. */
  56511. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  56512. /**
  56513. * @ignore
  56514. * The chromatic aberration PostProcess id in the pipeline
  56515. */
  56516. LensChromaticAberrationEffect: string;
  56517. /**
  56518. * @ignore
  56519. * The highlights enhancing PostProcess id in the pipeline
  56520. */
  56521. HighlightsEnhancingEffect: string;
  56522. /**
  56523. * @ignore
  56524. * The depth-of-field PostProcess id in the pipeline
  56525. */
  56526. LensDepthOfFieldEffect: string;
  56527. private _scene;
  56528. private _depthTexture;
  56529. private _grainTexture;
  56530. private _chromaticAberrationPostProcess;
  56531. private _highlightsPostProcess;
  56532. private _depthOfFieldPostProcess;
  56533. private _edgeBlur;
  56534. private _grainAmount;
  56535. private _chromaticAberration;
  56536. private _distortion;
  56537. private _highlightsGain;
  56538. private _highlightsThreshold;
  56539. private _dofDistance;
  56540. private _dofAperture;
  56541. private _dofDarken;
  56542. private _dofPentagon;
  56543. private _blurNoise;
  56544. /**
  56545. * @constructor
  56546. *
  56547. * Effect parameters are as follow:
  56548. * {
  56549. * chromatic_aberration: number; // from 0 to x (1 for realism)
  56550. * edge_blur: number; // from 0 to x (1 for realism)
  56551. * distortion: number; // from 0 to x (1 for realism)
  56552. * grain_amount: number; // from 0 to 1
  56553. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  56554. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  56555. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  56556. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  56557. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  56558. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  56559. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  56560. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  56561. * }
  56562. * Note: if an effect parameter is unset, effect is disabled
  56563. *
  56564. * @param name The rendering pipeline name
  56565. * @param parameters - An object containing all parameters (see above)
  56566. * @param scene The scene linked to this pipeline
  56567. * @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)
  56568. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56569. */
  56570. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  56571. /**
  56572. * Get the class name
  56573. * @returns "LensRenderingPipeline"
  56574. */
  56575. getClassName(): string;
  56576. /**
  56577. * Gets associated scene
  56578. */
  56579. readonly scene: Scene;
  56580. /**
  56581. * Gets or sets the edge blur
  56582. */
  56583. edgeBlur: number;
  56584. /**
  56585. * Gets or sets the grain amount
  56586. */
  56587. grainAmount: number;
  56588. /**
  56589. * Gets or sets the chromatic aberration amount
  56590. */
  56591. chromaticAberration: number;
  56592. /**
  56593. * Gets or sets the depth of field aperture
  56594. */
  56595. dofAperture: number;
  56596. /**
  56597. * Gets or sets the edge distortion
  56598. */
  56599. edgeDistortion: number;
  56600. /**
  56601. * Gets or sets the depth of field distortion
  56602. */
  56603. dofDistortion: number;
  56604. /**
  56605. * Gets or sets the darken out of focus amount
  56606. */
  56607. darkenOutOfFocus: number;
  56608. /**
  56609. * Gets or sets a boolean indicating if blur noise is enabled
  56610. */
  56611. blurNoise: boolean;
  56612. /**
  56613. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  56614. */
  56615. pentagonBokeh: boolean;
  56616. /**
  56617. * Gets or sets the highlight grain amount
  56618. */
  56619. highlightsGain: number;
  56620. /**
  56621. * Gets or sets the highlight threshold
  56622. */
  56623. highlightsThreshold: number;
  56624. /**
  56625. * Sets the amount of blur at the edges
  56626. * @param amount blur amount
  56627. */
  56628. setEdgeBlur(amount: number): void;
  56629. /**
  56630. * Sets edge blur to 0
  56631. */
  56632. disableEdgeBlur(): void;
  56633. /**
  56634. * Sets the amout of grain
  56635. * @param amount Amount of grain
  56636. */
  56637. setGrainAmount(amount: number): void;
  56638. /**
  56639. * Set grain amount to 0
  56640. */
  56641. disableGrain(): void;
  56642. /**
  56643. * Sets the chromatic aberration amount
  56644. * @param amount amount of chromatic aberration
  56645. */
  56646. setChromaticAberration(amount: number): void;
  56647. /**
  56648. * Sets chromatic aberration amount to 0
  56649. */
  56650. disableChromaticAberration(): void;
  56651. /**
  56652. * Sets the EdgeDistortion amount
  56653. * @param amount amount of EdgeDistortion
  56654. */
  56655. setEdgeDistortion(amount: number): void;
  56656. /**
  56657. * Sets edge distortion to 0
  56658. */
  56659. disableEdgeDistortion(): void;
  56660. /**
  56661. * Sets the FocusDistance amount
  56662. * @param amount amount of FocusDistance
  56663. */
  56664. setFocusDistance(amount: number): void;
  56665. /**
  56666. * Disables depth of field
  56667. */
  56668. disableDepthOfField(): void;
  56669. /**
  56670. * Sets the Aperture amount
  56671. * @param amount amount of Aperture
  56672. */
  56673. setAperture(amount: number): void;
  56674. /**
  56675. * Sets the DarkenOutOfFocus amount
  56676. * @param amount amount of DarkenOutOfFocus
  56677. */
  56678. setDarkenOutOfFocus(amount: number): void;
  56679. private _pentagonBokehIsEnabled;
  56680. /**
  56681. * Creates a pentagon bokeh effect
  56682. */
  56683. enablePentagonBokeh(): void;
  56684. /**
  56685. * Disables the pentagon bokeh effect
  56686. */
  56687. disablePentagonBokeh(): void;
  56688. /**
  56689. * Enables noise blur
  56690. */
  56691. enableNoiseBlur(): void;
  56692. /**
  56693. * Disables noise blur
  56694. */
  56695. disableNoiseBlur(): void;
  56696. /**
  56697. * Sets the HighlightsGain amount
  56698. * @param amount amount of HighlightsGain
  56699. */
  56700. setHighlightsGain(amount: number): void;
  56701. /**
  56702. * Sets the HighlightsThreshold amount
  56703. * @param amount amount of HighlightsThreshold
  56704. */
  56705. setHighlightsThreshold(amount: number): void;
  56706. /**
  56707. * Disables highlights
  56708. */
  56709. disableHighlights(): void;
  56710. /**
  56711. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  56712. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  56713. */
  56714. dispose(disableDepthRender?: boolean): void;
  56715. private _createChromaticAberrationPostProcess;
  56716. private _createHighlightsPostProcess;
  56717. private _createDepthOfFieldPostProcess;
  56718. private _createGrainTexture;
  56719. }
  56720. }
  56721. declare module BABYLON {
  56722. /** @hidden */
  56723. export var ssao2PixelShader: {
  56724. name: string;
  56725. shader: string;
  56726. };
  56727. }
  56728. declare module BABYLON {
  56729. /** @hidden */
  56730. export var ssaoCombinePixelShader: {
  56731. name: string;
  56732. shader: string;
  56733. };
  56734. }
  56735. declare module BABYLON {
  56736. /**
  56737. * Render pipeline to produce ssao effect
  56738. */
  56739. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56740. /**
  56741. * @ignore
  56742. * The PassPostProcess id in the pipeline that contains the original scene color
  56743. */
  56744. SSAOOriginalSceneColorEffect: string;
  56745. /**
  56746. * @ignore
  56747. * The SSAO PostProcess id in the pipeline
  56748. */
  56749. SSAORenderEffect: string;
  56750. /**
  56751. * @ignore
  56752. * The horizontal blur PostProcess id in the pipeline
  56753. */
  56754. SSAOBlurHRenderEffect: string;
  56755. /**
  56756. * @ignore
  56757. * The vertical blur PostProcess id in the pipeline
  56758. */
  56759. SSAOBlurVRenderEffect: string;
  56760. /**
  56761. * @ignore
  56762. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56763. */
  56764. SSAOCombineRenderEffect: string;
  56765. /**
  56766. * The output strength of the SSAO post-process. Default value is 1.0.
  56767. */
  56768. totalStrength: number;
  56769. /**
  56770. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56771. */
  56772. maxZ: number;
  56773. /**
  56774. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56775. */
  56776. minZAspect: number;
  56777. private _samples;
  56778. /**
  56779. * Number of samples used for the SSAO calculations. Default value is 8
  56780. */
  56781. samples: number;
  56782. private _textureSamples;
  56783. /**
  56784. * Number of samples to use for antialiasing
  56785. */
  56786. textureSamples: number;
  56787. /**
  56788. * Ratio object used for SSAO ratio and blur ratio
  56789. */
  56790. private _ratio;
  56791. /**
  56792. * Dynamically generated sphere sampler.
  56793. */
  56794. private _sampleSphere;
  56795. /**
  56796. * Blur filter offsets
  56797. */
  56798. private _samplerOffsets;
  56799. private _expensiveBlur;
  56800. /**
  56801. * If bilateral blur should be used
  56802. */
  56803. expensiveBlur: boolean;
  56804. /**
  56805. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56806. */
  56807. radius: number;
  56808. /**
  56809. * The base color of the SSAO post-process
  56810. * The final result is "base + ssao" between [0, 1]
  56811. */
  56812. base: number;
  56813. /**
  56814. * Support test.
  56815. */
  56816. static readonly IsSupported: boolean;
  56817. private _scene;
  56818. private _depthTexture;
  56819. private _normalTexture;
  56820. private _randomTexture;
  56821. private _originalColorPostProcess;
  56822. private _ssaoPostProcess;
  56823. private _blurHPostProcess;
  56824. private _blurVPostProcess;
  56825. private _ssaoCombinePostProcess;
  56826. private _firstUpdate;
  56827. /**
  56828. * Gets active scene
  56829. */
  56830. readonly scene: Scene;
  56831. /**
  56832. * @constructor
  56833. * @param name The rendering pipeline name
  56834. * @param scene The scene linked to this pipeline
  56835. * @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 }
  56836. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56837. */
  56838. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56839. /**
  56840. * Get the class name
  56841. * @returns "SSAO2RenderingPipeline"
  56842. */
  56843. getClassName(): string;
  56844. /**
  56845. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56846. */
  56847. dispose(disableGeometryBufferRenderer?: boolean): void;
  56848. private _createBlurPostProcess;
  56849. /** @hidden */
  56850. _rebuild(): void;
  56851. private _bits;
  56852. private _radicalInverse_VdC;
  56853. private _hammersley;
  56854. private _hemisphereSample_uniform;
  56855. private _generateHemisphere;
  56856. private _createSSAOPostProcess;
  56857. private _createSSAOCombinePostProcess;
  56858. private _createRandomTexture;
  56859. /**
  56860. * Serialize the rendering pipeline (Used when exporting)
  56861. * @returns the serialized object
  56862. */
  56863. serialize(): any;
  56864. /**
  56865. * Parse the serialized pipeline
  56866. * @param source Source pipeline.
  56867. * @param scene The scene to load the pipeline to.
  56868. * @param rootUrl The URL of the serialized pipeline.
  56869. * @returns An instantiated pipeline from the serialized object.
  56870. */
  56871. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56872. }
  56873. }
  56874. declare module BABYLON {
  56875. /** @hidden */
  56876. export var ssaoPixelShader: {
  56877. name: string;
  56878. shader: string;
  56879. };
  56880. }
  56881. declare module BABYLON {
  56882. /**
  56883. * Render pipeline to produce ssao effect
  56884. */
  56885. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56886. /**
  56887. * @ignore
  56888. * The PassPostProcess id in the pipeline that contains the original scene color
  56889. */
  56890. SSAOOriginalSceneColorEffect: string;
  56891. /**
  56892. * @ignore
  56893. * The SSAO PostProcess id in the pipeline
  56894. */
  56895. SSAORenderEffect: string;
  56896. /**
  56897. * @ignore
  56898. * The horizontal blur PostProcess id in the pipeline
  56899. */
  56900. SSAOBlurHRenderEffect: string;
  56901. /**
  56902. * @ignore
  56903. * The vertical blur PostProcess id in the pipeline
  56904. */
  56905. SSAOBlurVRenderEffect: string;
  56906. /**
  56907. * @ignore
  56908. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56909. */
  56910. SSAOCombineRenderEffect: string;
  56911. /**
  56912. * The output strength of the SSAO post-process. Default value is 1.0.
  56913. */
  56914. totalStrength: number;
  56915. /**
  56916. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56917. */
  56918. radius: number;
  56919. /**
  56920. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56921. * Must not be equal to fallOff and superior to fallOff.
  56922. * Default value is 0.0075
  56923. */
  56924. area: number;
  56925. /**
  56926. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56927. * Must not be equal to area and inferior to area.
  56928. * Default value is 0.000001
  56929. */
  56930. fallOff: number;
  56931. /**
  56932. * The base color of the SSAO post-process
  56933. * The final result is "base + ssao" between [0, 1]
  56934. */
  56935. base: number;
  56936. private _scene;
  56937. private _depthTexture;
  56938. private _randomTexture;
  56939. private _originalColorPostProcess;
  56940. private _ssaoPostProcess;
  56941. private _blurHPostProcess;
  56942. private _blurVPostProcess;
  56943. private _ssaoCombinePostProcess;
  56944. private _firstUpdate;
  56945. /**
  56946. * Gets active scene
  56947. */
  56948. readonly scene: Scene;
  56949. /**
  56950. * @constructor
  56951. * @param name - The rendering pipeline name
  56952. * @param scene - The scene linked to this pipeline
  56953. * @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 }
  56954. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56955. */
  56956. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56957. /**
  56958. * Get the class name
  56959. * @returns "SSAORenderingPipeline"
  56960. */
  56961. getClassName(): string;
  56962. /**
  56963. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56964. */
  56965. dispose(disableDepthRender?: boolean): void;
  56966. private _createBlurPostProcess;
  56967. /** @hidden */
  56968. _rebuild(): void;
  56969. private _createSSAOPostProcess;
  56970. private _createSSAOCombinePostProcess;
  56971. private _createRandomTexture;
  56972. }
  56973. }
  56974. declare module BABYLON {
  56975. /** @hidden */
  56976. export var standardPixelShader: {
  56977. name: string;
  56978. shader: string;
  56979. };
  56980. }
  56981. declare module BABYLON {
  56982. /**
  56983. * Standard rendering pipeline
  56984. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56985. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56986. */
  56987. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56988. /**
  56989. * Public members
  56990. */
  56991. /**
  56992. * Post-process which contains the original scene color before the pipeline applies all the effects
  56993. */
  56994. originalPostProcess: Nullable<PostProcess>;
  56995. /**
  56996. * Post-process used to down scale an image x4
  56997. */
  56998. downSampleX4PostProcess: Nullable<PostProcess>;
  56999. /**
  57000. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  57001. */
  57002. brightPassPostProcess: Nullable<PostProcess>;
  57003. /**
  57004. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  57005. */
  57006. blurHPostProcesses: PostProcess[];
  57007. /**
  57008. * Post-process array storing all the vertical blur post-processes used by the pipeline
  57009. */
  57010. blurVPostProcesses: PostProcess[];
  57011. /**
  57012. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  57013. */
  57014. textureAdderPostProcess: Nullable<PostProcess>;
  57015. /**
  57016. * Post-process used to create volumetric lighting effect
  57017. */
  57018. volumetricLightPostProcess: Nullable<PostProcess>;
  57019. /**
  57020. * Post-process used to smooth the previous volumetric light post-process on the X axis
  57021. */
  57022. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  57023. /**
  57024. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  57025. */
  57026. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  57027. /**
  57028. * Post-process used to merge the volumetric light effect and the real scene color
  57029. */
  57030. volumetricLightMergePostProces: Nullable<PostProcess>;
  57031. /**
  57032. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  57033. */
  57034. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  57035. /**
  57036. * Base post-process used to calculate the average luminance of the final image for HDR
  57037. */
  57038. luminancePostProcess: Nullable<PostProcess>;
  57039. /**
  57040. * Post-processes used to create down sample post-processes in order to get
  57041. * the average luminance of the final image for HDR
  57042. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  57043. */
  57044. luminanceDownSamplePostProcesses: PostProcess[];
  57045. /**
  57046. * Post-process used to create a HDR effect (light adaptation)
  57047. */
  57048. hdrPostProcess: Nullable<PostProcess>;
  57049. /**
  57050. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  57051. */
  57052. textureAdderFinalPostProcess: Nullable<PostProcess>;
  57053. /**
  57054. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  57055. */
  57056. lensFlareFinalPostProcess: Nullable<PostProcess>;
  57057. /**
  57058. * Post-process used to merge the final HDR post-process and the real scene color
  57059. */
  57060. hdrFinalPostProcess: Nullable<PostProcess>;
  57061. /**
  57062. * Post-process used to create a lens flare effect
  57063. */
  57064. lensFlarePostProcess: Nullable<PostProcess>;
  57065. /**
  57066. * Post-process that merges the result of the lens flare post-process and the real scene color
  57067. */
  57068. lensFlareComposePostProcess: Nullable<PostProcess>;
  57069. /**
  57070. * Post-process used to create a motion blur effect
  57071. */
  57072. motionBlurPostProcess: Nullable<PostProcess>;
  57073. /**
  57074. * Post-process used to create a depth of field effect
  57075. */
  57076. depthOfFieldPostProcess: Nullable<PostProcess>;
  57077. /**
  57078. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  57079. */
  57080. fxaaPostProcess: Nullable<FxaaPostProcess>;
  57081. /**
  57082. * Represents the brightness threshold in order to configure the illuminated surfaces
  57083. */
  57084. brightThreshold: number;
  57085. /**
  57086. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  57087. */
  57088. blurWidth: number;
  57089. /**
  57090. * Sets if the blur for highlighted surfaces must be only horizontal
  57091. */
  57092. horizontalBlur: boolean;
  57093. /**
  57094. * Gets the overall exposure used by the pipeline
  57095. */
  57096. /**
  57097. * Sets the overall exposure used by the pipeline
  57098. */
  57099. exposure: number;
  57100. /**
  57101. * Texture used typically to simulate "dirty" on camera lens
  57102. */
  57103. lensTexture: Nullable<Texture>;
  57104. /**
  57105. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  57106. */
  57107. volumetricLightCoefficient: number;
  57108. /**
  57109. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  57110. */
  57111. volumetricLightPower: number;
  57112. /**
  57113. * Used the set the blur intensity to smooth the volumetric lights
  57114. */
  57115. volumetricLightBlurScale: number;
  57116. /**
  57117. * Light (spot or directional) used to generate the volumetric lights rays
  57118. * The source light must have a shadow generate so the pipeline can get its
  57119. * depth map
  57120. */
  57121. sourceLight: Nullable<SpotLight | DirectionalLight>;
  57122. /**
  57123. * For eye adaptation, represents the minimum luminance the eye can see
  57124. */
  57125. hdrMinimumLuminance: number;
  57126. /**
  57127. * For eye adaptation, represents the decrease luminance speed
  57128. */
  57129. hdrDecreaseRate: number;
  57130. /**
  57131. * For eye adaptation, represents the increase luminance speed
  57132. */
  57133. hdrIncreaseRate: number;
  57134. /**
  57135. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  57136. */
  57137. /**
  57138. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  57139. */
  57140. hdrAutoExposure: boolean;
  57141. /**
  57142. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  57143. */
  57144. lensColorTexture: Nullable<Texture>;
  57145. /**
  57146. * The overall strengh for the lens flare effect
  57147. */
  57148. lensFlareStrength: number;
  57149. /**
  57150. * Dispersion coefficient for lens flare ghosts
  57151. */
  57152. lensFlareGhostDispersal: number;
  57153. /**
  57154. * Main lens flare halo width
  57155. */
  57156. lensFlareHaloWidth: number;
  57157. /**
  57158. * Based on the lens distortion effect, defines how much the lens flare result
  57159. * is distorted
  57160. */
  57161. lensFlareDistortionStrength: number;
  57162. /**
  57163. * Lens star texture must be used to simulate rays on the flares and is available
  57164. * in the documentation
  57165. */
  57166. lensStarTexture: Nullable<Texture>;
  57167. /**
  57168. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  57169. * flare effect by taking account of the dirt texture
  57170. */
  57171. lensFlareDirtTexture: Nullable<Texture>;
  57172. /**
  57173. * Represents the focal length for the depth of field effect
  57174. */
  57175. depthOfFieldDistance: number;
  57176. /**
  57177. * Represents the blur intensity for the blurred part of the depth of field effect
  57178. */
  57179. depthOfFieldBlurWidth: number;
  57180. /**
  57181. * Gets how much the image is blurred by the movement while using the motion blur post-process
  57182. */
  57183. /**
  57184. * Sets how much the image is blurred by the movement while using the motion blur post-process
  57185. */
  57186. motionStrength: number;
  57187. /**
  57188. * Gets wether or not the motion blur post-process is object based or screen based.
  57189. */
  57190. /**
  57191. * Sets wether or not the motion blur post-process should be object based or screen based
  57192. */
  57193. objectBasedMotionBlur: boolean;
  57194. /**
  57195. * List of animations for the pipeline (IAnimatable implementation)
  57196. */
  57197. animations: Animation[];
  57198. /**
  57199. * Private members
  57200. */
  57201. private _scene;
  57202. private _currentDepthOfFieldSource;
  57203. private _basePostProcess;
  57204. private _fixedExposure;
  57205. private _currentExposure;
  57206. private _hdrAutoExposure;
  57207. private _hdrCurrentLuminance;
  57208. private _motionStrength;
  57209. private _isObjectBasedMotionBlur;
  57210. private _floatTextureType;
  57211. private _ratio;
  57212. private _bloomEnabled;
  57213. private _depthOfFieldEnabled;
  57214. private _vlsEnabled;
  57215. private _lensFlareEnabled;
  57216. private _hdrEnabled;
  57217. private _motionBlurEnabled;
  57218. private _fxaaEnabled;
  57219. private _motionBlurSamples;
  57220. private _volumetricLightStepsCount;
  57221. private _samples;
  57222. /**
  57223. * @ignore
  57224. * Specifies if the bloom pipeline is enabled
  57225. */
  57226. BloomEnabled: boolean;
  57227. /**
  57228. * @ignore
  57229. * Specifies if the depth of field pipeline is enabed
  57230. */
  57231. DepthOfFieldEnabled: boolean;
  57232. /**
  57233. * @ignore
  57234. * Specifies if the lens flare pipeline is enabed
  57235. */
  57236. LensFlareEnabled: boolean;
  57237. /**
  57238. * @ignore
  57239. * Specifies if the HDR pipeline is enabled
  57240. */
  57241. HDREnabled: boolean;
  57242. /**
  57243. * @ignore
  57244. * Specifies if the volumetric lights scattering effect is enabled
  57245. */
  57246. VLSEnabled: boolean;
  57247. /**
  57248. * @ignore
  57249. * Specifies if the motion blur effect is enabled
  57250. */
  57251. MotionBlurEnabled: boolean;
  57252. /**
  57253. * Specifies if anti-aliasing is enabled
  57254. */
  57255. fxaaEnabled: boolean;
  57256. /**
  57257. * Specifies the number of steps used to calculate the volumetric lights
  57258. * Typically in interval [50, 200]
  57259. */
  57260. volumetricLightStepsCount: number;
  57261. /**
  57262. * Specifies the number of samples used for the motion blur effect
  57263. * Typically in interval [16, 64]
  57264. */
  57265. motionBlurSamples: number;
  57266. /**
  57267. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57268. */
  57269. samples: number;
  57270. /**
  57271. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57272. * @constructor
  57273. * @param name The rendering pipeline name
  57274. * @param scene The scene linked to this pipeline
  57275. * @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)
  57276. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  57277. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57278. */
  57279. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  57280. private _buildPipeline;
  57281. private _createDownSampleX4PostProcess;
  57282. private _createBrightPassPostProcess;
  57283. private _createBlurPostProcesses;
  57284. private _createTextureAdderPostProcess;
  57285. private _createVolumetricLightPostProcess;
  57286. private _createLuminancePostProcesses;
  57287. private _createHdrPostProcess;
  57288. private _createLensFlarePostProcess;
  57289. private _createDepthOfFieldPostProcess;
  57290. private _createMotionBlurPostProcess;
  57291. private _getDepthTexture;
  57292. private _disposePostProcesses;
  57293. /**
  57294. * Dispose of the pipeline and stop all post processes
  57295. */
  57296. dispose(): void;
  57297. /**
  57298. * Serialize the rendering pipeline (Used when exporting)
  57299. * @returns the serialized object
  57300. */
  57301. serialize(): any;
  57302. /**
  57303. * Parse the serialized pipeline
  57304. * @param source Source pipeline.
  57305. * @param scene The scene to load the pipeline to.
  57306. * @param rootUrl The URL of the serialized pipeline.
  57307. * @returns An instantiated pipeline from the serialized object.
  57308. */
  57309. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  57310. /**
  57311. * Luminance steps
  57312. */
  57313. static LuminanceSteps: number;
  57314. }
  57315. }
  57316. declare module BABYLON {
  57317. /** @hidden */
  57318. export var tonemapPixelShader: {
  57319. name: string;
  57320. shader: string;
  57321. };
  57322. }
  57323. declare module BABYLON {
  57324. /** Defines operator used for tonemapping */
  57325. export enum TonemappingOperator {
  57326. /** Hable */
  57327. Hable = 0,
  57328. /** Reinhard */
  57329. Reinhard = 1,
  57330. /** HejiDawson */
  57331. HejiDawson = 2,
  57332. /** Photographic */
  57333. Photographic = 3
  57334. }
  57335. /**
  57336. * Defines a post process to apply tone mapping
  57337. */
  57338. export class TonemapPostProcess extends PostProcess {
  57339. private _operator;
  57340. /** Defines the required exposure adjustement */
  57341. exposureAdjustment: number;
  57342. /**
  57343. * Creates a new TonemapPostProcess
  57344. * @param name defines the name of the postprocess
  57345. * @param _operator defines the operator to use
  57346. * @param exposureAdjustment defines the required exposure adjustement
  57347. * @param camera defines the camera to use (can be null)
  57348. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  57349. * @param engine defines the hosting engine (can be ignore if camera is set)
  57350. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57351. */
  57352. constructor(name: string, _operator: TonemappingOperator,
  57353. /** Defines the required exposure adjustement */
  57354. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  57355. }
  57356. }
  57357. declare module BABYLON {
  57358. /** @hidden */
  57359. export var depthVertexShader: {
  57360. name: string;
  57361. shader: string;
  57362. };
  57363. }
  57364. declare module BABYLON {
  57365. /** @hidden */
  57366. export var volumetricLightScatteringPixelShader: {
  57367. name: string;
  57368. shader: string;
  57369. };
  57370. }
  57371. declare module BABYLON {
  57372. /** @hidden */
  57373. export var volumetricLightScatteringPassPixelShader: {
  57374. name: string;
  57375. shader: string;
  57376. };
  57377. }
  57378. declare module BABYLON {
  57379. /**
  57380. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  57381. */
  57382. export class VolumetricLightScatteringPostProcess extends PostProcess {
  57383. private _volumetricLightScatteringPass;
  57384. private _volumetricLightScatteringRTT;
  57385. private _viewPort;
  57386. private _screenCoordinates;
  57387. private _cachedDefines;
  57388. /**
  57389. * If not undefined, the mesh position is computed from the attached node position
  57390. */
  57391. attachedNode: {
  57392. position: Vector3;
  57393. };
  57394. /**
  57395. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  57396. */
  57397. customMeshPosition: Vector3;
  57398. /**
  57399. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  57400. */
  57401. useCustomMeshPosition: boolean;
  57402. /**
  57403. * If the post-process should inverse the light scattering direction
  57404. */
  57405. invert: boolean;
  57406. /**
  57407. * The internal mesh used by the post-process
  57408. */
  57409. mesh: Mesh;
  57410. /**
  57411. * @hidden
  57412. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  57413. */
  57414. useDiffuseColor: boolean;
  57415. /**
  57416. * Array containing the excluded meshes not rendered in the internal pass
  57417. */
  57418. excludedMeshes: AbstractMesh[];
  57419. /**
  57420. * Controls the overall intensity of the post-process
  57421. */
  57422. exposure: number;
  57423. /**
  57424. * Dissipates each sample's contribution in range [0, 1]
  57425. */
  57426. decay: number;
  57427. /**
  57428. * Controls the overall intensity of each sample
  57429. */
  57430. weight: number;
  57431. /**
  57432. * Controls the density of each sample
  57433. */
  57434. density: number;
  57435. /**
  57436. * @constructor
  57437. * @param name The post-process name
  57438. * @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)
  57439. * @param camera The camera that the post-process will be attached to
  57440. * @param mesh The mesh used to create the light scattering
  57441. * @param samples The post-process quality, default 100
  57442. * @param samplingModeThe post-process filtering mode
  57443. * @param engine The babylon engine
  57444. * @param reusable If the post-process is reusable
  57445. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  57446. */
  57447. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  57448. /**
  57449. * Returns the string "VolumetricLightScatteringPostProcess"
  57450. * @returns "VolumetricLightScatteringPostProcess"
  57451. */
  57452. getClassName(): string;
  57453. private _isReady;
  57454. /**
  57455. * Sets the new light position for light scattering effect
  57456. * @param position The new custom light position
  57457. */
  57458. setCustomMeshPosition(position: Vector3): void;
  57459. /**
  57460. * Returns the light position for light scattering effect
  57461. * @return Vector3 The custom light position
  57462. */
  57463. getCustomMeshPosition(): Vector3;
  57464. /**
  57465. * Disposes the internal assets and detaches the post-process from the camera
  57466. */
  57467. dispose(camera: Camera): void;
  57468. /**
  57469. * Returns the render target texture used by the post-process
  57470. * @return the render target texture used by the post-process
  57471. */
  57472. getPass(): RenderTargetTexture;
  57473. private _meshExcluded;
  57474. private _createPass;
  57475. private _updateMeshScreenCoordinates;
  57476. /**
  57477. * Creates a default mesh for the Volumeric Light Scattering post-process
  57478. * @param name The mesh name
  57479. * @param scene The scene where to create the mesh
  57480. * @return the default mesh
  57481. */
  57482. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  57483. }
  57484. }
  57485. declare module BABYLON {
  57486. interface Scene {
  57487. /** @hidden (Backing field) */
  57488. _boundingBoxRenderer: BoundingBoxRenderer;
  57489. /** @hidden (Backing field) */
  57490. _forceShowBoundingBoxes: boolean;
  57491. /**
  57492. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  57493. */
  57494. forceShowBoundingBoxes: boolean;
  57495. /**
  57496. * Gets the bounding box renderer associated with the scene
  57497. * @returns a BoundingBoxRenderer
  57498. */
  57499. getBoundingBoxRenderer(): BoundingBoxRenderer;
  57500. }
  57501. interface AbstractMesh {
  57502. /** @hidden (Backing field) */
  57503. _showBoundingBox: boolean;
  57504. /**
  57505. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  57506. */
  57507. showBoundingBox: boolean;
  57508. }
  57509. /**
  57510. * Component responsible of rendering the bounding box of the meshes in a scene.
  57511. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  57512. */
  57513. export class BoundingBoxRenderer implements ISceneComponent {
  57514. /**
  57515. * The component name helpfull to identify the component in the list of scene components.
  57516. */
  57517. readonly name: string;
  57518. /**
  57519. * The scene the component belongs to.
  57520. */
  57521. scene: Scene;
  57522. /**
  57523. * Color of the bounding box lines placed in front of an object
  57524. */
  57525. frontColor: Color3;
  57526. /**
  57527. * Color of the bounding box lines placed behind an object
  57528. */
  57529. backColor: Color3;
  57530. /**
  57531. * Defines if the renderer should show the back lines or not
  57532. */
  57533. showBackLines: boolean;
  57534. /**
  57535. * @hidden
  57536. */
  57537. renderList: SmartArray<BoundingBox>;
  57538. private _colorShader;
  57539. private _vertexBuffers;
  57540. private _indexBuffer;
  57541. private _fillIndexBuffer;
  57542. private _fillIndexData;
  57543. /**
  57544. * Instantiates a new bounding box renderer in a scene.
  57545. * @param scene the scene the renderer renders in
  57546. */
  57547. constructor(scene: Scene);
  57548. /**
  57549. * Registers the component in a given scene
  57550. */
  57551. register(): void;
  57552. private _evaluateSubMesh;
  57553. private _activeMesh;
  57554. private _prepareRessources;
  57555. private _createIndexBuffer;
  57556. /**
  57557. * Rebuilds the elements related to this component in case of
  57558. * context lost for instance.
  57559. */
  57560. rebuild(): void;
  57561. /**
  57562. * @hidden
  57563. */
  57564. reset(): void;
  57565. /**
  57566. * Render the bounding boxes of a specific rendering group
  57567. * @param renderingGroupId defines the rendering group to render
  57568. */
  57569. render(renderingGroupId: number): void;
  57570. /**
  57571. * In case of occlusion queries, we can render the occlusion bounding box through this method
  57572. * @param mesh Define the mesh to render the occlusion bounding box for
  57573. */
  57574. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  57575. /**
  57576. * Dispose and release the resources attached to this renderer.
  57577. */
  57578. dispose(): void;
  57579. }
  57580. }
  57581. declare module BABYLON {
  57582. /** @hidden */
  57583. export var depthPixelShader: {
  57584. name: string;
  57585. shader: string;
  57586. };
  57587. }
  57588. declare module BABYLON {
  57589. /**
  57590. * This represents a depth renderer in Babylon.
  57591. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57592. */
  57593. export class DepthRenderer {
  57594. private _scene;
  57595. private _depthMap;
  57596. private _effect;
  57597. private _cachedDefines;
  57598. private _camera;
  57599. /**
  57600. * Specifiess that the depth renderer will only be used within
  57601. * the camera it is created for.
  57602. * This can help forcing its rendering during the camera processing.
  57603. */
  57604. useOnlyInActiveCamera: boolean;
  57605. /** @hidden */
  57606. static _SceneComponentInitialization: (scene: Scene) => void;
  57607. /**
  57608. * Instantiates a depth renderer
  57609. * @param scene The scene the renderer belongs to
  57610. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57611. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57612. */
  57613. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  57614. /**
  57615. * Creates the depth rendering effect and checks if the effect is ready.
  57616. * @param subMesh The submesh to be used to render the depth map of
  57617. * @param useInstances If multiple world instances should be used
  57618. * @returns if the depth renderer is ready to render the depth map
  57619. */
  57620. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57621. /**
  57622. * Gets the texture which the depth map will be written to.
  57623. * @returns The depth map texture
  57624. */
  57625. getDepthMap(): RenderTargetTexture;
  57626. /**
  57627. * Disposes of the depth renderer.
  57628. */
  57629. dispose(): void;
  57630. }
  57631. }
  57632. declare module BABYLON {
  57633. interface Scene {
  57634. /** @hidden (Backing field) */
  57635. _depthRenderer: {
  57636. [id: string]: DepthRenderer;
  57637. };
  57638. /**
  57639. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57640. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57641. * @returns the created depth renderer
  57642. */
  57643. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  57644. /**
  57645. * Disables a depth renderer for a given camera
  57646. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57647. */
  57648. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57649. }
  57650. /**
  57651. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57652. * in several rendering techniques.
  57653. */
  57654. export class DepthRendererSceneComponent implements ISceneComponent {
  57655. /**
  57656. * The component name helpfull to identify the component in the list of scene components.
  57657. */
  57658. readonly name: string;
  57659. /**
  57660. * The scene the component belongs to.
  57661. */
  57662. scene: Scene;
  57663. /**
  57664. * Creates a new instance of the component for the given scene
  57665. * @param scene Defines the scene to register the component in
  57666. */
  57667. constructor(scene: Scene);
  57668. /**
  57669. * Registers the component in a given scene
  57670. */
  57671. register(): void;
  57672. /**
  57673. * Rebuilds the elements related to this component in case of
  57674. * context lost for instance.
  57675. */
  57676. rebuild(): void;
  57677. /**
  57678. * Disposes the component and the associated ressources
  57679. */
  57680. dispose(): void;
  57681. private _gatherRenderTargets;
  57682. private _gatherActiveCameraRenderTargets;
  57683. }
  57684. }
  57685. declare module BABYLON {
  57686. /** @hidden */
  57687. export var outlinePixelShader: {
  57688. name: string;
  57689. shader: string;
  57690. };
  57691. }
  57692. declare module BABYLON {
  57693. /** @hidden */
  57694. export var outlineVertexShader: {
  57695. name: string;
  57696. shader: string;
  57697. };
  57698. }
  57699. declare module BABYLON {
  57700. interface Scene {
  57701. /** @hidden */
  57702. _outlineRenderer: OutlineRenderer;
  57703. /**
  57704. * Gets the outline renderer associated with the scene
  57705. * @returns a OutlineRenderer
  57706. */
  57707. getOutlineRenderer(): OutlineRenderer;
  57708. }
  57709. interface AbstractMesh {
  57710. /** @hidden (Backing field) */
  57711. _renderOutline: boolean;
  57712. /**
  57713. * Gets or sets a boolean indicating if the outline must be rendered as well
  57714. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57715. */
  57716. renderOutline: boolean;
  57717. /** @hidden (Backing field) */
  57718. _renderOverlay: boolean;
  57719. /**
  57720. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57721. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57722. */
  57723. renderOverlay: boolean;
  57724. }
  57725. /**
  57726. * This class is responsible to draw bothe outline/overlay of meshes.
  57727. * It should not be used directly but through the available method on mesh.
  57728. */
  57729. export class OutlineRenderer implements ISceneComponent {
  57730. /**
  57731. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57732. */
  57733. private static _StencilReference;
  57734. /**
  57735. * The name of the component. Each component must have a unique name.
  57736. */
  57737. name: string;
  57738. /**
  57739. * The scene the component belongs to.
  57740. */
  57741. scene: Scene;
  57742. /**
  57743. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57744. */
  57745. zOffset: number;
  57746. private _engine;
  57747. private _effect;
  57748. private _cachedDefines;
  57749. private _savedDepthWrite;
  57750. /**
  57751. * Instantiates a new outline renderer. (There could be only one per scene).
  57752. * @param scene Defines the scene it belongs to
  57753. */
  57754. constructor(scene: Scene);
  57755. /**
  57756. * Register the component to one instance of a scene.
  57757. */
  57758. register(): void;
  57759. /**
  57760. * Rebuilds the elements related to this component in case of
  57761. * context lost for instance.
  57762. */
  57763. rebuild(): void;
  57764. /**
  57765. * Disposes the component and the associated ressources.
  57766. */
  57767. dispose(): void;
  57768. /**
  57769. * Renders the outline in the canvas.
  57770. * @param subMesh Defines the sumesh to render
  57771. * @param batch Defines the batch of meshes in case of instances
  57772. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57773. */
  57774. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57775. /**
  57776. * Returns whether or not the outline renderer is ready for a given submesh.
  57777. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57778. * @param subMesh Defines the submesh to check readyness for
  57779. * @param useInstances Defines wheter wee are trying to render instances or not
  57780. * @returns true if ready otherwise false
  57781. */
  57782. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57783. private _beforeRenderingMesh;
  57784. private _afterRenderingMesh;
  57785. }
  57786. }
  57787. declare module BABYLON {
  57788. /**
  57789. * Defines the list of states available for a task inside a AssetsManager
  57790. */
  57791. export enum AssetTaskState {
  57792. /**
  57793. * Initialization
  57794. */
  57795. INIT = 0,
  57796. /**
  57797. * Running
  57798. */
  57799. RUNNING = 1,
  57800. /**
  57801. * Done
  57802. */
  57803. DONE = 2,
  57804. /**
  57805. * Error
  57806. */
  57807. ERROR = 3
  57808. }
  57809. /**
  57810. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57811. */
  57812. export abstract class AbstractAssetTask {
  57813. /**
  57814. * Task name
  57815. */ name: string;
  57816. /**
  57817. * Callback called when the task is successful
  57818. */
  57819. onSuccess: (task: any) => void;
  57820. /**
  57821. * Callback called when the task is not successful
  57822. */
  57823. onError: (task: any, message?: string, exception?: any) => void;
  57824. /**
  57825. * Creates a new AssetsManager
  57826. * @param name defines the name of the task
  57827. */
  57828. constructor(
  57829. /**
  57830. * Task name
  57831. */ name: string);
  57832. private _isCompleted;
  57833. private _taskState;
  57834. private _errorObject;
  57835. /**
  57836. * Get if the task is completed
  57837. */
  57838. readonly isCompleted: boolean;
  57839. /**
  57840. * Gets the current state of the task
  57841. */
  57842. readonly taskState: AssetTaskState;
  57843. /**
  57844. * Gets the current error object (if task is in error)
  57845. */
  57846. readonly errorObject: {
  57847. message?: string;
  57848. exception?: any;
  57849. };
  57850. /**
  57851. * Internal only
  57852. * @hidden
  57853. */
  57854. _setErrorObject(message?: string, exception?: any): void;
  57855. /**
  57856. * Execute the current task
  57857. * @param scene defines the scene where you want your assets to be loaded
  57858. * @param onSuccess is a callback called when the task is successfully executed
  57859. * @param onError is a callback called if an error occurs
  57860. */
  57861. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57862. /**
  57863. * Execute the current task
  57864. * @param scene defines the scene where you want your assets to be loaded
  57865. * @param onSuccess is a callback called when the task is successfully executed
  57866. * @param onError is a callback called if an error occurs
  57867. */
  57868. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57869. /**
  57870. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57871. * This can be used with failed tasks that have the reason for failure fixed.
  57872. */
  57873. reset(): void;
  57874. private onErrorCallback;
  57875. private onDoneCallback;
  57876. }
  57877. /**
  57878. * Define the interface used by progress events raised during assets loading
  57879. */
  57880. export interface IAssetsProgressEvent {
  57881. /**
  57882. * Defines the number of remaining tasks to process
  57883. */
  57884. remainingCount: number;
  57885. /**
  57886. * Defines the total number of tasks
  57887. */
  57888. totalCount: number;
  57889. /**
  57890. * Defines the task that was just processed
  57891. */
  57892. task: AbstractAssetTask;
  57893. }
  57894. /**
  57895. * Class used to share progress information about assets loading
  57896. */
  57897. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57898. /**
  57899. * Defines the number of remaining tasks to process
  57900. */
  57901. remainingCount: number;
  57902. /**
  57903. * Defines the total number of tasks
  57904. */
  57905. totalCount: number;
  57906. /**
  57907. * Defines the task that was just processed
  57908. */
  57909. task: AbstractAssetTask;
  57910. /**
  57911. * Creates a AssetsProgressEvent
  57912. * @param remainingCount defines the number of remaining tasks to process
  57913. * @param totalCount defines the total number of tasks
  57914. * @param task defines the task that was just processed
  57915. */
  57916. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57917. }
  57918. /**
  57919. * Define a task used by AssetsManager to load meshes
  57920. */
  57921. export class MeshAssetTask extends AbstractAssetTask {
  57922. /**
  57923. * Defines the name of the task
  57924. */
  57925. name: string;
  57926. /**
  57927. * Defines the list of mesh's names you want to load
  57928. */
  57929. meshesNames: any;
  57930. /**
  57931. * Defines the root url to use as a base to load your meshes and associated resources
  57932. */
  57933. rootUrl: string;
  57934. /**
  57935. * Defines the filename of the scene to load from
  57936. */
  57937. sceneFilename: string;
  57938. /**
  57939. * Gets the list of loaded meshes
  57940. */
  57941. loadedMeshes: Array<AbstractMesh>;
  57942. /**
  57943. * Gets the list of loaded particle systems
  57944. */
  57945. loadedParticleSystems: Array<IParticleSystem>;
  57946. /**
  57947. * Gets the list of loaded skeletons
  57948. */
  57949. loadedSkeletons: Array<Skeleton>;
  57950. /**
  57951. * Gets the list of loaded animation groups
  57952. */
  57953. loadedAnimationGroups: Array<AnimationGroup>;
  57954. /**
  57955. * Callback called when the task is successful
  57956. */
  57957. onSuccess: (task: MeshAssetTask) => void;
  57958. /**
  57959. * Callback called when the task is successful
  57960. */
  57961. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57962. /**
  57963. * Creates a new MeshAssetTask
  57964. * @param name defines the name of the task
  57965. * @param meshesNames defines the list of mesh's names you want to load
  57966. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57967. * @param sceneFilename defines the filename of the scene to load from
  57968. */
  57969. constructor(
  57970. /**
  57971. * Defines the name of the task
  57972. */
  57973. name: string,
  57974. /**
  57975. * Defines the list of mesh's names you want to load
  57976. */
  57977. meshesNames: any,
  57978. /**
  57979. * Defines the root url to use as a base to load your meshes and associated resources
  57980. */
  57981. rootUrl: string,
  57982. /**
  57983. * Defines the filename of the scene to load from
  57984. */
  57985. sceneFilename: string);
  57986. /**
  57987. * Execute the current task
  57988. * @param scene defines the scene where you want your assets to be loaded
  57989. * @param onSuccess is a callback called when the task is successfully executed
  57990. * @param onError is a callback called if an error occurs
  57991. */
  57992. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57993. }
  57994. /**
  57995. * Define a task used by AssetsManager to load text content
  57996. */
  57997. export class TextFileAssetTask extends AbstractAssetTask {
  57998. /**
  57999. * Defines the name of the task
  58000. */
  58001. name: string;
  58002. /**
  58003. * Defines the location of the file to load
  58004. */
  58005. url: string;
  58006. /**
  58007. * Gets the loaded text string
  58008. */
  58009. text: string;
  58010. /**
  58011. * Callback called when the task is successful
  58012. */
  58013. onSuccess: (task: TextFileAssetTask) => void;
  58014. /**
  58015. * Callback called when the task is successful
  58016. */
  58017. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  58018. /**
  58019. * Creates a new TextFileAssetTask object
  58020. * @param name defines the name of the task
  58021. * @param url defines the location of the file to load
  58022. */
  58023. constructor(
  58024. /**
  58025. * Defines the name of the task
  58026. */
  58027. name: string,
  58028. /**
  58029. * Defines the location of the file to load
  58030. */
  58031. url: string);
  58032. /**
  58033. * Execute the current task
  58034. * @param scene defines the scene where you want your assets to be loaded
  58035. * @param onSuccess is a callback called when the task is successfully executed
  58036. * @param onError is a callback called if an error occurs
  58037. */
  58038. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58039. }
  58040. /**
  58041. * Define a task used by AssetsManager to load binary data
  58042. */
  58043. export class BinaryFileAssetTask extends AbstractAssetTask {
  58044. /**
  58045. * Defines the name of the task
  58046. */
  58047. name: string;
  58048. /**
  58049. * Defines the location of the file to load
  58050. */
  58051. url: string;
  58052. /**
  58053. * Gets the lodaded data (as an array buffer)
  58054. */
  58055. data: ArrayBuffer;
  58056. /**
  58057. * Callback called when the task is successful
  58058. */
  58059. onSuccess: (task: BinaryFileAssetTask) => void;
  58060. /**
  58061. * Callback called when the task is successful
  58062. */
  58063. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  58064. /**
  58065. * Creates a new BinaryFileAssetTask object
  58066. * @param name defines the name of the new task
  58067. * @param url defines the location of the file to load
  58068. */
  58069. constructor(
  58070. /**
  58071. * Defines the name of the task
  58072. */
  58073. name: string,
  58074. /**
  58075. * Defines the location of the file to load
  58076. */
  58077. url: string);
  58078. /**
  58079. * Execute the current task
  58080. * @param scene defines the scene where you want your assets to be loaded
  58081. * @param onSuccess is a callback called when the task is successfully executed
  58082. * @param onError is a callback called if an error occurs
  58083. */
  58084. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58085. }
  58086. /**
  58087. * Define a task used by AssetsManager to load images
  58088. */
  58089. export class ImageAssetTask extends AbstractAssetTask {
  58090. /**
  58091. * Defines the name of the task
  58092. */
  58093. name: string;
  58094. /**
  58095. * Defines the location of the image to load
  58096. */
  58097. url: string;
  58098. /**
  58099. * Gets the loaded images
  58100. */
  58101. image: HTMLImageElement;
  58102. /**
  58103. * Callback called when the task is successful
  58104. */
  58105. onSuccess: (task: ImageAssetTask) => void;
  58106. /**
  58107. * Callback called when the task is successful
  58108. */
  58109. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  58110. /**
  58111. * Creates a new ImageAssetTask
  58112. * @param name defines the name of the task
  58113. * @param url defines the location of the image to load
  58114. */
  58115. constructor(
  58116. /**
  58117. * Defines the name of the task
  58118. */
  58119. name: string,
  58120. /**
  58121. * Defines the location of the image to load
  58122. */
  58123. url: string);
  58124. /**
  58125. * Execute the current task
  58126. * @param scene defines the scene where you want your assets to be loaded
  58127. * @param onSuccess is a callback called when the task is successfully executed
  58128. * @param onError is a callback called if an error occurs
  58129. */
  58130. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58131. }
  58132. /**
  58133. * Defines the interface used by texture loading tasks
  58134. */
  58135. export interface ITextureAssetTask<TEX extends BaseTexture> {
  58136. /**
  58137. * Gets the loaded texture
  58138. */
  58139. texture: TEX;
  58140. }
  58141. /**
  58142. * Define a task used by AssetsManager to load 2D textures
  58143. */
  58144. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  58145. /**
  58146. * Defines the name of the task
  58147. */
  58148. name: string;
  58149. /**
  58150. * Defines the location of the file to load
  58151. */
  58152. url: string;
  58153. /**
  58154. * Defines if mipmap should not be generated (default is false)
  58155. */
  58156. noMipmap?: boolean | undefined;
  58157. /**
  58158. * Defines if texture must be inverted on Y axis (default is false)
  58159. */
  58160. invertY?: boolean | undefined;
  58161. /**
  58162. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58163. */
  58164. samplingMode: number;
  58165. /**
  58166. * Gets the loaded texture
  58167. */
  58168. texture: Texture;
  58169. /**
  58170. * Callback called when the task is successful
  58171. */
  58172. onSuccess: (task: TextureAssetTask) => void;
  58173. /**
  58174. * Callback called when the task is successful
  58175. */
  58176. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  58177. /**
  58178. * Creates a new TextureAssetTask object
  58179. * @param name defines the name of the task
  58180. * @param url defines the location of the file to load
  58181. * @param noMipmap defines if mipmap should not be generated (default is false)
  58182. * @param invertY defines if texture must be inverted on Y axis (default is false)
  58183. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58184. */
  58185. constructor(
  58186. /**
  58187. * Defines the name of the task
  58188. */
  58189. name: string,
  58190. /**
  58191. * Defines the location of the file to load
  58192. */
  58193. url: string,
  58194. /**
  58195. * Defines if mipmap should not be generated (default is false)
  58196. */
  58197. noMipmap?: boolean | undefined,
  58198. /**
  58199. * Defines if texture must be inverted on Y axis (default is false)
  58200. */
  58201. invertY?: boolean | undefined,
  58202. /**
  58203. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58204. */
  58205. samplingMode?: number);
  58206. /**
  58207. * Execute the current task
  58208. * @param scene defines the scene where you want your assets to be loaded
  58209. * @param onSuccess is a callback called when the task is successfully executed
  58210. * @param onError is a callback called if an error occurs
  58211. */
  58212. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58213. }
  58214. /**
  58215. * Define a task used by AssetsManager to load cube textures
  58216. */
  58217. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  58218. /**
  58219. * Defines the name of the task
  58220. */
  58221. name: string;
  58222. /**
  58223. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58224. */
  58225. url: string;
  58226. /**
  58227. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58228. */
  58229. extensions?: string[] | undefined;
  58230. /**
  58231. * Defines if mipmaps should not be generated (default is false)
  58232. */
  58233. noMipmap?: boolean | undefined;
  58234. /**
  58235. * Defines the explicit list of files (undefined by default)
  58236. */
  58237. files?: string[] | undefined;
  58238. /**
  58239. * Gets the loaded texture
  58240. */
  58241. texture: CubeTexture;
  58242. /**
  58243. * Callback called when the task is successful
  58244. */
  58245. onSuccess: (task: CubeTextureAssetTask) => void;
  58246. /**
  58247. * Callback called when the task is successful
  58248. */
  58249. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  58250. /**
  58251. * Creates a new CubeTextureAssetTask
  58252. * @param name defines the name of the task
  58253. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58254. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58255. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58256. * @param files defines the explicit list of files (undefined by default)
  58257. */
  58258. constructor(
  58259. /**
  58260. * Defines the name of the task
  58261. */
  58262. name: string,
  58263. /**
  58264. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58265. */
  58266. url: string,
  58267. /**
  58268. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58269. */
  58270. extensions?: string[] | undefined,
  58271. /**
  58272. * Defines if mipmaps should not be generated (default is false)
  58273. */
  58274. noMipmap?: boolean | undefined,
  58275. /**
  58276. * Defines the explicit list of files (undefined by default)
  58277. */
  58278. files?: string[] | undefined);
  58279. /**
  58280. * Execute the current task
  58281. * @param scene defines the scene where you want your assets to be loaded
  58282. * @param onSuccess is a callback called when the task is successfully executed
  58283. * @param onError is a callback called if an error occurs
  58284. */
  58285. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58286. }
  58287. /**
  58288. * Define a task used by AssetsManager to load HDR cube textures
  58289. */
  58290. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  58291. /**
  58292. * Defines the name of the task
  58293. */
  58294. name: string;
  58295. /**
  58296. * Defines the location of the file to load
  58297. */
  58298. url: string;
  58299. /**
  58300. * Defines the desired size (the more it increases the longer the generation will be)
  58301. */
  58302. size: number;
  58303. /**
  58304. * Defines if mipmaps should not be generated (default is false)
  58305. */
  58306. noMipmap: boolean;
  58307. /**
  58308. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58309. */
  58310. generateHarmonics: boolean;
  58311. /**
  58312. * 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)
  58313. */
  58314. gammaSpace: boolean;
  58315. /**
  58316. * Internal Use Only
  58317. */
  58318. reserved: boolean;
  58319. /**
  58320. * Gets the loaded texture
  58321. */
  58322. texture: HDRCubeTexture;
  58323. /**
  58324. * Callback called when the task is successful
  58325. */
  58326. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  58327. /**
  58328. * Callback called when the task is successful
  58329. */
  58330. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  58331. /**
  58332. * Creates a new HDRCubeTextureAssetTask object
  58333. * @param name defines the name of the task
  58334. * @param url defines the location of the file to load
  58335. * @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.
  58336. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58337. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58338. * @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)
  58339. * @param reserved Internal use only
  58340. */
  58341. constructor(
  58342. /**
  58343. * Defines the name of the task
  58344. */
  58345. name: string,
  58346. /**
  58347. * Defines the location of the file to load
  58348. */
  58349. url: string,
  58350. /**
  58351. * Defines the desired size (the more it increases the longer the generation will be)
  58352. */
  58353. size: number,
  58354. /**
  58355. * Defines if mipmaps should not be generated (default is false)
  58356. */
  58357. noMipmap?: boolean,
  58358. /**
  58359. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58360. */
  58361. generateHarmonics?: boolean,
  58362. /**
  58363. * 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)
  58364. */
  58365. gammaSpace?: boolean,
  58366. /**
  58367. * Internal Use Only
  58368. */
  58369. reserved?: boolean);
  58370. /**
  58371. * Execute the current task
  58372. * @param scene defines the scene where you want your assets to be loaded
  58373. * @param onSuccess is a callback called when the task is successfully executed
  58374. * @param onError is a callback called if an error occurs
  58375. */
  58376. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58377. }
  58378. /**
  58379. * Define a task used by AssetsManager to load Equirectangular cube textures
  58380. */
  58381. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  58382. /**
  58383. * Defines the name of the task
  58384. */
  58385. name: string;
  58386. /**
  58387. * Defines the location of the file to load
  58388. */
  58389. url: string;
  58390. /**
  58391. * Defines the desired size (the more it increases the longer the generation will be)
  58392. */
  58393. size: number;
  58394. /**
  58395. * Defines if mipmaps should not be generated (default is false)
  58396. */
  58397. noMipmap: boolean;
  58398. /**
  58399. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58400. * but the standard material would require them in Gamma space) (default is true)
  58401. */
  58402. gammaSpace: boolean;
  58403. /**
  58404. * Gets the loaded texture
  58405. */
  58406. texture: EquiRectangularCubeTexture;
  58407. /**
  58408. * Callback called when the task is successful
  58409. */
  58410. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  58411. /**
  58412. * Callback called when the task is successful
  58413. */
  58414. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  58415. /**
  58416. * Creates a new EquiRectangularCubeTextureAssetTask object
  58417. * @param name defines the name of the task
  58418. * @param url defines the location of the file to load
  58419. * @param size defines the desired size (the more it increases the longer the generation will be)
  58420. * If the size is omitted this implies you are using a preprocessed cubemap.
  58421. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58422. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  58423. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  58424. * (default is true)
  58425. */
  58426. constructor(
  58427. /**
  58428. * Defines the name of the task
  58429. */
  58430. name: string,
  58431. /**
  58432. * Defines the location of the file to load
  58433. */
  58434. url: string,
  58435. /**
  58436. * Defines the desired size (the more it increases the longer the generation will be)
  58437. */
  58438. size: number,
  58439. /**
  58440. * Defines if mipmaps should not be generated (default is false)
  58441. */
  58442. noMipmap?: boolean,
  58443. /**
  58444. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58445. * but the standard material would require them in Gamma space) (default is true)
  58446. */
  58447. gammaSpace?: boolean);
  58448. /**
  58449. * Execute the current task
  58450. * @param scene defines the scene where you want your assets to be loaded
  58451. * @param onSuccess is a callback called when the task is successfully executed
  58452. * @param onError is a callback called if an error occurs
  58453. */
  58454. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58455. }
  58456. /**
  58457. * This class can be used to easily import assets into a scene
  58458. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  58459. */
  58460. export class AssetsManager {
  58461. private _scene;
  58462. private _isLoading;
  58463. protected _tasks: AbstractAssetTask[];
  58464. protected _waitingTasksCount: number;
  58465. protected _totalTasksCount: number;
  58466. /**
  58467. * Callback called when all tasks are processed
  58468. */
  58469. onFinish: (tasks: AbstractAssetTask[]) => void;
  58470. /**
  58471. * Callback called when a task is successful
  58472. */
  58473. onTaskSuccess: (task: AbstractAssetTask) => void;
  58474. /**
  58475. * Callback called when a task had an error
  58476. */
  58477. onTaskError: (task: AbstractAssetTask) => void;
  58478. /**
  58479. * Callback called when a task is done (whatever the result is)
  58480. */
  58481. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  58482. /**
  58483. * Observable called when all tasks are processed
  58484. */
  58485. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  58486. /**
  58487. * Observable called when a task had an error
  58488. */
  58489. onTaskErrorObservable: Observable<AbstractAssetTask>;
  58490. /**
  58491. * Observable called when all tasks were executed
  58492. */
  58493. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  58494. /**
  58495. * Observable called when a task is done (whatever the result is)
  58496. */
  58497. onProgressObservable: Observable<IAssetsProgressEvent>;
  58498. /**
  58499. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  58500. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  58501. */
  58502. useDefaultLoadingScreen: boolean;
  58503. /**
  58504. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  58505. * when all assets have been downloaded.
  58506. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  58507. */
  58508. autoHideLoadingUI: boolean;
  58509. /**
  58510. * Creates a new AssetsManager
  58511. * @param scene defines the scene to work on
  58512. */
  58513. constructor(scene: Scene);
  58514. /**
  58515. * Add a MeshAssetTask to the list of active tasks
  58516. * @param taskName defines the name of the new task
  58517. * @param meshesNames defines the name of meshes to load
  58518. * @param rootUrl defines the root url to use to locate files
  58519. * @param sceneFilename defines the filename of the scene file
  58520. * @returns a new MeshAssetTask object
  58521. */
  58522. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  58523. /**
  58524. * Add a TextFileAssetTask to the list of active tasks
  58525. * @param taskName defines the name of the new task
  58526. * @param url defines the url of the file to load
  58527. * @returns a new TextFileAssetTask object
  58528. */
  58529. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  58530. /**
  58531. * Add a BinaryFileAssetTask to the list of active tasks
  58532. * @param taskName defines the name of the new task
  58533. * @param url defines the url of the file to load
  58534. * @returns a new BinaryFileAssetTask object
  58535. */
  58536. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  58537. /**
  58538. * Add a ImageAssetTask to the list of active tasks
  58539. * @param taskName defines the name of the new task
  58540. * @param url defines the url of the file to load
  58541. * @returns a new ImageAssetTask object
  58542. */
  58543. addImageTask(taskName: string, url: string): ImageAssetTask;
  58544. /**
  58545. * Add a TextureAssetTask to the list of active tasks
  58546. * @param taskName defines the name of the new task
  58547. * @param url defines the url of the file to load
  58548. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58549. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  58550. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58551. * @returns a new TextureAssetTask object
  58552. */
  58553. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  58554. /**
  58555. * Add a CubeTextureAssetTask to the list of active tasks
  58556. * @param taskName defines the name of the new task
  58557. * @param url defines the url of the file to load
  58558. * @param extensions defines the extension to use to load the cube map (can be null)
  58559. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58560. * @param files defines the list of files to load (can be null)
  58561. * @returns a new CubeTextureAssetTask object
  58562. */
  58563. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  58564. /**
  58565. *
  58566. * Add a HDRCubeTextureAssetTask to the list of active tasks
  58567. * @param taskName defines the name of the new task
  58568. * @param url defines the url of the file to load
  58569. * @param size defines the size you want for the cubemap (can be null)
  58570. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58571. * @param generateHarmonics defines if you want to automatically generate (true by default)
  58572. * @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)
  58573. * @param reserved Internal use only
  58574. * @returns a new HDRCubeTextureAssetTask object
  58575. */
  58576. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  58577. /**
  58578. *
  58579. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  58580. * @param taskName defines the name of the new task
  58581. * @param url defines the url of the file to load
  58582. * @param size defines the size you want for the cubemap (can be null)
  58583. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58584. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58585. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58586. * @returns a new EquiRectangularCubeTextureAssetTask object
  58587. */
  58588. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58589. /**
  58590. * Remove a task from the assets manager.
  58591. * @param task the task to remove
  58592. */
  58593. removeTask(task: AbstractAssetTask): void;
  58594. private _decreaseWaitingTasksCount;
  58595. private _runTask;
  58596. /**
  58597. * Reset the AssetsManager and remove all tasks
  58598. * @return the current instance of the AssetsManager
  58599. */
  58600. reset(): AssetsManager;
  58601. /**
  58602. * Start the loading process
  58603. * @return the current instance of the AssetsManager
  58604. */
  58605. load(): AssetsManager;
  58606. /**
  58607. * Start the loading process as an async operation
  58608. * @return a promise returning the list of failed tasks
  58609. */
  58610. loadAsync(): Promise<void>;
  58611. }
  58612. }
  58613. declare module BABYLON {
  58614. /**
  58615. * Wrapper class for promise with external resolve and reject.
  58616. */
  58617. export class Deferred<T> {
  58618. /**
  58619. * The promise associated with this deferred object.
  58620. */
  58621. readonly promise: Promise<T>;
  58622. private _resolve;
  58623. private _reject;
  58624. /**
  58625. * The resolve method of the promise associated with this deferred object.
  58626. */
  58627. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58628. /**
  58629. * The reject method of the promise associated with this deferred object.
  58630. */
  58631. readonly reject: (reason?: any) => void;
  58632. /**
  58633. * Constructor for this deferred object.
  58634. */
  58635. constructor();
  58636. }
  58637. }
  58638. declare module BABYLON {
  58639. /**
  58640. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58641. */
  58642. export class MeshExploder {
  58643. private _centerMesh;
  58644. private _meshes;
  58645. private _meshesOrigins;
  58646. private _toCenterVectors;
  58647. private _scaledDirection;
  58648. private _newPosition;
  58649. private _centerPosition;
  58650. /**
  58651. * Explodes meshes from a center mesh.
  58652. * @param meshes The meshes to explode.
  58653. * @param centerMesh The mesh to be center of explosion.
  58654. */
  58655. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58656. private _setCenterMesh;
  58657. /**
  58658. * Get class name
  58659. * @returns "MeshExploder"
  58660. */
  58661. getClassName(): string;
  58662. /**
  58663. * "Exploded meshes"
  58664. * @returns Array of meshes with the centerMesh at index 0.
  58665. */
  58666. getMeshes(): Array<Mesh>;
  58667. /**
  58668. * Explodes meshes giving a specific direction
  58669. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58670. */
  58671. explode(direction?: number): void;
  58672. }
  58673. }
  58674. declare module BABYLON {
  58675. /**
  58676. * Class used to help managing file picking and drag'n'drop
  58677. */
  58678. export class FilesInput {
  58679. /**
  58680. * List of files ready to be loaded
  58681. */
  58682. static readonly FilesToLoad: {
  58683. [key: string]: File;
  58684. };
  58685. /**
  58686. * Callback called when a file is processed
  58687. */
  58688. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58689. private _engine;
  58690. private _currentScene;
  58691. private _sceneLoadedCallback;
  58692. private _progressCallback;
  58693. private _additionalRenderLoopLogicCallback;
  58694. private _textureLoadingCallback;
  58695. private _startingProcessingFilesCallback;
  58696. private _onReloadCallback;
  58697. private _errorCallback;
  58698. private _elementToMonitor;
  58699. private _sceneFileToLoad;
  58700. private _filesToLoad;
  58701. /**
  58702. * Creates a new FilesInput
  58703. * @param engine defines the rendering engine
  58704. * @param scene defines the hosting scene
  58705. * @param sceneLoadedCallback callback called when scene is loaded
  58706. * @param progressCallback callback called to track progress
  58707. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58708. * @param textureLoadingCallback callback called when a texture is loading
  58709. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58710. * @param onReloadCallback callback called when a reload is requested
  58711. * @param errorCallback callback call if an error occurs
  58712. */
  58713. 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);
  58714. private _dragEnterHandler;
  58715. private _dragOverHandler;
  58716. private _dropHandler;
  58717. /**
  58718. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58719. * @param elementToMonitor defines the DOM element to track
  58720. */
  58721. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58722. /**
  58723. * Release all associated resources
  58724. */
  58725. dispose(): void;
  58726. private renderFunction;
  58727. private drag;
  58728. private drop;
  58729. private _traverseFolder;
  58730. private _processFiles;
  58731. /**
  58732. * Load files from a drop event
  58733. * @param event defines the drop event to use as source
  58734. */
  58735. loadFiles(event: any): void;
  58736. private _processReload;
  58737. /**
  58738. * Reload the current scene from the loaded files
  58739. */
  58740. reload(): void;
  58741. }
  58742. }
  58743. declare module BABYLON {
  58744. /**
  58745. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58746. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58747. */
  58748. export class SceneOptimization {
  58749. /**
  58750. * Defines the priority of this optimization (0 by default which means first in the list)
  58751. */
  58752. priority: number;
  58753. /**
  58754. * Gets a string describing the action executed by the current optimization
  58755. * @returns description string
  58756. */
  58757. getDescription(): string;
  58758. /**
  58759. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58760. * @param scene defines the current scene where to apply this optimization
  58761. * @param optimizer defines the current optimizer
  58762. * @returns true if everything that can be done was applied
  58763. */
  58764. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58765. /**
  58766. * Creates the SceneOptimization object
  58767. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58768. * @param desc defines the description associated with the optimization
  58769. */
  58770. constructor(
  58771. /**
  58772. * Defines the priority of this optimization (0 by default which means first in the list)
  58773. */
  58774. priority?: number);
  58775. }
  58776. /**
  58777. * Defines an optimization used to reduce the size of render target textures
  58778. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58779. */
  58780. export class TextureOptimization 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 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
  58787. */
  58788. maximumSize: number;
  58789. /**
  58790. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58791. */
  58792. step: number;
  58793. /**
  58794. * Gets a string describing the action executed by the current optimization
  58795. * @returns description string
  58796. */
  58797. getDescription(): string;
  58798. /**
  58799. * Creates the TextureOptimization object
  58800. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58801. * @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
  58802. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58803. */
  58804. constructor(
  58805. /**
  58806. * Defines the priority of this optimization (0 by default which means first in the list)
  58807. */
  58808. priority?: number,
  58809. /**
  58810. * 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
  58811. */
  58812. maximumSize?: number,
  58813. /**
  58814. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58815. */
  58816. step?: number);
  58817. /**
  58818. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58819. * @param scene defines the current scene where to apply this optimization
  58820. * @param optimizer defines the current optimizer
  58821. * @returns true if everything that can be done was applied
  58822. */
  58823. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58824. }
  58825. /**
  58826. * Defines an optimization used to increase or decrease the rendering resolution
  58827. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58828. */
  58829. export class HardwareScalingOptimization extends SceneOptimization {
  58830. /**
  58831. * Defines the priority of this optimization (0 by default which means first in the list)
  58832. */
  58833. priority: number;
  58834. /**
  58835. * Defines the maximum scale to use (2 by default)
  58836. */
  58837. maximumScale: number;
  58838. /**
  58839. * Defines the step to use between two passes (0.5 by default)
  58840. */
  58841. step: number;
  58842. private _currentScale;
  58843. private _directionOffset;
  58844. /**
  58845. * Gets a string describing the action executed by the current optimization
  58846. * @return description string
  58847. */
  58848. getDescription(): string;
  58849. /**
  58850. * Creates the HardwareScalingOptimization object
  58851. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58852. * @param maximumScale defines the maximum scale to use (2 by default)
  58853. * @param step defines the step to use between two passes (0.5 by default)
  58854. */
  58855. constructor(
  58856. /**
  58857. * Defines the priority of this optimization (0 by default which means first in the list)
  58858. */
  58859. priority?: number,
  58860. /**
  58861. * Defines the maximum scale to use (2 by default)
  58862. */
  58863. maximumScale?: number,
  58864. /**
  58865. * Defines the step to use between two passes (0.5 by default)
  58866. */
  58867. step?: number);
  58868. /**
  58869. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58870. * @param scene defines the current scene where to apply this optimization
  58871. * @param optimizer defines the current optimizer
  58872. * @returns true if everything that can be done was applied
  58873. */
  58874. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58875. }
  58876. /**
  58877. * Defines an optimization used to remove shadows
  58878. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58879. */
  58880. export class ShadowsOptimization extends SceneOptimization {
  58881. /**
  58882. * Gets a string describing the action executed by the current optimization
  58883. * @return description string
  58884. */
  58885. getDescription(): string;
  58886. /**
  58887. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58888. * @param scene defines the current scene where to apply this optimization
  58889. * @param optimizer defines the current optimizer
  58890. * @returns true if everything that can be done was applied
  58891. */
  58892. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58893. }
  58894. /**
  58895. * Defines an optimization used to turn post-processes off
  58896. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58897. */
  58898. export class PostProcessesOptimization extends SceneOptimization {
  58899. /**
  58900. * Gets a string describing the action executed by the current optimization
  58901. * @return description string
  58902. */
  58903. getDescription(): string;
  58904. /**
  58905. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58906. * @param scene defines the current scene where to apply this optimization
  58907. * @param optimizer defines the current optimizer
  58908. * @returns true if everything that can be done was applied
  58909. */
  58910. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58911. }
  58912. /**
  58913. * Defines an optimization used to turn lens flares off
  58914. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58915. */
  58916. export class LensFlaresOptimization extends SceneOptimization {
  58917. /**
  58918. * Gets a string describing the action executed by the current optimization
  58919. * @return description string
  58920. */
  58921. getDescription(): string;
  58922. /**
  58923. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58924. * @param scene defines the current scene where to apply this optimization
  58925. * @param optimizer defines the current optimizer
  58926. * @returns true if everything that can be done was applied
  58927. */
  58928. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58929. }
  58930. /**
  58931. * Defines an optimization based on user defined callback.
  58932. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58933. */
  58934. export class CustomOptimization extends SceneOptimization {
  58935. /**
  58936. * Callback called to apply the custom optimization.
  58937. */
  58938. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58939. /**
  58940. * Callback called to get custom description
  58941. */
  58942. onGetDescription: () => string;
  58943. /**
  58944. * Gets a string describing the action executed by the current optimization
  58945. * @returns description string
  58946. */
  58947. getDescription(): string;
  58948. /**
  58949. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58950. * @param scene defines the current scene where to apply this optimization
  58951. * @param optimizer defines the current optimizer
  58952. * @returns true if everything that can be done was applied
  58953. */
  58954. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58955. }
  58956. /**
  58957. * Defines an optimization used to turn particles off
  58958. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58959. */
  58960. export class ParticlesOptimization extends SceneOptimization {
  58961. /**
  58962. * Gets a string describing the action executed by the current optimization
  58963. * @return description string
  58964. */
  58965. getDescription(): string;
  58966. /**
  58967. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58968. * @param scene defines the current scene where to apply this optimization
  58969. * @param optimizer defines the current optimizer
  58970. * @returns true if everything that can be done was applied
  58971. */
  58972. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58973. }
  58974. /**
  58975. * Defines an optimization used to turn render targets off
  58976. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58977. */
  58978. export class RenderTargetsOptimization extends SceneOptimization {
  58979. /**
  58980. * Gets a string describing the action executed by the current optimization
  58981. * @return description string
  58982. */
  58983. getDescription(): string;
  58984. /**
  58985. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58986. * @param scene defines the current scene where to apply this optimization
  58987. * @param optimizer defines the current optimizer
  58988. * @returns true if everything that can be done was applied
  58989. */
  58990. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58991. }
  58992. /**
  58993. * Defines an optimization used to merge meshes with compatible materials
  58994. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58995. */
  58996. export class MergeMeshesOptimization extends SceneOptimization {
  58997. private static _UpdateSelectionTree;
  58998. /**
  58999. * Gets or sets a boolean which defines if optimization octree has to be updated
  59000. */
  59001. /**
  59002. * Gets or sets a boolean which defines if optimization octree has to be updated
  59003. */
  59004. static UpdateSelectionTree: boolean;
  59005. /**
  59006. * Gets a string describing the action executed by the current optimization
  59007. * @return description string
  59008. */
  59009. getDescription(): string;
  59010. private _canBeMerged;
  59011. /**
  59012. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59013. * @param scene defines the current scene where to apply this optimization
  59014. * @param optimizer defines the current optimizer
  59015. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  59016. * @returns true if everything that can be done was applied
  59017. */
  59018. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  59019. }
  59020. /**
  59021. * Defines a list of options used by SceneOptimizer
  59022. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59023. */
  59024. export class SceneOptimizerOptions {
  59025. /**
  59026. * Defines the target frame rate to reach (60 by default)
  59027. */
  59028. targetFrameRate: number;
  59029. /**
  59030. * Defines the interval between two checkes (2000ms by default)
  59031. */
  59032. trackerDuration: number;
  59033. /**
  59034. * Gets the list of optimizations to apply
  59035. */
  59036. optimizations: SceneOptimization[];
  59037. /**
  59038. * Creates a new list of options used by SceneOptimizer
  59039. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  59040. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  59041. */
  59042. constructor(
  59043. /**
  59044. * Defines the target frame rate to reach (60 by default)
  59045. */
  59046. targetFrameRate?: number,
  59047. /**
  59048. * Defines the interval between two checkes (2000ms by default)
  59049. */
  59050. trackerDuration?: number);
  59051. /**
  59052. * Add a new optimization
  59053. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  59054. * @returns the current SceneOptimizerOptions
  59055. */
  59056. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  59057. /**
  59058. * Add a new custom optimization
  59059. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  59060. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  59061. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59062. * @returns the current SceneOptimizerOptions
  59063. */
  59064. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  59065. /**
  59066. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  59067. * @param targetFrameRate defines the target frame rate (60 by default)
  59068. * @returns a SceneOptimizerOptions object
  59069. */
  59070. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59071. /**
  59072. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  59073. * @param targetFrameRate defines the target frame rate (60 by default)
  59074. * @returns a SceneOptimizerOptions object
  59075. */
  59076. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59077. /**
  59078. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  59079. * @param targetFrameRate defines the target frame rate (60 by default)
  59080. * @returns a SceneOptimizerOptions object
  59081. */
  59082. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59083. }
  59084. /**
  59085. * Class used to run optimizations in order to reach a target frame rate
  59086. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59087. */
  59088. export class SceneOptimizer implements IDisposable {
  59089. private _isRunning;
  59090. private _options;
  59091. private _scene;
  59092. private _currentPriorityLevel;
  59093. private _targetFrameRate;
  59094. private _trackerDuration;
  59095. private _currentFrameRate;
  59096. private _sceneDisposeObserver;
  59097. private _improvementMode;
  59098. /**
  59099. * Defines an observable called when the optimizer reaches the target frame rate
  59100. */
  59101. onSuccessObservable: Observable<SceneOptimizer>;
  59102. /**
  59103. * Defines an observable called when the optimizer enables an optimization
  59104. */
  59105. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  59106. /**
  59107. * Defines an observable called when the optimizer is not able to reach the target frame rate
  59108. */
  59109. onFailureObservable: Observable<SceneOptimizer>;
  59110. /**
  59111. * Gets a boolean indicating if the optimizer is in improvement mode
  59112. */
  59113. readonly isInImprovementMode: boolean;
  59114. /**
  59115. * Gets the current priority level (0 at start)
  59116. */
  59117. readonly currentPriorityLevel: number;
  59118. /**
  59119. * Gets the current frame rate checked by the SceneOptimizer
  59120. */
  59121. readonly currentFrameRate: number;
  59122. /**
  59123. * Gets or sets the current target frame rate (60 by default)
  59124. */
  59125. /**
  59126. * Gets or sets the current target frame rate (60 by default)
  59127. */
  59128. targetFrameRate: number;
  59129. /**
  59130. * Gets or sets the current interval between two checks (every 2000ms by default)
  59131. */
  59132. /**
  59133. * Gets or sets the current interval between two checks (every 2000ms by default)
  59134. */
  59135. trackerDuration: number;
  59136. /**
  59137. * Gets the list of active optimizations
  59138. */
  59139. readonly optimizations: SceneOptimization[];
  59140. /**
  59141. * Creates a new SceneOptimizer
  59142. * @param scene defines the scene to work on
  59143. * @param options defines the options to use with the SceneOptimizer
  59144. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  59145. * @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)
  59146. */
  59147. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  59148. /**
  59149. * Stops the current optimizer
  59150. */
  59151. stop(): void;
  59152. /**
  59153. * Reset the optimizer to initial step (current priority level = 0)
  59154. */
  59155. reset(): void;
  59156. /**
  59157. * Start the optimizer. By default it will try to reach a specific framerate
  59158. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  59159. */
  59160. start(): void;
  59161. private _checkCurrentState;
  59162. /**
  59163. * Release all resources
  59164. */
  59165. dispose(): void;
  59166. /**
  59167. * Helper function to create a SceneOptimizer with one single line of code
  59168. * @param scene defines the scene to work on
  59169. * @param options defines the options to use with the SceneOptimizer
  59170. * @param onSuccess defines a callback to call on success
  59171. * @param onFailure defines a callback to call on failure
  59172. * @returns the new SceneOptimizer object
  59173. */
  59174. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  59175. }
  59176. }
  59177. declare module BABYLON {
  59178. /**
  59179. * Class used to serialize a scene into a string
  59180. */
  59181. export class SceneSerializer {
  59182. /**
  59183. * Clear cache used by a previous serialization
  59184. */
  59185. static ClearCache(): void;
  59186. /**
  59187. * Serialize a scene into a JSON compatible object
  59188. * @param scene defines the scene to serialize
  59189. * @returns a JSON compatible object
  59190. */
  59191. static Serialize(scene: Scene): any;
  59192. /**
  59193. * Serialize a mesh into a JSON compatible object
  59194. * @param toSerialize defines the mesh to serialize
  59195. * @param withParents defines if parents must be serialized as well
  59196. * @param withChildren defines if children must be serialized as well
  59197. * @returns a JSON compatible object
  59198. */
  59199. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  59200. }
  59201. }
  59202. declare module BABYLON {
  59203. /**
  59204. * Class used to host texture specific utilities
  59205. */
  59206. export class TextureTools {
  59207. /**
  59208. * Uses the GPU to create a copy texture rescaled at a given size
  59209. * @param texture Texture to copy from
  59210. * @param width defines the desired width
  59211. * @param height defines the desired height
  59212. * @param useBilinearMode defines if bilinear mode has to be used
  59213. * @return the generated texture
  59214. */
  59215. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  59216. }
  59217. }
  59218. declare module BABYLON {
  59219. /**
  59220. * This represents the different options available for the video capture.
  59221. */
  59222. export interface VideoRecorderOptions {
  59223. /** Defines the mime type of the video. */
  59224. mimeType: string;
  59225. /** Defines the FPS the video should be recorded at. */
  59226. fps: number;
  59227. /** Defines the chunk size for the recording data. */
  59228. recordChunckSize: number;
  59229. /** The audio tracks to attach to the recording. */
  59230. audioTracks?: MediaStreamTrack[];
  59231. }
  59232. /**
  59233. * This can help with recording videos from BabylonJS.
  59234. * This is based on the available WebRTC functionalities of the browser.
  59235. *
  59236. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  59237. */
  59238. export class VideoRecorder {
  59239. private static readonly _defaultOptions;
  59240. /**
  59241. * Returns whether or not the VideoRecorder is available in your browser.
  59242. * @param engine Defines the Babylon Engine.
  59243. * @returns true if supported otherwise false.
  59244. */
  59245. static IsSupported(engine: Engine): boolean;
  59246. private readonly _options;
  59247. private _canvas;
  59248. private _mediaRecorder;
  59249. private _recordedChunks;
  59250. private _fileName;
  59251. private _resolve;
  59252. private _reject;
  59253. /**
  59254. * True when a recording is already in progress.
  59255. */
  59256. readonly isRecording: boolean;
  59257. /**
  59258. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  59259. * @param engine Defines the BabylonJS Engine you wish to record.
  59260. * @param options Defines options that can be used to customize the capture.
  59261. */
  59262. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  59263. /**
  59264. * Stops the current recording before the default capture timeout passed in the startRecording function.
  59265. */
  59266. stopRecording(): void;
  59267. /**
  59268. * Starts recording the canvas for a max duration specified in parameters.
  59269. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  59270. * If null no automatic download will start and you can rely on the promise to get the data back.
  59271. * @param maxDuration Defines the maximum recording time in seconds.
  59272. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  59273. * @return A promise callback at the end of the recording with the video data in Blob.
  59274. */
  59275. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  59276. /**
  59277. * Releases internal resources used during the recording.
  59278. */
  59279. dispose(): void;
  59280. private _handleDataAvailable;
  59281. private _handleError;
  59282. private _handleStop;
  59283. }
  59284. }
  59285. declare module BABYLON {
  59286. /**
  59287. * Class containing a set of static utilities functions for screenshots
  59288. */
  59289. export class ScreenshotTools {
  59290. /**
  59291. * Captures a screenshot of the current rendering
  59292. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59293. * @param engine defines the rendering engine
  59294. * @param camera defines the source camera
  59295. * @param size This parameter can be set to a single number or to an object with the
  59296. * following (optional) properties: precision, width, height. If a single number is passed,
  59297. * it will be used for both width and height. If an object is passed, the screenshot size
  59298. * will be derived from the parameters. The precision property is a multiplier allowing
  59299. * rendering at a higher or lower resolution
  59300. * @param successCallback defines the callback receives a single parameter which contains the
  59301. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59302. * src parameter of an <img> to display it
  59303. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  59304. * Check your browser for supported MIME types
  59305. */
  59306. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  59307. /**
  59308. * Generates an image screenshot from the specified camera.
  59309. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59310. * @param engine The engine to use for rendering
  59311. * @param camera The camera to use for rendering
  59312. * @param size This parameter can be set to a single number or to an object with the
  59313. * following (optional) properties: precision, width, height. If a single number is passed,
  59314. * it will be used for both width and height. If an object is passed, the screenshot size
  59315. * will be derived from the parameters. The precision property is a multiplier allowing
  59316. * rendering at a higher or lower resolution
  59317. * @param successCallback The callback receives a single parameter which contains the
  59318. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59319. * src parameter of an <img> to display it
  59320. * @param mimeType The MIME type of the screenshot image (default: image/png).
  59321. * Check your browser for supported MIME types
  59322. * @param samples Texture samples (default: 1)
  59323. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  59324. * @param fileName A name for for the downloaded file.
  59325. */
  59326. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  59327. }
  59328. }
  59329. declare module BABYLON {
  59330. /**
  59331. * A cursor which tracks a point on a path
  59332. */
  59333. export class PathCursor {
  59334. private path;
  59335. /**
  59336. * Stores path cursor callbacks for when an onchange event is triggered
  59337. */
  59338. private _onchange;
  59339. /**
  59340. * The value of the path cursor
  59341. */
  59342. value: number;
  59343. /**
  59344. * The animation array of the path cursor
  59345. */
  59346. animations: Animation[];
  59347. /**
  59348. * Initializes the path cursor
  59349. * @param path The path to track
  59350. */
  59351. constructor(path: Path2);
  59352. /**
  59353. * Gets the cursor point on the path
  59354. * @returns A point on the path cursor at the cursor location
  59355. */
  59356. getPoint(): Vector3;
  59357. /**
  59358. * Moves the cursor ahead by the step amount
  59359. * @param step The amount to move the cursor forward
  59360. * @returns This path cursor
  59361. */
  59362. moveAhead(step?: number): PathCursor;
  59363. /**
  59364. * Moves the cursor behind by the step amount
  59365. * @param step The amount to move the cursor back
  59366. * @returns This path cursor
  59367. */
  59368. moveBack(step?: number): PathCursor;
  59369. /**
  59370. * Moves the cursor by the step amount
  59371. * If the step amount is greater than one, an exception is thrown
  59372. * @param step The amount to move the cursor
  59373. * @returns This path cursor
  59374. */
  59375. move(step: number): PathCursor;
  59376. /**
  59377. * Ensures that the value is limited between zero and one
  59378. * @returns This path cursor
  59379. */
  59380. private ensureLimits;
  59381. /**
  59382. * Runs onchange callbacks on change (used by the animation engine)
  59383. * @returns This path cursor
  59384. */
  59385. private raiseOnChange;
  59386. /**
  59387. * Executes a function on change
  59388. * @param f A path cursor onchange callback
  59389. * @returns This path cursor
  59390. */
  59391. onchange(f: (cursor: PathCursor) => void): PathCursor;
  59392. }
  59393. }
  59394. declare module BABYLON {
  59395. /** @hidden */
  59396. export var blurPixelShader: {
  59397. name: string;
  59398. shader: string;
  59399. };
  59400. }
  59401. declare module BABYLON {
  59402. /** @hidden */
  59403. export var pointCloudVertexDeclaration: {
  59404. name: string;
  59405. shader: string;
  59406. };
  59407. }
  59408. // Mixins
  59409. interface Window {
  59410. mozIndexedDB: IDBFactory;
  59411. webkitIndexedDB: IDBFactory;
  59412. msIndexedDB: IDBFactory;
  59413. webkitURL: typeof URL;
  59414. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  59415. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  59416. WebGLRenderingContext: WebGLRenderingContext;
  59417. MSGesture: MSGesture;
  59418. CANNON: any;
  59419. AudioContext: AudioContext;
  59420. webkitAudioContext: AudioContext;
  59421. PointerEvent: any;
  59422. Math: Math;
  59423. Uint8Array: Uint8ArrayConstructor;
  59424. Float32Array: Float32ArrayConstructor;
  59425. mozURL: typeof URL;
  59426. msURL: typeof URL;
  59427. VRFrameData: any; // WebVR, from specs 1.1
  59428. DracoDecoderModule: any;
  59429. setImmediate(handler: (...args: any[]) => void): number;
  59430. }
  59431. interface HTMLCanvasElement {
  59432. requestPointerLock(): void;
  59433. msRequestPointerLock?(): void;
  59434. mozRequestPointerLock?(): void;
  59435. webkitRequestPointerLock?(): void;
  59436. /** Track wether a record is in progress */
  59437. isRecording: boolean;
  59438. /** Capture Stream method defined by some browsers */
  59439. captureStream(fps?: number): MediaStream;
  59440. }
  59441. interface CanvasRenderingContext2D {
  59442. msImageSmoothingEnabled: boolean;
  59443. }
  59444. interface MouseEvent {
  59445. mozMovementX: number;
  59446. mozMovementY: number;
  59447. webkitMovementX: number;
  59448. webkitMovementY: number;
  59449. msMovementX: number;
  59450. msMovementY: number;
  59451. }
  59452. interface Navigator {
  59453. mozGetVRDevices: (any: any) => any;
  59454. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59455. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59456. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59457. webkitGetGamepads(): Gamepad[];
  59458. msGetGamepads(): Gamepad[];
  59459. webkitGamepads(): Gamepad[];
  59460. }
  59461. interface HTMLVideoElement {
  59462. mozSrcObject: any;
  59463. }
  59464. interface Math {
  59465. fround(x: number): number;
  59466. imul(a: number, b: number): number;
  59467. }
  59468. interface WebGLRenderingContext {
  59469. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59470. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59471. vertexAttribDivisor(index: number, divisor: number): void;
  59472. createVertexArray(): any;
  59473. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59474. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59475. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59476. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59477. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59478. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59479. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59480. // Queries
  59481. createQuery(): WebGLQuery;
  59482. deleteQuery(query: WebGLQuery): void;
  59483. beginQuery(target: number, query: WebGLQuery): void;
  59484. endQuery(target: number): void;
  59485. getQueryParameter(query: WebGLQuery, pname: number): any;
  59486. getQuery(target: number, pname: number): any;
  59487. MAX_SAMPLES: number;
  59488. RGBA8: number;
  59489. READ_FRAMEBUFFER: number;
  59490. DRAW_FRAMEBUFFER: number;
  59491. UNIFORM_BUFFER: number;
  59492. HALF_FLOAT_OES: number;
  59493. RGBA16F: number;
  59494. RGBA32F: number;
  59495. R32F: number;
  59496. RG32F: number;
  59497. RGB32F: number;
  59498. R16F: number;
  59499. RG16F: number;
  59500. RGB16F: number;
  59501. RED: number;
  59502. RG: number;
  59503. R8: number;
  59504. RG8: number;
  59505. UNSIGNED_INT_24_8: number;
  59506. DEPTH24_STENCIL8: number;
  59507. /* Multiple Render Targets */
  59508. drawBuffers(buffers: number[]): void;
  59509. readBuffer(src: number): void;
  59510. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59511. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59512. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59513. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59514. // Occlusion Query
  59515. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59516. ANY_SAMPLES_PASSED: number;
  59517. QUERY_RESULT_AVAILABLE: number;
  59518. QUERY_RESULT: number;
  59519. }
  59520. interface WebGLProgram {
  59521. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59522. }
  59523. interface EXT_disjoint_timer_query {
  59524. QUERY_COUNTER_BITS_EXT: number;
  59525. TIME_ELAPSED_EXT: number;
  59526. TIMESTAMP_EXT: number;
  59527. GPU_DISJOINT_EXT: number;
  59528. QUERY_RESULT_EXT: number;
  59529. QUERY_RESULT_AVAILABLE_EXT: number;
  59530. queryCounterEXT(query: WebGLQuery, target: number): void;
  59531. createQueryEXT(): WebGLQuery;
  59532. beginQueryEXT(target: number, query: WebGLQuery): void;
  59533. endQueryEXT(target: number): void;
  59534. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59535. deleteQueryEXT(query: WebGLQuery): void;
  59536. }
  59537. interface WebGLUniformLocation {
  59538. _currentState: any;
  59539. }
  59540. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59541. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59542. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59543. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59544. interface WebGLRenderingContext {
  59545. readonly RASTERIZER_DISCARD: number;
  59546. readonly DEPTH_COMPONENT24: number;
  59547. readonly TEXTURE_3D: number;
  59548. readonly TEXTURE_2D_ARRAY: number;
  59549. readonly TEXTURE_COMPARE_FUNC: number;
  59550. readonly TEXTURE_COMPARE_MODE: number;
  59551. readonly COMPARE_REF_TO_TEXTURE: number;
  59552. readonly TEXTURE_WRAP_R: number;
  59553. readonly HALF_FLOAT: number;
  59554. readonly RGB8: number;
  59555. readonly RED_INTEGER: number;
  59556. readonly RG_INTEGER: number;
  59557. readonly RGB_INTEGER: number;
  59558. readonly RGBA_INTEGER: number;
  59559. readonly R8_SNORM: number;
  59560. readonly RG8_SNORM: number;
  59561. readonly RGB8_SNORM: number;
  59562. readonly RGBA8_SNORM: number;
  59563. readonly R8I: number;
  59564. readonly RG8I: number;
  59565. readonly RGB8I: number;
  59566. readonly RGBA8I: number;
  59567. readonly R8UI: number;
  59568. readonly RG8UI: number;
  59569. readonly RGB8UI: number;
  59570. readonly RGBA8UI: number;
  59571. readonly R16I: number;
  59572. readonly RG16I: number;
  59573. readonly RGB16I: number;
  59574. readonly RGBA16I: number;
  59575. readonly R16UI: number;
  59576. readonly RG16UI: number;
  59577. readonly RGB16UI: number;
  59578. readonly RGBA16UI: number;
  59579. readonly R32I: number;
  59580. readonly RG32I: number;
  59581. readonly RGB32I: number;
  59582. readonly RGBA32I: number;
  59583. readonly R32UI: number;
  59584. readonly RG32UI: number;
  59585. readonly RGB32UI: number;
  59586. readonly RGBA32UI: number;
  59587. readonly RGB10_A2UI: number;
  59588. readonly R11F_G11F_B10F: number;
  59589. readonly RGB9_E5: number;
  59590. readonly RGB10_A2: number;
  59591. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59592. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59593. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59594. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59595. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59596. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59597. 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;
  59598. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59599. readonly TRANSFORM_FEEDBACK: number;
  59600. readonly INTERLEAVED_ATTRIBS: number;
  59601. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59602. createTransformFeedback(): WebGLTransformFeedback;
  59603. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59604. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59605. beginTransformFeedback(primitiveMode: number): void;
  59606. endTransformFeedback(): void;
  59607. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59608. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59609. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59610. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59611. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59612. }
  59613. interface ImageBitmap {
  59614. readonly width: number;
  59615. readonly height: number;
  59616. close(): void;
  59617. }
  59618. interface WebGLQuery extends WebGLObject {
  59619. }
  59620. declare var WebGLQuery: {
  59621. prototype: WebGLQuery;
  59622. new(): WebGLQuery;
  59623. };
  59624. interface WebGLSampler extends WebGLObject {
  59625. }
  59626. declare var WebGLSampler: {
  59627. prototype: WebGLSampler;
  59628. new(): WebGLSampler;
  59629. };
  59630. interface WebGLSync extends WebGLObject {
  59631. }
  59632. declare var WebGLSync: {
  59633. prototype: WebGLSync;
  59634. new(): WebGLSync;
  59635. };
  59636. interface WebGLTransformFeedback extends WebGLObject {
  59637. }
  59638. declare var WebGLTransformFeedback: {
  59639. prototype: WebGLTransformFeedback;
  59640. new(): WebGLTransformFeedback;
  59641. };
  59642. interface WebGLVertexArrayObject extends WebGLObject {
  59643. }
  59644. declare var WebGLVertexArrayObject: {
  59645. prototype: WebGLVertexArrayObject;
  59646. new(): WebGLVertexArrayObject;
  59647. };
  59648. // Type definitions for WebVR API
  59649. // Project: https://w3c.github.io/webvr/
  59650. // Definitions by: six a <https://github.com/lostfictions>
  59651. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59652. interface VRDisplay extends EventTarget {
  59653. /**
  59654. * Dictionary of capabilities describing the VRDisplay.
  59655. */
  59656. readonly capabilities: VRDisplayCapabilities;
  59657. /**
  59658. * z-depth defining the far plane of the eye view frustum
  59659. * enables mapping of values in the render target depth
  59660. * attachment to scene coordinates. Initially set to 10000.0.
  59661. */
  59662. depthFar: number;
  59663. /**
  59664. * z-depth defining the near plane of the eye view frustum
  59665. * enables mapping of values in the render target depth
  59666. * attachment to scene coordinates. Initially set to 0.01.
  59667. */
  59668. depthNear: number;
  59669. /**
  59670. * An identifier for this distinct VRDisplay. Used as an
  59671. * association point in the Gamepad API.
  59672. */
  59673. readonly displayId: number;
  59674. /**
  59675. * A display name, a user-readable name identifying it.
  59676. */
  59677. readonly displayName: string;
  59678. readonly isConnected: boolean;
  59679. readonly isPresenting: boolean;
  59680. /**
  59681. * If this VRDisplay supports room-scale experiences, the optional
  59682. * stage attribute contains details on the room-scale parameters.
  59683. */
  59684. readonly stageParameters: VRStageParameters | null;
  59685. /**
  59686. * Passing the value returned by `requestAnimationFrame` to
  59687. * `cancelAnimationFrame` will unregister the callback.
  59688. * @param handle Define the hanle of the request to cancel
  59689. */
  59690. cancelAnimationFrame(handle: number): void;
  59691. /**
  59692. * Stops presenting to the VRDisplay.
  59693. * @returns a promise to know when it stopped
  59694. */
  59695. exitPresent(): Promise<void>;
  59696. /**
  59697. * Return the current VREyeParameters for the given eye.
  59698. * @param whichEye Define the eye we want the parameter for
  59699. * @returns the eye parameters
  59700. */
  59701. getEyeParameters(whichEye: string): VREyeParameters;
  59702. /**
  59703. * Populates the passed VRFrameData with the information required to render
  59704. * the current frame.
  59705. * @param frameData Define the data structure to populate
  59706. * @returns true if ok otherwise false
  59707. */
  59708. getFrameData(frameData: VRFrameData): boolean;
  59709. /**
  59710. * Get the layers currently being presented.
  59711. * @returns the list of VR layers
  59712. */
  59713. getLayers(): VRLayer[];
  59714. /**
  59715. * Return a VRPose containing the future predicted pose of the VRDisplay
  59716. * when the current frame will be presented. The value returned will not
  59717. * change until JavaScript has returned control to the browser.
  59718. *
  59719. * The VRPose will contain the position, orientation, velocity,
  59720. * and acceleration of each of these properties.
  59721. * @returns the pose object
  59722. */
  59723. getPose(): VRPose;
  59724. /**
  59725. * Return the current instantaneous pose of the VRDisplay, with no
  59726. * prediction applied.
  59727. * @returns the current instantaneous pose
  59728. */
  59729. getImmediatePose(): VRPose;
  59730. /**
  59731. * The callback passed to `requestAnimationFrame` will be called
  59732. * any time a new frame should be rendered. When the VRDisplay is
  59733. * presenting the callback will be called at the native refresh
  59734. * rate of the HMD. When not presenting this function acts
  59735. * identically to how window.requestAnimationFrame acts. Content should
  59736. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59737. * asynchronously from other displays and at differing refresh rates.
  59738. * @param callback Define the eaction to run next frame
  59739. * @returns the request handle it
  59740. */
  59741. requestAnimationFrame(callback: FrameRequestCallback): number;
  59742. /**
  59743. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59744. * Repeat calls while already presenting will update the VRLayers being displayed.
  59745. * @param layers Define the list of layer to present
  59746. * @returns a promise to know when the request has been fulfilled
  59747. */
  59748. requestPresent(layers: VRLayer[]): Promise<void>;
  59749. /**
  59750. * Reset the pose for this display, treating its current position and
  59751. * orientation as the "origin/zero" values. VRPose.position,
  59752. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59753. * updated when calling resetPose(). This should be called in only
  59754. * sitting-space experiences.
  59755. */
  59756. resetPose(): void;
  59757. /**
  59758. * The VRLayer provided to the VRDisplay will be captured and presented
  59759. * in the HMD. Calling this function has the same effect on the source
  59760. * canvas as any other operation that uses its source image, and canvases
  59761. * created without preserveDrawingBuffer set to true will be cleared.
  59762. * @param pose Define the pose to submit
  59763. */
  59764. submitFrame(pose?: VRPose): void;
  59765. }
  59766. declare var VRDisplay: {
  59767. prototype: VRDisplay;
  59768. new(): VRDisplay;
  59769. };
  59770. interface VRLayer {
  59771. leftBounds?: number[] | Float32Array | null;
  59772. rightBounds?: number[] | Float32Array | null;
  59773. source?: HTMLCanvasElement | null;
  59774. }
  59775. interface VRDisplayCapabilities {
  59776. readonly canPresent: boolean;
  59777. readonly hasExternalDisplay: boolean;
  59778. readonly hasOrientation: boolean;
  59779. readonly hasPosition: boolean;
  59780. readonly maxLayers: number;
  59781. }
  59782. interface VREyeParameters {
  59783. /** @deprecated */
  59784. readonly fieldOfView: VRFieldOfView;
  59785. readonly offset: Float32Array;
  59786. readonly renderHeight: number;
  59787. readonly renderWidth: number;
  59788. }
  59789. interface VRFieldOfView {
  59790. readonly downDegrees: number;
  59791. readonly leftDegrees: number;
  59792. readonly rightDegrees: number;
  59793. readonly upDegrees: number;
  59794. }
  59795. interface VRFrameData {
  59796. readonly leftProjectionMatrix: Float32Array;
  59797. readonly leftViewMatrix: Float32Array;
  59798. readonly pose: VRPose;
  59799. readonly rightProjectionMatrix: Float32Array;
  59800. readonly rightViewMatrix: Float32Array;
  59801. readonly timestamp: number;
  59802. }
  59803. interface VRPose {
  59804. readonly angularAcceleration: Float32Array | null;
  59805. readonly angularVelocity: Float32Array | null;
  59806. readonly linearAcceleration: Float32Array | null;
  59807. readonly linearVelocity: Float32Array | null;
  59808. readonly orientation: Float32Array | null;
  59809. readonly position: Float32Array | null;
  59810. readonly timestamp: number;
  59811. }
  59812. interface VRStageParameters {
  59813. sittingToStandingTransform?: Float32Array;
  59814. sizeX?: number;
  59815. sizeY?: number;
  59816. }
  59817. interface Navigator {
  59818. getVRDisplays(): Promise<VRDisplay[]>;
  59819. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59820. }
  59821. interface Window {
  59822. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59823. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59824. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59825. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59826. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59827. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59828. }
  59829. interface Gamepad {
  59830. readonly displayId: number;
  59831. }
  59832. interface XRDevice {
  59833. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59834. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59835. }
  59836. interface XRSession {
  59837. getInputSources(): Array<any>;
  59838. baseLayer: XRWebGLLayer;
  59839. requestFrameOfReference(type: string): Promise<void>;
  59840. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59841. end(): Promise<void>;
  59842. requestAnimationFrame: Function;
  59843. addEventListener: Function;
  59844. }
  59845. interface XRSessionCreationOptions {
  59846. outputContext?: WebGLRenderingContext | null;
  59847. immersive?: boolean;
  59848. environmentIntegration?: boolean;
  59849. }
  59850. interface XRLayer {
  59851. getViewport: Function;
  59852. framebufferWidth: number;
  59853. framebufferHeight: number;
  59854. }
  59855. interface XRView {
  59856. projectionMatrix: Float32Array;
  59857. }
  59858. interface XRFrame {
  59859. getDevicePose: Function;
  59860. getInputPose: Function;
  59861. views: Array<XRView>;
  59862. baseLayer: XRLayer;
  59863. }
  59864. interface XRFrameOfReference {
  59865. }
  59866. interface XRWebGLLayer extends XRLayer {
  59867. framebuffer: WebGLFramebuffer;
  59868. }
  59869. declare var XRWebGLLayer: {
  59870. prototype: XRWebGLLayer;
  59871. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59872. };
  59873. declare module BABYLON.GUI {
  59874. /**
  59875. * Class used to specific a value and its associated unit
  59876. */
  59877. export class ValueAndUnit {
  59878. /** defines the unit to store */
  59879. unit: number;
  59880. /** defines a boolean indicating if the value can be negative */
  59881. negativeValueAllowed: boolean;
  59882. private _value;
  59883. private _originalUnit;
  59884. /**
  59885. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  59886. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59887. */
  59888. ignoreAdaptiveScaling: boolean;
  59889. /**
  59890. * Creates a new ValueAndUnit
  59891. * @param value defines the value to store
  59892. * @param unit defines the unit to store
  59893. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  59894. */
  59895. constructor(value: number,
  59896. /** defines the unit to store */
  59897. unit?: number,
  59898. /** defines a boolean indicating if the value can be negative */
  59899. negativeValueAllowed?: boolean);
  59900. /** Gets a boolean indicating if the value is a percentage */
  59901. readonly isPercentage: boolean;
  59902. /** Gets a boolean indicating if the value is store as pixel */
  59903. readonly isPixel: boolean;
  59904. /** Gets direct internal value */
  59905. readonly internalValue: number;
  59906. /**
  59907. * Gets value as pixel
  59908. * @param host defines the root host
  59909. * @param refValue defines the reference value for percentages
  59910. * @returns the value as pixel
  59911. */
  59912. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  59913. /**
  59914. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  59915. * @param value defines the value to store
  59916. * @param unit defines the unit to store
  59917. * @returns the current ValueAndUnit
  59918. */
  59919. updateInPlace(value: number, unit?: number): ValueAndUnit;
  59920. /**
  59921. * Gets the value accordingly to its unit
  59922. * @param host defines the root host
  59923. * @returns the value
  59924. */
  59925. getValue(host: AdvancedDynamicTexture): number;
  59926. /**
  59927. * Gets a string representation of the value
  59928. * @param host defines the root host
  59929. * @param decimals defines an optional number of decimals to display
  59930. * @returns a string
  59931. */
  59932. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  59933. /**
  59934. * Store a value parsed from a string
  59935. * @param source defines the source string
  59936. * @returns true if the value was successfully parsed
  59937. */
  59938. fromString(source: string | number): boolean;
  59939. private static _Regex;
  59940. private static _UNITMODE_PERCENTAGE;
  59941. private static _UNITMODE_PIXEL;
  59942. /** UNITMODE_PERCENTAGE */
  59943. static readonly UNITMODE_PERCENTAGE: number;
  59944. /** UNITMODE_PIXEL */
  59945. static readonly UNITMODE_PIXEL: number;
  59946. }
  59947. }
  59948. declare module BABYLON.GUI {
  59949. /**
  59950. * Define a style used by control to automatically setup properties based on a template.
  59951. * Only support font related properties so far
  59952. */
  59953. export class Style implements BABYLON.IDisposable {
  59954. private _fontFamily;
  59955. private _fontStyle;
  59956. private _fontWeight;
  59957. /** @hidden */
  59958. _host: AdvancedDynamicTexture;
  59959. /** @hidden */
  59960. _fontSize: ValueAndUnit;
  59961. /**
  59962. * BABYLON.Observable raised when the style values are changed
  59963. */
  59964. onChangedObservable: BABYLON.Observable<Style>;
  59965. /**
  59966. * Creates a new style object
  59967. * @param host defines the AdvancedDynamicTexture which hosts this style
  59968. */
  59969. constructor(host: AdvancedDynamicTexture);
  59970. /**
  59971. * Gets or sets the font size
  59972. */
  59973. fontSize: string | number;
  59974. /**
  59975. * Gets or sets the font family
  59976. */
  59977. fontFamily: string;
  59978. /**
  59979. * Gets or sets the font style
  59980. */
  59981. fontStyle: string;
  59982. /** Gets or sets font weight */
  59983. fontWeight: string;
  59984. /** Dispose all associated resources */
  59985. dispose(): void;
  59986. }
  59987. }
  59988. declare module BABYLON.GUI {
  59989. /**
  59990. * Class used to transport BABYLON.Vector2 information for pointer events
  59991. */
  59992. export class Vector2WithInfo extends BABYLON.Vector2 {
  59993. /** defines the current mouse button index */
  59994. buttonIndex: number;
  59995. /**
  59996. * Creates a new Vector2WithInfo
  59997. * @param source defines the vector2 data to transport
  59998. * @param buttonIndex defines the current mouse button index
  59999. */
  60000. constructor(source: BABYLON.Vector2,
  60001. /** defines the current mouse button index */
  60002. buttonIndex?: number);
  60003. }
  60004. /** Class used to provide 2D matrix features */
  60005. export class Matrix2D {
  60006. /** Gets the internal array of 6 floats used to store matrix data */
  60007. m: Float32Array;
  60008. /**
  60009. * Creates a new matrix
  60010. * @param m00 defines value for (0, 0)
  60011. * @param m01 defines value for (0, 1)
  60012. * @param m10 defines value for (1, 0)
  60013. * @param m11 defines value for (1, 1)
  60014. * @param m20 defines value for (2, 0)
  60015. * @param m21 defines value for (2, 1)
  60016. */
  60017. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  60018. /**
  60019. * Fills the matrix from direct values
  60020. * @param m00 defines value for (0, 0)
  60021. * @param m01 defines value for (0, 1)
  60022. * @param m10 defines value for (1, 0)
  60023. * @param m11 defines value for (1, 1)
  60024. * @param m20 defines value for (2, 0)
  60025. * @param m21 defines value for (2, 1)
  60026. * @returns the current modified matrix
  60027. */
  60028. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  60029. /**
  60030. * Gets matrix determinant
  60031. * @returns the determinant
  60032. */
  60033. determinant(): number;
  60034. /**
  60035. * Inverses the matrix and stores it in a target matrix
  60036. * @param result defines the target matrix
  60037. * @returns the current matrix
  60038. */
  60039. invertToRef(result: Matrix2D): Matrix2D;
  60040. /**
  60041. * Multiplies the current matrix with another one
  60042. * @param other defines the second operand
  60043. * @param result defines the target matrix
  60044. * @returns the current matrix
  60045. */
  60046. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  60047. /**
  60048. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  60049. * @param x defines the x coordinate to transform
  60050. * @param y defines the x coordinate to transform
  60051. * @param result defines the target vector2
  60052. * @returns the current matrix
  60053. */
  60054. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  60055. /**
  60056. * Creates an identity matrix
  60057. * @returns a new matrix
  60058. */
  60059. static Identity(): Matrix2D;
  60060. /**
  60061. * Creates a translation matrix and stores it in a target matrix
  60062. * @param x defines the x coordinate of the translation
  60063. * @param y defines the y coordinate of the translation
  60064. * @param result defines the target matrix
  60065. */
  60066. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  60067. /**
  60068. * Creates a scaling matrix and stores it in a target matrix
  60069. * @param x defines the x coordinate of the scaling
  60070. * @param y defines the y coordinate of the scaling
  60071. * @param result defines the target matrix
  60072. */
  60073. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  60074. /**
  60075. * Creates a rotation matrix and stores it in a target matrix
  60076. * @param angle defines the rotation angle
  60077. * @param result defines the target matrix
  60078. */
  60079. static RotationToRef(angle: number, result: Matrix2D): void;
  60080. private static _TempPreTranslationMatrix;
  60081. private static _TempPostTranslationMatrix;
  60082. private static _TempRotationMatrix;
  60083. private static _TempScalingMatrix;
  60084. private static _TempCompose0;
  60085. private static _TempCompose1;
  60086. private static _TempCompose2;
  60087. /**
  60088. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  60089. * @param tx defines the x coordinate of the translation
  60090. * @param ty defines the y coordinate of the translation
  60091. * @param angle defines the rotation angle
  60092. * @param scaleX defines the x coordinate of the scaling
  60093. * @param scaleY defines the y coordinate of the scaling
  60094. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  60095. * @param result defines the target matrix
  60096. */
  60097. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  60098. }
  60099. }
  60100. declare module BABYLON.GUI {
  60101. /**
  60102. * Class used to store 2D control sizes
  60103. */
  60104. export class Measure {
  60105. /** defines left coordinate */
  60106. left: number;
  60107. /** defines top coordinate */
  60108. top: number;
  60109. /** defines width dimension */
  60110. width: number;
  60111. /** defines height dimension */
  60112. height: number;
  60113. /**
  60114. * Creates a new measure
  60115. * @param left defines left coordinate
  60116. * @param top defines top coordinate
  60117. * @param width defines width dimension
  60118. * @param height defines height dimension
  60119. */
  60120. constructor(
  60121. /** defines left coordinate */
  60122. left: number,
  60123. /** defines top coordinate */
  60124. top: number,
  60125. /** defines width dimension */
  60126. width: number,
  60127. /** defines height dimension */
  60128. height: number);
  60129. /**
  60130. * Copy from another measure
  60131. * @param other defines the other measure to copy from
  60132. */
  60133. copyFrom(other: Measure): void;
  60134. /**
  60135. * Copy from a group of 4 floats
  60136. * @param left defines left coordinate
  60137. * @param top defines top coordinate
  60138. * @param width defines width dimension
  60139. * @param height defines height dimension
  60140. */
  60141. copyFromFloats(left: number, top: number, width: number, height: number): void;
  60142. /**
  60143. * Computes the axis aligned bounding box measure for two given measures
  60144. * @param a Input measure
  60145. * @param b Input measure
  60146. * @param result the resulting bounding measure
  60147. */
  60148. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  60149. /**
  60150. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  60151. * @param transform the matrix to transform the measure before computing the AABB
  60152. * @param result the resulting AABB
  60153. */
  60154. transformToRef(transform: Matrix2D, result: Measure): void;
  60155. /**
  60156. * Check equality between this measure and another one
  60157. * @param other defines the other measures
  60158. * @returns true if both measures are equals
  60159. */
  60160. isEqualsTo(other: Measure): boolean;
  60161. /**
  60162. * Creates an empty measure
  60163. * @returns a new measure
  60164. */
  60165. static Empty(): Measure;
  60166. }
  60167. }
  60168. declare module BABYLON.GUI {
  60169. /**
  60170. * Interface used to define a control that can receive focus
  60171. */
  60172. export interface IFocusableControl {
  60173. /**
  60174. * Function called when the control receives the focus
  60175. */
  60176. onFocus(): void;
  60177. /**
  60178. * Function called when the control loses the focus
  60179. */
  60180. onBlur(): void;
  60181. /**
  60182. * Function called to let the control handle keyboard events
  60183. * @param evt defines the current keyboard event
  60184. */
  60185. processKeyboard(evt: KeyboardEvent): void;
  60186. /**
  60187. * Function called to get the list of controls that should not steal the focus from this control
  60188. * @returns an array of controls
  60189. */
  60190. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  60191. }
  60192. /**
  60193. * Class used to create texture to support 2D GUI elements
  60194. * @see http://doc.babylonjs.com/how_to/gui
  60195. */
  60196. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  60197. private _isDirty;
  60198. private _renderObserver;
  60199. private _resizeObserver;
  60200. private _preKeyboardObserver;
  60201. private _pointerMoveObserver;
  60202. private _pointerObserver;
  60203. private _canvasPointerOutObserver;
  60204. private _background;
  60205. /** @hidden */
  60206. _rootContainer: Container;
  60207. /** @hidden */
  60208. _lastPickedControl: Control;
  60209. /** @hidden */
  60210. _lastControlOver: {
  60211. [pointerId: number]: Control;
  60212. };
  60213. /** @hidden */
  60214. _lastControlDown: {
  60215. [pointerId: number]: Control;
  60216. };
  60217. /** @hidden */
  60218. _capturingControl: {
  60219. [pointerId: number]: Control;
  60220. };
  60221. /** @hidden */
  60222. _shouldBlockPointer: boolean;
  60223. /** @hidden */
  60224. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  60225. /** @hidden */
  60226. _linkedControls: Control[];
  60227. private _isFullscreen;
  60228. private _fullscreenViewport;
  60229. private _idealWidth;
  60230. private _idealHeight;
  60231. private _useSmallestIdeal;
  60232. private _renderAtIdealSize;
  60233. private _focusedControl;
  60234. private _blockNextFocusCheck;
  60235. private _renderScale;
  60236. private _rootCanvas;
  60237. private _cursorChanged;
  60238. /**
  60239. * Define type to string to ensure compatibility across browsers
  60240. * Safari doesn't support DataTransfer constructor
  60241. */
  60242. private _clipboardData;
  60243. /**
  60244. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  60245. */
  60246. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  60247. /**
  60248. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  60249. */
  60250. onControlPickedObservable: BABYLON.Observable<Control>;
  60251. /**
  60252. * BABYLON.Observable event triggered before layout is evaluated
  60253. */
  60254. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60255. /**
  60256. * BABYLON.Observable event triggered after the layout was evaluated
  60257. */
  60258. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60259. /**
  60260. * BABYLON.Observable event triggered before the texture is rendered
  60261. */
  60262. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60263. /**
  60264. * BABYLON.Observable event triggered after the texture was rendered
  60265. */
  60266. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60267. /**
  60268. * Gets or sets a boolean defining if alpha is stored as premultiplied
  60269. */
  60270. premulAlpha: boolean;
  60271. /**
  60272. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  60273. * Useful when you want more antialiasing
  60274. */
  60275. renderScale: number;
  60276. /** Gets or sets the background color */
  60277. background: string;
  60278. /**
  60279. * Gets or sets the ideal width used to design controls.
  60280. * The GUI will then rescale everything accordingly
  60281. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60282. */
  60283. idealWidth: number;
  60284. /**
  60285. * Gets or sets the ideal height used to design controls.
  60286. * The GUI will then rescale everything accordingly
  60287. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60288. */
  60289. idealHeight: number;
  60290. /**
  60291. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  60292. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60293. */
  60294. useSmallestIdeal: boolean;
  60295. /**
  60296. * Gets or sets a boolean indicating if adaptive scaling must be used
  60297. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60298. */
  60299. renderAtIdealSize: boolean;
  60300. /**
  60301. * Gets the underlying layer used to render the texture when in fullscreen mode
  60302. */
  60303. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  60304. /**
  60305. * Gets the root container control
  60306. */
  60307. readonly rootContainer: Container;
  60308. /**
  60309. * Returns an array containing the root container.
  60310. * This is mostly used to let the Inspector introspects the ADT
  60311. * @returns an array containing the rootContainer
  60312. */
  60313. getChildren(): Array<Container>;
  60314. /**
  60315. * Will return all controls that are inside this texture
  60316. * @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
  60317. * @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
  60318. * @return all child controls
  60319. */
  60320. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  60321. /**
  60322. * Gets or sets the current focused control
  60323. */
  60324. focusedControl: BABYLON.Nullable<IFocusableControl>;
  60325. /**
  60326. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  60327. */
  60328. isForeground: boolean;
  60329. /**
  60330. * Gets or set information about clipboardData
  60331. */
  60332. clipboardData: string;
  60333. /**
  60334. * Creates a new AdvancedDynamicTexture
  60335. * @param name defines the name of the texture
  60336. * @param width defines the width of the texture
  60337. * @param height defines the height of the texture
  60338. * @param scene defines the hosting scene
  60339. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  60340. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  60341. */
  60342. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  60343. /**
  60344. * Get the current class name of the texture useful for serialization or dynamic coding.
  60345. * @returns "AdvancedDynamicTexture"
  60346. */
  60347. getClassName(): string;
  60348. /**
  60349. * Function used to execute a function on all controls
  60350. * @param func defines the function to execute
  60351. * @param container defines the container where controls belong. If null the root container will be used
  60352. */
  60353. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  60354. private _useInvalidateRectOptimization;
  60355. /**
  60356. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  60357. */
  60358. useInvalidateRectOptimization: boolean;
  60359. private _invalidatedRectangle;
  60360. /**
  60361. * Invalidates a rectangle area on the gui texture
  60362. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  60363. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  60364. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  60365. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  60366. */
  60367. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  60368. /**
  60369. * Marks the texture as dirty forcing a complete update
  60370. */
  60371. markAsDirty(): void;
  60372. /**
  60373. * Helper function used to create a new style
  60374. * @returns a new style
  60375. * @see http://doc.babylonjs.com/how_to/gui#styles
  60376. */
  60377. createStyle(): Style;
  60378. /**
  60379. * Adds a new control to the root container
  60380. * @param control defines the control to add
  60381. * @returns the current texture
  60382. */
  60383. addControl(control: Control): AdvancedDynamicTexture;
  60384. /**
  60385. * Removes a control from the root container
  60386. * @param control defines the control to remove
  60387. * @returns the current texture
  60388. */
  60389. removeControl(control: Control): AdvancedDynamicTexture;
  60390. /**
  60391. * Release all resources
  60392. */
  60393. dispose(): void;
  60394. private _onResize;
  60395. /** @hidden */
  60396. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  60397. /**
  60398. * Get screen coordinates for a vector3
  60399. * @param position defines the position to project
  60400. * @param worldMatrix defines the world matrix to use
  60401. * @returns the projected position
  60402. */
  60403. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  60404. private _checkUpdate;
  60405. private _clearMeasure;
  60406. private _render;
  60407. /** @hidden */
  60408. _changeCursor(cursor: string): void;
  60409. /** @hidden */
  60410. _registerLastControlDown(control: Control, pointerId: number): void;
  60411. private _doPicking;
  60412. /** @hidden */
  60413. _cleanControlAfterRemovalFromList(list: {
  60414. [pointerId: number]: Control;
  60415. }, control: Control): void;
  60416. /** @hidden */
  60417. _cleanControlAfterRemoval(control: Control): void;
  60418. /** Attach to all scene events required to support pointer events */
  60419. attach(): void;
  60420. /** @hidden */
  60421. private onClipboardCopy;
  60422. /** @hidden */
  60423. private onClipboardCut;
  60424. /** @hidden */
  60425. private onClipboardPaste;
  60426. /**
  60427. * Register the clipboard Events onto the canvas
  60428. */
  60429. registerClipboardEvents(): void;
  60430. /**
  60431. * Unregister the clipboard Events from the canvas
  60432. */
  60433. unRegisterClipboardEvents(): void;
  60434. /**
  60435. * Connect the texture to a hosting mesh to enable interactions
  60436. * @param mesh defines the mesh to attach to
  60437. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  60438. */
  60439. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  60440. /**
  60441. * Move the focus to a specific control
  60442. * @param control defines the control which will receive the focus
  60443. */
  60444. moveFocusToControl(control: IFocusableControl): void;
  60445. private _manageFocus;
  60446. private _attachToOnPointerOut;
  60447. /**
  60448. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  60449. * @param mesh defines the mesh which will receive the texture
  60450. * @param width defines the texture width (1024 by default)
  60451. * @param height defines the texture height (1024 by default)
  60452. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  60453. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  60454. * @returns a new AdvancedDynamicTexture
  60455. */
  60456. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  60457. /**
  60458. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  60459. * In this mode the texture will rely on a layer for its rendering.
  60460. * This allows it to be treated like any other layer.
  60461. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  60462. * LayerMask is set through advancedTexture.layer.layerMask
  60463. * @param name defines name for the texture
  60464. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  60465. * @param scene defines the hsoting scene
  60466. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  60467. * @returns a new AdvancedDynamicTexture
  60468. */
  60469. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  60470. }
  60471. }
  60472. declare module BABYLON.GUI {
  60473. /**
  60474. * Root class used for all 2D controls
  60475. * @see http://doc.babylonjs.com/how_to/gui#controls
  60476. */
  60477. export class Control {
  60478. /** defines the name of the control */
  60479. name?: string | undefined;
  60480. /**
  60481. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  60482. */
  60483. static AllowAlphaInheritance: boolean;
  60484. private _alpha;
  60485. private _alphaSet;
  60486. private _zIndex;
  60487. /** @hidden */
  60488. _host: AdvancedDynamicTexture;
  60489. /** Gets or sets the control parent */
  60490. parent: BABYLON.Nullable<Container>;
  60491. /** @hidden */
  60492. _currentMeasure: Measure;
  60493. private _fontFamily;
  60494. private _fontStyle;
  60495. private _fontWeight;
  60496. private _fontSize;
  60497. private _font;
  60498. /** @hidden */
  60499. _width: ValueAndUnit;
  60500. /** @hidden */
  60501. _height: ValueAndUnit;
  60502. /** @hidden */
  60503. protected _fontOffset: {
  60504. ascent: number;
  60505. height: number;
  60506. descent: number;
  60507. };
  60508. private _color;
  60509. private _style;
  60510. private _styleObserver;
  60511. /** @hidden */
  60512. protected _horizontalAlignment: number;
  60513. /** @hidden */
  60514. protected _verticalAlignment: number;
  60515. /** @hidden */
  60516. protected _isDirty: boolean;
  60517. /** @hidden */
  60518. protected _wasDirty: boolean;
  60519. /** @hidden */
  60520. _tempParentMeasure: Measure;
  60521. /** @hidden */
  60522. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  60523. /** @hidden */
  60524. protected _cachedParentMeasure: Measure;
  60525. private _paddingLeft;
  60526. private _paddingRight;
  60527. private _paddingTop;
  60528. private _paddingBottom;
  60529. /** @hidden */
  60530. _left: ValueAndUnit;
  60531. /** @hidden */
  60532. _top: ValueAndUnit;
  60533. private _scaleX;
  60534. private _scaleY;
  60535. private _rotation;
  60536. private _transformCenterX;
  60537. private _transformCenterY;
  60538. /** @hidden */
  60539. _transformMatrix: Matrix2D;
  60540. /** @hidden */
  60541. protected _invertTransformMatrix: Matrix2D;
  60542. /** @hidden */
  60543. protected _transformedPosition: BABYLON.Vector2;
  60544. private _isMatrixDirty;
  60545. private _cachedOffsetX;
  60546. private _cachedOffsetY;
  60547. private _isVisible;
  60548. private _isHighlighted;
  60549. /** @hidden */
  60550. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  60551. private _fontSet;
  60552. private _dummyVector2;
  60553. private _downCount;
  60554. private _enterCount;
  60555. private _doNotRender;
  60556. private _downPointerIds;
  60557. protected _isEnabled: boolean;
  60558. protected _disabledColor: string;
  60559. /** @hidden */
  60560. protected _rebuildLayout: boolean;
  60561. /** @hidden */
  60562. _isClipped: boolean;
  60563. /** @hidden */
  60564. _tag: any;
  60565. /**
  60566. * 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
  60567. */
  60568. uniqueId: number;
  60569. /**
  60570. * Gets or sets an object used to store user defined information for the node
  60571. */
  60572. metadata: any;
  60573. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  60574. isHitTestVisible: boolean;
  60575. /** Gets or sets a boolean indicating if the control can block pointer events */
  60576. isPointerBlocker: boolean;
  60577. /** Gets or sets a boolean indicating if the control can be focusable */
  60578. isFocusInvisible: boolean;
  60579. /**
  60580. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  60581. * 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
  60582. */
  60583. clipChildren: boolean;
  60584. /**
  60585. * Gets or sets a boolean indicating that control content must be clipped
  60586. * 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
  60587. */
  60588. clipContent: boolean;
  60589. /**
  60590. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  60591. */
  60592. useBitmapCache: boolean;
  60593. private _cacheData;
  60594. private _shadowOffsetX;
  60595. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  60596. shadowOffsetX: number;
  60597. private _shadowOffsetY;
  60598. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  60599. shadowOffsetY: number;
  60600. private _shadowBlur;
  60601. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  60602. shadowBlur: number;
  60603. private _shadowColor;
  60604. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  60605. shadowColor: string;
  60606. /** Gets or sets the cursor to use when the control is hovered */
  60607. hoverCursor: string;
  60608. /** @hidden */
  60609. protected _linkOffsetX: ValueAndUnit;
  60610. /** @hidden */
  60611. protected _linkOffsetY: ValueAndUnit;
  60612. /** Gets the control type name */
  60613. readonly typeName: string;
  60614. /**
  60615. * Get the current class name of the control.
  60616. * @returns current class name
  60617. */
  60618. getClassName(): string;
  60619. /**
  60620. * An event triggered when the pointer move over the control.
  60621. */
  60622. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  60623. /**
  60624. * An event triggered when the pointer move out of the control.
  60625. */
  60626. onPointerOutObservable: BABYLON.Observable<Control>;
  60627. /**
  60628. * An event triggered when the pointer taps the control
  60629. */
  60630. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  60631. /**
  60632. * An event triggered when pointer up
  60633. */
  60634. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  60635. /**
  60636. * An event triggered when a control is clicked on
  60637. */
  60638. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  60639. /**
  60640. * An event triggered when pointer enters the control
  60641. */
  60642. onPointerEnterObservable: BABYLON.Observable<Control>;
  60643. /**
  60644. * An event triggered when the control is marked as dirty
  60645. */
  60646. onDirtyObservable: BABYLON.Observable<Control>;
  60647. /**
  60648. * An event triggered before drawing the control
  60649. */
  60650. onBeforeDrawObservable: BABYLON.Observable<Control>;
  60651. /**
  60652. * An event triggered after the control was drawn
  60653. */
  60654. onAfterDrawObservable: BABYLON.Observable<Control>;
  60655. /**
  60656. * Get the hosting AdvancedDynamicTexture
  60657. */
  60658. readonly host: AdvancedDynamicTexture;
  60659. /** Gets or set information about font offsets (used to render and align text) */
  60660. fontOffset: {
  60661. ascent: number;
  60662. height: number;
  60663. descent: number;
  60664. };
  60665. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  60666. alpha: number;
  60667. /**
  60668. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  60669. */
  60670. isHighlighted: boolean;
  60671. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  60672. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60673. */
  60674. scaleX: number;
  60675. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  60676. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60677. */
  60678. scaleY: number;
  60679. /** Gets or sets the rotation angle (0 by default)
  60680. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60681. */
  60682. rotation: number;
  60683. /** Gets or sets the transformation center on Y axis (0 by default)
  60684. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60685. */
  60686. transformCenterY: number;
  60687. /** Gets or sets the transformation center on X axis (0 by default)
  60688. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60689. */
  60690. transformCenterX: number;
  60691. /**
  60692. * Gets or sets the horizontal alignment
  60693. * @see http://doc.babylonjs.com/how_to/gui#alignments
  60694. */
  60695. horizontalAlignment: number;
  60696. /**
  60697. * Gets or sets the vertical alignment
  60698. * @see http://doc.babylonjs.com/how_to/gui#alignments
  60699. */
  60700. verticalAlignment: number;
  60701. /**
  60702. * Gets or sets control width
  60703. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60704. */
  60705. width: string | number;
  60706. /**
  60707. * Gets or sets the control width in pixel
  60708. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60709. */
  60710. widthInPixels: number;
  60711. /**
  60712. * Gets or sets control height
  60713. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60714. */
  60715. height: string | number;
  60716. /**
  60717. * Gets or sets control height in pixel
  60718. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60719. */
  60720. heightInPixels: number;
  60721. /** Gets or set font family */
  60722. fontFamily: string;
  60723. /** Gets or sets font style */
  60724. fontStyle: string;
  60725. /** Gets or sets font weight */
  60726. fontWeight: string;
  60727. /**
  60728. * Gets or sets style
  60729. * @see http://doc.babylonjs.com/how_to/gui#styles
  60730. */
  60731. style: BABYLON.Nullable<Style>;
  60732. /** @hidden */
  60733. readonly _isFontSizeInPercentage: boolean;
  60734. /** Gets or sets font size in pixels */
  60735. fontSizeInPixels: number;
  60736. /** Gets or sets font size */
  60737. fontSize: string | number;
  60738. /** Gets or sets foreground color */
  60739. color: string;
  60740. /** Gets or sets z index which is used to reorder controls on the z axis */
  60741. zIndex: number;
  60742. /** Gets or sets a boolean indicating if the control can be rendered */
  60743. notRenderable: boolean;
  60744. /** Gets or sets a boolean indicating if the control is visible */
  60745. isVisible: boolean;
  60746. /** Gets a boolean indicating that the control needs to update its rendering */
  60747. readonly isDirty: boolean;
  60748. /**
  60749. * Gets the current linked mesh (or null if none)
  60750. */
  60751. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  60752. /**
  60753. * Gets or sets a value indicating the padding to use on the left of the control
  60754. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60755. */
  60756. paddingLeft: string | number;
  60757. /**
  60758. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  60759. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60760. */
  60761. paddingLeftInPixels: number;
  60762. /**
  60763. * Gets or sets a value indicating the padding to use on the right of the control
  60764. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60765. */
  60766. paddingRight: string | number;
  60767. /**
  60768. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  60769. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60770. */
  60771. paddingRightInPixels: number;
  60772. /**
  60773. * Gets or sets a value indicating the padding to use on the top of the control
  60774. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60775. */
  60776. paddingTop: string | number;
  60777. /**
  60778. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  60779. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60780. */
  60781. paddingTopInPixels: number;
  60782. /**
  60783. * Gets or sets a value indicating the padding to use on the bottom of the control
  60784. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60785. */
  60786. paddingBottom: string | number;
  60787. /**
  60788. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  60789. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60790. */
  60791. paddingBottomInPixels: number;
  60792. /**
  60793. * Gets or sets a value indicating the left coordinate of the control
  60794. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60795. */
  60796. left: string | number;
  60797. /**
  60798. * Gets or sets a value indicating the left coordinate in pixels of the control
  60799. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60800. */
  60801. leftInPixels: number;
  60802. /**
  60803. * Gets or sets a value indicating the top coordinate of the control
  60804. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60805. */
  60806. top: string | number;
  60807. /**
  60808. * Gets or sets a value indicating the top coordinate in pixels of the control
  60809. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60810. */
  60811. topInPixels: number;
  60812. /**
  60813. * Gets or sets a value indicating the offset on X axis to the linked mesh
  60814. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60815. */
  60816. linkOffsetX: string | number;
  60817. /**
  60818. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  60819. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60820. */
  60821. linkOffsetXInPixels: number;
  60822. /**
  60823. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  60824. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60825. */
  60826. linkOffsetY: string | number;
  60827. /**
  60828. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  60829. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60830. */
  60831. linkOffsetYInPixels: number;
  60832. /** Gets the center coordinate on X axis */
  60833. readonly centerX: number;
  60834. /** Gets the center coordinate on Y axis */
  60835. readonly centerY: number;
  60836. /** Gets or sets if control is Enabled*/
  60837. isEnabled: boolean;
  60838. /** Gets or sets background color of control if it's disabled*/
  60839. disabledColor: string;
  60840. /**
  60841. * Creates a new control
  60842. * @param name defines the name of the control
  60843. */
  60844. constructor(
  60845. /** defines the name of the control */
  60846. name?: string | undefined);
  60847. /** @hidden */
  60848. protected _getTypeName(): string;
  60849. /**
  60850. * Gets the first ascendant in the hierarchy of the given type
  60851. * @param className defines the required type
  60852. * @returns the ascendant or null if not found
  60853. */
  60854. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  60855. /** @hidden */
  60856. _resetFontCache(): void;
  60857. /**
  60858. * Determines if a container is an ascendant of the current control
  60859. * @param container defines the container to look for
  60860. * @returns true if the container is one of the ascendant of the control
  60861. */
  60862. isAscendant(container: Control): boolean;
  60863. /**
  60864. * Gets coordinates in local control space
  60865. * @param globalCoordinates defines the coordinates to transform
  60866. * @returns the new coordinates in local space
  60867. */
  60868. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  60869. /**
  60870. * Gets coordinates in local control space
  60871. * @param globalCoordinates defines the coordinates to transform
  60872. * @param result defines the target vector2 where to store the result
  60873. * @returns the current control
  60874. */
  60875. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  60876. /**
  60877. * Gets coordinates in parent local control space
  60878. * @param globalCoordinates defines the coordinates to transform
  60879. * @returns the new coordinates in parent local space
  60880. */
  60881. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  60882. /**
  60883. * Move the current control to a vector3 position projected onto the screen.
  60884. * @param position defines the target position
  60885. * @param scene defines the hosting scene
  60886. */
  60887. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  60888. /** @hidden */
  60889. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  60890. /**
  60891. * Will return all controls that have this control as ascendant
  60892. * @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
  60893. * @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
  60894. * @return all child controls
  60895. */
  60896. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  60897. /**
  60898. * Link current control with a target mesh
  60899. * @param mesh defines the mesh to link with
  60900. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60901. */
  60902. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  60903. /** @hidden */
  60904. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  60905. /** @hidden */
  60906. _offsetLeft(offset: number): void;
  60907. /** @hidden */
  60908. _offsetTop(offset: number): void;
  60909. /** @hidden */
  60910. _markMatrixAsDirty(): void;
  60911. /** @hidden */
  60912. _flagDescendantsAsMatrixDirty(): void;
  60913. /** @hidden */
  60914. _intersectsRect(rect: Measure): boolean;
  60915. /** @hidden */
  60916. protected invalidateRect(): void;
  60917. /** @hidden */
  60918. _markAsDirty(force?: boolean): void;
  60919. /** @hidden */
  60920. _markAllAsDirty(): void;
  60921. /** @hidden */
  60922. _link(host: AdvancedDynamicTexture): void;
  60923. /** @hidden */
  60924. protected _transform(context?: CanvasRenderingContext2D): void;
  60925. /** @hidden */
  60926. _renderHighlight(context: CanvasRenderingContext2D): void;
  60927. /** @hidden */
  60928. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  60929. /** @hidden */
  60930. protected _applyStates(context: CanvasRenderingContext2D): void;
  60931. /** @hidden */
  60932. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  60933. /** @hidden */
  60934. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60935. protected _evaluateClippingState(parentMeasure: Measure): void;
  60936. /** @hidden */
  60937. _measure(): void;
  60938. /** @hidden */
  60939. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60940. /** @hidden */
  60941. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60942. /** @hidden */
  60943. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60944. /** @hidden */
  60945. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  60946. private static _ClipMeasure;
  60947. private _tmpMeasureA;
  60948. private _clip;
  60949. /** @hidden */
  60950. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  60951. /** @hidden */
  60952. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  60953. /**
  60954. * Tests if a given coordinates belong to the current control
  60955. * @param x defines x coordinate to test
  60956. * @param y defines y coordinate to test
  60957. * @returns true if the coordinates are inside the control
  60958. */
  60959. contains(x: number, y: number): boolean;
  60960. /** @hidden */
  60961. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60962. /** @hidden */
  60963. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  60964. /** @hidden */
  60965. _onPointerEnter(target: Control): boolean;
  60966. /** @hidden */
  60967. _onPointerOut(target: Control, force?: boolean): void;
  60968. /** @hidden */
  60969. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60970. /** @hidden */
  60971. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  60972. /** @hidden */
  60973. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  60974. /** @hidden */
  60975. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  60976. private _prepareFont;
  60977. /** Releases associated resources */
  60978. dispose(): void;
  60979. private static _HORIZONTAL_ALIGNMENT_LEFT;
  60980. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  60981. private static _HORIZONTAL_ALIGNMENT_CENTER;
  60982. private static _VERTICAL_ALIGNMENT_TOP;
  60983. private static _VERTICAL_ALIGNMENT_BOTTOM;
  60984. private static _VERTICAL_ALIGNMENT_CENTER;
  60985. /** HORIZONTAL_ALIGNMENT_LEFT */
  60986. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  60987. /** HORIZONTAL_ALIGNMENT_RIGHT */
  60988. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  60989. /** HORIZONTAL_ALIGNMENT_CENTER */
  60990. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  60991. /** VERTICAL_ALIGNMENT_TOP */
  60992. static readonly VERTICAL_ALIGNMENT_TOP: number;
  60993. /** VERTICAL_ALIGNMENT_BOTTOM */
  60994. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  60995. /** VERTICAL_ALIGNMENT_CENTER */
  60996. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  60997. private static _FontHeightSizes;
  60998. /** @hidden */
  60999. static _GetFontOffset(font: string): {
  61000. ascent: number;
  61001. height: number;
  61002. descent: number;
  61003. };
  61004. /**
  61005. * Creates a stack panel that can be used to render headers
  61006. * @param control defines the control to associate with the header
  61007. * @param text defines the text of the header
  61008. * @param size defines the size of the header
  61009. * @param options defines options used to configure the header
  61010. * @returns a new StackPanel
  61011. * @ignore
  61012. * @hidden
  61013. */
  61014. static AddHeader: (control: Control, text: string, size: string | number, options: {
  61015. isHorizontal: boolean;
  61016. controlFirst: boolean;
  61017. }) => any;
  61018. /** @hidden */
  61019. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  61020. }
  61021. }
  61022. declare module BABYLON.GUI {
  61023. /**
  61024. * Root class for 2D containers
  61025. * @see http://doc.babylonjs.com/how_to/gui#containers
  61026. */
  61027. export class Container extends Control {
  61028. name?: string | undefined;
  61029. /** @hidden */
  61030. protected _children: Control[];
  61031. /** @hidden */
  61032. protected _measureForChildren: Measure;
  61033. /** @hidden */
  61034. protected _background: string;
  61035. /** @hidden */
  61036. protected _adaptWidthToChildren: boolean;
  61037. /** @hidden */
  61038. protected _adaptHeightToChildren: boolean;
  61039. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  61040. adaptHeightToChildren: boolean;
  61041. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  61042. adaptWidthToChildren: boolean;
  61043. /** Gets or sets background color */
  61044. background: string;
  61045. /** Gets the list of children */
  61046. readonly children: Control[];
  61047. /**
  61048. * Creates a new Container
  61049. * @param name defines the name of the container
  61050. */
  61051. constructor(name?: string | undefined);
  61052. protected _getTypeName(): string;
  61053. _flagDescendantsAsMatrixDirty(): void;
  61054. /**
  61055. * Gets a child using its name
  61056. * @param name defines the child name to look for
  61057. * @returns the child control if found
  61058. */
  61059. getChildByName(name: string): BABYLON.Nullable<Control>;
  61060. /**
  61061. * Gets a child using its type and its name
  61062. * @param name defines the child name to look for
  61063. * @param type defines the child type to look for
  61064. * @returns the child control if found
  61065. */
  61066. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  61067. /**
  61068. * Search for a specific control in children
  61069. * @param control defines the control to look for
  61070. * @returns true if the control is in child list
  61071. */
  61072. containsControl(control: Control): boolean;
  61073. /**
  61074. * Adds a new control to the current container
  61075. * @param control defines the control to add
  61076. * @returns the current container
  61077. */
  61078. addControl(control: BABYLON.Nullable<Control>): Container;
  61079. /**
  61080. * Removes all controls from the current container
  61081. * @returns the current container
  61082. */
  61083. clearControls(): Container;
  61084. /**
  61085. * Removes a control from the current container
  61086. * @param control defines the control to remove
  61087. * @returns the current container
  61088. */
  61089. removeControl(control: Control): Container;
  61090. /** @hidden */
  61091. _reOrderControl(control: Control): void;
  61092. /** @hidden */
  61093. _offsetLeft(offset: number): void;
  61094. /** @hidden */
  61095. _offsetTop(offset: number): void;
  61096. /** @hidden */
  61097. _markAllAsDirty(): void;
  61098. /** @hidden */
  61099. protected _localDraw(context: CanvasRenderingContext2D): void;
  61100. /** @hidden */
  61101. _link(host: AdvancedDynamicTexture): void;
  61102. /** @hidden */
  61103. protected _beforeLayout(): void;
  61104. /** @hidden */
  61105. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61106. /** @hidden */
  61107. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  61108. protected _postMeasure(): void;
  61109. /** @hidden */
  61110. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  61111. /** @hidden */
  61112. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  61113. /** @hidden */
  61114. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  61115. /** @hidden */
  61116. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61117. /** Releases associated resources */
  61118. dispose(): void;
  61119. }
  61120. }
  61121. declare module BABYLON.GUI {
  61122. /** Class used to create rectangle container */
  61123. export class Rectangle extends Container {
  61124. name?: string | undefined;
  61125. private _thickness;
  61126. private _cornerRadius;
  61127. /** Gets or sets border thickness */
  61128. thickness: number;
  61129. /** Gets or sets the corner radius angle */
  61130. cornerRadius: number;
  61131. /**
  61132. * Creates a new Rectangle
  61133. * @param name defines the control name
  61134. */
  61135. constructor(name?: string | undefined);
  61136. protected _getTypeName(): string;
  61137. protected _localDraw(context: CanvasRenderingContext2D): void;
  61138. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61139. private _drawRoundedRect;
  61140. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  61141. }
  61142. }
  61143. declare module BABYLON.GUI {
  61144. /**
  61145. * Enum that determines the text-wrapping mode to use.
  61146. */
  61147. export enum TextWrapping {
  61148. /**
  61149. * Clip the text when it's larger than Control.width; this is the default mode.
  61150. */
  61151. Clip = 0,
  61152. /**
  61153. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  61154. */
  61155. WordWrap = 1,
  61156. /**
  61157. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  61158. */
  61159. Ellipsis = 2
  61160. }
  61161. /**
  61162. * Class used to create text block control
  61163. */
  61164. export class TextBlock extends Control {
  61165. /**
  61166. * Defines the name of the control
  61167. */
  61168. name?: string | undefined;
  61169. private _text;
  61170. private _textWrapping;
  61171. private _textHorizontalAlignment;
  61172. private _textVerticalAlignment;
  61173. private _lines;
  61174. private _resizeToFit;
  61175. private _lineSpacing;
  61176. private _outlineWidth;
  61177. private _outlineColor;
  61178. /**
  61179. * An event triggered after the text is changed
  61180. */
  61181. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  61182. /**
  61183. * An event triggered after the text was broken up into lines
  61184. */
  61185. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  61186. /**
  61187. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  61188. */
  61189. readonly lines: any[];
  61190. /**
  61191. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  61192. */
  61193. /**
  61194. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  61195. */
  61196. resizeToFit: boolean;
  61197. /**
  61198. * Gets or sets a boolean indicating if text must be wrapped
  61199. */
  61200. /**
  61201. * Gets or sets a boolean indicating if text must be wrapped
  61202. */
  61203. textWrapping: TextWrapping | boolean;
  61204. /**
  61205. * Gets or sets text to display
  61206. */
  61207. /**
  61208. * Gets or sets text to display
  61209. */
  61210. text: string;
  61211. /**
  61212. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  61213. */
  61214. /**
  61215. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  61216. */
  61217. textHorizontalAlignment: number;
  61218. /**
  61219. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  61220. */
  61221. /**
  61222. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  61223. */
  61224. textVerticalAlignment: number;
  61225. /**
  61226. * Gets or sets line spacing value
  61227. */
  61228. /**
  61229. * Gets or sets line spacing value
  61230. */
  61231. lineSpacing: string | number;
  61232. /**
  61233. * Gets or sets outlineWidth of the text to display
  61234. */
  61235. /**
  61236. * Gets or sets outlineWidth of the text to display
  61237. */
  61238. outlineWidth: number;
  61239. /**
  61240. * Gets or sets outlineColor of the text to display
  61241. */
  61242. /**
  61243. * Gets or sets outlineColor of the text to display
  61244. */
  61245. outlineColor: string;
  61246. /**
  61247. * Creates a new TextBlock object
  61248. * @param name defines the name of the control
  61249. * @param text defines the text to display (emptry string by default)
  61250. */
  61251. constructor(
  61252. /**
  61253. * Defines the name of the control
  61254. */
  61255. name?: string | undefined, text?: string);
  61256. protected _getTypeName(): string;
  61257. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61258. private _drawText;
  61259. /** @hidden */
  61260. _draw(context: CanvasRenderingContext2D): void;
  61261. protected _applyStates(context: CanvasRenderingContext2D): void;
  61262. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  61263. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  61264. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  61265. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  61266. protected _renderLines(context: CanvasRenderingContext2D): void;
  61267. /**
  61268. * Given a width constraint applied on the text block, find the expected height
  61269. * @returns expected height
  61270. */
  61271. computeExpectedHeight(): number;
  61272. dispose(): void;
  61273. }
  61274. }
  61275. declare module BABYLON.GUI {
  61276. /**
  61277. * Class used to create 2D images
  61278. */
  61279. export class Image extends Control {
  61280. name?: string | undefined;
  61281. private static _WorkingCanvas;
  61282. private _domImage;
  61283. private _imageWidth;
  61284. private _imageHeight;
  61285. private _loaded;
  61286. private _stretch;
  61287. private _source;
  61288. private _autoScale;
  61289. private _sourceLeft;
  61290. private _sourceTop;
  61291. private _sourceWidth;
  61292. private _sourceHeight;
  61293. private _cellWidth;
  61294. private _cellHeight;
  61295. private _cellId;
  61296. private _populateNinePatchSlicesFromImage;
  61297. private _sliceLeft;
  61298. private _sliceRight;
  61299. private _sliceTop;
  61300. private _sliceBottom;
  61301. private _detectPointerOnOpaqueOnly;
  61302. /**
  61303. * BABYLON.Observable notified when the content is loaded
  61304. */
  61305. onImageLoadedObservable: BABYLON.Observable<Image>;
  61306. /**
  61307. * Gets a boolean indicating that the content is loaded
  61308. */
  61309. readonly isLoaded: boolean;
  61310. /**
  61311. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  61312. */
  61313. populateNinePatchSlicesFromImage: boolean;
  61314. /**
  61315. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  61316. * Beware using this as this will comsume more memory as the image has to be stored twice
  61317. */
  61318. detectPointerOnOpaqueOnly: boolean;
  61319. /**
  61320. * Gets or sets the left value for slicing (9-patch)
  61321. */
  61322. sliceLeft: number;
  61323. /**
  61324. * Gets or sets the right value for slicing (9-patch)
  61325. */
  61326. sliceRight: number;
  61327. /**
  61328. * Gets or sets the top value for slicing (9-patch)
  61329. */
  61330. sliceTop: number;
  61331. /**
  61332. * Gets or sets the bottom value for slicing (9-patch)
  61333. */
  61334. sliceBottom: number;
  61335. /**
  61336. * Gets or sets the left coordinate in the source image
  61337. */
  61338. sourceLeft: number;
  61339. /**
  61340. * Gets or sets the top coordinate in the source image
  61341. */
  61342. sourceTop: number;
  61343. /**
  61344. * Gets or sets the width to capture in the source image
  61345. */
  61346. sourceWidth: number;
  61347. /**
  61348. * Gets or sets the height to capture in the source image
  61349. */
  61350. sourceHeight: number;
  61351. /**
  61352. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  61353. * @see http://doc.babylonjs.com/how_to/gui#image
  61354. */
  61355. autoScale: boolean;
  61356. /** Gets or sets the streching mode used by the image */
  61357. stretch: number;
  61358. /**
  61359. * Gets or sets the internal DOM image used to render the control
  61360. */
  61361. domImage: HTMLImageElement;
  61362. private _onImageLoaded;
  61363. private _extractNinePatchSliceDataFromImage;
  61364. /**
  61365. * Gets or sets image source url
  61366. */
  61367. source: BABYLON.Nullable<string>;
  61368. /**
  61369. * Gets or sets the cell width to use when animation sheet is enabled
  61370. * @see http://doc.babylonjs.com/how_to/gui#image
  61371. */
  61372. cellWidth: number;
  61373. /**
  61374. * Gets or sets the cell height to use when animation sheet is enabled
  61375. * @see http://doc.babylonjs.com/how_to/gui#image
  61376. */
  61377. cellHeight: number;
  61378. /**
  61379. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  61380. * @see http://doc.babylonjs.com/how_to/gui#image
  61381. */
  61382. cellId: number;
  61383. /**
  61384. * Creates a new Image
  61385. * @param name defines the control name
  61386. * @param url defines the image url
  61387. */
  61388. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  61389. /**
  61390. * Tests if a given coordinates belong to the current control
  61391. * @param x defines x coordinate to test
  61392. * @param y defines y coordinate to test
  61393. * @returns true if the coordinates are inside the control
  61394. */
  61395. contains(x: number, y: number): boolean;
  61396. protected _getTypeName(): string;
  61397. /** Force the control to synchronize with its content */
  61398. synchronizeSizeWithContent(): void;
  61399. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61400. private _prepareWorkingCanvasForOpaqueDetection;
  61401. private _drawImage;
  61402. _draw(context: CanvasRenderingContext2D): void;
  61403. private _renderCornerPatch;
  61404. private _renderNinePatch;
  61405. dispose(): void;
  61406. /** STRETCH_NONE */
  61407. static readonly STRETCH_NONE: number;
  61408. /** STRETCH_FILL */
  61409. static readonly STRETCH_FILL: number;
  61410. /** STRETCH_UNIFORM */
  61411. static readonly STRETCH_UNIFORM: number;
  61412. /** STRETCH_EXTEND */
  61413. static readonly STRETCH_EXTEND: number;
  61414. /** NINE_PATCH */
  61415. static readonly STRETCH_NINE_PATCH: number;
  61416. }
  61417. }
  61418. declare module BABYLON.GUI {
  61419. /**
  61420. * Class used to create 2D buttons
  61421. */
  61422. export class Button extends Rectangle {
  61423. name?: string | undefined;
  61424. /**
  61425. * Function called to generate a pointer enter animation
  61426. */
  61427. pointerEnterAnimation: () => void;
  61428. /**
  61429. * Function called to generate a pointer out animation
  61430. */
  61431. pointerOutAnimation: () => void;
  61432. /**
  61433. * Function called to generate a pointer down animation
  61434. */
  61435. pointerDownAnimation: () => void;
  61436. /**
  61437. * Function called to generate a pointer up animation
  61438. */
  61439. pointerUpAnimation: () => void;
  61440. private _image;
  61441. /**
  61442. * Returns the image part of the button (if any)
  61443. */
  61444. readonly image: BABYLON.Nullable<Image>;
  61445. private _textBlock;
  61446. /**
  61447. * Returns the image part of the button (if any)
  61448. */
  61449. readonly textBlock: BABYLON.Nullable<TextBlock>;
  61450. /**
  61451. * Creates a new Button
  61452. * @param name defines the name of the button
  61453. */
  61454. constructor(name?: string | undefined);
  61455. protected _getTypeName(): string;
  61456. /** @hidden */
  61457. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  61458. /** @hidden */
  61459. _onPointerEnter(target: Control): boolean;
  61460. /** @hidden */
  61461. _onPointerOut(target: Control, force?: boolean): void;
  61462. /** @hidden */
  61463. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61464. /** @hidden */
  61465. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61466. /**
  61467. * Creates a new button made with an image and a text
  61468. * @param name defines the name of the button
  61469. * @param text defines the text of the button
  61470. * @param imageUrl defines the url of the image
  61471. * @returns a new Button
  61472. */
  61473. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  61474. /**
  61475. * Creates a new button made with an image
  61476. * @param name defines the name of the button
  61477. * @param imageUrl defines the url of the image
  61478. * @returns a new Button
  61479. */
  61480. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  61481. /**
  61482. * Creates a new button made with a text
  61483. * @param name defines the name of the button
  61484. * @param text defines the text of the button
  61485. * @returns a new Button
  61486. */
  61487. static CreateSimpleButton(name: string, text: string): Button;
  61488. /**
  61489. * Creates a new button made with an image and a centered text
  61490. * @param name defines the name of the button
  61491. * @param text defines the text of the button
  61492. * @param imageUrl defines the url of the image
  61493. * @returns a new Button
  61494. */
  61495. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  61496. }
  61497. }
  61498. declare module BABYLON.GUI {
  61499. /**
  61500. * Class used to create a 2D stack panel container
  61501. */
  61502. export class StackPanel extends Container {
  61503. name?: string | undefined;
  61504. private _isVertical;
  61505. private _manualWidth;
  61506. private _manualHeight;
  61507. private _doNotTrackManualChanges;
  61508. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  61509. isVertical: boolean;
  61510. /**
  61511. * Gets or sets panel width.
  61512. * This value should not be set when in horizontal mode as it will be computed automatically
  61513. */
  61514. width: string | number;
  61515. /**
  61516. * Gets or sets panel height.
  61517. * This value should not be set when in vertical mode as it will be computed automatically
  61518. */
  61519. height: string | number;
  61520. /**
  61521. * Creates a new StackPanel
  61522. * @param name defines control name
  61523. */
  61524. constructor(name?: string | undefined);
  61525. protected _getTypeName(): string;
  61526. /** @hidden */
  61527. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61528. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61529. protected _postMeasure(): void;
  61530. }
  61531. }
  61532. declare module BABYLON.GUI {
  61533. /**
  61534. * Class used to represent a 2D checkbox
  61535. */
  61536. export class Checkbox extends Control {
  61537. name?: string | undefined;
  61538. private _isChecked;
  61539. private _background;
  61540. private _checkSizeRatio;
  61541. private _thickness;
  61542. /** Gets or sets border thickness */
  61543. thickness: number;
  61544. /**
  61545. * BABYLON.Observable raised when isChecked property changes
  61546. */
  61547. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  61548. /** Gets or sets a value indicating the ratio between overall size and check size */
  61549. checkSizeRatio: number;
  61550. /** Gets or sets background color */
  61551. background: string;
  61552. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  61553. isChecked: boolean;
  61554. /**
  61555. * Creates a new CheckBox
  61556. * @param name defines the control name
  61557. */
  61558. constructor(name?: string | undefined);
  61559. protected _getTypeName(): string;
  61560. /** @hidden */
  61561. _draw(context: CanvasRenderingContext2D): void;
  61562. /** @hidden */
  61563. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61564. /**
  61565. * Utility function to easily create a checkbox with a header
  61566. * @param title defines the label to use for the header
  61567. * @param onValueChanged defines the callback to call when value changes
  61568. * @returns a StackPanel containing the checkbox and a textBlock
  61569. */
  61570. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  61571. }
  61572. }
  61573. declare module BABYLON.GUI {
  61574. /**
  61575. * Class used to store key control properties
  61576. */
  61577. export class KeyPropertySet {
  61578. /** Width */
  61579. width?: string;
  61580. /** Height */
  61581. height?: string;
  61582. /** Left padding */
  61583. paddingLeft?: string;
  61584. /** Right padding */
  61585. paddingRight?: string;
  61586. /** Top padding */
  61587. paddingTop?: string;
  61588. /** Bottom padding */
  61589. paddingBottom?: string;
  61590. /** Foreground color */
  61591. color?: string;
  61592. /** Background color */
  61593. background?: string;
  61594. }
  61595. /**
  61596. * Class used to create virtual keyboard
  61597. */
  61598. export class VirtualKeyboard extends StackPanel {
  61599. /** BABYLON.Observable raised when a key is pressed */
  61600. onKeyPressObservable: BABYLON.Observable<string>;
  61601. /** Gets or sets default key button width */
  61602. defaultButtonWidth: string;
  61603. /** Gets or sets default key button height */
  61604. defaultButtonHeight: string;
  61605. /** Gets or sets default key button left padding */
  61606. defaultButtonPaddingLeft: string;
  61607. /** Gets or sets default key button right padding */
  61608. defaultButtonPaddingRight: string;
  61609. /** Gets or sets default key button top padding */
  61610. defaultButtonPaddingTop: string;
  61611. /** Gets or sets default key button bottom padding */
  61612. defaultButtonPaddingBottom: string;
  61613. /** Gets or sets default key button foreground color */
  61614. defaultButtonColor: string;
  61615. /** Gets or sets default key button background color */
  61616. defaultButtonBackground: string;
  61617. /** Gets or sets shift button foreground color */
  61618. shiftButtonColor: string;
  61619. /** Gets or sets shift button thickness*/
  61620. selectedShiftThickness: number;
  61621. /** Gets shift key state */
  61622. shiftState: number;
  61623. protected _getTypeName(): string;
  61624. private _createKey;
  61625. /**
  61626. * Adds a new row of keys
  61627. * @param keys defines the list of keys to add
  61628. * @param propertySets defines the associated property sets
  61629. */
  61630. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  61631. /**
  61632. * Set the shift key to a specific state
  61633. * @param shiftState defines the new shift state
  61634. */
  61635. applyShiftState(shiftState: number): void;
  61636. private _currentlyConnectedInputText;
  61637. private _connectedInputTexts;
  61638. private _onKeyPressObserver;
  61639. /** Gets the input text control currently attached to the keyboard */
  61640. readonly connectedInputText: BABYLON.Nullable<InputText>;
  61641. /**
  61642. * Connects the keyboard with an input text control
  61643. *
  61644. * @param input defines the target control
  61645. */
  61646. connect(input: InputText): void;
  61647. /**
  61648. * Disconnects the keyboard from connected InputText controls
  61649. *
  61650. * @param input optionally defines a target control, otherwise all are disconnected
  61651. */
  61652. disconnect(input?: InputText): void;
  61653. private _removeConnectedInputObservables;
  61654. /**
  61655. * Release all resources
  61656. */
  61657. dispose(): void;
  61658. /**
  61659. * Creates a new keyboard using a default layout
  61660. *
  61661. * @param name defines control name
  61662. * @returns a new VirtualKeyboard
  61663. */
  61664. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  61665. }
  61666. }
  61667. declare module BABYLON.GUI {
  61668. /**
  61669. * Class used to create input text control
  61670. */
  61671. export class InputText extends Control implements IFocusableControl {
  61672. name?: string | undefined;
  61673. private _text;
  61674. private _placeholderText;
  61675. private _background;
  61676. private _focusedBackground;
  61677. private _focusedColor;
  61678. private _placeholderColor;
  61679. private _thickness;
  61680. private _margin;
  61681. private _autoStretchWidth;
  61682. private _maxWidth;
  61683. private _isFocused;
  61684. private _blinkTimeout;
  61685. private _blinkIsEven;
  61686. private _cursorOffset;
  61687. private _scrollLeft;
  61688. private _textWidth;
  61689. private _clickedCoordinate;
  61690. private _deadKey;
  61691. private _addKey;
  61692. private _currentKey;
  61693. private _isTextHighlightOn;
  61694. private _textHighlightColor;
  61695. private _highligherOpacity;
  61696. private _highlightedText;
  61697. private _startHighlightIndex;
  61698. private _endHighlightIndex;
  61699. private _cursorIndex;
  61700. private _onFocusSelectAll;
  61701. private _isPointerDown;
  61702. private _onClipboardObserver;
  61703. private _onPointerDblTapObserver;
  61704. /** @hidden */
  61705. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  61706. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  61707. promptMessage: string;
  61708. /** BABYLON.Observable raised when the text changes */
  61709. onTextChangedObservable: BABYLON.Observable<InputText>;
  61710. /** BABYLON.Observable raised just before an entered character is to be added */
  61711. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  61712. /** BABYLON.Observable raised when the control gets the focus */
  61713. onFocusObservable: BABYLON.Observable<InputText>;
  61714. /** BABYLON.Observable raised when the control loses the focus */
  61715. onBlurObservable: BABYLON.Observable<InputText>;
  61716. /**Observable raised when the text is highlighted */
  61717. onTextHighlightObservable: BABYLON.Observable<InputText>;
  61718. /**Observable raised when copy event is triggered */
  61719. onTextCopyObservable: BABYLON.Observable<InputText>;
  61720. /** BABYLON.Observable raised when cut event is triggered */
  61721. onTextCutObservable: BABYLON.Observable<InputText>;
  61722. /** BABYLON.Observable raised when paste event is triggered */
  61723. onTextPasteObservable: BABYLON.Observable<InputText>;
  61724. /** BABYLON.Observable raised when a key event was processed */
  61725. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  61726. /** Gets or sets the maximum width allowed by the control */
  61727. maxWidth: string | number;
  61728. /** Gets the maximum width allowed by the control in pixels */
  61729. readonly maxWidthInPixels: number;
  61730. /** Gets or sets the text highlighter transparency; default: 0.4 */
  61731. highligherOpacity: number;
  61732. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  61733. onFocusSelectAll: boolean;
  61734. /** Gets or sets the text hightlight color */
  61735. textHighlightColor: string;
  61736. /** Gets or sets control margin */
  61737. margin: string;
  61738. /** Gets control margin in pixels */
  61739. readonly marginInPixels: number;
  61740. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  61741. autoStretchWidth: boolean;
  61742. /** Gets or sets border thickness */
  61743. thickness: number;
  61744. /** Gets or sets the background color when focused */
  61745. focusedBackground: string;
  61746. /** Gets or sets the background color when focused */
  61747. focusedColor: string;
  61748. /** Gets or sets the background color */
  61749. background: string;
  61750. /** Gets or sets the placeholder color */
  61751. placeholderColor: string;
  61752. /** Gets or sets the text displayed when the control is empty */
  61753. placeholderText: string;
  61754. /** Gets or sets the dead key flag */
  61755. deadKey: boolean;
  61756. /** Gets or sets the highlight text */
  61757. highlightedText: string;
  61758. /** Gets or sets if the current key should be added */
  61759. addKey: boolean;
  61760. /** Gets or sets the value of the current key being entered */
  61761. currentKey: string;
  61762. /** Gets or sets the text displayed in the control */
  61763. text: string;
  61764. /** Gets or sets control width */
  61765. width: string | number;
  61766. /**
  61767. * Creates a new InputText
  61768. * @param name defines the control name
  61769. * @param text defines the text of the control
  61770. */
  61771. constructor(name?: string | undefined, text?: string);
  61772. /** @hidden */
  61773. onBlur(): void;
  61774. /** @hidden */
  61775. onFocus(): void;
  61776. protected _getTypeName(): string;
  61777. /**
  61778. * Function called to get the list of controls that should not steal the focus from this control
  61779. * @returns an array of controls
  61780. */
  61781. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  61782. /** @hidden */
  61783. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  61784. /** @hidden */
  61785. private _updateValueFromCursorIndex;
  61786. /** @hidden */
  61787. private _processDblClick;
  61788. /** @hidden */
  61789. private _selectAllText;
  61790. /**
  61791. * Handles the keyboard event
  61792. * @param evt Defines the KeyboardEvent
  61793. */
  61794. processKeyboard(evt: KeyboardEvent): void;
  61795. /** @hidden */
  61796. private _onCopyText;
  61797. /** @hidden */
  61798. private _onCutText;
  61799. /** @hidden */
  61800. private _onPasteText;
  61801. _draw(context: CanvasRenderingContext2D): void;
  61802. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61803. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61804. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61805. protected _beforeRenderText(text: string): string;
  61806. dispose(): void;
  61807. }
  61808. }
  61809. declare module BABYLON.GUI {
  61810. /**
  61811. * Class used to create a 2D grid container
  61812. */
  61813. export class Grid extends Container {
  61814. name?: string | undefined;
  61815. private _rowDefinitions;
  61816. private _columnDefinitions;
  61817. private _cells;
  61818. private _childControls;
  61819. /**
  61820. * Gets the number of columns
  61821. */
  61822. readonly columnCount: number;
  61823. /**
  61824. * Gets the number of rows
  61825. */
  61826. readonly rowCount: number;
  61827. /** Gets the list of children */
  61828. readonly children: Control[];
  61829. /** Gets the list of cells (e.g. the containers) */
  61830. readonly cells: {
  61831. [key: string]: Container;
  61832. };
  61833. /**
  61834. * Gets the definition of a specific row
  61835. * @param index defines the index of the row
  61836. * @returns the row definition
  61837. */
  61838. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  61839. /**
  61840. * Gets the definition of a specific column
  61841. * @param index defines the index of the column
  61842. * @returns the column definition
  61843. */
  61844. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  61845. /**
  61846. * Adds a new row to the grid
  61847. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  61848. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  61849. * @returns the current grid
  61850. */
  61851. addRowDefinition(height: number, isPixel?: boolean): Grid;
  61852. /**
  61853. * Adds a new column to the grid
  61854. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  61855. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  61856. * @returns the current grid
  61857. */
  61858. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  61859. /**
  61860. * Update a row definition
  61861. * @param index defines the index of the row to update
  61862. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  61863. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  61864. * @returns the current grid
  61865. */
  61866. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  61867. /**
  61868. * Update a column definition
  61869. * @param index defines the index of the column to update
  61870. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  61871. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  61872. * @returns the current grid
  61873. */
  61874. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  61875. /**
  61876. * Gets the list of children stored in a specific cell
  61877. * @param row defines the row to check
  61878. * @param column defines the column to check
  61879. * @returns the list of controls
  61880. */
  61881. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  61882. /**
  61883. * Gets a string representing the child cell info (row x column)
  61884. * @param child defines the control to get info from
  61885. * @returns a string containing the child cell info (row x column)
  61886. */
  61887. getChildCellInfo(child: Control): string;
  61888. private _removeCell;
  61889. private _offsetCell;
  61890. /**
  61891. * Remove a column definition at specified index
  61892. * @param index defines the index of the column to remove
  61893. * @returns the current grid
  61894. */
  61895. removeColumnDefinition(index: number): Grid;
  61896. /**
  61897. * Remove a row definition at specified index
  61898. * @param index defines the index of the row to remove
  61899. * @returns the current grid
  61900. */
  61901. removeRowDefinition(index: number): Grid;
  61902. /**
  61903. * Adds a new control to the current grid
  61904. * @param control defines the control to add
  61905. * @param row defines the row where to add the control (0 by default)
  61906. * @param column defines the column where to add the control (0 by default)
  61907. * @returns the current grid
  61908. */
  61909. addControl(control: Control, row?: number, column?: number): Grid;
  61910. /**
  61911. * Removes a control from the current container
  61912. * @param control defines the control to remove
  61913. * @returns the current container
  61914. */
  61915. removeControl(control: Control): Container;
  61916. /**
  61917. * Creates a new Grid
  61918. * @param name defines control name
  61919. */
  61920. constructor(name?: string | undefined);
  61921. protected _getTypeName(): string;
  61922. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  61923. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61924. _flagDescendantsAsMatrixDirty(): void;
  61925. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  61926. /** Releases associated resources */
  61927. dispose(): void;
  61928. }
  61929. }
  61930. declare module BABYLON.GUI {
  61931. /** Class used to create color pickers */
  61932. export class ColorPicker extends Control {
  61933. name?: string | undefined;
  61934. private static _Epsilon;
  61935. private _colorWheelCanvas;
  61936. private _value;
  61937. private _tmpColor;
  61938. private _pointerStartedOnSquare;
  61939. private _pointerStartedOnWheel;
  61940. private _squareLeft;
  61941. private _squareTop;
  61942. private _squareSize;
  61943. private _h;
  61944. private _s;
  61945. private _v;
  61946. private _lastPointerDownID;
  61947. /**
  61948. * BABYLON.Observable raised when the value changes
  61949. */
  61950. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  61951. /** Gets or sets the color of the color picker */
  61952. value: BABYLON.Color3;
  61953. /**
  61954. * Gets or sets control width
  61955. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61956. */
  61957. width: string | number;
  61958. /**
  61959. * Gets or sets control height
  61960. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61961. */
  61962. /** Gets or sets control height */
  61963. height: string | number;
  61964. /** Gets or sets control size */
  61965. size: string | number;
  61966. /**
  61967. * Creates a new ColorPicker
  61968. * @param name defines the control name
  61969. */
  61970. constructor(name?: string | undefined);
  61971. protected _getTypeName(): string;
  61972. /** @hidden */
  61973. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61974. private _updateSquareProps;
  61975. private _drawGradientSquare;
  61976. private _drawCircle;
  61977. private _createColorWheelCanvas;
  61978. /** @hidden */
  61979. _draw(context: CanvasRenderingContext2D): void;
  61980. private _pointerIsDown;
  61981. private _updateValueFromPointer;
  61982. private _isPointOnSquare;
  61983. private _isPointOnWheel;
  61984. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61985. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61986. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61987. /**
  61988. * This function expands the color picker by creating a color picker dialog with manual
  61989. * color value input and the ability to save colors into an array to be used later in
  61990. * subsequent launches of the dialogue.
  61991. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  61992. * @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.
  61993. * @returns picked color as a hex string and the saved colors array as hex strings.
  61994. */
  61995. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  61996. pickerWidth?: string;
  61997. pickerHeight?: string;
  61998. headerHeight?: string;
  61999. lastColor?: string;
  62000. swatchLimit?: number;
  62001. numSwatchesPerLine?: number;
  62002. savedColors?: Array<string>;
  62003. }): Promise<{
  62004. savedColors?: string[];
  62005. pickedColor: string;
  62006. }>;
  62007. }
  62008. }
  62009. declare module BABYLON.GUI {
  62010. /** Class used to create 2D ellipse containers */
  62011. export class Ellipse extends Container {
  62012. name?: string | undefined;
  62013. private _thickness;
  62014. /** Gets or sets border thickness */
  62015. thickness: number;
  62016. /**
  62017. * Creates a new Ellipse
  62018. * @param name defines the control name
  62019. */
  62020. constructor(name?: string | undefined);
  62021. protected _getTypeName(): string;
  62022. protected _localDraw(context: CanvasRenderingContext2D): void;
  62023. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62024. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  62025. }
  62026. }
  62027. declare module BABYLON.GUI {
  62028. /**
  62029. * Class used to create a password control
  62030. */
  62031. export class InputPassword extends InputText {
  62032. protected _beforeRenderText(text: string): string;
  62033. }
  62034. }
  62035. declare module BABYLON.GUI {
  62036. /** Class used to render 2D lines */
  62037. export class Line extends Control {
  62038. name?: string | undefined;
  62039. private _lineWidth;
  62040. private _x1;
  62041. private _y1;
  62042. private _x2;
  62043. private _y2;
  62044. private _dash;
  62045. private _connectedControl;
  62046. private _connectedControlDirtyObserver;
  62047. /** Gets or sets the dash pattern */
  62048. dash: Array<number>;
  62049. /** Gets or sets the control connected with the line end */
  62050. connectedControl: Control;
  62051. /** Gets or sets start coordinates on X axis */
  62052. x1: string | number;
  62053. /** Gets or sets start coordinates on Y axis */
  62054. y1: string | number;
  62055. /** Gets or sets end coordinates on X axis */
  62056. x2: string | number;
  62057. /** Gets or sets end coordinates on Y axis */
  62058. y2: string | number;
  62059. /** Gets or sets line width */
  62060. lineWidth: number;
  62061. /** Gets or sets horizontal alignment */
  62062. horizontalAlignment: number;
  62063. /** Gets or sets vertical alignment */
  62064. verticalAlignment: number;
  62065. private readonly _effectiveX2;
  62066. private readonly _effectiveY2;
  62067. /**
  62068. * Creates a new Line
  62069. * @param name defines the control name
  62070. */
  62071. constructor(name?: string | undefined);
  62072. protected _getTypeName(): string;
  62073. _draw(context: CanvasRenderingContext2D): void;
  62074. _measure(): void;
  62075. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62076. /**
  62077. * Move one end of the line given 3D cartesian coordinates.
  62078. * @param position Targeted world position
  62079. * @param scene BABYLON.Scene
  62080. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  62081. */
  62082. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  62083. /**
  62084. * Move one end of the line to a position in screen absolute space.
  62085. * @param projectedPosition Position in screen absolute space (X, Y)
  62086. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  62087. */
  62088. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  62089. }
  62090. }
  62091. declare module BABYLON.GUI {
  62092. /**
  62093. * Class used to store a point for a MultiLine object.
  62094. * The point can be pure 2D coordinates, a mesh or a control
  62095. */
  62096. export class MultiLinePoint {
  62097. private _multiLine;
  62098. private _x;
  62099. private _y;
  62100. private _control;
  62101. private _mesh;
  62102. private _controlObserver;
  62103. private _meshObserver;
  62104. /** @hidden */
  62105. _point: BABYLON.Vector2;
  62106. /**
  62107. * Creates a new MultiLinePoint
  62108. * @param multiLine defines the source MultiLine object
  62109. */
  62110. constructor(multiLine: MultiLine);
  62111. /** Gets or sets x coordinate */
  62112. x: string | number;
  62113. /** Gets or sets y coordinate */
  62114. y: string | number;
  62115. /** Gets or sets the control associated with this point */
  62116. control: BABYLON.Nullable<Control>;
  62117. /** Gets or sets the mesh associated with this point */
  62118. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62119. /** Resets links */
  62120. resetLinks(): void;
  62121. /**
  62122. * Gets a translation vector
  62123. * @returns the translation vector
  62124. */
  62125. translate(): BABYLON.Vector2;
  62126. private _translatePoint;
  62127. /** Release associated resources */
  62128. dispose(): void;
  62129. }
  62130. }
  62131. declare module BABYLON.GUI {
  62132. /**
  62133. * Class used to create multi line control
  62134. */
  62135. export class MultiLine extends Control {
  62136. name?: string | undefined;
  62137. private _lineWidth;
  62138. private _dash;
  62139. private _points;
  62140. private _minX;
  62141. private _minY;
  62142. private _maxX;
  62143. private _maxY;
  62144. /**
  62145. * Creates a new MultiLine
  62146. * @param name defines the control name
  62147. */
  62148. constructor(name?: string | undefined);
  62149. /** Gets or sets dash pattern */
  62150. dash: Array<number>;
  62151. /**
  62152. * Gets point stored at specified index
  62153. * @param index defines the index to look for
  62154. * @returns the requested point if found
  62155. */
  62156. getAt(index: number): MultiLinePoint;
  62157. /** Function called when a point is updated */
  62158. onPointUpdate: () => void;
  62159. /**
  62160. * Adds new points to the point collection
  62161. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  62162. * @returns the list of created MultiLinePoint
  62163. */
  62164. add(...items: (AbstractMesh | Control | {
  62165. x: string | number;
  62166. y: string | number;
  62167. })[]): MultiLinePoint[];
  62168. /**
  62169. * Adds a new point to the point collection
  62170. * @param item defines the item (mesh, control or 2d coordiantes) to add
  62171. * @returns the created MultiLinePoint
  62172. */
  62173. push(item?: (AbstractMesh | Control | {
  62174. x: string | number;
  62175. y: string | number;
  62176. })): MultiLinePoint;
  62177. /**
  62178. * Remove a specific value or point from the active point collection
  62179. * @param value defines the value or point to remove
  62180. */
  62181. remove(value: number | MultiLinePoint): void;
  62182. /**
  62183. * Resets this object to initial state (no point)
  62184. */
  62185. reset(): void;
  62186. /**
  62187. * Resets all links
  62188. */
  62189. resetLinks(): void;
  62190. /** Gets or sets line width */
  62191. lineWidth: number;
  62192. horizontalAlignment: number;
  62193. verticalAlignment: number;
  62194. protected _getTypeName(): string;
  62195. _draw(context: CanvasRenderingContext2D): void;
  62196. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62197. _measure(): void;
  62198. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62199. dispose(): void;
  62200. }
  62201. }
  62202. declare module BABYLON.GUI {
  62203. /**
  62204. * Class used to create radio button controls
  62205. */
  62206. export class RadioButton extends Control {
  62207. name?: string | undefined;
  62208. private _isChecked;
  62209. private _background;
  62210. private _checkSizeRatio;
  62211. private _thickness;
  62212. /** Gets or sets border thickness */
  62213. thickness: number;
  62214. /** Gets or sets group name */
  62215. group: string;
  62216. /** BABYLON.Observable raised when isChecked is changed */
  62217. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  62218. /** Gets or sets a value indicating the ratio between overall size and check size */
  62219. checkSizeRatio: number;
  62220. /** Gets or sets background color */
  62221. background: string;
  62222. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  62223. isChecked: boolean;
  62224. /**
  62225. * Creates a new RadioButton
  62226. * @param name defines the control name
  62227. */
  62228. constructor(name?: string | undefined);
  62229. protected _getTypeName(): string;
  62230. _draw(context: CanvasRenderingContext2D): void;
  62231. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62232. /**
  62233. * Utility function to easily create a radio button with a header
  62234. * @param title defines the label to use for the header
  62235. * @param group defines the group to use for the radio button
  62236. * @param isChecked defines the initial state of the radio button
  62237. * @param onValueChanged defines the callback to call when value changes
  62238. * @returns a StackPanel containing the radio button and a textBlock
  62239. */
  62240. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  62241. }
  62242. }
  62243. declare module BABYLON.GUI {
  62244. /**
  62245. * Class used to create slider controls
  62246. */
  62247. export class BaseSlider extends Control {
  62248. name?: string | undefined;
  62249. protected _thumbWidth: ValueAndUnit;
  62250. private _minimum;
  62251. private _maximum;
  62252. private _value;
  62253. private _isVertical;
  62254. protected _barOffset: ValueAndUnit;
  62255. private _isThumbClamped;
  62256. protected _displayThumb: boolean;
  62257. private _step;
  62258. private _lastPointerDownID;
  62259. protected _effectiveBarOffset: number;
  62260. protected _renderLeft: number;
  62261. protected _renderTop: number;
  62262. protected _renderWidth: number;
  62263. protected _renderHeight: number;
  62264. protected _backgroundBoxLength: number;
  62265. protected _backgroundBoxThickness: number;
  62266. protected _effectiveThumbThickness: number;
  62267. /** BABYLON.Observable raised when the sldier value changes */
  62268. onValueChangedObservable: BABYLON.Observable<number>;
  62269. /** Gets or sets a boolean indicating if the thumb must be rendered */
  62270. displayThumb: boolean;
  62271. /** Gets or sets a step to apply to values (0 by default) */
  62272. step: number;
  62273. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  62274. barOffset: string | number;
  62275. /** Gets main bar offset in pixels*/
  62276. readonly barOffsetInPixels: number;
  62277. /** Gets or sets thumb width */
  62278. thumbWidth: string | number;
  62279. /** Gets thumb width in pixels */
  62280. readonly thumbWidthInPixels: number;
  62281. /** Gets or sets minimum value */
  62282. minimum: number;
  62283. /** Gets or sets maximum value */
  62284. maximum: number;
  62285. /** Gets or sets current value */
  62286. value: number;
  62287. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  62288. isVertical: boolean;
  62289. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  62290. isThumbClamped: boolean;
  62291. /**
  62292. * Creates a new BaseSlider
  62293. * @param name defines the control name
  62294. */
  62295. constructor(name?: string | undefined);
  62296. protected _getTypeName(): string;
  62297. protected _getThumbPosition(): number;
  62298. protected _getThumbThickness(type: string): number;
  62299. protected _prepareRenderingData(type: string): void;
  62300. private _pointerIsDown;
  62301. /** @hidden */
  62302. protected _updateValueFromPointer(x: number, y: number): void;
  62303. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62304. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  62305. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62306. }
  62307. }
  62308. declare module BABYLON.GUI {
  62309. /**
  62310. * Class used to create slider controls
  62311. */
  62312. export class Slider extends BaseSlider {
  62313. name?: string | undefined;
  62314. private _background;
  62315. private _borderColor;
  62316. private _isThumbCircle;
  62317. protected _displayValueBar: boolean;
  62318. /** Gets or sets a boolean indicating if the value bar must be rendered */
  62319. displayValueBar: boolean;
  62320. /** Gets or sets border color */
  62321. borderColor: string;
  62322. /** Gets or sets background color */
  62323. background: string;
  62324. /** Gets or sets a boolean indicating if the thumb should be round or square */
  62325. isThumbCircle: boolean;
  62326. /**
  62327. * Creates a new Slider
  62328. * @param name defines the control name
  62329. */
  62330. constructor(name?: string | undefined);
  62331. protected _getTypeName(): string;
  62332. _draw(context: CanvasRenderingContext2D): void;
  62333. }
  62334. }
  62335. declare module BABYLON.GUI {
  62336. /** Class used to create a RadioGroup
  62337. * which contains groups of radio buttons
  62338. */
  62339. export class SelectorGroup {
  62340. /** name of SelectorGroup */
  62341. name: string;
  62342. private _groupPanel;
  62343. private _selectors;
  62344. private _groupHeader;
  62345. /**
  62346. * Creates a new SelectorGroup
  62347. * @param name of group, used as a group heading
  62348. */
  62349. constructor(
  62350. /** name of SelectorGroup */
  62351. name: string);
  62352. /** Gets the groupPanel of the SelectorGroup */
  62353. readonly groupPanel: StackPanel;
  62354. /** Gets the selectors array */
  62355. readonly selectors: StackPanel[];
  62356. /** Gets and sets the group header */
  62357. header: string;
  62358. /** @hidden */
  62359. private _addGroupHeader;
  62360. /** @hidden*/
  62361. _getSelector(selectorNb: number): StackPanel | undefined;
  62362. /** Removes the selector at the given position
  62363. * @param selectorNb the position of the selector within the group
  62364. */
  62365. removeSelector(selectorNb: number): void;
  62366. }
  62367. /** Class used to create a CheckboxGroup
  62368. * which contains groups of checkbox buttons
  62369. */
  62370. export class CheckboxGroup extends SelectorGroup {
  62371. /** Adds a checkbox as a control
  62372. * @param text is the label for the selector
  62373. * @param func is the function called when the Selector is checked
  62374. * @param checked is true when Selector is checked
  62375. */
  62376. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  62377. /** @hidden */
  62378. _setSelectorLabel(selectorNb: number, label: string): void;
  62379. /** @hidden */
  62380. _setSelectorLabelColor(selectorNb: number, color: string): void;
  62381. /** @hidden */
  62382. _setSelectorButtonColor(selectorNb: number, color: string): void;
  62383. /** @hidden */
  62384. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62385. }
  62386. /** Class used to create a RadioGroup
  62387. * which contains groups of radio buttons
  62388. */
  62389. export class RadioGroup extends SelectorGroup {
  62390. private _selectNb;
  62391. /** Adds a radio button as a control
  62392. * @param label is the label for the selector
  62393. * @param func is the function called when the Selector is checked
  62394. * @param checked is true when Selector is checked
  62395. */
  62396. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  62397. /** @hidden */
  62398. _setSelectorLabel(selectorNb: number, label: string): void;
  62399. /** @hidden */
  62400. _setSelectorLabelColor(selectorNb: number, color: string): void;
  62401. /** @hidden */
  62402. _setSelectorButtonColor(selectorNb: number, color: string): void;
  62403. /** @hidden */
  62404. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62405. }
  62406. /** Class used to create a SliderGroup
  62407. * which contains groups of slider buttons
  62408. */
  62409. export class SliderGroup extends SelectorGroup {
  62410. /**
  62411. * Adds a slider to the SelectorGroup
  62412. * @param label is the label for the SliderBar
  62413. * @param func is the function called when the Slider moves
  62414. * @param unit is a string describing the units used, eg degrees or metres
  62415. * @param min is the minimum value for the Slider
  62416. * @param max is the maximum value for the Slider
  62417. * @param value is the start value for the Slider between min and max
  62418. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  62419. */
  62420. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  62421. /** @hidden */
  62422. _setSelectorLabel(selectorNb: number, label: string): void;
  62423. /** @hidden */
  62424. _setSelectorLabelColor(selectorNb: number, color: string): void;
  62425. /** @hidden */
  62426. _setSelectorButtonColor(selectorNb: number, color: string): void;
  62427. /** @hidden */
  62428. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62429. }
  62430. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  62431. * @see http://doc.babylonjs.com/how_to/selector
  62432. */
  62433. export class SelectionPanel extends Rectangle {
  62434. /** name of SelectionPanel */
  62435. name: string;
  62436. /** an array of SelectionGroups */
  62437. groups: SelectorGroup[];
  62438. private _panel;
  62439. private _buttonColor;
  62440. private _buttonBackground;
  62441. private _headerColor;
  62442. private _barColor;
  62443. private _barHeight;
  62444. private _spacerHeight;
  62445. private _labelColor;
  62446. private _groups;
  62447. private _bars;
  62448. /**
  62449. * Creates a new SelectionPanel
  62450. * @param name of SelectionPanel
  62451. * @param groups is an array of SelectionGroups
  62452. */
  62453. constructor(
  62454. /** name of SelectionPanel */
  62455. name: string,
  62456. /** an array of SelectionGroups */
  62457. groups?: SelectorGroup[]);
  62458. protected _getTypeName(): string;
  62459. /** Gets or sets the headerColor */
  62460. headerColor: string;
  62461. private _setHeaderColor;
  62462. /** Gets or sets the button color */
  62463. buttonColor: string;
  62464. private _setbuttonColor;
  62465. /** Gets or sets the label color */
  62466. labelColor: string;
  62467. private _setLabelColor;
  62468. /** Gets or sets the button background */
  62469. buttonBackground: string;
  62470. private _setButtonBackground;
  62471. /** Gets or sets the color of separator bar */
  62472. barColor: string;
  62473. private _setBarColor;
  62474. /** Gets or sets the height of separator bar */
  62475. barHeight: string;
  62476. private _setBarHeight;
  62477. /** Gets or sets the height of spacers*/
  62478. spacerHeight: string;
  62479. private _setSpacerHeight;
  62480. /** Adds a bar between groups */
  62481. private _addSpacer;
  62482. /** Add a group to the selection panel
  62483. * @param group is the selector group to add
  62484. */
  62485. addGroup(group: SelectorGroup): void;
  62486. /** Remove the group from the given position
  62487. * @param groupNb is the position of the group in the list
  62488. */
  62489. removeGroup(groupNb: number): void;
  62490. /** Change a group header label
  62491. * @param label is the new group header label
  62492. * @param groupNb is the number of the group to relabel
  62493. * */
  62494. setHeaderName(label: string, groupNb: number): void;
  62495. /** Change selector label to the one given
  62496. * @param label is the new selector label
  62497. * @param groupNb is the number of the groupcontaining the selector
  62498. * @param selectorNb is the number of the selector within a group to relabel
  62499. * */
  62500. relabel(label: string, groupNb: number, selectorNb: number): void;
  62501. /** For a given group position remove the selector at the given position
  62502. * @param groupNb is the number of the group to remove the selector from
  62503. * @param selectorNb is the number of the selector within the group
  62504. */
  62505. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  62506. /** For a given group position of correct type add a checkbox button
  62507. * @param groupNb is the number of the group to remove the selector from
  62508. * @param label is the label for the selector
  62509. * @param func is the function called when the Selector is checked
  62510. * @param checked is true when Selector is checked
  62511. */
  62512. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  62513. /** For a given group position of correct type add a radio button
  62514. * @param groupNb is the number of the group to remove the selector from
  62515. * @param label is the label for the selector
  62516. * @param func is the function called when the Selector is checked
  62517. * @param checked is true when Selector is checked
  62518. */
  62519. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  62520. /**
  62521. * For a given slider group add a slider
  62522. * @param groupNb is the number of the group to add the slider to
  62523. * @param label is the label for the Slider
  62524. * @param func is the function called when the Slider moves
  62525. * @param unit is a string describing the units used, eg degrees or metres
  62526. * @param min is the minimum value for the Slider
  62527. * @param max is the maximum value for the Slider
  62528. * @param value is the start value for the Slider between min and max
  62529. * @param onVal is the function used to format the value displayed, eg radians to degrees
  62530. */
  62531. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  62532. }
  62533. }
  62534. declare module BABYLON.GUI {
  62535. /**
  62536. * Class used to hold a the container for ScrollViewer
  62537. * @hidden
  62538. */
  62539. export class _ScrollViewerWindow extends Container {
  62540. parentClientWidth: number;
  62541. parentClientHeight: number;
  62542. /**
  62543. * Creates a new ScrollViewerWindow
  62544. * @param name of ScrollViewerWindow
  62545. */
  62546. constructor(name?: string);
  62547. protected _getTypeName(): string;
  62548. /** @hidden */
  62549. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62550. protected _postMeasure(): void;
  62551. }
  62552. }
  62553. declare module BABYLON.GUI {
  62554. /**
  62555. * Class used to create slider controls
  62556. */
  62557. export class ScrollBar extends BaseSlider {
  62558. name?: string | undefined;
  62559. private _background;
  62560. private _borderColor;
  62561. private _thumbMeasure;
  62562. /** Gets or sets border color */
  62563. borderColor: string;
  62564. /** Gets or sets background color */
  62565. background: string;
  62566. /**
  62567. * Creates a new Slider
  62568. * @param name defines the control name
  62569. */
  62570. constructor(name?: string | undefined);
  62571. protected _getTypeName(): string;
  62572. protected _getThumbThickness(): number;
  62573. _draw(context: CanvasRenderingContext2D): void;
  62574. private _first;
  62575. private _originX;
  62576. private _originY;
  62577. /** @hidden */
  62578. protected _updateValueFromPointer(x: number, y: number): void;
  62579. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62580. }
  62581. }
  62582. declare module BABYLON.GUI {
  62583. /**
  62584. * Class used to hold a viewer window and sliders in a grid
  62585. */
  62586. export class ScrollViewer extends Rectangle {
  62587. private _grid;
  62588. private _horizontalBarSpace;
  62589. private _verticalBarSpace;
  62590. private _dragSpace;
  62591. private _horizontalBar;
  62592. private _verticalBar;
  62593. private _barColor;
  62594. private _barBackground;
  62595. private _barSize;
  62596. private _endLeft;
  62597. private _endTop;
  62598. private _window;
  62599. private _pointerIsOver;
  62600. private _wheelPrecision;
  62601. private _onPointerObserver;
  62602. private _clientWidth;
  62603. private _clientHeight;
  62604. /**
  62605. * Gets the horizontal scrollbar
  62606. */
  62607. readonly horizontalBar: ScrollBar;
  62608. /**
  62609. * Gets the vertical scrollbar
  62610. */
  62611. readonly verticalBar: ScrollBar;
  62612. /**
  62613. * Adds a new control to the current container
  62614. * @param control defines the control to add
  62615. * @returns the current container
  62616. */
  62617. addControl(control: BABYLON.Nullable<Control>): Container;
  62618. /**
  62619. * Removes a control from the current container
  62620. * @param control defines the control to remove
  62621. * @returns the current container
  62622. */
  62623. removeControl(control: Control): Container;
  62624. /** Gets the list of children */
  62625. readonly children: Control[];
  62626. _flagDescendantsAsMatrixDirty(): void;
  62627. /**
  62628. * Creates a new ScrollViewer
  62629. * @param name of ScrollViewer
  62630. */
  62631. constructor(name?: string);
  62632. /** Reset the scroll viewer window to initial size */
  62633. resetWindow(): void;
  62634. protected _getTypeName(): string;
  62635. private _buildClientSizes;
  62636. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62637. protected _postMeasure(): void;
  62638. /**
  62639. * Gets or sets the mouse wheel precision
  62640. * from 0 to 1 with a default value of 0.05
  62641. * */
  62642. wheelPrecision: number;
  62643. /** Gets or sets the bar color */
  62644. barColor: string;
  62645. /** Gets or sets the size of the bar */
  62646. barSize: number;
  62647. /** Gets or sets the bar background */
  62648. barBackground: string;
  62649. /** @hidden */
  62650. private _updateScroller;
  62651. _link(host: AdvancedDynamicTexture): void;
  62652. /** @hidden */
  62653. private _attachWheel;
  62654. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  62655. /** Releases associated resources */
  62656. dispose(): void;
  62657. }
  62658. }
  62659. declare module BABYLON.GUI {
  62660. /** Class used to render a grid */
  62661. export class DisplayGrid extends Control {
  62662. name?: string | undefined;
  62663. private _cellWidth;
  62664. private _cellHeight;
  62665. private _minorLineTickness;
  62666. private _minorLineColor;
  62667. private _majorLineTickness;
  62668. private _majorLineColor;
  62669. private _majorLineFrequency;
  62670. private _background;
  62671. private _displayMajorLines;
  62672. private _displayMinorLines;
  62673. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  62674. displayMinorLines: boolean;
  62675. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  62676. displayMajorLines: boolean;
  62677. /** Gets or sets background color (Black by default) */
  62678. background: string;
  62679. /** Gets or sets the width of each cell (20 by default) */
  62680. cellWidth: number;
  62681. /** Gets or sets the height of each cell (20 by default) */
  62682. cellHeight: number;
  62683. /** Gets or sets the tickness of minor lines (1 by default) */
  62684. minorLineTickness: number;
  62685. /** Gets or sets the color of minor lines (DarkGray by default) */
  62686. minorLineColor: string;
  62687. /** Gets or sets the tickness of major lines (2 by default) */
  62688. majorLineTickness: number;
  62689. /** Gets or sets the color of major lines (White by default) */
  62690. majorLineColor: string;
  62691. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  62692. majorLineFrequency: number;
  62693. /**
  62694. * Creates a new GridDisplayRectangle
  62695. * @param name defines the control name
  62696. */
  62697. constructor(name?: string | undefined);
  62698. _draw(context: CanvasRenderingContext2D): void;
  62699. protected _getTypeName(): string;
  62700. }
  62701. }
  62702. declare module BABYLON.GUI {
  62703. /**
  62704. * Class used to create slider controls based on images
  62705. */
  62706. export class ImageBasedSlider extends BaseSlider {
  62707. name?: string | undefined;
  62708. private _backgroundImage;
  62709. private _thumbImage;
  62710. private _valueBarImage;
  62711. private _tempMeasure;
  62712. displayThumb: boolean;
  62713. /**
  62714. * Gets or sets the image used to render the background
  62715. */
  62716. backgroundImage: Image;
  62717. /**
  62718. * Gets or sets the image used to render the value bar
  62719. */
  62720. valueBarImage: Image;
  62721. /**
  62722. * Gets or sets the image used to render the thumb
  62723. */
  62724. thumbImage: Image;
  62725. /**
  62726. * Creates a new ImageBasedSlider
  62727. * @param name defines the control name
  62728. */
  62729. constructor(name?: string | undefined);
  62730. protected _getTypeName(): string;
  62731. _draw(context: CanvasRenderingContext2D): void;
  62732. }
  62733. }
  62734. declare module BABYLON.GUI {
  62735. /**
  62736. * Forcing an export so that this code will execute
  62737. * @hidden
  62738. */
  62739. const name = "Statics";
  62740. }
  62741. declare module BABYLON.GUI {
  62742. /**
  62743. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  62744. */
  62745. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  62746. /**
  62747. * Define the instrumented AdvancedDynamicTexture.
  62748. */
  62749. texture: AdvancedDynamicTexture;
  62750. private _captureRenderTime;
  62751. private _renderTime;
  62752. private _captureLayoutTime;
  62753. private _layoutTime;
  62754. private _onBeginRenderObserver;
  62755. private _onEndRenderObserver;
  62756. private _onBeginLayoutObserver;
  62757. private _onEndLayoutObserver;
  62758. /**
  62759. * Gets the perf counter used to capture render time
  62760. */
  62761. readonly renderTimeCounter: BABYLON.PerfCounter;
  62762. /**
  62763. * Gets the perf counter used to capture layout time
  62764. */
  62765. readonly layoutTimeCounter: BABYLON.PerfCounter;
  62766. /**
  62767. * Enable or disable the render time capture
  62768. */
  62769. captureRenderTime: boolean;
  62770. /**
  62771. * Enable or disable the layout time capture
  62772. */
  62773. captureLayoutTime: boolean;
  62774. /**
  62775. * Instantiates a new advanced dynamic texture instrumentation.
  62776. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  62777. * @param texture Defines the AdvancedDynamicTexture to instrument
  62778. */
  62779. constructor(
  62780. /**
  62781. * Define the instrumented AdvancedDynamicTexture.
  62782. */
  62783. texture: AdvancedDynamicTexture);
  62784. /**
  62785. * Dispose and release associated resources.
  62786. */
  62787. dispose(): void;
  62788. }
  62789. }
  62790. declare module BABYLON.GUI {
  62791. /**
  62792. * Class used to create containers for controls
  62793. */
  62794. export class Container3D extends Control3D {
  62795. private _blockLayout;
  62796. /**
  62797. * Gets the list of child controls
  62798. */
  62799. protected _children: Control3D[];
  62800. /**
  62801. * Gets the list of child controls
  62802. */
  62803. readonly children: Array<Control3D>;
  62804. /**
  62805. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  62806. * This is helpful to optimize layout operation when adding multiple children in a row
  62807. */
  62808. blockLayout: boolean;
  62809. /**
  62810. * Creates a new container
  62811. * @param name defines the container name
  62812. */
  62813. constructor(name?: string);
  62814. /**
  62815. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  62816. * @returns the current container
  62817. */
  62818. updateLayout(): Container3D;
  62819. /**
  62820. * Gets a boolean indicating if the given control is in the children of this control
  62821. * @param control defines the control to check
  62822. * @returns true if the control is in the child list
  62823. */
  62824. containsControl(control: Control3D): boolean;
  62825. /**
  62826. * Adds a control to the children of this control
  62827. * @param control defines the control to add
  62828. * @returns the current container
  62829. */
  62830. addControl(control: Control3D): Container3D;
  62831. /**
  62832. * This function will be called everytime a new control is added
  62833. */
  62834. protected _arrangeChildren(): void;
  62835. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  62836. /**
  62837. * Removes a control from the children of this control
  62838. * @param control defines the control to remove
  62839. * @returns the current container
  62840. */
  62841. removeControl(control: Control3D): Container3D;
  62842. protected _getTypeName(): string;
  62843. /**
  62844. * Releases all associated resources
  62845. */
  62846. dispose(): void;
  62847. /** Control rotation will remain unchanged */
  62848. static readonly UNSET_ORIENTATION: number;
  62849. /** Control will rotate to make it look at sphere central axis */
  62850. static readonly FACEORIGIN_ORIENTATION: number;
  62851. /** Control will rotate to make it look back at sphere central axis */
  62852. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  62853. /** Control will rotate to look at z axis (0, 0, 1) */
  62854. static readonly FACEFORWARD_ORIENTATION: number;
  62855. /** Control will rotate to look at negative z axis (0, 0, -1) */
  62856. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  62857. }
  62858. }
  62859. declare module BABYLON.GUI {
  62860. /**
  62861. * Class used to manage 3D user interface
  62862. * @see http://doc.babylonjs.com/how_to/gui3d
  62863. */
  62864. export class GUI3DManager implements BABYLON.IDisposable {
  62865. private _scene;
  62866. private _sceneDisposeObserver;
  62867. private _utilityLayer;
  62868. private _rootContainer;
  62869. private _pointerObserver;
  62870. private _pointerOutObserver;
  62871. /** @hidden */
  62872. _lastPickedControl: Control3D;
  62873. /** @hidden */
  62874. _lastControlOver: {
  62875. [pointerId: number]: Control3D;
  62876. };
  62877. /** @hidden */
  62878. _lastControlDown: {
  62879. [pointerId: number]: Control3D;
  62880. };
  62881. /**
  62882. * BABYLON.Observable raised when the point picked by the pointer events changed
  62883. */
  62884. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  62885. /** @hidden */
  62886. _sharedMaterials: {
  62887. [key: string]: BABYLON.Material;
  62888. };
  62889. /** Gets the hosting scene */
  62890. readonly scene: BABYLON.Scene;
  62891. /** Gets associated utility layer */
  62892. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  62893. /**
  62894. * Creates a new GUI3DManager
  62895. * @param scene
  62896. */
  62897. constructor(scene?: BABYLON.Scene);
  62898. private _handlePointerOut;
  62899. private _doPicking;
  62900. /**
  62901. * Gets the root container
  62902. */
  62903. readonly rootContainer: Container3D;
  62904. /**
  62905. * Gets a boolean indicating if the given control is in the root child list
  62906. * @param control defines the control to check
  62907. * @returns true if the control is in the root child list
  62908. */
  62909. containsControl(control: Control3D): boolean;
  62910. /**
  62911. * Adds a control to the root child list
  62912. * @param control defines the control to add
  62913. * @returns the current manager
  62914. */
  62915. addControl(control: Control3D): GUI3DManager;
  62916. /**
  62917. * Removes a control from the root child list
  62918. * @param control defines the control to remove
  62919. * @returns the current container
  62920. */
  62921. removeControl(control: Control3D): GUI3DManager;
  62922. /**
  62923. * Releases all associated resources
  62924. */
  62925. dispose(): void;
  62926. }
  62927. }
  62928. declare module BABYLON.GUI {
  62929. /**
  62930. * Class used to transport BABYLON.Vector3 information for pointer events
  62931. */
  62932. export class Vector3WithInfo extends BABYLON.Vector3 {
  62933. /** defines the current mouse button index */
  62934. buttonIndex: number;
  62935. /**
  62936. * Creates a new Vector3WithInfo
  62937. * @param source defines the vector3 data to transport
  62938. * @param buttonIndex defines the current mouse button index
  62939. */
  62940. constructor(source: BABYLON.Vector3,
  62941. /** defines the current mouse button index */
  62942. buttonIndex?: number);
  62943. }
  62944. }
  62945. declare module BABYLON.GUI {
  62946. /**
  62947. * Class used as base class for controls
  62948. */
  62949. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  62950. /** Defines the control name */
  62951. name?: string | undefined;
  62952. /** @hidden */
  62953. _host: GUI3DManager;
  62954. private _node;
  62955. private _downCount;
  62956. private _enterCount;
  62957. private _downPointerIds;
  62958. private _isVisible;
  62959. /** Gets or sets the control position in world space */
  62960. position: BABYLON.Vector3;
  62961. /** Gets or sets the control scaling in world space */
  62962. scaling: BABYLON.Vector3;
  62963. /** Callback used to start pointer enter animation */
  62964. pointerEnterAnimation: () => void;
  62965. /** Callback used to start pointer out animation */
  62966. pointerOutAnimation: () => void;
  62967. /** Callback used to start pointer down animation */
  62968. pointerDownAnimation: () => void;
  62969. /** Callback used to start pointer up animation */
  62970. pointerUpAnimation: () => void;
  62971. /**
  62972. * An event triggered when the pointer move over the control
  62973. */
  62974. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  62975. /**
  62976. * An event triggered when the pointer move out of the control
  62977. */
  62978. onPointerOutObservable: BABYLON.Observable<Control3D>;
  62979. /**
  62980. * An event triggered when the pointer taps the control
  62981. */
  62982. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  62983. /**
  62984. * An event triggered when pointer is up
  62985. */
  62986. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  62987. /**
  62988. * An event triggered when a control is clicked on (with a mouse)
  62989. */
  62990. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  62991. /**
  62992. * An event triggered when pointer enters the control
  62993. */
  62994. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  62995. /**
  62996. * Gets or sets the parent container
  62997. */
  62998. parent: BABYLON.Nullable<Container3D>;
  62999. private _behaviors;
  63000. /**
  63001. * Gets the list of attached behaviors
  63002. * @see http://doc.babylonjs.com/features/behaviour
  63003. */
  63004. readonly behaviors: BABYLON.Behavior<Control3D>[];
  63005. /**
  63006. * Attach a behavior to the control
  63007. * @see http://doc.babylonjs.com/features/behaviour
  63008. * @param behavior defines the behavior to attach
  63009. * @returns the current control
  63010. */
  63011. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  63012. /**
  63013. * Remove an attached behavior
  63014. * @see http://doc.babylonjs.com/features/behaviour
  63015. * @param behavior defines the behavior to attach
  63016. * @returns the current control
  63017. */
  63018. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  63019. /**
  63020. * Gets an attached behavior by name
  63021. * @param name defines the name of the behavior to look for
  63022. * @see http://doc.babylonjs.com/features/behaviour
  63023. * @returns null if behavior was not found else the requested behavior
  63024. */
  63025. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  63026. /** Gets or sets a boolean indicating if the control is visible */
  63027. isVisible: boolean;
  63028. /**
  63029. * Creates a new control
  63030. * @param name defines the control name
  63031. */
  63032. constructor(
  63033. /** Defines the control name */
  63034. name?: string | undefined);
  63035. /**
  63036. * Gets a string representing the class name
  63037. */
  63038. readonly typeName: string;
  63039. /**
  63040. * Get the current class name of the control.
  63041. * @returns current class name
  63042. */
  63043. getClassName(): string;
  63044. protected _getTypeName(): string;
  63045. /**
  63046. * Gets the transform node used by this control
  63047. */
  63048. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  63049. /**
  63050. * Gets the mesh used to render this control
  63051. */
  63052. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63053. /**
  63054. * Link the control as child of the given node
  63055. * @param node defines the node to link to. Use null to unlink the control
  63056. * @returns the current control
  63057. */
  63058. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  63059. /** @hidden **/
  63060. _prepareNode(scene: BABYLON.Scene): void;
  63061. /**
  63062. * Node creation.
  63063. * Can be overriden by children
  63064. * @param scene defines the scene where the node must be attached
  63065. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  63066. */
  63067. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  63068. /**
  63069. * Affect a material to the given mesh
  63070. * @param mesh defines the mesh which will represent the control
  63071. */
  63072. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63073. /** @hidden */
  63074. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  63075. /** @hidden */
  63076. _onPointerEnter(target: Control3D): boolean;
  63077. /** @hidden */
  63078. _onPointerOut(target: Control3D): void;
  63079. /** @hidden */
  63080. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  63081. /** @hidden */
  63082. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63083. /** @hidden */
  63084. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  63085. /** @hidden */
  63086. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  63087. /** @hidden */
  63088. _disposeNode(): void;
  63089. /**
  63090. * Releases all associated resources
  63091. */
  63092. dispose(): void;
  63093. }
  63094. }
  63095. declare module BABYLON.GUI {
  63096. /**
  63097. * Class used as a root to all buttons
  63098. */
  63099. export class AbstractButton3D extends Control3D {
  63100. /**
  63101. * Creates a new button
  63102. * @param name defines the control name
  63103. */
  63104. constructor(name?: string);
  63105. protected _getTypeName(): string;
  63106. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63107. }
  63108. }
  63109. declare module BABYLON.GUI {
  63110. /**
  63111. * Class used to create a button in 3D
  63112. */
  63113. export class Button3D extends AbstractButton3D {
  63114. /** @hidden */
  63115. protected _currentMaterial: BABYLON.Material;
  63116. private _facadeTexture;
  63117. private _content;
  63118. private _contentResolution;
  63119. private _contentScaleRatio;
  63120. /**
  63121. * Gets or sets the texture resolution used to render content (512 by default)
  63122. */
  63123. contentResolution: BABYLON.int;
  63124. /**
  63125. * Gets or sets the texture scale ratio used to render content (2 by default)
  63126. */
  63127. contentScaleRatio: number;
  63128. protected _disposeFacadeTexture(): void;
  63129. protected _resetContent(): void;
  63130. /**
  63131. * Creates a new button
  63132. * @param name defines the control name
  63133. */
  63134. constructor(name?: string);
  63135. /**
  63136. * Gets or sets the GUI 2D content used to display the button's facade
  63137. */
  63138. content: Control;
  63139. /**
  63140. * Apply the facade texture (created from the content property).
  63141. * This function can be overloaded by child classes
  63142. * @param facadeTexture defines the AdvancedDynamicTexture to use
  63143. */
  63144. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  63145. protected _getTypeName(): string;
  63146. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63147. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63148. /**
  63149. * Releases all associated resources
  63150. */
  63151. dispose(): void;
  63152. }
  63153. }
  63154. declare module BABYLON.GUI {
  63155. /**
  63156. * Abstract class used to create a container panel deployed on the surface of a volume
  63157. */
  63158. export abstract class VolumeBasedPanel extends Container3D {
  63159. private _columns;
  63160. private _rows;
  63161. private _rowThenColum;
  63162. private _orientation;
  63163. protected _cellWidth: number;
  63164. protected _cellHeight: number;
  63165. /**
  63166. * Gets or sets the distance between elements
  63167. */
  63168. margin: number;
  63169. /**
  63170. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  63171. * | Value | Type | Description |
  63172. * | ----- | ----------------------------------- | ----------- |
  63173. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  63174. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  63175. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  63176. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  63177. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  63178. */
  63179. orientation: number;
  63180. /**
  63181. * Gets or sets the number of columns requested (10 by default).
  63182. * The panel will automatically compute the number of rows based on number of child controls.
  63183. */
  63184. columns: BABYLON.int;
  63185. /**
  63186. * Gets or sets a the number of rows requested.
  63187. * The panel will automatically compute the number of columns based on number of child controls.
  63188. */
  63189. rows: BABYLON.int;
  63190. /**
  63191. * Creates new VolumeBasedPanel
  63192. */
  63193. constructor();
  63194. protected _arrangeChildren(): void;
  63195. /** Child classes must implement this function to provide correct control positioning */
  63196. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63197. /** Child classes can implement this function to provide additional processing */
  63198. protected _finalProcessing(): void;
  63199. }
  63200. }
  63201. declare module BABYLON.GUI {
  63202. /**
  63203. * Class used to create a container panel deployed on the surface of a cylinder
  63204. */
  63205. export class CylinderPanel extends VolumeBasedPanel {
  63206. private _radius;
  63207. /**
  63208. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  63209. */
  63210. radius: BABYLON.float;
  63211. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63212. private _cylindricalMapping;
  63213. }
  63214. }
  63215. declare module BABYLON.GUI {
  63216. /** @hidden */
  63217. export var fluentVertexShader: {
  63218. name: string;
  63219. shader: string;
  63220. };
  63221. }
  63222. declare module BABYLON.GUI {
  63223. /** @hidden */
  63224. export var fluentPixelShader: {
  63225. name: string;
  63226. shader: string;
  63227. };
  63228. }
  63229. declare module BABYLON.GUI {
  63230. /** @hidden */
  63231. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  63232. INNERGLOW: boolean;
  63233. BORDER: boolean;
  63234. HOVERLIGHT: boolean;
  63235. TEXTURE: boolean;
  63236. constructor();
  63237. }
  63238. /**
  63239. * Class used to render controls with fluent desgin
  63240. */
  63241. export class FluentMaterial extends BABYLON.PushMaterial {
  63242. /**
  63243. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  63244. */
  63245. innerGlowColorIntensity: number;
  63246. /**
  63247. * Gets or sets the inner glow color (white by default)
  63248. */
  63249. innerGlowColor: BABYLON.Color3;
  63250. /**
  63251. * Gets or sets alpha value (default is 1.0)
  63252. */
  63253. alpha: number;
  63254. /**
  63255. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  63256. */
  63257. albedoColor: BABYLON.Color3;
  63258. /**
  63259. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  63260. */
  63261. renderBorders: boolean;
  63262. /**
  63263. * Gets or sets border width (default is 0.5)
  63264. */
  63265. borderWidth: number;
  63266. /**
  63267. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  63268. */
  63269. edgeSmoothingValue: number;
  63270. /**
  63271. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  63272. */
  63273. borderMinValue: number;
  63274. /**
  63275. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  63276. */
  63277. renderHoverLight: boolean;
  63278. /**
  63279. * Gets or sets the radius used to render the hover light (default is 1.0)
  63280. */
  63281. hoverRadius: number;
  63282. /**
  63283. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  63284. */
  63285. hoverColor: BABYLON.Color4;
  63286. /**
  63287. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  63288. */
  63289. hoverPosition: BABYLON.Vector3;
  63290. private _albedoTexture;
  63291. /** Gets or sets the texture to use for albedo color */
  63292. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63293. /**
  63294. * Creates a new Fluent material
  63295. * @param name defines the name of the material
  63296. * @param scene defines the hosting scene
  63297. */
  63298. constructor(name: string, scene: BABYLON.Scene);
  63299. needAlphaBlending(): boolean;
  63300. needAlphaTesting(): boolean;
  63301. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63302. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63303. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63304. getActiveTextures(): BABYLON.BaseTexture[];
  63305. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63306. dispose(forceDisposeEffect?: boolean): void;
  63307. clone(name: string): FluentMaterial;
  63308. serialize(): any;
  63309. getClassName(): string;
  63310. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  63311. }
  63312. }
  63313. declare module BABYLON.GUI {
  63314. /**
  63315. * Class used to create a holographic button in 3D
  63316. */
  63317. export class HolographicButton extends Button3D {
  63318. private _backPlate;
  63319. private _textPlate;
  63320. private _frontPlate;
  63321. private _text;
  63322. private _imageUrl;
  63323. private _shareMaterials;
  63324. private _frontMaterial;
  63325. private _backMaterial;
  63326. private _plateMaterial;
  63327. private _pickedPointObserver;
  63328. private _tooltipFade;
  63329. private _tooltipTextBlock;
  63330. private _tooltipTexture;
  63331. private _tooltipMesh;
  63332. private _tooltipHoverObserver;
  63333. private _tooltipOutObserver;
  63334. private _disposeTooltip;
  63335. /**
  63336. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  63337. */
  63338. tooltipText: BABYLON.Nullable<string>;
  63339. /**
  63340. * Gets or sets text for the button
  63341. */
  63342. text: string;
  63343. /**
  63344. * Gets or sets the image url for the button
  63345. */
  63346. imageUrl: string;
  63347. /**
  63348. * Gets the back material used by this button
  63349. */
  63350. readonly backMaterial: FluentMaterial;
  63351. /**
  63352. * Gets the front material used by this button
  63353. */
  63354. readonly frontMaterial: FluentMaterial;
  63355. /**
  63356. * Gets the plate material used by this button
  63357. */
  63358. readonly plateMaterial: BABYLON.StandardMaterial;
  63359. /**
  63360. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  63361. */
  63362. readonly shareMaterials: boolean;
  63363. /**
  63364. * Creates a new button
  63365. * @param name defines the control name
  63366. */
  63367. constructor(name?: string, shareMaterials?: boolean);
  63368. protected _getTypeName(): string;
  63369. private _rebuildContent;
  63370. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63371. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  63372. private _createBackMaterial;
  63373. private _createFrontMaterial;
  63374. private _createPlateMaterial;
  63375. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  63376. /**
  63377. * Releases all associated resources
  63378. */
  63379. dispose(): void;
  63380. }
  63381. }
  63382. declare module BABYLON.GUI {
  63383. /**
  63384. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  63385. */
  63386. export class MeshButton3D extends Button3D {
  63387. /** @hidden */
  63388. protected _currentMesh: BABYLON.Mesh;
  63389. /**
  63390. * Creates a new 3D button based on a mesh
  63391. * @param mesh mesh to become a 3D button
  63392. * @param name defines the control name
  63393. */
  63394. constructor(mesh: BABYLON.Mesh, name?: string);
  63395. protected _getTypeName(): string;
  63396. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63397. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63398. }
  63399. }
  63400. declare module BABYLON.GUI {
  63401. /**
  63402. * Class used to create a container panel deployed on the surface of a plane
  63403. */
  63404. export class PlanePanel extends VolumeBasedPanel {
  63405. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63406. }
  63407. }
  63408. declare module BABYLON.GUI {
  63409. /**
  63410. * Class used to create a container panel where items get randomized planar mapping
  63411. */
  63412. export class ScatterPanel extends VolumeBasedPanel {
  63413. private _iteration;
  63414. /**
  63415. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  63416. */
  63417. iteration: BABYLON.float;
  63418. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63419. private _scatterMapping;
  63420. protected _finalProcessing(): void;
  63421. }
  63422. }
  63423. declare module BABYLON.GUI {
  63424. /**
  63425. * Class used to create a container panel deployed on the surface of a sphere
  63426. */
  63427. export class SpherePanel extends VolumeBasedPanel {
  63428. private _radius;
  63429. /**
  63430. * Gets or sets the radius of the sphere where to project controls (5 by default)
  63431. */
  63432. radius: BABYLON.float;
  63433. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63434. private _sphericalMapping;
  63435. }
  63436. }
  63437. declare module BABYLON.GUI {
  63438. /**
  63439. * Class used to create a stack panel in 3D on XY plane
  63440. */
  63441. export class StackPanel3D extends Container3D {
  63442. private _isVertical;
  63443. /**
  63444. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  63445. */
  63446. isVertical: boolean;
  63447. /**
  63448. * Gets or sets the distance between elements
  63449. */
  63450. margin: number;
  63451. /**
  63452. * Creates new StackPanel
  63453. * @param isVertical
  63454. */
  63455. constructor(isVertical?: boolean);
  63456. protected _arrangeChildren(): void;
  63457. }
  63458. }
  63459. declare module BABYLON {
  63460. /**
  63461. * Mode that determines the coordinate system to use.
  63462. */
  63463. export enum GLTFLoaderCoordinateSystemMode {
  63464. /**
  63465. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  63466. */
  63467. AUTO = 0,
  63468. /**
  63469. * Sets the useRightHandedSystem flag on the scene.
  63470. */
  63471. FORCE_RIGHT_HANDED = 1
  63472. }
  63473. /**
  63474. * Mode that determines what animations will start.
  63475. */
  63476. export enum GLTFLoaderAnimationStartMode {
  63477. /**
  63478. * No animation will start.
  63479. */
  63480. NONE = 0,
  63481. /**
  63482. * The first animation will start.
  63483. */
  63484. FIRST = 1,
  63485. /**
  63486. * All animations will start.
  63487. */
  63488. ALL = 2
  63489. }
  63490. /**
  63491. * Interface that contains the data for the glTF asset.
  63492. */
  63493. export interface IGLTFLoaderData {
  63494. /**
  63495. * Object that represents the glTF JSON.
  63496. */
  63497. json: Object;
  63498. /**
  63499. * The BIN chunk of a binary glTF.
  63500. */
  63501. bin: Nullable<ArrayBufferView>;
  63502. }
  63503. /**
  63504. * Interface for extending the loader.
  63505. */
  63506. export interface IGLTFLoaderExtension {
  63507. /**
  63508. * The name of this extension.
  63509. */
  63510. readonly name: string;
  63511. /**
  63512. * Defines whether this extension is enabled.
  63513. */
  63514. enabled: boolean;
  63515. }
  63516. /**
  63517. * Loader state.
  63518. */
  63519. export enum GLTFLoaderState {
  63520. /**
  63521. * The asset is loading.
  63522. */
  63523. LOADING = 0,
  63524. /**
  63525. * The asset is ready for rendering.
  63526. */
  63527. READY = 1,
  63528. /**
  63529. * The asset is completely loaded.
  63530. */
  63531. COMPLETE = 2
  63532. }
  63533. /** @hidden */
  63534. export interface IGLTFLoader extends IDisposable {
  63535. readonly state: Nullable<GLTFLoaderState>;
  63536. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  63537. meshes: AbstractMesh[];
  63538. particleSystems: IParticleSystem[];
  63539. skeletons: Skeleton[];
  63540. animationGroups: AnimationGroup[];
  63541. }>;
  63542. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  63543. }
  63544. /**
  63545. * File loader for loading glTF files into a scene.
  63546. */
  63547. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  63548. /** @hidden */
  63549. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  63550. /** @hidden */
  63551. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  63552. /**
  63553. * Raised when the asset has been parsed
  63554. */
  63555. onParsedObservable: Observable<IGLTFLoaderData>;
  63556. private _onParsedObserver;
  63557. /**
  63558. * Raised when the asset has been parsed
  63559. */
  63560. onParsed: (loaderData: IGLTFLoaderData) => void;
  63561. /**
  63562. * 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.
  63563. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  63564. * Defaults to true.
  63565. * @hidden
  63566. */
  63567. static IncrementalLoading: boolean;
  63568. /**
  63569. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  63570. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  63571. * @hidden
  63572. */
  63573. static HomogeneousCoordinates: boolean;
  63574. /**
  63575. * The coordinate system mode. Defaults to AUTO.
  63576. */
  63577. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  63578. /**
  63579. * The animation start mode. Defaults to FIRST.
  63580. */
  63581. animationStartMode: GLTFLoaderAnimationStartMode;
  63582. /**
  63583. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  63584. */
  63585. compileMaterials: boolean;
  63586. /**
  63587. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  63588. */
  63589. useClipPlane: boolean;
  63590. /**
  63591. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  63592. */
  63593. compileShadowGenerators: boolean;
  63594. /**
  63595. * Defines if the Alpha blended materials are only applied as coverage.
  63596. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  63597. * If true, no extra effects are applied to transparent pixels.
  63598. */
  63599. transparencyAsCoverage: boolean;
  63600. /**
  63601. * Function called before loading a url referenced by the asset.
  63602. */
  63603. preprocessUrlAsync: (url: string) => Promise<string>;
  63604. /**
  63605. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  63606. */
  63607. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  63608. private _onMeshLoadedObserver;
  63609. /**
  63610. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  63611. */
  63612. onMeshLoaded: (mesh: AbstractMesh) => void;
  63613. /**
  63614. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  63615. */
  63616. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  63617. private _onTextureLoadedObserver;
  63618. /**
  63619. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  63620. */
  63621. onTextureLoaded: (texture: BaseTexture) => void;
  63622. /**
  63623. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  63624. */
  63625. readonly onMaterialLoadedObservable: Observable<Material>;
  63626. private _onMaterialLoadedObserver;
  63627. /**
  63628. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  63629. */
  63630. onMaterialLoaded: (material: Material) => void;
  63631. /**
  63632. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  63633. */
  63634. readonly onCameraLoadedObservable: Observable<Camera>;
  63635. private _onCameraLoadedObserver;
  63636. /**
  63637. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  63638. */
  63639. onCameraLoaded: (camera: Camera) => void;
  63640. /**
  63641. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  63642. * For assets with LODs, raised when all of the LODs are complete.
  63643. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  63644. */
  63645. readonly onCompleteObservable: Observable<void>;
  63646. private _onCompleteObserver;
  63647. /**
  63648. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  63649. * For assets with LODs, raised when all of the LODs are complete.
  63650. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  63651. */
  63652. onComplete: () => void;
  63653. /**
  63654. * Observable raised when an error occurs.
  63655. */
  63656. readonly onErrorObservable: Observable<any>;
  63657. private _onErrorObserver;
  63658. /**
  63659. * Callback raised when an error occurs.
  63660. */
  63661. onError: (reason: any) => void;
  63662. /**
  63663. * Observable raised after the loader is disposed.
  63664. */
  63665. readonly onDisposeObservable: Observable<void>;
  63666. private _onDisposeObserver;
  63667. /**
  63668. * Callback raised after the loader is disposed.
  63669. */
  63670. onDispose: () => void;
  63671. /**
  63672. * Observable raised after a loader extension is created.
  63673. * Set additional options for a loader extension in this event.
  63674. */
  63675. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  63676. private _onExtensionLoadedObserver;
  63677. /**
  63678. * Callback raised after a loader extension is created.
  63679. */
  63680. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  63681. /**
  63682. * Defines if the loader logging is enabled.
  63683. */
  63684. loggingEnabled: boolean;
  63685. /**
  63686. * Defines if the loader should capture performance counters.
  63687. */
  63688. capturePerformanceCounters: boolean;
  63689. /**
  63690. * Defines if the loader should validate the asset.
  63691. */
  63692. validate: boolean;
  63693. /**
  63694. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  63695. */
  63696. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  63697. private _onValidatedObserver;
  63698. /**
  63699. * Callback raised after a loader extension is created.
  63700. */
  63701. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  63702. private _loader;
  63703. /**
  63704. * Name of the loader ("gltf")
  63705. */
  63706. name: string;
  63707. /**
  63708. * Supported file extensions of the loader (.gltf, .glb)
  63709. */
  63710. extensions: ISceneLoaderPluginExtensions;
  63711. /**
  63712. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  63713. */
  63714. dispose(): void;
  63715. /** @hidden */
  63716. _clear(): void;
  63717. /**
  63718. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  63719. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  63720. * @param scene the scene the meshes should be added to
  63721. * @param data the glTF data to load
  63722. * @param rootUrl root url to load from
  63723. * @param onProgress event that fires when loading progress has occured
  63724. * @param fileName Defines the name of the file to load
  63725. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  63726. */
  63727. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  63728. meshes: AbstractMesh[];
  63729. particleSystems: IParticleSystem[];
  63730. skeletons: Skeleton[];
  63731. animationGroups: AnimationGroup[];
  63732. }>;
  63733. /**
  63734. * Imports all objects from the loaded glTF data and adds them to the scene
  63735. * @param scene the scene the objects should be added to
  63736. * @param data the glTF data to load
  63737. * @param rootUrl root url to load from
  63738. * @param onProgress event that fires when loading progress has occured
  63739. * @param fileName Defines the name of the file to load
  63740. * @returns a promise which completes when objects have been loaded to the scene
  63741. */
  63742. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  63743. /**
  63744. * Load into an asset container.
  63745. * @param scene The scene to load into
  63746. * @param data The data to import
  63747. * @param rootUrl The root url for scene and resources
  63748. * @param onProgress The callback when the load progresses
  63749. * @param fileName Defines the name of the file to load
  63750. * @returns The loaded asset container
  63751. */
  63752. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  63753. /**
  63754. * If the data string can be loaded directly.
  63755. * @param data string contianing the file data
  63756. * @returns if the data can be loaded directly
  63757. */
  63758. canDirectLoad(data: string): boolean;
  63759. /**
  63760. * Rewrites a url by combining a root url and response url.
  63761. */
  63762. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  63763. /**
  63764. * Instantiates a glTF file loader plugin.
  63765. * @returns the created plugin
  63766. */
  63767. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  63768. /**
  63769. * The loader state or null if the loader is not active.
  63770. */
  63771. readonly loaderState: Nullable<GLTFLoaderState>;
  63772. /**
  63773. * Returns a promise that resolves when the asset is completely loaded.
  63774. * @returns a promise that resolves when the asset is completely loaded.
  63775. */
  63776. whenCompleteAsync(): Promise<void>;
  63777. private _parseAsync;
  63778. private _validateAsync;
  63779. private _getLoader;
  63780. private _unpackBinary;
  63781. private _unpackBinaryV1;
  63782. private _unpackBinaryV2;
  63783. private static _parseVersion;
  63784. private static _compareVersion;
  63785. private static _decodeBufferToText;
  63786. private static readonly _logSpaces;
  63787. private _logIndentLevel;
  63788. private _loggingEnabled;
  63789. /** @hidden */
  63790. _log: (message: string) => void;
  63791. /** @hidden */
  63792. _logOpen(message: string): void;
  63793. /** @hidden */
  63794. _logClose(): void;
  63795. private _logEnabled;
  63796. private _logDisabled;
  63797. private _capturePerformanceCounters;
  63798. /** @hidden */
  63799. _startPerformanceCounter: (counterName: string) => void;
  63800. /** @hidden */
  63801. _endPerformanceCounter: (counterName: string) => void;
  63802. private _startPerformanceCounterEnabled;
  63803. private _startPerformanceCounterDisabled;
  63804. private _endPerformanceCounterEnabled;
  63805. private _endPerformanceCounterDisabled;
  63806. }
  63807. }
  63808. declare module BABYLON.GLTF1 {
  63809. /**
  63810. * Enums
  63811. * @hidden
  63812. */
  63813. export enum EComponentType {
  63814. BYTE = 5120,
  63815. UNSIGNED_BYTE = 5121,
  63816. SHORT = 5122,
  63817. UNSIGNED_SHORT = 5123,
  63818. FLOAT = 5126
  63819. }
  63820. /** @hidden */
  63821. export enum EShaderType {
  63822. FRAGMENT = 35632,
  63823. VERTEX = 35633
  63824. }
  63825. /** @hidden */
  63826. export enum EParameterType {
  63827. BYTE = 5120,
  63828. UNSIGNED_BYTE = 5121,
  63829. SHORT = 5122,
  63830. UNSIGNED_SHORT = 5123,
  63831. INT = 5124,
  63832. UNSIGNED_INT = 5125,
  63833. FLOAT = 5126,
  63834. FLOAT_VEC2 = 35664,
  63835. FLOAT_VEC3 = 35665,
  63836. FLOAT_VEC4 = 35666,
  63837. INT_VEC2 = 35667,
  63838. INT_VEC3 = 35668,
  63839. INT_VEC4 = 35669,
  63840. BOOL = 35670,
  63841. BOOL_VEC2 = 35671,
  63842. BOOL_VEC3 = 35672,
  63843. BOOL_VEC4 = 35673,
  63844. FLOAT_MAT2 = 35674,
  63845. FLOAT_MAT3 = 35675,
  63846. FLOAT_MAT4 = 35676,
  63847. SAMPLER_2D = 35678
  63848. }
  63849. /** @hidden */
  63850. export enum ETextureWrapMode {
  63851. CLAMP_TO_EDGE = 33071,
  63852. MIRRORED_REPEAT = 33648,
  63853. REPEAT = 10497
  63854. }
  63855. /** @hidden */
  63856. export enum ETextureFilterType {
  63857. NEAREST = 9728,
  63858. LINEAR = 9728,
  63859. NEAREST_MIPMAP_NEAREST = 9984,
  63860. LINEAR_MIPMAP_NEAREST = 9985,
  63861. NEAREST_MIPMAP_LINEAR = 9986,
  63862. LINEAR_MIPMAP_LINEAR = 9987
  63863. }
  63864. /** @hidden */
  63865. export enum ETextureFormat {
  63866. ALPHA = 6406,
  63867. RGB = 6407,
  63868. RGBA = 6408,
  63869. LUMINANCE = 6409,
  63870. LUMINANCE_ALPHA = 6410
  63871. }
  63872. /** @hidden */
  63873. export enum ECullingType {
  63874. FRONT = 1028,
  63875. BACK = 1029,
  63876. FRONT_AND_BACK = 1032
  63877. }
  63878. /** @hidden */
  63879. export enum EBlendingFunction {
  63880. ZERO = 0,
  63881. ONE = 1,
  63882. SRC_COLOR = 768,
  63883. ONE_MINUS_SRC_COLOR = 769,
  63884. DST_COLOR = 774,
  63885. ONE_MINUS_DST_COLOR = 775,
  63886. SRC_ALPHA = 770,
  63887. ONE_MINUS_SRC_ALPHA = 771,
  63888. DST_ALPHA = 772,
  63889. ONE_MINUS_DST_ALPHA = 773,
  63890. CONSTANT_COLOR = 32769,
  63891. ONE_MINUS_CONSTANT_COLOR = 32770,
  63892. CONSTANT_ALPHA = 32771,
  63893. ONE_MINUS_CONSTANT_ALPHA = 32772,
  63894. SRC_ALPHA_SATURATE = 776
  63895. }
  63896. /** @hidden */
  63897. export interface IGLTFProperty {
  63898. extensions?: {
  63899. [key: string]: any;
  63900. };
  63901. extras?: Object;
  63902. }
  63903. /** @hidden */
  63904. export interface IGLTFChildRootProperty extends IGLTFProperty {
  63905. name?: string;
  63906. }
  63907. /** @hidden */
  63908. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  63909. bufferView: string;
  63910. byteOffset: number;
  63911. byteStride: number;
  63912. count: number;
  63913. type: string;
  63914. componentType: EComponentType;
  63915. max?: number[];
  63916. min?: number[];
  63917. name?: string;
  63918. }
  63919. /** @hidden */
  63920. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  63921. buffer: string;
  63922. byteOffset: number;
  63923. byteLength: number;
  63924. byteStride: number;
  63925. target?: number;
  63926. }
  63927. /** @hidden */
  63928. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  63929. uri: string;
  63930. byteLength?: number;
  63931. type?: string;
  63932. }
  63933. /** @hidden */
  63934. export interface IGLTFShader extends IGLTFChildRootProperty {
  63935. uri: string;
  63936. type: EShaderType;
  63937. }
  63938. /** @hidden */
  63939. export interface IGLTFProgram extends IGLTFChildRootProperty {
  63940. attributes: string[];
  63941. fragmentShader: string;
  63942. vertexShader: string;
  63943. }
  63944. /** @hidden */
  63945. export interface IGLTFTechniqueParameter {
  63946. type: number;
  63947. count?: number;
  63948. semantic?: string;
  63949. node?: string;
  63950. value?: number | boolean | string | Array<any>;
  63951. source?: string;
  63952. babylonValue?: any;
  63953. }
  63954. /** @hidden */
  63955. export interface IGLTFTechniqueCommonProfile {
  63956. lightingModel: string;
  63957. texcoordBindings: Object;
  63958. parameters?: Array<any>;
  63959. }
  63960. /** @hidden */
  63961. export interface IGLTFTechniqueStatesFunctions {
  63962. blendColor?: number[];
  63963. blendEquationSeparate?: number[];
  63964. blendFuncSeparate?: number[];
  63965. colorMask: boolean[];
  63966. cullFace: number[];
  63967. }
  63968. /** @hidden */
  63969. export interface IGLTFTechniqueStates {
  63970. enable: number[];
  63971. functions: IGLTFTechniqueStatesFunctions;
  63972. }
  63973. /** @hidden */
  63974. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  63975. parameters: {
  63976. [key: string]: IGLTFTechniqueParameter;
  63977. };
  63978. program: string;
  63979. attributes: {
  63980. [key: string]: string;
  63981. };
  63982. uniforms: {
  63983. [key: string]: string;
  63984. };
  63985. states: IGLTFTechniqueStates;
  63986. }
  63987. /** @hidden */
  63988. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  63989. technique?: string;
  63990. values: string[];
  63991. }
  63992. /** @hidden */
  63993. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  63994. attributes: {
  63995. [key: string]: string;
  63996. };
  63997. indices: string;
  63998. material: string;
  63999. mode?: number;
  64000. }
  64001. /** @hidden */
  64002. export interface IGLTFMesh extends IGLTFChildRootProperty {
  64003. primitives: IGLTFMeshPrimitive[];
  64004. }
  64005. /** @hidden */
  64006. export interface IGLTFImage extends IGLTFChildRootProperty {
  64007. uri: string;
  64008. }
  64009. /** @hidden */
  64010. export interface IGLTFSampler extends IGLTFChildRootProperty {
  64011. magFilter?: number;
  64012. minFilter?: number;
  64013. wrapS?: number;
  64014. wrapT?: number;
  64015. }
  64016. /** @hidden */
  64017. export interface IGLTFTexture extends IGLTFChildRootProperty {
  64018. sampler: string;
  64019. source: string;
  64020. format?: ETextureFormat;
  64021. internalFormat?: ETextureFormat;
  64022. target?: number;
  64023. type?: number;
  64024. babylonTexture?: Texture;
  64025. }
  64026. /** @hidden */
  64027. export interface IGLTFAmbienLight {
  64028. color?: number[];
  64029. }
  64030. /** @hidden */
  64031. export interface IGLTFDirectionalLight {
  64032. color?: number[];
  64033. }
  64034. /** @hidden */
  64035. export interface IGLTFPointLight {
  64036. color?: number[];
  64037. constantAttenuation?: number;
  64038. linearAttenuation?: number;
  64039. quadraticAttenuation?: number;
  64040. }
  64041. /** @hidden */
  64042. export interface IGLTFSpotLight {
  64043. color?: number[];
  64044. constantAttenuation?: number;
  64045. fallOfAngle?: number;
  64046. fallOffExponent?: number;
  64047. linearAttenuation?: number;
  64048. quadraticAttenuation?: number;
  64049. }
  64050. /** @hidden */
  64051. export interface IGLTFLight extends IGLTFChildRootProperty {
  64052. type: string;
  64053. }
  64054. /** @hidden */
  64055. export interface IGLTFCameraOrthographic {
  64056. xmag: number;
  64057. ymag: number;
  64058. zfar: number;
  64059. znear: number;
  64060. }
  64061. /** @hidden */
  64062. export interface IGLTFCameraPerspective {
  64063. aspectRatio: number;
  64064. yfov: number;
  64065. zfar: number;
  64066. znear: number;
  64067. }
  64068. /** @hidden */
  64069. export interface IGLTFCamera extends IGLTFChildRootProperty {
  64070. type: string;
  64071. }
  64072. /** @hidden */
  64073. export interface IGLTFAnimationChannelTarget {
  64074. id: string;
  64075. path: string;
  64076. }
  64077. /** @hidden */
  64078. export interface IGLTFAnimationChannel {
  64079. sampler: string;
  64080. target: IGLTFAnimationChannelTarget;
  64081. }
  64082. /** @hidden */
  64083. export interface IGLTFAnimationSampler {
  64084. input: string;
  64085. output: string;
  64086. interpolation?: string;
  64087. }
  64088. /** @hidden */
  64089. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  64090. channels?: IGLTFAnimationChannel[];
  64091. parameters?: {
  64092. [key: string]: string;
  64093. };
  64094. samplers?: {
  64095. [key: string]: IGLTFAnimationSampler;
  64096. };
  64097. }
  64098. /** @hidden */
  64099. export interface IGLTFNodeInstanceSkin {
  64100. skeletons: string[];
  64101. skin: string;
  64102. meshes: string[];
  64103. }
  64104. /** @hidden */
  64105. export interface IGLTFSkins extends IGLTFChildRootProperty {
  64106. bindShapeMatrix: number[];
  64107. inverseBindMatrices: string;
  64108. jointNames: string[];
  64109. babylonSkeleton?: Skeleton;
  64110. }
  64111. /** @hidden */
  64112. export interface IGLTFNode extends IGLTFChildRootProperty {
  64113. camera?: string;
  64114. children: string[];
  64115. skin?: string;
  64116. jointName?: string;
  64117. light?: string;
  64118. matrix: number[];
  64119. mesh?: string;
  64120. meshes?: string[];
  64121. rotation?: number[];
  64122. scale?: number[];
  64123. translation?: number[];
  64124. babylonNode?: Node;
  64125. }
  64126. /** @hidden */
  64127. export interface IGLTFScene extends IGLTFChildRootProperty {
  64128. nodes: string[];
  64129. }
  64130. /** @hidden */
  64131. export interface IGLTFRuntime {
  64132. extensions: {
  64133. [key: string]: any;
  64134. };
  64135. accessors: {
  64136. [key: string]: IGLTFAccessor;
  64137. };
  64138. buffers: {
  64139. [key: string]: IGLTFBuffer;
  64140. };
  64141. bufferViews: {
  64142. [key: string]: IGLTFBufferView;
  64143. };
  64144. meshes: {
  64145. [key: string]: IGLTFMesh;
  64146. };
  64147. lights: {
  64148. [key: string]: IGLTFLight;
  64149. };
  64150. cameras: {
  64151. [key: string]: IGLTFCamera;
  64152. };
  64153. nodes: {
  64154. [key: string]: IGLTFNode;
  64155. };
  64156. images: {
  64157. [key: string]: IGLTFImage;
  64158. };
  64159. textures: {
  64160. [key: string]: IGLTFTexture;
  64161. };
  64162. shaders: {
  64163. [key: string]: IGLTFShader;
  64164. };
  64165. programs: {
  64166. [key: string]: IGLTFProgram;
  64167. };
  64168. samplers: {
  64169. [key: string]: IGLTFSampler;
  64170. };
  64171. techniques: {
  64172. [key: string]: IGLTFTechnique;
  64173. };
  64174. materials: {
  64175. [key: string]: IGLTFMaterial;
  64176. };
  64177. animations: {
  64178. [key: string]: IGLTFAnimation;
  64179. };
  64180. skins: {
  64181. [key: string]: IGLTFSkins;
  64182. };
  64183. currentScene?: Object;
  64184. scenes: {
  64185. [key: string]: IGLTFScene;
  64186. };
  64187. extensionsUsed: string[];
  64188. extensionsRequired?: string[];
  64189. buffersCount: number;
  64190. shaderscount: number;
  64191. scene: Scene;
  64192. rootUrl: string;
  64193. loadedBufferCount: number;
  64194. loadedBufferViews: {
  64195. [name: string]: ArrayBufferView;
  64196. };
  64197. loadedShaderCount: number;
  64198. importOnlyMeshes: boolean;
  64199. importMeshesNames?: string[];
  64200. dummyNodes: Node[];
  64201. }
  64202. /** @hidden */
  64203. export interface INodeToRoot {
  64204. bone: Bone;
  64205. node: IGLTFNode;
  64206. id: string;
  64207. }
  64208. /** @hidden */
  64209. export interface IJointNode {
  64210. node: IGLTFNode;
  64211. id: string;
  64212. }
  64213. }
  64214. declare module BABYLON.GLTF1 {
  64215. /**
  64216. * Utils functions for GLTF
  64217. * @hidden
  64218. */
  64219. export class GLTFUtils {
  64220. /**
  64221. * Sets the given "parameter" matrix
  64222. * @param scene: the Scene object
  64223. * @param source: the source node where to pick the matrix
  64224. * @param parameter: the GLTF technique parameter
  64225. * @param uniformName: the name of the shader's uniform
  64226. * @param shaderMaterial: the shader material
  64227. */
  64228. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  64229. /**
  64230. * Sets the given "parameter" matrix
  64231. * @param shaderMaterial: the shader material
  64232. * @param uniform: the name of the shader's uniform
  64233. * @param value: the value of the uniform
  64234. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  64235. */
  64236. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  64237. /**
  64238. * Returns the wrap mode of the texture
  64239. * @param mode: the mode value
  64240. */
  64241. static GetWrapMode(mode: number): number;
  64242. /**
  64243. * Returns the byte stride giving an accessor
  64244. * @param accessor: the GLTF accessor objet
  64245. */
  64246. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  64247. /**
  64248. * Returns the texture filter mode giving a mode value
  64249. * @param mode: the filter mode value
  64250. */
  64251. static GetTextureFilterMode(mode: number): ETextureFilterType;
  64252. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  64253. /**
  64254. * Returns a buffer from its accessor
  64255. * @param gltfRuntime: the GLTF runtime
  64256. * @param accessor: the GLTF accessor
  64257. */
  64258. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  64259. /**
  64260. * Decodes a buffer view into a string
  64261. * @param view: the buffer view
  64262. */
  64263. static DecodeBufferToText(view: ArrayBufferView): string;
  64264. /**
  64265. * Returns the default material of gltf. Related to
  64266. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  64267. * @param scene: the Babylon.js scene
  64268. */
  64269. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  64270. private static _DefaultMaterial;
  64271. }
  64272. }
  64273. declare module BABYLON.GLTF1 {
  64274. /**
  64275. * Implementation of the base glTF spec
  64276. * @hidden
  64277. */
  64278. export class GLTFLoaderBase {
  64279. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  64280. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  64281. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  64282. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  64283. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  64284. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  64285. }
  64286. /**
  64287. * glTF V1 Loader
  64288. * @hidden
  64289. */
  64290. export class GLTFLoader implements IGLTFLoader {
  64291. static Extensions: {
  64292. [name: string]: GLTFLoaderExtension;
  64293. };
  64294. static RegisterExtension(extension: GLTFLoaderExtension): void;
  64295. state: Nullable<GLTFLoaderState>;
  64296. dispose(): void;
  64297. private _importMeshAsync;
  64298. /**
  64299. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  64300. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  64301. * @param scene the scene the meshes should be added to
  64302. * @param data gltf data containing information of the meshes in a loaded file
  64303. * @param rootUrl root url to load from
  64304. * @param onProgress event that fires when loading progress has occured
  64305. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  64306. */
  64307. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  64308. meshes: AbstractMesh[];
  64309. particleSystems: IParticleSystem[];
  64310. skeletons: Skeleton[];
  64311. animationGroups: AnimationGroup[];
  64312. }>;
  64313. private _loadAsync;
  64314. /**
  64315. * Imports all objects from a loaded gltf file and adds them to the scene
  64316. * @param scene the scene the objects should be added to
  64317. * @param data gltf data containing information of the meshes in a loaded file
  64318. * @param rootUrl root url to load from
  64319. * @param onProgress event that fires when loading progress has occured
  64320. * @returns a promise which completes when objects have been loaded to the scene
  64321. */
  64322. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  64323. private _loadShadersAsync;
  64324. private _loadBuffersAsync;
  64325. private _createNodes;
  64326. }
  64327. /** @hidden */
  64328. export abstract class GLTFLoaderExtension {
  64329. private _name;
  64330. constructor(name: string);
  64331. readonly name: string;
  64332. /**
  64333. * Defines an override for loading the runtime
  64334. * Return true to stop further extensions from loading the runtime
  64335. */
  64336. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  64337. /**
  64338. * Defines an onverride for creating gltf runtime
  64339. * Return true to stop further extensions from creating the runtime
  64340. */
  64341. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  64342. /**
  64343. * Defines an override for loading buffers
  64344. * Return true to stop further extensions from loading this buffer
  64345. */
  64346. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  64347. /**
  64348. * Defines an override for loading texture buffers
  64349. * Return true to stop further extensions from loading this texture data
  64350. */
  64351. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64352. /**
  64353. * Defines an override for creating textures
  64354. * Return true to stop further extensions from loading this texture
  64355. */
  64356. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  64357. /**
  64358. * Defines an override for loading shader strings
  64359. * Return true to stop further extensions from loading this shader data
  64360. */
  64361. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  64362. /**
  64363. * Defines an override for loading materials
  64364. * Return true to stop further extensions from loading this material
  64365. */
  64366. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  64367. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  64368. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  64369. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  64370. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  64371. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  64372. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  64373. private static LoadTextureBufferAsync;
  64374. private static CreateTextureAsync;
  64375. private static ApplyExtensions;
  64376. }
  64377. }
  64378. declare module BABYLON.GLTF1 {
  64379. /** @hidden */
  64380. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  64381. private _bin;
  64382. constructor();
  64383. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  64384. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64385. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64386. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  64387. }
  64388. }
  64389. declare module BABYLON.GLTF1 {
  64390. /** @hidden */
  64391. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  64392. constructor();
  64393. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  64394. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  64395. private _loadTexture;
  64396. }
  64397. }
  64398. declare module BABYLON.GLTF2.Loader {
  64399. /**
  64400. * Loader interface with an index field.
  64401. */
  64402. export interface IArrayItem {
  64403. /**
  64404. * The index of this item in the array.
  64405. */
  64406. index: number;
  64407. }
  64408. /**
  64409. * Loader interface with additional members.
  64410. */
  64411. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  64412. /** @hidden */
  64413. _data?: Promise<ArrayBufferView>;
  64414. /** @hidden */
  64415. _babylonVertexBuffer?: Promise<VertexBuffer>;
  64416. }
  64417. /**
  64418. * Loader interface with additional members.
  64419. */
  64420. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  64421. }
  64422. /** @hidden */
  64423. export interface _IAnimationSamplerData {
  64424. input: Float32Array;
  64425. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  64426. output: Float32Array;
  64427. }
  64428. /**
  64429. * Loader interface with additional members.
  64430. */
  64431. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  64432. /** @hidden */
  64433. _data?: Promise<_IAnimationSamplerData>;
  64434. }
  64435. /**
  64436. * Loader interface with additional members.
  64437. */
  64438. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  64439. channels: IAnimationChannel[];
  64440. samplers: IAnimationSampler[];
  64441. /** @hidden */
  64442. _babylonAnimationGroup?: AnimationGroup;
  64443. }
  64444. /**
  64445. * Loader interface with additional members.
  64446. */
  64447. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  64448. /** @hidden */
  64449. _data?: Promise<ArrayBufferView>;
  64450. }
  64451. /**
  64452. * Loader interface with additional members.
  64453. */
  64454. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  64455. /** @hidden */
  64456. _data?: Promise<ArrayBufferView>;
  64457. /** @hidden */
  64458. _babylonBuffer?: Promise<Buffer>;
  64459. }
  64460. /**
  64461. * Loader interface with additional members.
  64462. */
  64463. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  64464. }
  64465. /**
  64466. * Loader interface with additional members.
  64467. */
  64468. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  64469. /** @hidden */
  64470. _data?: Promise<ArrayBufferView>;
  64471. }
  64472. /**
  64473. * Loader interface with additional members.
  64474. */
  64475. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  64476. }
  64477. /**
  64478. * Loader interface with additional members.
  64479. */
  64480. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  64481. }
  64482. /**
  64483. * Loader interface with additional members.
  64484. */
  64485. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  64486. baseColorTexture?: ITextureInfo;
  64487. metallicRoughnessTexture?: ITextureInfo;
  64488. }
  64489. /**
  64490. * Loader interface with additional members.
  64491. */
  64492. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  64493. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  64494. normalTexture?: IMaterialNormalTextureInfo;
  64495. occlusionTexture?: IMaterialOcclusionTextureInfo;
  64496. emissiveTexture?: ITextureInfo;
  64497. /** @hidden */
  64498. _data?: {
  64499. [babylonDrawMode: number]: {
  64500. babylonMaterial: Material;
  64501. babylonMeshes: AbstractMesh[];
  64502. promise: Promise<void>;
  64503. };
  64504. };
  64505. }
  64506. /**
  64507. * Loader interface with additional members.
  64508. */
  64509. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  64510. primitives: IMeshPrimitive[];
  64511. }
  64512. /**
  64513. * Loader interface with additional members.
  64514. */
  64515. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  64516. /** @hidden */
  64517. _instanceData?: {
  64518. babylonSourceMesh: Mesh;
  64519. promise: Promise<any>;
  64520. };
  64521. }
  64522. /**
  64523. * Loader interface with additional members.
  64524. */
  64525. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  64526. /**
  64527. * The parent glTF node.
  64528. */
  64529. parent?: INode;
  64530. /** @hidden */
  64531. _babylonTransformNode?: TransformNode;
  64532. /** @hidden */
  64533. _primitiveBabylonMeshes?: AbstractMesh[];
  64534. /** @hidden */
  64535. _babylonBones?: Bone[];
  64536. /** @hidden */
  64537. _numMorphTargets?: number;
  64538. }
  64539. /** @hidden */
  64540. export interface _ISamplerData {
  64541. noMipMaps: boolean;
  64542. samplingMode: number;
  64543. wrapU: number;
  64544. wrapV: number;
  64545. }
  64546. /**
  64547. * Loader interface with additional members.
  64548. */
  64549. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  64550. /** @hidden */
  64551. _data?: _ISamplerData;
  64552. }
  64553. /**
  64554. * Loader interface with additional members.
  64555. */
  64556. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  64557. }
  64558. /**
  64559. * Loader interface with additional members.
  64560. */
  64561. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  64562. /** @hidden */
  64563. _data?: {
  64564. babylonSkeleton: Skeleton;
  64565. promise: Promise<void>;
  64566. };
  64567. }
  64568. /**
  64569. * Loader interface with additional members.
  64570. */
  64571. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  64572. }
  64573. /**
  64574. * Loader interface with additional members.
  64575. */
  64576. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  64577. }
  64578. /**
  64579. * Loader interface with additional members.
  64580. */
  64581. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  64582. accessors?: IAccessor[];
  64583. animations?: IAnimation[];
  64584. buffers?: IBuffer[];
  64585. bufferViews?: IBufferView[];
  64586. cameras?: ICamera[];
  64587. images?: IImage[];
  64588. materials?: IMaterial[];
  64589. meshes?: IMesh[];
  64590. nodes?: INode[];
  64591. samplers?: ISampler[];
  64592. scenes?: IScene[];
  64593. skins?: ISkin[];
  64594. textures?: ITexture[];
  64595. }
  64596. }
  64597. declare module BABYLON.GLTF2 {
  64598. /**
  64599. * Interface for a glTF loader extension.
  64600. */
  64601. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  64602. /**
  64603. * Called after the loader state changes to LOADING.
  64604. */
  64605. onLoading?(): void;
  64606. /**
  64607. * Called after the loader state changes to READY.
  64608. */
  64609. onReady?(): void;
  64610. /**
  64611. * Define this method to modify the default behavior when loading scenes.
  64612. * @param context The context when loading the asset
  64613. * @param scene The glTF scene property
  64614. * @returns A promise that resolves when the load is complete or null if not handled
  64615. */
  64616. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  64617. /**
  64618. * Define this method to modify the default behavior when loading nodes.
  64619. * @param context The context when loading the asset
  64620. * @param node The glTF node property
  64621. * @param assign A function called synchronously after parsing the glTF properties
  64622. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  64623. */
  64624. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64625. /**
  64626. * Define this method to modify the default behavior when loading cameras.
  64627. * @param context The context when loading the asset
  64628. * @param camera The glTF camera property
  64629. * @param assign A function called synchronously after parsing the glTF properties
  64630. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  64631. */
  64632. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  64633. /**
  64634. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  64635. * @param context The context when loading the asset
  64636. * @param primitive The glTF mesh primitive property
  64637. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  64638. */
  64639. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  64640. /**
  64641. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  64642. * @param context The context when loading the asset
  64643. * @param name The mesh name when loading the asset
  64644. * @param node The glTF node when loading the asset
  64645. * @param mesh The glTF mesh when loading the asset
  64646. * @param primitive The glTF mesh primitive property
  64647. * @param assign A function called synchronously after parsing the glTF properties
  64648. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  64649. */
  64650. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  64651. /**
  64652. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  64653. * @param context The context when loading the asset
  64654. * @param material The glTF material property
  64655. * @param assign A function called synchronously after parsing the glTF properties
  64656. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  64657. */
  64658. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  64659. /**
  64660. * Define this method to modify the default behavior when creating materials.
  64661. * @param context The context when loading the asset
  64662. * @param material The glTF material property
  64663. * @param babylonDrawMode The draw mode for the Babylon material
  64664. * @returns The Babylon material or null if not handled
  64665. */
  64666. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  64667. /**
  64668. * Define this method to modify the default behavior when loading material properties.
  64669. * @param context The context when loading the asset
  64670. * @param material The glTF material property
  64671. * @param babylonMaterial The Babylon material
  64672. * @returns A promise that resolves when the load is complete or null if not handled
  64673. */
  64674. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64675. /**
  64676. * Define this method to modify the default behavior when loading texture infos.
  64677. * @param context The context when loading the asset
  64678. * @param textureInfo The glTF texture info property
  64679. * @param assign A function called synchronously after parsing the glTF properties
  64680. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  64681. */
  64682. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  64683. /**
  64684. * Define this method to modify the default behavior when loading animations.
  64685. * @param context The context when loading the asset
  64686. * @param animation The glTF animation property
  64687. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  64688. */
  64689. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  64690. /**
  64691. * @hidden Define this method to modify the default behavior when loading skins.
  64692. * @param context The context when loading the asset
  64693. * @param node The glTF node property
  64694. * @param skin The glTF skin property
  64695. * @returns A promise that resolves when the load is complete or null if not handled
  64696. */
  64697. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  64698. /**
  64699. * @hidden Define this method to modify the default behavior when loading uris.
  64700. * @param context The context when loading the asset
  64701. * @param property The glTF property associated with the uri
  64702. * @param uri The uri to load
  64703. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  64704. */
  64705. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  64706. }
  64707. }
  64708. declare module BABYLON.GLTF2 {
  64709. /**
  64710. * Helper class for working with arrays when loading the glTF asset
  64711. */
  64712. export class ArrayItem {
  64713. /**
  64714. * Gets an item from the given array.
  64715. * @param context The context when loading the asset
  64716. * @param array The array to get the item from
  64717. * @param index The index to the array
  64718. * @returns The array item
  64719. */
  64720. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  64721. /**
  64722. * Assign an `index` field to each item of the given array.
  64723. * @param array The array of items
  64724. */
  64725. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  64726. }
  64727. /**
  64728. * The glTF 2.0 loader
  64729. */
  64730. export class GLTFLoader implements IGLTFLoader {
  64731. /** @hidden */
  64732. _completePromises: Promise<any>[];
  64733. private _disposed;
  64734. private _parent;
  64735. private _state;
  64736. private _extensions;
  64737. private _rootUrl;
  64738. private _fileName;
  64739. private _uniqueRootUrl;
  64740. private _gltf;
  64741. private _babylonScene;
  64742. private _rootBabylonMesh;
  64743. private _defaultBabylonMaterialData;
  64744. private _progressCallback?;
  64745. private _requests;
  64746. private static readonly _DefaultSampler;
  64747. private static _ExtensionNames;
  64748. private static _ExtensionFactories;
  64749. /**
  64750. * Registers a loader extension.
  64751. * @param name The name of the loader extension.
  64752. * @param factory The factory function that creates the loader extension.
  64753. */
  64754. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  64755. /**
  64756. * Unregisters a loader extension.
  64757. * @param name The name of the loader extenion.
  64758. * @returns A boolean indicating whether the extension has been unregistered
  64759. */
  64760. static UnregisterExtension(name: string): boolean;
  64761. /**
  64762. * Gets the loader state.
  64763. */
  64764. readonly state: Nullable<GLTFLoaderState>;
  64765. /**
  64766. * The glTF object parsed from the JSON.
  64767. */
  64768. readonly gltf: IGLTF;
  64769. /**
  64770. * The Babylon scene when loading the asset.
  64771. */
  64772. readonly babylonScene: Scene;
  64773. /**
  64774. * The root Babylon mesh when loading the asset.
  64775. */
  64776. readonly rootBabylonMesh: Mesh;
  64777. /** @hidden */
  64778. constructor(parent: GLTFFileLoader);
  64779. /** @hidden */
  64780. dispose(): void;
  64781. /** @hidden */
  64782. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  64783. meshes: AbstractMesh[];
  64784. particleSystems: IParticleSystem[];
  64785. skeletons: Skeleton[];
  64786. animationGroups: AnimationGroup[];
  64787. }>;
  64788. /** @hidden */
  64789. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  64790. private _loadAsync;
  64791. private _loadData;
  64792. private _setupData;
  64793. private _loadExtensions;
  64794. private _checkExtensions;
  64795. private _setState;
  64796. private _createRootNode;
  64797. /**
  64798. * Loads a glTF scene.
  64799. * @param context The context when loading the asset
  64800. * @param scene The glTF scene property
  64801. * @returns A promise that resolves when the load is complete
  64802. */
  64803. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  64804. private _forEachPrimitive;
  64805. private _getMeshes;
  64806. private _getSkeletons;
  64807. private _getAnimationGroups;
  64808. private _startAnimations;
  64809. /**
  64810. * Loads a glTF node.
  64811. * @param context The context when loading the asset
  64812. * @param node The glTF node property
  64813. * @param assign A function called synchronously after parsing the glTF properties
  64814. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  64815. */
  64816. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  64817. private _loadMeshAsync;
  64818. /**
  64819. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  64820. * @param context The context when loading the asset
  64821. * @param name The mesh name when loading the asset
  64822. * @param node The glTF node when loading the asset
  64823. * @param mesh The glTF mesh when loading the asset
  64824. * @param primitive The glTF mesh primitive property
  64825. * @param assign A function called synchronously after parsing the glTF properties
  64826. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  64827. */
  64828. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  64829. private _loadVertexDataAsync;
  64830. private _createMorphTargets;
  64831. private _loadMorphTargetsAsync;
  64832. private _loadMorphTargetVertexDataAsync;
  64833. private static _LoadTransform;
  64834. private _loadSkinAsync;
  64835. private _loadBones;
  64836. private _loadBone;
  64837. private _loadSkinInverseBindMatricesDataAsync;
  64838. private _updateBoneMatrices;
  64839. private _getNodeMatrix;
  64840. /**
  64841. * Loads a glTF camera.
  64842. * @param context The context when loading the asset
  64843. * @param camera The glTF camera property
  64844. * @param assign A function called synchronously after parsing the glTF properties
  64845. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  64846. */
  64847. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  64848. private _loadAnimationsAsync;
  64849. /**
  64850. * Loads a glTF animation.
  64851. * @param context The context when loading the asset
  64852. * @param animation The glTF animation property
  64853. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  64854. */
  64855. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  64856. /**
  64857. * @hidden Loads a glTF animation channel.
  64858. * @param context The context when loading the asset
  64859. * @param animationContext The context of the animation when loading the asset
  64860. * @param animation The glTF animation property
  64861. * @param channel The glTF animation channel property
  64862. * @param babylonAnimationGroup The babylon animation group property
  64863. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  64864. * @returns A void promise when the channel load is complete
  64865. */
  64866. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  64867. private _loadAnimationSamplerAsync;
  64868. private _loadBufferAsync;
  64869. /**
  64870. * Loads a glTF buffer view.
  64871. * @param context The context when loading the asset
  64872. * @param bufferView The glTF buffer view property
  64873. * @returns A promise that resolves with the loaded data when the load is complete
  64874. */
  64875. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  64876. private _loadIndicesAccessorAsync;
  64877. private _loadFloatAccessorAsync;
  64878. private _loadVertexBufferViewAsync;
  64879. private _loadVertexAccessorAsync;
  64880. private _loadMaterialMetallicRoughnessPropertiesAsync;
  64881. /** @hidden */
  64882. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  64883. private _createDefaultMaterial;
  64884. /**
  64885. * Creates a Babylon material from a glTF material.
  64886. * @param context The context when loading the asset
  64887. * @param material The glTF material property
  64888. * @param babylonDrawMode The draw mode for the Babylon material
  64889. * @returns The Babylon material
  64890. */
  64891. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  64892. /**
  64893. * Loads properties from a glTF material into a Babylon material.
  64894. * @param context The context when loading the asset
  64895. * @param material The glTF material property
  64896. * @param babylonMaterial The Babylon material
  64897. * @returns A promise that resolves when the load is complete
  64898. */
  64899. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  64900. /**
  64901. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  64902. * @param context The context when loading the asset
  64903. * @param material The glTF material property
  64904. * @param babylonMaterial The Babylon material
  64905. * @returns A promise that resolves when the load is complete
  64906. */
  64907. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  64908. /**
  64909. * Loads the alpha properties from a glTF material into a Babylon material.
  64910. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  64911. * @param context The context when loading the asset
  64912. * @param material The glTF material property
  64913. * @param babylonMaterial The Babylon material
  64914. */
  64915. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  64916. /**
  64917. * Loads a glTF texture info.
  64918. * @param context The context when loading the asset
  64919. * @param textureInfo The glTF texture info property
  64920. * @param assign A function called synchronously after parsing the glTF properties
  64921. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  64922. */
  64923. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  64924. private _loadTextureAsync;
  64925. private _loadSampler;
  64926. /**
  64927. * Loads a glTF image.
  64928. * @param context The context when loading the asset
  64929. * @param image The glTF image property
  64930. * @returns A promise that resolves with the loaded data when the load is complete
  64931. */
  64932. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  64933. /**
  64934. * Loads a glTF uri.
  64935. * @param context The context when loading the asset
  64936. * @param property The glTF property associated with the uri
  64937. * @param uri The base64 or relative uri
  64938. * @returns A promise that resolves with the loaded data when the load is complete
  64939. */
  64940. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  64941. private _onProgress;
  64942. /**
  64943. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  64944. * @param babylonObject the Babylon object with metadata
  64945. * @param pointer the JSON pointer
  64946. */
  64947. static AddPointerMetadata(babylonObject: {
  64948. metadata: any;
  64949. }, pointer: string): void;
  64950. private static _GetTextureWrapMode;
  64951. private static _GetTextureSamplingMode;
  64952. private static _GetTypedArray;
  64953. private static _GetNumComponents;
  64954. private static _ValidateUri;
  64955. private static _GetDrawMode;
  64956. private _compileMaterialsAsync;
  64957. private _compileShadowGeneratorsAsync;
  64958. private _forEachExtensions;
  64959. private _applyExtensions;
  64960. private _extensionsOnLoading;
  64961. private _extensionsOnReady;
  64962. private _extensionsLoadSceneAsync;
  64963. private _extensionsLoadNodeAsync;
  64964. private _extensionsLoadCameraAsync;
  64965. private _extensionsLoadVertexDataAsync;
  64966. private _extensionsLoadMeshPrimitiveAsync;
  64967. private _extensionsLoadMaterialAsync;
  64968. private _extensionsCreateMaterial;
  64969. private _extensionsLoadMaterialPropertiesAsync;
  64970. private _extensionsLoadTextureInfoAsync;
  64971. private _extensionsLoadAnimationAsync;
  64972. private _extensionsLoadSkinAsync;
  64973. private _extensionsLoadUriAsync;
  64974. /**
  64975. * Helper method called by a loader extension to load an glTF extension.
  64976. * @param context The context when loading the asset
  64977. * @param property The glTF property to load the extension from
  64978. * @param extensionName The name of the extension to load
  64979. * @param actionAsync The action to run
  64980. * @returns The promise returned by actionAsync or null if the extension does not exist
  64981. */
  64982. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  64983. /**
  64984. * Helper method called by a loader extension to load a glTF extra.
  64985. * @param context The context when loading the asset
  64986. * @param property The glTF property to load the extra from
  64987. * @param extensionName The name of the extension to load
  64988. * @param actionAsync The action to run
  64989. * @returns The promise returned by actionAsync or null if the extra does not exist
  64990. */
  64991. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  64992. /**
  64993. * Increments the indentation level and logs a message.
  64994. * @param message The message to log
  64995. */
  64996. logOpen(message: string): void;
  64997. /**
  64998. * Decrements the indentation level.
  64999. */
  65000. logClose(): void;
  65001. /**
  65002. * Logs a message
  65003. * @param message The message to log
  65004. */
  65005. log(message: string): void;
  65006. /**
  65007. * Starts a performance counter.
  65008. * @param counterName The name of the performance counter
  65009. */
  65010. startPerformanceCounter(counterName: string): void;
  65011. /**
  65012. * Ends a performance counter.
  65013. * @param counterName The name of the performance counter
  65014. */
  65015. endPerformanceCounter(counterName: string): void;
  65016. }
  65017. }
  65018. declare module BABYLON.GLTF2.Loader.Extensions {
  65019. /**
  65020. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  65021. */
  65022. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  65023. /** The name of this extension. */
  65024. readonly name: string;
  65025. /** Defines whether this extension is enabled. */
  65026. enabled: boolean;
  65027. private _loader;
  65028. private _lights?;
  65029. /** @hidden */
  65030. constructor(loader: GLTFLoader);
  65031. /** @hidden */
  65032. dispose(): void;
  65033. /** @hidden */
  65034. onLoading(): void;
  65035. /** @hidden */
  65036. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  65037. private _loadLightAsync;
  65038. }
  65039. }
  65040. declare module BABYLON.GLTF2.Loader.Extensions {
  65041. /**
  65042. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  65043. */
  65044. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  65045. /** The name of this extension. */
  65046. readonly name: string;
  65047. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  65048. dracoCompression?: DracoCompression;
  65049. /** Defines whether this extension is enabled. */
  65050. enabled: boolean;
  65051. private _loader;
  65052. /** @hidden */
  65053. constructor(loader: GLTFLoader);
  65054. /** @hidden */
  65055. dispose(): void;
  65056. /** @hidden */
  65057. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  65058. }
  65059. }
  65060. declare module BABYLON.GLTF2.Loader.Extensions {
  65061. /**
  65062. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  65063. */
  65064. export class KHR_lights implements IGLTFLoaderExtension {
  65065. /** The name of this extension. */
  65066. readonly name: string;
  65067. /** Defines whether this extension is enabled. */
  65068. enabled: boolean;
  65069. private _loader;
  65070. private _lights?;
  65071. /** @hidden */
  65072. constructor(loader: GLTFLoader);
  65073. /** @hidden */
  65074. dispose(): void;
  65075. /** @hidden */
  65076. onLoading(): void;
  65077. /** @hidden */
  65078. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65079. }
  65080. }
  65081. declare module BABYLON.GLTF2.Loader.Extensions {
  65082. /**
  65083. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  65084. */
  65085. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  65086. /** The name of this extension. */
  65087. readonly name: string;
  65088. /** Defines whether this extension is enabled. */
  65089. enabled: boolean;
  65090. private _loader;
  65091. /** @hidden */
  65092. constructor(loader: GLTFLoader);
  65093. /** @hidden */
  65094. dispose(): void;
  65095. /** @hidden */
  65096. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65097. private _loadSpecularGlossinessPropertiesAsync;
  65098. }
  65099. }
  65100. declare module BABYLON.GLTF2.Loader.Extensions {
  65101. /**
  65102. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  65103. */
  65104. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  65105. /** The name of this extension. */
  65106. readonly name: string;
  65107. /** Defines whether this extension is enabled. */
  65108. enabled: boolean;
  65109. private _loader;
  65110. /** @hidden */
  65111. constructor(loader: GLTFLoader);
  65112. /** @hidden */
  65113. dispose(): void;
  65114. /** @hidden */
  65115. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65116. private _loadUnlitPropertiesAsync;
  65117. }
  65118. }
  65119. declare module BABYLON.GLTF2.Loader.Extensions {
  65120. /**
  65121. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  65122. */
  65123. export class KHR_texture_transform implements IGLTFLoaderExtension {
  65124. /** The name of this extension. */
  65125. readonly name: string;
  65126. /** Defines whether this extension is enabled. */
  65127. enabled: boolean;
  65128. private _loader;
  65129. /** @hidden */
  65130. constructor(loader: GLTFLoader);
  65131. /** @hidden */
  65132. dispose(): void;
  65133. /** @hidden */
  65134. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  65135. }
  65136. }
  65137. declare module BABYLON.GLTF2.Loader.Extensions {
  65138. /**
  65139. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  65140. */
  65141. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  65142. /** The name of this extension. */
  65143. readonly name: string;
  65144. /** Defines whether this extension is enabled. */
  65145. enabled: boolean;
  65146. private _loader;
  65147. private _clips;
  65148. private _emitters;
  65149. /** @hidden */
  65150. constructor(loader: GLTFLoader);
  65151. /** @hidden */
  65152. dispose(): void;
  65153. /** @hidden */
  65154. onLoading(): void;
  65155. /** @hidden */
  65156. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  65157. /** @hidden */
  65158. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65159. /** @hidden */
  65160. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  65161. private _loadClipAsync;
  65162. private _loadEmitterAsync;
  65163. private _getEventAction;
  65164. private _loadAnimationEventAsync;
  65165. }
  65166. }
  65167. declare module BABYLON.GLTF2.Loader.Extensions {
  65168. /**
  65169. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  65170. */
  65171. export class MSFT_lod implements IGLTFLoaderExtension {
  65172. /** The name of this extension. */
  65173. readonly name: string;
  65174. /** Defines whether this extension is enabled. */
  65175. enabled: boolean;
  65176. /**
  65177. * Maximum number of LODs to load, starting from the lowest LOD.
  65178. */
  65179. maxLODsToLoad: number;
  65180. /**
  65181. * Observable raised when all node LODs of one level are loaded.
  65182. * The event data is the index of the loaded LOD starting from zero.
  65183. * Dispose the loader to cancel the loading of the next level of LODs.
  65184. */
  65185. onNodeLODsLoadedObservable: Observable<number>;
  65186. /**
  65187. * Observable raised when all material LODs of one level are loaded.
  65188. * The event data is the index of the loaded LOD starting from zero.
  65189. * Dispose the loader to cancel the loading of the next level of LODs.
  65190. */
  65191. onMaterialLODsLoadedObservable: Observable<number>;
  65192. private _loader;
  65193. private _nodeIndexLOD;
  65194. private _nodeSignalLODs;
  65195. private _nodePromiseLODs;
  65196. private _materialIndexLOD;
  65197. private _materialSignalLODs;
  65198. private _materialPromiseLODs;
  65199. /** @hidden */
  65200. constructor(loader: GLTFLoader);
  65201. /** @hidden */
  65202. dispose(): void;
  65203. /** @hidden */
  65204. onReady(): void;
  65205. /** @hidden */
  65206. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65207. /** @hidden */
  65208. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  65209. /** @hidden */
  65210. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  65211. /**
  65212. * Gets an array of LOD properties from lowest to highest.
  65213. */
  65214. private _getLODs;
  65215. private _disposeUnusedMaterials;
  65216. }
  65217. }
  65218. declare module BABYLON.GLTF2.Loader.Extensions {
  65219. /** @hidden */
  65220. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  65221. readonly name: string;
  65222. enabled: boolean;
  65223. private _loader;
  65224. constructor(loader: GLTFLoader);
  65225. dispose(): void;
  65226. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65227. }
  65228. }
  65229. declare module BABYLON.GLTF2.Loader.Extensions {
  65230. /** @hidden */
  65231. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  65232. readonly name: string;
  65233. enabled: boolean;
  65234. private _loader;
  65235. constructor(loader: GLTFLoader);
  65236. dispose(): void;
  65237. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65238. }
  65239. }
  65240. declare module BABYLON.GLTF2.Loader.Extensions {
  65241. /**
  65242. * Store glTF extras (if present) in BJS objects' metadata
  65243. */
  65244. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  65245. /** The name of this extension. */
  65246. readonly name: string;
  65247. /** Defines whether this extension is enabled. */
  65248. enabled: boolean;
  65249. private _loader;
  65250. private _assignExtras;
  65251. /** @hidden */
  65252. constructor(loader: GLTFLoader);
  65253. /** @hidden */
  65254. dispose(): void;
  65255. /** @hidden */
  65256. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65257. /** @hidden */
  65258. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  65259. /** @hidden */
  65260. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  65261. }
  65262. }
  65263. declare module BABYLON {
  65264. /**
  65265. * Class reading and parsing the MTL file bundled with the obj file.
  65266. */
  65267. export class MTLFileLoader {
  65268. /**
  65269. * All material loaded from the mtl will be set here
  65270. */
  65271. materials: StandardMaterial[];
  65272. /**
  65273. * This function will read the mtl file and create each material described inside
  65274. * This function could be improve by adding :
  65275. * -some component missing (Ni, Tf...)
  65276. * -including the specific options available
  65277. *
  65278. * @param scene defines the scene the material will be created in
  65279. * @param data defines the mtl data to parse
  65280. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  65281. */
  65282. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  65283. /**
  65284. * Gets the texture for the material.
  65285. *
  65286. * If the material is imported from input file,
  65287. * We sanitize the url to ensure it takes the textre from aside the material.
  65288. *
  65289. * @param rootUrl The root url to load from
  65290. * @param value The value stored in the mtl
  65291. * @return The Texture
  65292. */
  65293. private static _getTexture;
  65294. }
  65295. /**
  65296. * Options for loading OBJ/MTL files
  65297. */
  65298. type MeshLoadOptions = {
  65299. /**
  65300. * Defines if UVs are optimized by default during load.
  65301. */
  65302. OptimizeWithUV: boolean;
  65303. /**
  65304. * Defines custom scaling of UV coordinates of loaded meshes.
  65305. */
  65306. UVScaling: Vector2;
  65307. /**
  65308. * Invert model on y-axis (does a model scaling inversion)
  65309. */
  65310. InvertY: boolean;
  65311. /**
  65312. * Invert Y-Axis of referenced textures on load
  65313. */
  65314. InvertTextureY: boolean;
  65315. /**
  65316. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  65317. */
  65318. ImportVertexColors: boolean;
  65319. /**
  65320. * Compute the normals for the model, even if normals are present in the file.
  65321. */
  65322. ComputeNormals: boolean;
  65323. /**
  65324. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  65325. */
  65326. SkipMaterials: boolean;
  65327. /**
  65328. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  65329. */
  65330. MaterialLoadingFailsSilently: boolean;
  65331. };
  65332. /**
  65333. * OBJ file type loader.
  65334. * This is a babylon scene loader plugin.
  65335. */
  65336. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  65337. /**
  65338. * Defines if UVs are optimized by default during load.
  65339. */
  65340. static OPTIMIZE_WITH_UV: boolean;
  65341. /**
  65342. * Invert model on y-axis (does a model scaling inversion)
  65343. */
  65344. static INVERT_Y: boolean;
  65345. /**
  65346. * Invert Y-Axis of referenced textures on load
  65347. */
  65348. static INVERT_TEXTURE_Y: boolean;
  65349. /**
  65350. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  65351. */
  65352. static IMPORT_VERTEX_COLORS: boolean;
  65353. /**
  65354. * Compute the normals for the model, even if normals are present in the file.
  65355. */
  65356. static COMPUTE_NORMALS: boolean;
  65357. /**
  65358. * Defines custom scaling of UV coordinates of loaded meshes.
  65359. */
  65360. static UV_SCALING: Vector2;
  65361. /**
  65362. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  65363. */
  65364. static SKIP_MATERIALS: boolean;
  65365. /**
  65366. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  65367. *
  65368. * Defaults to true for backwards compatibility.
  65369. */
  65370. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  65371. /**
  65372. * Defines the name of the plugin.
  65373. */
  65374. name: string;
  65375. /**
  65376. * Defines the extension the plugin is able to load.
  65377. */
  65378. extensions: string;
  65379. /** @hidden */
  65380. obj: RegExp;
  65381. /** @hidden */
  65382. group: RegExp;
  65383. /** @hidden */
  65384. mtllib: RegExp;
  65385. /** @hidden */
  65386. usemtl: RegExp;
  65387. /** @hidden */
  65388. smooth: RegExp;
  65389. /** @hidden */
  65390. vertexPattern: RegExp;
  65391. /** @hidden */
  65392. normalPattern: RegExp;
  65393. /** @hidden */
  65394. uvPattern: RegExp;
  65395. /** @hidden */
  65396. facePattern1: RegExp;
  65397. /** @hidden */
  65398. facePattern2: RegExp;
  65399. /** @hidden */
  65400. facePattern3: RegExp;
  65401. /** @hidden */
  65402. facePattern4: RegExp;
  65403. /** @hidden */
  65404. facePattern5: RegExp;
  65405. private _meshLoadOptions;
  65406. /**
  65407. * Creates loader for .OBJ files
  65408. *
  65409. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  65410. */
  65411. constructor(meshLoadOptions?: MeshLoadOptions);
  65412. private static readonly currentMeshLoadOptions;
  65413. /**
  65414. * Calls synchronously the MTL file attached to this obj.
  65415. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  65416. * Without this function materials are not displayed in the first frame (but displayed after).
  65417. * In consequence it is impossible to get material information in your HTML file
  65418. *
  65419. * @param url The URL of the MTL file
  65420. * @param rootUrl
  65421. * @param onSuccess Callback function to be called when the MTL file is loaded
  65422. * @private
  65423. */
  65424. private _loadMTL;
  65425. /**
  65426. * Instantiates a OBJ file loader plugin.
  65427. * @returns the created plugin
  65428. */
  65429. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  65430. /**
  65431. * If the data string can be loaded directly.
  65432. *
  65433. * @param data string containing the file data
  65434. * @returns if the data can be loaded directly
  65435. */
  65436. canDirectLoad(data: string): boolean;
  65437. /**
  65438. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  65439. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  65440. * @param scene the scene the meshes should be added to
  65441. * @param data the OBJ data to load
  65442. * @param rootUrl root url to load from
  65443. * @param onProgress event that fires when loading progress has occured
  65444. * @param fileName Defines the name of the file to load
  65445. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  65446. */
  65447. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  65448. meshes: AbstractMesh[];
  65449. particleSystems: IParticleSystem[];
  65450. skeletons: Skeleton[];
  65451. animationGroups: AnimationGroup[];
  65452. }>;
  65453. /**
  65454. * Imports all objects from the loaded OBJ data and adds them to the scene
  65455. * @param scene the scene the objects should be added to
  65456. * @param data the OBJ data to load
  65457. * @param rootUrl root url to load from
  65458. * @param onProgress event that fires when loading progress has occured
  65459. * @param fileName Defines the name of the file to load
  65460. * @returns a promise which completes when objects have been loaded to the scene
  65461. */
  65462. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  65463. /**
  65464. * Load into an asset container.
  65465. * @param scene The scene to load into
  65466. * @param data The data to import
  65467. * @param rootUrl The root url for scene and resources
  65468. * @param onProgress The callback when the load progresses
  65469. * @param fileName Defines the name of the file to load
  65470. * @returns The loaded asset container
  65471. */
  65472. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  65473. /**
  65474. * Read the OBJ file and create an Array of meshes.
  65475. * Each mesh contains all information given by the OBJ and the MTL file.
  65476. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  65477. *
  65478. * @param meshesNames
  65479. * @param scene Scene The scene where are displayed the data
  65480. * @param data String The content of the obj file
  65481. * @param rootUrl String The path to the folder
  65482. * @returns Array<AbstractMesh>
  65483. * @private
  65484. */
  65485. private _parseSolid;
  65486. }
  65487. }
  65488. declare module BABYLON {
  65489. /**
  65490. * STL file type loader.
  65491. * This is a babylon scene loader plugin.
  65492. */
  65493. export class STLFileLoader implements ISceneLoaderPlugin {
  65494. /** @hidden */
  65495. solidPattern: RegExp;
  65496. /** @hidden */
  65497. facetsPattern: RegExp;
  65498. /** @hidden */
  65499. normalPattern: RegExp;
  65500. /** @hidden */
  65501. vertexPattern: RegExp;
  65502. /**
  65503. * Defines the name of the plugin.
  65504. */
  65505. name: string;
  65506. /**
  65507. * Defines the extensions the stl loader is able to load.
  65508. * force data to come in as an ArrayBuffer
  65509. * we'll convert to string if it looks like it's an ASCII .stl
  65510. */
  65511. extensions: ISceneLoaderPluginExtensions;
  65512. /**
  65513. * Import meshes into a scene.
  65514. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  65515. * @param scene The scene to import into
  65516. * @param data The data to import
  65517. * @param rootUrl The root url for scene and resources
  65518. * @param meshes The meshes array to import into
  65519. * @param particleSystems The particle systems array to import into
  65520. * @param skeletons The skeletons array to import into
  65521. * @param onError The callback when import fails
  65522. * @returns True if successful or false otherwise
  65523. */
  65524. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  65525. /**
  65526. * Load into a scene.
  65527. * @param scene The scene to load into
  65528. * @param data The data to import
  65529. * @param rootUrl The root url for scene and resources
  65530. * @param onError The callback when import fails
  65531. * @returns true if successful or false otherwise
  65532. */
  65533. load(scene: Scene, data: any, rootUrl: string): boolean;
  65534. /**
  65535. * Load into an asset container.
  65536. * @param scene The scene to load into
  65537. * @param data The data to import
  65538. * @param rootUrl The root url for scene and resources
  65539. * @param onError The callback when import fails
  65540. * @returns The loaded asset container
  65541. */
  65542. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  65543. private _isBinary;
  65544. private _parseBinary;
  65545. private _parseASCII;
  65546. }
  65547. }
  65548. declare module BABYLON {
  65549. /**
  65550. * Class for generating OBJ data from a Babylon scene.
  65551. */
  65552. export class OBJExport {
  65553. /**
  65554. * Exports the geometry of a Mesh array in .OBJ file format (text)
  65555. * @param mesh defines the list of meshes to serialize
  65556. * @param materials defines if materials should be exported
  65557. * @param matlibname defines the name of the associated mtl file
  65558. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  65559. * @returns the OBJ content
  65560. */
  65561. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  65562. /**
  65563. * Exports the material(s) of a mesh in .MTL file format (text)
  65564. * @param mesh defines the mesh to extract the material from
  65565. * @returns the mtl content
  65566. */
  65567. static MTL(mesh: Mesh): string;
  65568. }
  65569. }
  65570. declare module BABYLON {
  65571. /** @hidden */
  65572. export var __IGLTFExporterExtension: number;
  65573. /**
  65574. * Interface for extending the exporter
  65575. * @hidden
  65576. */
  65577. export interface IGLTFExporterExtension {
  65578. /**
  65579. * The name of this extension
  65580. */
  65581. readonly name: string;
  65582. /**
  65583. * Defines whether this extension is enabled
  65584. */
  65585. enabled: boolean;
  65586. /**
  65587. * Defines whether this extension is required
  65588. */
  65589. required: boolean;
  65590. }
  65591. }
  65592. declare module BABYLON.GLTF2.Exporter {
  65593. /** @hidden */
  65594. export var __IGLTFExporterExtensionV2: number;
  65595. /**
  65596. * Interface for a glTF exporter extension
  65597. * @hidden
  65598. */
  65599. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  65600. /**
  65601. * Define this method to modify the default behavior before exporting a texture
  65602. * @param context The context when loading the asset
  65603. * @param babylonTexture The glTF texture info property
  65604. * @param mimeType The mime-type of the generated image
  65605. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  65606. */
  65607. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  65608. /**
  65609. * Define this method to modify the default behavior when exporting texture info
  65610. * @param context The context when loading the asset
  65611. * @param meshPrimitive glTF mesh primitive
  65612. * @param babylonSubMesh Babylon submesh
  65613. * @param binaryWriter glTF serializer binary writer instance
  65614. * @returns nullable IMeshPrimitive promise
  65615. */
  65616. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  65617. /**
  65618. * Define this method to modify the default behavior when exporting a node
  65619. * @param context The context when exporting the node
  65620. * @param node glTF node
  65621. * @param babylonNode BabylonJS node
  65622. * @returns nullable INode promise
  65623. */
  65624. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  65625. /**
  65626. * Called after the exporter state changes to EXPORTING
  65627. */
  65628. onExporting?(): void;
  65629. }
  65630. }
  65631. declare module BABYLON.GLTF2.Exporter {
  65632. /**
  65633. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  65634. * @hidden
  65635. */
  65636. export class _GLTFMaterialExporter {
  65637. /**
  65638. * Represents the dielectric specular values for R, G and B
  65639. */
  65640. private static readonly _DielectricSpecular;
  65641. /**
  65642. * Allows the maximum specular power to be defined for material calculations
  65643. */
  65644. private static readonly _MaxSpecularPower;
  65645. /**
  65646. * Mapping to store textures
  65647. */
  65648. private _textureMap;
  65649. /**
  65650. * Numeric tolerance value
  65651. */
  65652. private static readonly _Epsilon;
  65653. /**
  65654. * Reference to the glTF Exporter
  65655. */
  65656. private _exporter;
  65657. constructor(exporter: _Exporter);
  65658. /**
  65659. * Specifies if two colors are approximately equal in value
  65660. * @param color1 first color to compare to
  65661. * @param color2 second color to compare to
  65662. * @param epsilon threshold value
  65663. */
  65664. private static FuzzyEquals;
  65665. /**
  65666. * Gets the materials from a Babylon scene and converts them to glTF materials
  65667. * @param scene babylonjs scene
  65668. * @param mimeType texture mime type
  65669. * @param images array of images
  65670. * @param textures array of textures
  65671. * @param materials array of materials
  65672. * @param imageData mapping of texture names to base64 textures
  65673. * @param hasTextureCoords specifies if texture coordinates are present on the material
  65674. */
  65675. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65676. /**
  65677. * Makes a copy of the glTF material without the texture parameters
  65678. * @param originalMaterial original glTF material
  65679. * @returns glTF material without texture parameters
  65680. */
  65681. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  65682. /**
  65683. * Specifies if the material has any texture parameters present
  65684. * @param material glTF Material
  65685. * @returns boolean specifying if texture parameters are present
  65686. */
  65687. _hasTexturesPresent(material: IMaterial): boolean;
  65688. /**
  65689. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  65690. * @param babylonStandardMaterial
  65691. * @returns glTF Metallic Roughness Material representation
  65692. */
  65693. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  65694. /**
  65695. * Computes the metallic factor
  65696. * @param diffuse diffused value
  65697. * @param specular specular value
  65698. * @param oneMinusSpecularStrength one minus the specular strength
  65699. * @returns metallic value
  65700. */
  65701. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  65702. /**
  65703. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  65704. * @param glTFMaterial glTF material
  65705. * @param babylonMaterial Babylon material
  65706. */
  65707. private static _SetAlphaMode;
  65708. /**
  65709. * Converts a Babylon Standard Material to a glTF Material
  65710. * @param babylonStandardMaterial BJS Standard Material
  65711. * @param mimeType mime type to use for the textures
  65712. * @param images array of glTF image interfaces
  65713. * @param textures array of glTF texture interfaces
  65714. * @param materials array of glTF material interfaces
  65715. * @param imageData map of image file name to data
  65716. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65717. */
  65718. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65719. /**
  65720. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  65721. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  65722. * @param mimeType mime type to use for the textures
  65723. * @param images array of glTF image interfaces
  65724. * @param textures array of glTF texture interfaces
  65725. * @param materials array of glTF material interfaces
  65726. * @param imageData map of image file name to data
  65727. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65728. */
  65729. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65730. /**
  65731. * Converts an image typed array buffer to a base64 image
  65732. * @param buffer typed array buffer
  65733. * @param width width of the image
  65734. * @param height height of the image
  65735. * @param mimeType mimetype of the image
  65736. * @returns base64 image string
  65737. */
  65738. private _createBase64FromCanvasAsync;
  65739. /**
  65740. * Generates a white texture based on the specified width and height
  65741. * @param width width of the texture in pixels
  65742. * @param height height of the texture in pixels
  65743. * @param scene babylonjs scene
  65744. * @returns white texture
  65745. */
  65746. private _createWhiteTexture;
  65747. /**
  65748. * 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
  65749. * @param texture1 first texture to resize
  65750. * @param texture2 second texture to resize
  65751. * @param scene babylonjs scene
  65752. * @returns resized textures or null
  65753. */
  65754. private _resizeTexturesToSameDimensions;
  65755. /**
  65756. * Converts an array of pixels to a Float32Array
  65757. * Throws an error if the pixel format is not supported
  65758. * @param pixels - array buffer containing pixel values
  65759. * @returns Float32 of pixels
  65760. */
  65761. private _convertPixelArrayToFloat32;
  65762. /**
  65763. * Convert Specular Glossiness Textures to Metallic Roughness
  65764. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  65765. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  65766. * @param diffuseTexture texture used to store diffuse information
  65767. * @param specularGlossinessTexture texture used to store specular and glossiness information
  65768. * @param factors specular glossiness material factors
  65769. * @param mimeType the mime type to use for the texture
  65770. * @returns pbr metallic roughness interface or null
  65771. */
  65772. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  65773. /**
  65774. * Converts specular glossiness material properties to metallic roughness
  65775. * @param specularGlossiness interface with specular glossiness material properties
  65776. * @returns interface with metallic roughness material properties
  65777. */
  65778. private _convertSpecularGlossinessToMetallicRoughness;
  65779. /**
  65780. * Calculates the surface reflectance, independent of lighting conditions
  65781. * @param color Color source to calculate brightness from
  65782. * @returns number representing the perceived brightness, or zero if color is undefined
  65783. */
  65784. private _getPerceivedBrightness;
  65785. /**
  65786. * Returns the maximum color component value
  65787. * @param color
  65788. * @returns maximum color component value, or zero if color is null or undefined
  65789. */
  65790. private _getMaxComponent;
  65791. /**
  65792. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  65793. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  65794. * @param mimeType mime type to use for the textures
  65795. * @param images array of glTF image interfaces
  65796. * @param textures array of glTF texture interfaces
  65797. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  65798. * @param imageData map of image file name to data
  65799. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65800. * @returns glTF PBR Metallic Roughness factors
  65801. */
  65802. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  65803. private _getGLTFTextureSampler;
  65804. private _getGLTFTextureWrapMode;
  65805. private _getGLTFTextureWrapModesSampler;
  65806. /**
  65807. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  65808. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  65809. * @param mimeType mime type to use for the textures
  65810. * @param images array of glTF image interfaces
  65811. * @param textures array of glTF texture interfaces
  65812. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  65813. * @param imageData map of image file name to data
  65814. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65815. * @returns glTF PBR Metallic Roughness factors
  65816. */
  65817. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  65818. /**
  65819. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  65820. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  65821. * @param mimeType mime type to use for the textures
  65822. * @param images array of glTF image interfaces
  65823. * @param textures array of glTF texture interfaces
  65824. * @param materials array of glTF material interfaces
  65825. * @param imageData map of image file name to data
  65826. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65827. */
  65828. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65829. private setMetallicRoughnessPbrMaterial;
  65830. private getPixelsFromTexture;
  65831. /**
  65832. * Extracts a texture from a Babylon texture into file data and glTF data
  65833. * @param babylonTexture Babylon texture to extract
  65834. * @param mimeType Mime Type of the babylonTexture
  65835. * @return glTF texture info, or null if the texture format is not supported
  65836. */
  65837. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  65838. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  65839. /**
  65840. * Builds a texture from base64 string
  65841. * @param base64Texture base64 texture string
  65842. * @param baseTextureName Name to use for the texture
  65843. * @param mimeType image mime type for the texture
  65844. * @param images array of images
  65845. * @param textures array of textures
  65846. * @param imageData map of image data
  65847. * @returns glTF texture info, or null if the texture format is not supported
  65848. */
  65849. private _getTextureInfoFromBase64;
  65850. }
  65851. }
  65852. declare module BABYLON {
  65853. /**
  65854. * Class for holding and downloading glTF file data
  65855. */
  65856. export class GLTFData {
  65857. /**
  65858. * Object which contains the file name as the key and its data as the value
  65859. */
  65860. glTFFiles: {
  65861. [fileName: string]: string | Blob;
  65862. };
  65863. /**
  65864. * Initializes the glTF file object
  65865. */
  65866. constructor();
  65867. /**
  65868. * Downloads the glTF data as files based on their names and data
  65869. */
  65870. downloadFiles(): void;
  65871. }
  65872. }
  65873. declare module BABYLON {
  65874. /**
  65875. * Holds a collection of exporter options and parameters
  65876. */
  65877. export interface IExportOptions {
  65878. /**
  65879. * Function which indicates whether a babylon node should be exported or not
  65880. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  65881. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  65882. */
  65883. shouldExportNode?(node: Node): boolean;
  65884. /**
  65885. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  65886. * @param metadata source metadata to read from
  65887. * @returns the data to store to glTF node extras
  65888. */
  65889. metadataSelector?(metadata: any): any;
  65890. /**
  65891. * The sample rate to bake animation curves
  65892. */
  65893. animationSampleRate?: number;
  65894. /**
  65895. * Begin serialization without waiting for the scene to be ready
  65896. */
  65897. exportWithoutWaitingForScene?: boolean;
  65898. }
  65899. /**
  65900. * Class for generating glTF data from a Babylon scene.
  65901. */
  65902. export class GLTF2Export {
  65903. /**
  65904. * Exports the geometry of the scene to .gltf file format asynchronously
  65905. * @param scene Babylon scene with scene hierarchy information
  65906. * @param filePrefix File prefix to use when generating the glTF file
  65907. * @param options Exporter options
  65908. * @returns Returns an object with a .gltf file and associates texture names
  65909. * as keys and their data and paths as values
  65910. */
  65911. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  65912. private static _PreExportAsync;
  65913. private static _PostExportAsync;
  65914. /**
  65915. * Exports the geometry of the scene to .glb file format asychronously
  65916. * @param scene Babylon scene with scene hierarchy information
  65917. * @param filePrefix File prefix to use when generating glb file
  65918. * @param options Exporter options
  65919. * @returns Returns an object with a .glb filename as key and data as value
  65920. */
  65921. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  65922. }
  65923. }
  65924. declare module BABYLON.GLTF2.Exporter {
  65925. /**
  65926. * @hidden
  65927. */
  65928. export class _GLTFUtilities {
  65929. /**
  65930. * Creates a buffer view based on the supplied arguments
  65931. * @param bufferIndex index value of the specified buffer
  65932. * @param byteOffset byte offset value
  65933. * @param byteLength byte length of the bufferView
  65934. * @param byteStride byte distance between conequential elements
  65935. * @param name name of the buffer view
  65936. * @returns bufferView for glTF
  65937. */
  65938. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  65939. /**
  65940. * Creates an accessor based on the supplied arguments
  65941. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  65942. * @param name The name of the accessor
  65943. * @param type The type of the accessor
  65944. * @param componentType The datatype of components in the attribute
  65945. * @param count The number of attributes referenced by this accessor
  65946. * @param byteOffset The offset relative to the start of the bufferView in bytes
  65947. * @param min Minimum value of each component in this attribute
  65948. * @param max Maximum value of each component in this attribute
  65949. * @returns accessor for glTF
  65950. */
  65951. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  65952. /**
  65953. * Calculates the minimum and maximum values of an array of position floats
  65954. * @param positions Positions array of a mesh
  65955. * @param vertexStart Starting vertex offset to calculate min and max values
  65956. * @param vertexCount Number of vertices to check for min and max values
  65957. * @returns min number array and max number array
  65958. */
  65959. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  65960. min: number[];
  65961. max: number[];
  65962. };
  65963. /**
  65964. * Converts a new right-handed Vector3
  65965. * @param vector vector3 array
  65966. * @returns right-handed Vector3
  65967. */
  65968. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  65969. /**
  65970. * Converts a Vector3 to right-handed
  65971. * @param vector Vector3 to convert to right-handed
  65972. */
  65973. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  65974. /**
  65975. * Converts a three element number array to right-handed
  65976. * @param vector number array to convert to right-handed
  65977. */
  65978. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  65979. /**
  65980. * Converts a new right-handed Vector3
  65981. * @param vector vector3 array
  65982. * @returns right-handed Vector3
  65983. */
  65984. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  65985. /**
  65986. * Converts a Vector3 to right-handed
  65987. * @param vector Vector3 to convert to right-handed
  65988. */
  65989. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  65990. /**
  65991. * Converts a three element number array to right-handed
  65992. * @param vector number array to convert to right-handed
  65993. */
  65994. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  65995. /**
  65996. * Converts a Vector4 to right-handed
  65997. * @param vector Vector4 to convert to right-handed
  65998. */
  65999. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  66000. /**
  66001. * Converts a Vector4 to right-handed
  66002. * @param vector Vector4 to convert to right-handed
  66003. */
  66004. static _GetRightHandedArray4FromRef(vector: number[]): void;
  66005. /**
  66006. * Converts a Quaternion to right-handed
  66007. * @param quaternion Source quaternion to convert to right-handed
  66008. */
  66009. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  66010. /**
  66011. * Converts a Quaternion to right-handed
  66012. * @param quaternion Source quaternion to convert to right-handed
  66013. */
  66014. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  66015. static _NormalizeTangentFromRef(tangent: Vector4): void;
  66016. }
  66017. }
  66018. declare module BABYLON.GLTF2.Exporter {
  66019. /**
  66020. * Converts Babylon Scene into glTF 2.0.
  66021. * @hidden
  66022. */
  66023. export class _Exporter {
  66024. /**
  66025. * Stores the glTF to export
  66026. */
  66027. _glTF: IGLTF;
  66028. /**
  66029. * Stores all generated buffer views, which represents views into the main glTF buffer data
  66030. */
  66031. _bufferViews: IBufferView[];
  66032. /**
  66033. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  66034. */
  66035. _accessors: IAccessor[];
  66036. /**
  66037. * Stores all the generated nodes, which contains transform and/or mesh information per node
  66038. */
  66039. private _nodes;
  66040. /**
  66041. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  66042. */
  66043. private _scenes;
  66044. /**
  66045. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  66046. */
  66047. private _meshes;
  66048. /**
  66049. * Stores all the generated material information, which represents the appearance of each primitive
  66050. */
  66051. _materials: IMaterial[];
  66052. _materialMap: {
  66053. [materialID: number]: number;
  66054. };
  66055. /**
  66056. * Stores all the generated texture information, which is referenced by glTF materials
  66057. */
  66058. _textures: ITexture[];
  66059. /**
  66060. * Stores all the generated image information, which is referenced by glTF textures
  66061. */
  66062. _images: IImage[];
  66063. /**
  66064. * Stores all the texture samplers
  66065. */
  66066. _samplers: ISampler[];
  66067. /**
  66068. * Stores all the generated animation samplers, which is referenced by glTF animations
  66069. */
  66070. /**
  66071. * Stores the animations for glTF models
  66072. */
  66073. private _animations;
  66074. /**
  66075. * Stores the total amount of bytes stored in the glTF buffer
  66076. */
  66077. private _totalByteLength;
  66078. /**
  66079. * Stores a reference to the Babylon scene containing the source geometry and material information
  66080. */
  66081. _babylonScene: Scene;
  66082. /**
  66083. * Stores a map of the image data, where the key is the file name and the value
  66084. * is the image data
  66085. */
  66086. _imageData: {
  66087. [fileName: string]: {
  66088. data: Uint8Array;
  66089. mimeType: ImageMimeType;
  66090. };
  66091. };
  66092. /**
  66093. * Stores a map of the unique id of a node to its index in the node array
  66094. */
  66095. private _nodeMap;
  66096. /**
  66097. * Specifies if the Babylon scene should be converted to right-handed on export
  66098. */
  66099. _convertToRightHandedSystem: boolean;
  66100. /**
  66101. * Baked animation sample rate
  66102. */
  66103. private _animationSampleRate;
  66104. private _options;
  66105. private _localEngine;
  66106. _glTFMaterialExporter: _GLTFMaterialExporter;
  66107. private _extensions;
  66108. private static _ExtensionNames;
  66109. private static _ExtensionFactories;
  66110. private _applyExtensions;
  66111. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  66112. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  66113. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  66114. private _forEachExtensions;
  66115. private _extensionsOnExporting;
  66116. /**
  66117. * Load glTF serializer extensions
  66118. */
  66119. private _loadExtensions;
  66120. /**
  66121. * Creates a glTF Exporter instance, which can accept optional exporter options
  66122. * @param babylonScene Babylon scene object
  66123. * @param options Options to modify the behavior of the exporter
  66124. */
  66125. constructor(babylonScene: Scene, options?: IExportOptions);
  66126. /**
  66127. * Registers a glTF exporter extension
  66128. * @param name Name of the extension to export
  66129. * @param factory The factory function that creates the exporter extension
  66130. */
  66131. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  66132. /**
  66133. * Un-registers an exporter extension
  66134. * @param name The name fo the exporter extension
  66135. * @returns A boolean indicating whether the extension has been un-registered
  66136. */
  66137. static UnregisterExtension(name: string): boolean;
  66138. /**
  66139. * Lazy load a local engine with premultiplied alpha set to false
  66140. */
  66141. _getLocalEngine(): Engine;
  66142. private reorderIndicesBasedOnPrimitiveMode;
  66143. /**
  66144. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  66145. * clock-wise during export to glTF
  66146. * @param submesh BabylonJS submesh
  66147. * @param primitiveMode Primitive mode of the mesh
  66148. * @param sideOrientation the winding order of the submesh
  66149. * @param vertexBufferKind The type of vertex attribute
  66150. * @param meshAttributeArray The vertex attribute data
  66151. * @param byteOffset The offset to the binary data
  66152. * @param binaryWriter The binary data for the glTF file
  66153. */
  66154. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  66155. /**
  66156. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  66157. * clock-wise during export to glTF
  66158. * @param submesh BabylonJS submesh
  66159. * @param primitiveMode Primitive mode of the mesh
  66160. * @param sideOrientation the winding order of the submesh
  66161. * @param vertexBufferKind The type of vertex attribute
  66162. * @param meshAttributeArray The vertex attribute data
  66163. * @param byteOffset The offset to the binary data
  66164. * @param binaryWriter The binary data for the glTF file
  66165. */
  66166. private reorderTriangleFillMode;
  66167. /**
  66168. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  66169. * clock-wise during export to glTF
  66170. * @param submesh BabylonJS submesh
  66171. * @param primitiveMode Primitive mode of the mesh
  66172. * @param sideOrientation the winding order of the submesh
  66173. * @param vertexBufferKind The type of vertex attribute
  66174. * @param meshAttributeArray The vertex attribute data
  66175. * @param byteOffset The offset to the binary data
  66176. * @param binaryWriter The binary data for the glTF file
  66177. */
  66178. private reorderTriangleStripDrawMode;
  66179. /**
  66180. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  66181. * clock-wise during export to glTF
  66182. * @param submesh BabylonJS submesh
  66183. * @param primitiveMode Primitive mode of the mesh
  66184. * @param sideOrientation the winding order of the submesh
  66185. * @param vertexBufferKind The type of vertex attribute
  66186. * @param meshAttributeArray The vertex attribute data
  66187. * @param byteOffset The offset to the binary data
  66188. * @param binaryWriter The binary data for the glTF file
  66189. */
  66190. private reorderTriangleFanMode;
  66191. /**
  66192. * Writes the vertex attribute data to binary
  66193. * @param vertices The vertices to write to the binary writer
  66194. * @param byteOffset The offset into the binary writer to overwrite binary data
  66195. * @param vertexAttributeKind The vertex attribute type
  66196. * @param meshAttributeArray The vertex attribute data
  66197. * @param binaryWriter The writer containing the binary data
  66198. */
  66199. private writeVertexAttributeData;
  66200. /**
  66201. * Writes mesh attribute data to a data buffer
  66202. * Returns the bytelength of the data
  66203. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  66204. * @param meshAttributeArray Array containing the attribute data
  66205. * @param binaryWriter The buffer to write the binary data to
  66206. * @param indices Used to specify the order of the vertex data
  66207. */
  66208. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  66209. /**
  66210. * Generates glTF json data
  66211. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  66212. * @param glTFPrefix Text to use when prefixing a glTF file
  66213. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  66214. * @returns json data as string
  66215. */
  66216. private generateJSON;
  66217. /**
  66218. * Generates data for .gltf and .bin files based on the glTF prefix string
  66219. * @param glTFPrefix Text to use when prefixing a glTF file
  66220. * @returns GLTFData with glTF file data
  66221. */
  66222. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  66223. /**
  66224. * Creates a binary buffer for glTF
  66225. * @returns array buffer for binary data
  66226. */
  66227. private _generateBinaryAsync;
  66228. /**
  66229. * Pads the number to a multiple of 4
  66230. * @param num number to pad
  66231. * @returns padded number
  66232. */
  66233. private _getPadding;
  66234. /**
  66235. * Generates a glb file from the json and binary data
  66236. * Returns an object with the glb file name as the key and data as the value
  66237. * @param glTFPrefix
  66238. * @returns object with glb filename as key and data as value
  66239. */
  66240. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  66241. /**
  66242. * Sets the TRS for each node
  66243. * @param node glTF Node for storing the transformation data
  66244. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  66245. */
  66246. private setNodeTransformation;
  66247. private getVertexBufferFromMesh;
  66248. /**
  66249. * Creates a bufferview based on the vertices type for the Babylon mesh
  66250. * @param kind Indicates the type of vertices data
  66251. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  66252. * @param binaryWriter The buffer to write the bufferview data to
  66253. */
  66254. private createBufferViewKind;
  66255. /**
  66256. * The primitive mode of the Babylon mesh
  66257. * @param babylonMesh The BabylonJS mesh
  66258. */
  66259. private getMeshPrimitiveMode;
  66260. /**
  66261. * Sets the primitive mode of the glTF mesh primitive
  66262. * @param meshPrimitive glTF mesh primitive
  66263. * @param primitiveMode The primitive mode
  66264. */
  66265. private setPrimitiveMode;
  66266. /**
  66267. * Sets the vertex attribute accessor based of the glTF mesh primitive
  66268. * @param meshPrimitive glTF mesh primitive
  66269. * @param attributeKind vertex attribute
  66270. * @returns boolean specifying if uv coordinates are present
  66271. */
  66272. private setAttributeKind;
  66273. /**
  66274. * Sets data for the primitive attributes of each submesh
  66275. * @param mesh glTF Mesh object to store the primitive attribute information
  66276. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  66277. * @param binaryWriter Buffer to write the attribute data to
  66278. */
  66279. private setPrimitiveAttributesAsync;
  66280. /**
  66281. * Creates a glTF scene based on the array of meshes
  66282. * Returns the the total byte offset
  66283. * @param babylonScene Babylon scene to get the mesh data from
  66284. * @param binaryWriter Buffer to write binary data to
  66285. */
  66286. private createSceneAsync;
  66287. /**
  66288. * Creates a mapping of Node unique id to node index and handles animations
  66289. * @param babylonScene Babylon Scene
  66290. * @param nodes Babylon transform nodes
  66291. * @param binaryWriter Buffer to write binary data to
  66292. * @returns Node mapping of unique id to index
  66293. */
  66294. private createNodeMapAndAnimationsAsync;
  66295. /**
  66296. * Creates a glTF node from a Babylon mesh
  66297. * @param babylonMesh Source Babylon mesh
  66298. * @param binaryWriter Buffer for storing geometry data
  66299. * @returns glTF node
  66300. */
  66301. private createNodeAsync;
  66302. }
  66303. /**
  66304. * @hidden
  66305. *
  66306. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  66307. */
  66308. export class _BinaryWriter {
  66309. /**
  66310. * Array buffer which stores all binary data
  66311. */
  66312. private _arrayBuffer;
  66313. /**
  66314. * View of the array buffer
  66315. */
  66316. private _dataView;
  66317. /**
  66318. * byte offset of data in array buffer
  66319. */
  66320. private _byteOffset;
  66321. /**
  66322. * Initialize binary writer with an initial byte length
  66323. * @param byteLength Initial byte length of the array buffer
  66324. */
  66325. constructor(byteLength: number);
  66326. /**
  66327. * Resize the array buffer to the specified byte length
  66328. * @param byteLength
  66329. */
  66330. private resizeBuffer;
  66331. /**
  66332. * Get an array buffer with the length of the byte offset
  66333. * @returns ArrayBuffer resized to the byte offset
  66334. */
  66335. getArrayBuffer(): ArrayBuffer;
  66336. /**
  66337. * Get the byte offset of the array buffer
  66338. * @returns byte offset
  66339. */
  66340. getByteOffset(): number;
  66341. /**
  66342. * Stores an UInt8 in the array buffer
  66343. * @param entry
  66344. * @param byteOffset If defined, specifies where to set the value as an offset.
  66345. */
  66346. setUInt8(entry: number, byteOffset?: number): void;
  66347. /**
  66348. * Gets an UInt32 in the array buffer
  66349. * @param entry
  66350. * @param byteOffset If defined, specifies where to set the value as an offset.
  66351. */
  66352. getUInt32(byteOffset: number): number;
  66353. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  66354. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  66355. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  66356. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  66357. /**
  66358. * Stores a Float32 in the array buffer
  66359. * @param entry
  66360. */
  66361. setFloat32(entry: number, byteOffset?: number): void;
  66362. /**
  66363. * Stores an UInt32 in the array buffer
  66364. * @param entry
  66365. * @param byteOffset If defined, specifies where to set the value as an offset.
  66366. */
  66367. setUInt32(entry: number, byteOffset?: number): void;
  66368. }
  66369. }
  66370. declare module BABYLON.GLTF2.Exporter {
  66371. /**
  66372. * @hidden
  66373. * Interface to store animation data.
  66374. */
  66375. export interface _IAnimationData {
  66376. /**
  66377. * Keyframe data.
  66378. */
  66379. inputs: number[];
  66380. /**
  66381. * Value data.
  66382. */
  66383. outputs: number[][];
  66384. /**
  66385. * Animation interpolation data.
  66386. */
  66387. samplerInterpolation: AnimationSamplerInterpolation;
  66388. /**
  66389. * Minimum keyframe value.
  66390. */
  66391. inputsMin: number;
  66392. /**
  66393. * Maximum keyframe value.
  66394. */
  66395. inputsMax: number;
  66396. }
  66397. /**
  66398. * @hidden
  66399. */
  66400. export interface _IAnimationInfo {
  66401. /**
  66402. * The target channel for the animation
  66403. */
  66404. animationChannelTargetPath: AnimationChannelTargetPath;
  66405. /**
  66406. * The glTF accessor type for the data.
  66407. */
  66408. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  66409. /**
  66410. * Specifies if quaternions should be used.
  66411. */
  66412. useQuaternion: boolean;
  66413. }
  66414. /**
  66415. * @hidden
  66416. * Utility class for generating glTF animation data from BabylonJS.
  66417. */
  66418. export class _GLTFAnimation {
  66419. /**
  66420. * @ignore
  66421. *
  66422. * Creates glTF channel animation from BabylonJS animation.
  66423. * @param babylonTransformNode - BabylonJS mesh.
  66424. * @param animation - animation.
  66425. * @param animationChannelTargetPath - The target animation channel.
  66426. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  66427. * @param useQuaternion - Specifies if quaternions are used.
  66428. * @returns nullable IAnimationData
  66429. */
  66430. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  66431. private static _DeduceAnimationInfo;
  66432. /**
  66433. * @ignore
  66434. * Create node animations from the transform node animations
  66435. * @param babylonNode
  66436. * @param runtimeGLTFAnimation
  66437. * @param idleGLTFAnimations
  66438. * @param nodeMap
  66439. * @param nodes
  66440. * @param binaryWriter
  66441. * @param bufferViews
  66442. * @param accessors
  66443. * @param convertToRightHandedSystem
  66444. */
  66445. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  66446. [key: number]: number;
  66447. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  66448. /**
  66449. * @ignore
  66450. * Create node animations from the animation groups
  66451. * @param babylonScene
  66452. * @param glTFAnimations
  66453. * @param nodeMap
  66454. * @param nodes
  66455. * @param binaryWriter
  66456. * @param bufferViews
  66457. * @param accessors
  66458. * @param convertToRightHandedSystem
  66459. */
  66460. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  66461. [key: number]: number;
  66462. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  66463. private static AddAnimation;
  66464. /**
  66465. * Create a baked animation
  66466. * @param babylonTransformNode BabylonJS mesh
  66467. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  66468. * @param animationChannelTargetPath animation target channel
  66469. * @param minFrame minimum animation frame
  66470. * @param maxFrame maximum animation frame
  66471. * @param fps frames per second of the animation
  66472. * @param inputs input key frames of the animation
  66473. * @param outputs output key frame data of the animation
  66474. * @param convertToRightHandedSystem converts the values to right-handed
  66475. * @param useQuaternion specifies if quaternions should be used
  66476. */
  66477. private static _CreateBakedAnimation;
  66478. private static _ConvertFactorToVector3OrQuaternion;
  66479. private static _SetInterpolatedValue;
  66480. /**
  66481. * Creates linear animation from the animation key frames
  66482. * @param babylonTransformNode BabylonJS mesh
  66483. * @param animation BabylonJS animation
  66484. * @param animationChannelTargetPath The target animation channel
  66485. * @param frameDelta The difference between the last and first frame of the animation
  66486. * @param inputs Array to store the key frame times
  66487. * @param outputs Array to store the key frame data
  66488. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  66489. * @param useQuaternion Specifies if quaternions are used in the animation
  66490. */
  66491. private static _CreateLinearOrStepAnimation;
  66492. /**
  66493. * Creates cubic spline animation from the animation key frames
  66494. * @param babylonTransformNode BabylonJS mesh
  66495. * @param animation BabylonJS animation
  66496. * @param animationChannelTargetPath The target animation channel
  66497. * @param frameDelta The difference between the last and first frame of the animation
  66498. * @param inputs Array to store the key frame times
  66499. * @param outputs Array to store the key frame data
  66500. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  66501. * @param useQuaternion Specifies if quaternions are used in the animation
  66502. */
  66503. private static _CreateCubicSplineAnimation;
  66504. private static _GetBasePositionRotationOrScale;
  66505. /**
  66506. * Adds a key frame value
  66507. * @param keyFrame
  66508. * @param animation
  66509. * @param outputs
  66510. * @param animationChannelTargetPath
  66511. * @param basePositionRotationOrScale
  66512. * @param convertToRightHandedSystem
  66513. * @param useQuaternion
  66514. */
  66515. private static _AddKeyframeValue;
  66516. /**
  66517. * Determine the interpolation based on the key frames
  66518. * @param keyFrames
  66519. * @param animationChannelTargetPath
  66520. * @param useQuaternion
  66521. */
  66522. private static _DeduceInterpolation;
  66523. /**
  66524. * Adds an input tangent or output tangent to the output data
  66525. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  66526. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  66527. * @param outputs The animation data by keyframe
  66528. * @param animationChannelTargetPath The target animation channel
  66529. * @param interpolation The interpolation type
  66530. * @param keyFrame The key frame with the animation data
  66531. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  66532. * @param useQuaternion Specifies if quaternions are used
  66533. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  66534. */
  66535. private static AddSplineTangent;
  66536. /**
  66537. * Get the minimum and maximum key frames' frame values
  66538. * @param keyFrames animation key frames
  66539. * @returns the minimum and maximum key frame value
  66540. */
  66541. private static calculateMinMaxKeyFrames;
  66542. }
  66543. }
  66544. declare module BABYLON.GLTF2.Exporter {
  66545. /** @hidden */
  66546. export var textureTransformPixelShader: {
  66547. name: string;
  66548. shader: string;
  66549. };
  66550. }
  66551. declare module BABYLON.GLTF2.Exporter.Extensions {
  66552. /**
  66553. * @hidden
  66554. */
  66555. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  66556. /** Name of this extension */
  66557. readonly name: string;
  66558. /** Defines whether this extension is enabled */
  66559. enabled: boolean;
  66560. /** Defines whether this extension is required */
  66561. required: boolean;
  66562. /** Reference to the glTF exporter */
  66563. private _exporter;
  66564. constructor(exporter: _Exporter);
  66565. dispose(): void;
  66566. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  66567. /**
  66568. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  66569. * @param babylonTexture
  66570. * @param offset
  66571. * @param rotation
  66572. * @param scale
  66573. * @param scene
  66574. */
  66575. private _textureTransformTextureAsync;
  66576. }
  66577. }
  66578. declare module BABYLON.GLTF2.Exporter.Extensions {
  66579. /**
  66580. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  66581. */
  66582. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  66583. /** The name of this extension. */
  66584. readonly name: string;
  66585. /** Defines whether this extension is enabled. */
  66586. enabled: boolean;
  66587. /** Defines whether this extension is required */
  66588. required: boolean;
  66589. /** Reference to the glTF exporter */
  66590. private _exporter;
  66591. private _lights;
  66592. /** @hidden */
  66593. constructor(exporter: _Exporter);
  66594. /** @hidden */
  66595. dispose(): void;
  66596. /** @hidden */
  66597. onExporting(): void;
  66598. /**
  66599. * Define this method to modify the default behavior when exporting a node
  66600. * @param context The context when exporting the node
  66601. * @param node glTF node
  66602. * @param babylonNode BabylonJS node
  66603. * @returns nullable INode promise
  66604. */
  66605. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  66606. }
  66607. }
  66608. declare module BABYLON {
  66609. /**
  66610. * Class for generating STL data from a Babylon scene.
  66611. */
  66612. export class STLExport {
  66613. /**
  66614. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  66615. * @param meshes list defines the mesh to serialize
  66616. * @param download triggers the automatic download of the file.
  66617. * @param fileName changes the downloads fileName.
  66618. * @param binary changes the STL to a binary type.
  66619. * @param isLittleEndian toggle for binary type exporter.
  66620. * @returns the STL as UTF8 string
  66621. */
  66622. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  66623. }
  66624. }
  66625. /**
  66626. * @ignoreChildren
  66627. * @ignore
  66628. */
  66629. declare module "babylonjs-gltf2interface" {
  66630. export = BABYLON.GLTF2;
  66631. }
  66632. /**
  66633. * Module for glTF 2.0 Interface
  66634. * @ignoreChildren
  66635. * @ignore
  66636. */
  66637. declare module BABYLON.GLTF2 {
  66638. /**
  66639. * The datatype of the components in the attribute
  66640. */
  66641. const enum AccessorComponentType {
  66642. /**
  66643. * Byte
  66644. */
  66645. BYTE = 5120,
  66646. /**
  66647. * Unsigned Byte
  66648. */
  66649. UNSIGNED_BYTE = 5121,
  66650. /**
  66651. * Short
  66652. */
  66653. SHORT = 5122,
  66654. /**
  66655. * Unsigned Short
  66656. */
  66657. UNSIGNED_SHORT = 5123,
  66658. /**
  66659. * Unsigned Int
  66660. */
  66661. UNSIGNED_INT = 5125,
  66662. /**
  66663. * Float
  66664. */
  66665. FLOAT = 5126,
  66666. }
  66667. /**
  66668. * Specifies if the attirbute is a scalar, vector, or matrix
  66669. */
  66670. const enum AccessorType {
  66671. /**
  66672. * Scalar
  66673. */
  66674. SCALAR = "SCALAR",
  66675. /**
  66676. * Vector2
  66677. */
  66678. VEC2 = "VEC2",
  66679. /**
  66680. * Vector3
  66681. */
  66682. VEC3 = "VEC3",
  66683. /**
  66684. * Vector4
  66685. */
  66686. VEC4 = "VEC4",
  66687. /**
  66688. * Matrix2x2
  66689. */
  66690. MAT2 = "MAT2",
  66691. /**
  66692. * Matrix3x3
  66693. */
  66694. MAT3 = "MAT3",
  66695. /**
  66696. * Matrix4x4
  66697. */
  66698. MAT4 = "MAT4",
  66699. }
  66700. /**
  66701. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  66702. */
  66703. const enum AnimationChannelTargetPath {
  66704. /**
  66705. * Translation
  66706. */
  66707. TRANSLATION = "translation",
  66708. /**
  66709. * Rotation
  66710. */
  66711. ROTATION = "rotation",
  66712. /**
  66713. * Scale
  66714. */
  66715. SCALE = "scale",
  66716. /**
  66717. * Weights
  66718. */
  66719. WEIGHTS = "weights",
  66720. }
  66721. /**
  66722. * Interpolation algorithm
  66723. */
  66724. const enum AnimationSamplerInterpolation {
  66725. /**
  66726. * The animated values are linearly interpolated between keyframes
  66727. */
  66728. LINEAR = "LINEAR",
  66729. /**
  66730. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  66731. */
  66732. STEP = "STEP",
  66733. /**
  66734. * The animation's interpolation is computed using a cubic spline with specified tangents
  66735. */
  66736. CUBICSPLINE = "CUBICSPLINE",
  66737. }
  66738. /**
  66739. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  66740. */
  66741. const enum CameraType {
  66742. /**
  66743. * A perspective camera containing properties to create a perspective projection matrix
  66744. */
  66745. PERSPECTIVE = "perspective",
  66746. /**
  66747. * An orthographic camera containing properties to create an orthographic projection matrix
  66748. */
  66749. ORTHOGRAPHIC = "orthographic",
  66750. }
  66751. /**
  66752. * The mime-type of the image
  66753. */
  66754. const enum ImageMimeType {
  66755. /**
  66756. * JPEG Mime-type
  66757. */
  66758. JPEG = "image/jpeg",
  66759. /**
  66760. * PNG Mime-type
  66761. */
  66762. PNG = "image/png",
  66763. }
  66764. /**
  66765. * The alpha rendering mode of the material
  66766. */
  66767. const enum MaterialAlphaMode {
  66768. /**
  66769. * The alpha value is ignored and the rendered output is fully opaque
  66770. */
  66771. OPAQUE = "OPAQUE",
  66772. /**
  66773. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  66774. */
  66775. MASK = "MASK",
  66776. /**
  66777. * 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)
  66778. */
  66779. BLEND = "BLEND",
  66780. }
  66781. /**
  66782. * The type of the primitives to render
  66783. */
  66784. const enum MeshPrimitiveMode {
  66785. /**
  66786. * Points
  66787. */
  66788. POINTS = 0,
  66789. /**
  66790. * Lines
  66791. */
  66792. LINES = 1,
  66793. /**
  66794. * Line Loop
  66795. */
  66796. LINE_LOOP = 2,
  66797. /**
  66798. * Line Strip
  66799. */
  66800. LINE_STRIP = 3,
  66801. /**
  66802. * Triangles
  66803. */
  66804. TRIANGLES = 4,
  66805. /**
  66806. * Triangle Strip
  66807. */
  66808. TRIANGLE_STRIP = 5,
  66809. /**
  66810. * Triangle Fan
  66811. */
  66812. TRIANGLE_FAN = 6,
  66813. }
  66814. /**
  66815. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  66816. */
  66817. const enum TextureMagFilter {
  66818. /**
  66819. * Nearest
  66820. */
  66821. NEAREST = 9728,
  66822. /**
  66823. * Linear
  66824. */
  66825. LINEAR = 9729,
  66826. }
  66827. /**
  66828. * Minification filter. All valid values correspond to WebGL enums
  66829. */
  66830. const enum TextureMinFilter {
  66831. /**
  66832. * Nearest
  66833. */
  66834. NEAREST = 9728,
  66835. /**
  66836. * Linear
  66837. */
  66838. LINEAR = 9729,
  66839. /**
  66840. * Nearest Mip-Map Nearest
  66841. */
  66842. NEAREST_MIPMAP_NEAREST = 9984,
  66843. /**
  66844. * Linear Mipmap Nearest
  66845. */
  66846. LINEAR_MIPMAP_NEAREST = 9985,
  66847. /**
  66848. * Nearest Mipmap Linear
  66849. */
  66850. NEAREST_MIPMAP_LINEAR = 9986,
  66851. /**
  66852. * Linear Mipmap Linear
  66853. */
  66854. LINEAR_MIPMAP_LINEAR = 9987,
  66855. }
  66856. /**
  66857. * S (U) wrapping mode. All valid values correspond to WebGL enums
  66858. */
  66859. const enum TextureWrapMode {
  66860. /**
  66861. * Clamp to Edge
  66862. */
  66863. CLAMP_TO_EDGE = 33071,
  66864. /**
  66865. * Mirrored Repeat
  66866. */
  66867. MIRRORED_REPEAT = 33648,
  66868. /**
  66869. * Repeat
  66870. */
  66871. REPEAT = 10497,
  66872. }
  66873. /**
  66874. * glTF Property
  66875. */
  66876. interface IProperty {
  66877. /**
  66878. * Dictionary object with extension-specific objects
  66879. */
  66880. extensions?: {
  66881. [key: string]: any;
  66882. };
  66883. /**
  66884. * Application-Specific data
  66885. */
  66886. extras?: any;
  66887. }
  66888. /**
  66889. * glTF Child of Root Property
  66890. */
  66891. interface IChildRootProperty extends IProperty {
  66892. /**
  66893. * The user-defined name of this object
  66894. */
  66895. name?: string;
  66896. }
  66897. /**
  66898. * Indices of those attributes that deviate from their initialization value
  66899. */
  66900. interface IAccessorSparseIndices extends IProperty {
  66901. /**
  66902. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  66903. */
  66904. bufferView: number;
  66905. /**
  66906. * The offset relative to the start of the bufferView in bytes. Must be aligned
  66907. */
  66908. byteOffset?: number;
  66909. /**
  66910. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  66911. */
  66912. componentType: AccessorComponentType;
  66913. }
  66914. /**
  66915. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  66916. */
  66917. interface IAccessorSparseValues extends IProperty {
  66918. /**
  66919. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  66920. */
  66921. bufferView: number;
  66922. /**
  66923. * The offset relative to the start of the bufferView in bytes. Must be aligned
  66924. */
  66925. byteOffset?: number;
  66926. }
  66927. /**
  66928. * Sparse storage of attributes that deviate from their initialization value
  66929. */
  66930. interface IAccessorSparse extends IProperty {
  66931. /**
  66932. * The number of attributes encoded in this sparse accessor
  66933. */
  66934. count: number;
  66935. /**
  66936. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  66937. */
  66938. indices: IAccessorSparseIndices;
  66939. /**
  66940. * 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
  66941. */
  66942. values: IAccessorSparseValues;
  66943. }
  66944. /**
  66945. * 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
  66946. */
  66947. interface IAccessor extends IChildRootProperty {
  66948. /**
  66949. * The index of the bufferview
  66950. */
  66951. bufferView?: number;
  66952. /**
  66953. * The offset relative to the start of the bufferView in bytes
  66954. */
  66955. byteOffset?: number;
  66956. /**
  66957. * The datatype of components in the attribute
  66958. */
  66959. componentType: AccessorComponentType;
  66960. /**
  66961. * Specifies whether integer data values should be normalized
  66962. */
  66963. normalized?: boolean;
  66964. /**
  66965. * The number of attributes referenced by this accessor
  66966. */
  66967. count: number;
  66968. /**
  66969. * Specifies if the attribute is a scalar, vector, or matrix
  66970. */
  66971. type: AccessorType;
  66972. /**
  66973. * Maximum value of each component in this attribute
  66974. */
  66975. max?: number[];
  66976. /**
  66977. * Minimum value of each component in this attribute
  66978. */
  66979. min?: number[];
  66980. /**
  66981. * Sparse storage of attributes that deviate from their initialization value
  66982. */
  66983. sparse?: IAccessorSparse;
  66984. }
  66985. /**
  66986. * Targets an animation's sampler at a node's property
  66987. */
  66988. interface IAnimationChannel extends IProperty {
  66989. /**
  66990. * The index of a sampler in this animation used to compute the value for the target
  66991. */
  66992. sampler: number;
  66993. /**
  66994. * The index of the node and TRS property to target
  66995. */
  66996. target: IAnimationChannelTarget;
  66997. }
  66998. /**
  66999. * The index of the node and TRS property that an animation channel targets
  67000. */
  67001. interface IAnimationChannelTarget extends IProperty {
  67002. /**
  67003. * The index of the node to target
  67004. */
  67005. node: number;
  67006. /**
  67007. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  67008. */
  67009. path: AnimationChannelTargetPath;
  67010. }
  67011. /**
  67012. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  67013. */
  67014. interface IAnimationSampler extends IProperty {
  67015. /**
  67016. * The index of an accessor containing keyframe input values, e.g., time
  67017. */
  67018. input: number;
  67019. /**
  67020. * Interpolation algorithm
  67021. */
  67022. interpolation?: AnimationSamplerInterpolation;
  67023. /**
  67024. * The index of an accessor, containing keyframe output values
  67025. */
  67026. output: number;
  67027. }
  67028. /**
  67029. * A keyframe animation
  67030. */
  67031. interface IAnimation extends IChildRootProperty {
  67032. /**
  67033. * An array of channels, each of which targets an animation's sampler at a node's property
  67034. */
  67035. channels: IAnimationChannel[];
  67036. /**
  67037. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  67038. */
  67039. samplers: IAnimationSampler[];
  67040. }
  67041. /**
  67042. * Metadata about the glTF asset
  67043. */
  67044. interface IAsset extends IChildRootProperty {
  67045. /**
  67046. * A copyright message suitable for display to credit the content creator
  67047. */
  67048. copyright?: string;
  67049. /**
  67050. * Tool that generated this glTF model. Useful for debugging
  67051. */
  67052. generator?: string;
  67053. /**
  67054. * The glTF version that this asset targets
  67055. */
  67056. version: string;
  67057. /**
  67058. * The minimum glTF version that this asset targets
  67059. */
  67060. minVersion?: string;
  67061. }
  67062. /**
  67063. * A buffer points to binary geometry, animation, or skins
  67064. */
  67065. interface IBuffer extends IChildRootProperty {
  67066. /**
  67067. * 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
  67068. */
  67069. uri?: string;
  67070. /**
  67071. * The length of the buffer in bytes
  67072. */
  67073. byteLength: number;
  67074. }
  67075. /**
  67076. * A view into a buffer generally representing a subset of the buffer
  67077. */
  67078. interface IBufferView extends IChildRootProperty {
  67079. /**
  67080. * The index of the buffer
  67081. */
  67082. buffer: number;
  67083. /**
  67084. * The offset into the buffer in bytes
  67085. */
  67086. byteOffset?: number;
  67087. /**
  67088. * The lenth of the bufferView in bytes
  67089. */
  67090. byteLength: number;
  67091. /**
  67092. * The stride, in bytes
  67093. */
  67094. byteStride?: number;
  67095. }
  67096. /**
  67097. * An orthographic camera containing properties to create an orthographic projection matrix
  67098. */
  67099. interface ICameraOrthographic extends IProperty {
  67100. /**
  67101. * The floating-point horizontal magnification of the view. Must not be zero
  67102. */
  67103. xmag: number;
  67104. /**
  67105. * The floating-point vertical magnification of the view. Must not be zero
  67106. */
  67107. ymag: number;
  67108. /**
  67109. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  67110. */
  67111. zfar: number;
  67112. /**
  67113. * The floating-point distance to the near clipping plane
  67114. */
  67115. znear: number;
  67116. }
  67117. /**
  67118. * A perspective camera containing properties to create a perspective projection matrix
  67119. */
  67120. interface ICameraPerspective extends IProperty {
  67121. /**
  67122. * The floating-point aspect ratio of the field of view
  67123. */
  67124. aspectRatio?: number;
  67125. /**
  67126. * The floating-point vertical field of view in radians
  67127. */
  67128. yfov: number;
  67129. /**
  67130. * The floating-point distance to the far clipping plane
  67131. */
  67132. zfar?: number;
  67133. /**
  67134. * The floating-point distance to the near clipping plane
  67135. */
  67136. znear: number;
  67137. }
  67138. /**
  67139. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  67140. */
  67141. interface ICamera extends IChildRootProperty {
  67142. /**
  67143. * An orthographic camera containing properties to create an orthographic projection matrix
  67144. */
  67145. orthographic?: ICameraOrthographic;
  67146. /**
  67147. * A perspective camera containing properties to create a perspective projection matrix
  67148. */
  67149. perspective?: ICameraPerspective;
  67150. /**
  67151. * Specifies if the camera uses a perspective or orthographic projection
  67152. */
  67153. type: CameraType;
  67154. }
  67155. /**
  67156. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  67157. */
  67158. interface IImage extends IChildRootProperty {
  67159. /**
  67160. * 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
  67161. */
  67162. uri?: string;
  67163. /**
  67164. * The image's MIME type
  67165. */
  67166. mimeType?: ImageMimeType;
  67167. /**
  67168. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  67169. */
  67170. bufferView?: number;
  67171. }
  67172. /**
  67173. * Material Normal Texture Info
  67174. */
  67175. interface IMaterialNormalTextureInfo extends ITextureInfo {
  67176. /**
  67177. * The scalar multiplier applied to each normal vector of the normal texture
  67178. */
  67179. scale?: number;
  67180. }
  67181. /**
  67182. * Material Occlusion Texture Info
  67183. */
  67184. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  67185. /**
  67186. * A scalar multiplier controlling the amount of occlusion applied
  67187. */
  67188. strength?: number;
  67189. }
  67190. /**
  67191. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  67192. */
  67193. interface IMaterialPbrMetallicRoughness {
  67194. /**
  67195. * The material's base color factor
  67196. */
  67197. baseColorFactor?: number[];
  67198. /**
  67199. * The base color texture
  67200. */
  67201. baseColorTexture?: ITextureInfo;
  67202. /**
  67203. * The metalness of the material
  67204. */
  67205. metallicFactor?: number;
  67206. /**
  67207. * The roughness of the material
  67208. */
  67209. roughnessFactor?: number;
  67210. /**
  67211. * The metallic-roughness texture
  67212. */
  67213. metallicRoughnessTexture?: ITextureInfo;
  67214. }
  67215. /**
  67216. * The material appearance of a primitive
  67217. */
  67218. interface IMaterial extends IChildRootProperty {
  67219. /**
  67220. * 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
  67221. */
  67222. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  67223. /**
  67224. * The normal map texture
  67225. */
  67226. normalTexture?: IMaterialNormalTextureInfo;
  67227. /**
  67228. * The occlusion map texture
  67229. */
  67230. occlusionTexture?: IMaterialOcclusionTextureInfo;
  67231. /**
  67232. * The emissive map texture
  67233. */
  67234. emissiveTexture?: ITextureInfo;
  67235. /**
  67236. * 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
  67237. */
  67238. emissiveFactor?: number[];
  67239. /**
  67240. * The alpha rendering mode of the material
  67241. */
  67242. alphaMode?: MaterialAlphaMode;
  67243. /**
  67244. * The alpha cutoff value of the material
  67245. */
  67246. alphaCutoff?: number;
  67247. /**
  67248. * Specifies whether the material is double sided
  67249. */
  67250. doubleSided?: boolean;
  67251. }
  67252. /**
  67253. * Geometry to be rendered with the given material
  67254. */
  67255. interface IMeshPrimitive extends IProperty {
  67256. /**
  67257. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  67258. */
  67259. attributes: {
  67260. [name: string]: number;
  67261. };
  67262. /**
  67263. * The index of the accessor that contains the indices
  67264. */
  67265. indices?: number;
  67266. /**
  67267. * The index of the material to apply to this primitive when rendering
  67268. */
  67269. material?: number;
  67270. /**
  67271. * The type of primitives to render. All valid values correspond to WebGL enums
  67272. */
  67273. mode?: MeshPrimitiveMode;
  67274. /**
  67275. * 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
  67276. */
  67277. targets?: {
  67278. [name: string]: number;
  67279. }[];
  67280. }
  67281. /**
  67282. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  67283. */
  67284. interface IMesh extends IChildRootProperty {
  67285. /**
  67286. * An array of primitives, each defining geometry to be rendered with a material
  67287. */
  67288. primitives: IMeshPrimitive[];
  67289. /**
  67290. * Array of weights to be applied to the Morph Targets
  67291. */
  67292. weights?: number[];
  67293. }
  67294. /**
  67295. * A node in the node hierarchy
  67296. */
  67297. interface INode extends IChildRootProperty {
  67298. /**
  67299. * The index of the camera referenced by this node
  67300. */
  67301. camera?: number;
  67302. /**
  67303. * The indices of this node's children
  67304. */
  67305. children?: number[];
  67306. /**
  67307. * The index of the skin referenced by this node
  67308. */
  67309. skin?: number;
  67310. /**
  67311. * A floating-point 4x4 transformation matrix stored in column-major order
  67312. */
  67313. matrix?: number[];
  67314. /**
  67315. * The index of the mesh in this node
  67316. */
  67317. mesh?: number;
  67318. /**
  67319. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  67320. */
  67321. rotation?: number[];
  67322. /**
  67323. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  67324. */
  67325. scale?: number[];
  67326. /**
  67327. * The node's translation along the x, y, and z axes
  67328. */
  67329. translation?: number[];
  67330. /**
  67331. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  67332. */
  67333. weights?: number[];
  67334. }
  67335. /**
  67336. * Texture sampler properties for filtering and wrapping modes
  67337. */
  67338. interface ISampler extends IChildRootProperty {
  67339. /**
  67340. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  67341. */
  67342. magFilter?: TextureMagFilter;
  67343. /**
  67344. * Minification filter. All valid values correspond to WebGL enums
  67345. */
  67346. minFilter?: TextureMinFilter;
  67347. /**
  67348. * S (U) wrapping mode. All valid values correspond to WebGL enums
  67349. */
  67350. wrapS?: TextureWrapMode;
  67351. /**
  67352. * T (V) wrapping mode. All valid values correspond to WebGL enums
  67353. */
  67354. wrapT?: TextureWrapMode;
  67355. }
  67356. /**
  67357. * The root nodes of a scene
  67358. */
  67359. interface IScene extends IChildRootProperty {
  67360. /**
  67361. * The indices of each root node
  67362. */
  67363. nodes: number[];
  67364. }
  67365. /**
  67366. * Joints and matrices defining a skin
  67367. */
  67368. interface ISkin extends IChildRootProperty {
  67369. /**
  67370. * 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
  67371. */
  67372. inverseBindMatrices?: number;
  67373. /**
  67374. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  67375. */
  67376. skeleton?: number;
  67377. /**
  67378. * 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)
  67379. */
  67380. joints: number[];
  67381. }
  67382. /**
  67383. * A texture and its sampler
  67384. */
  67385. interface ITexture extends IChildRootProperty {
  67386. /**
  67387. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  67388. */
  67389. sampler?: number;
  67390. /**
  67391. * The index of the image used by this texture
  67392. */
  67393. source: number;
  67394. }
  67395. /**
  67396. * Reference to a texture
  67397. */
  67398. interface ITextureInfo extends IProperty {
  67399. /**
  67400. * The index of the texture
  67401. */
  67402. index: number;
  67403. /**
  67404. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  67405. */
  67406. texCoord?: number;
  67407. }
  67408. /**
  67409. * The root object for a glTF asset
  67410. */
  67411. interface IGLTF extends IProperty {
  67412. /**
  67413. * An array of accessors. An accessor is a typed view into a bufferView
  67414. */
  67415. accessors?: IAccessor[];
  67416. /**
  67417. * An array of keyframe animations
  67418. */
  67419. animations?: IAnimation[];
  67420. /**
  67421. * Metadata about the glTF asset
  67422. */
  67423. asset: IAsset;
  67424. /**
  67425. * An array of buffers. A buffer points to binary geometry, animation, or skins
  67426. */
  67427. buffers?: IBuffer[];
  67428. /**
  67429. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  67430. */
  67431. bufferViews?: IBufferView[];
  67432. /**
  67433. * An array of cameras
  67434. */
  67435. cameras?: ICamera[];
  67436. /**
  67437. * Names of glTF extensions used somewhere in this asset
  67438. */
  67439. extensionsUsed?: string[];
  67440. /**
  67441. * Names of glTF extensions required to properly load this asset
  67442. */
  67443. extensionsRequired?: string[];
  67444. /**
  67445. * An array of images. An image defines data used to create a texture
  67446. */
  67447. images?: IImage[];
  67448. /**
  67449. * An array of materials. A material defines the appearance of a primitive
  67450. */
  67451. materials?: IMaterial[];
  67452. /**
  67453. * An array of meshes. A mesh is a set of primitives to be rendered
  67454. */
  67455. meshes?: IMesh[];
  67456. /**
  67457. * An array of nodes
  67458. */
  67459. nodes?: INode[];
  67460. /**
  67461. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  67462. */
  67463. samplers?: ISampler[];
  67464. /**
  67465. * The index of the default scene
  67466. */
  67467. scene?: number;
  67468. /**
  67469. * An array of scenes
  67470. */
  67471. scenes?: IScene[];
  67472. /**
  67473. * An array of skins. A skin is defined by joints and matrices
  67474. */
  67475. skins?: ISkin[];
  67476. /**
  67477. * An array of textures
  67478. */
  67479. textures?: ITexture[];
  67480. }
  67481. /**
  67482. * The glTF validation results
  67483. */
  67484. interface IGLTFValidationResults {
  67485. info: {
  67486. generator: string;
  67487. hasAnimations: boolean;
  67488. hasDefaultScene: boolean;
  67489. hasMaterials: boolean;
  67490. hasMorphTargets: boolean;
  67491. hasSkins: boolean;
  67492. hasTextures: boolean;
  67493. maxAttributesUsed: number;
  67494. primitivesCount: number
  67495. };
  67496. issues: {
  67497. messages: Array<string>;
  67498. numErrors: number;
  67499. numHints: number;
  67500. numInfos: number;
  67501. numWarnings: number;
  67502. truncated: boolean
  67503. };
  67504. mimeType: string;
  67505. uri: string;
  67506. validatedAt: string;
  67507. validatorVersion: string;
  67508. }
  67509. /**
  67510. * The glTF validation options
  67511. */
  67512. interface IGLTFValidationOptions {
  67513. uri?: string;
  67514. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  67515. validateAccessorData?: boolean;
  67516. maxIssues?: number;
  67517. ignoredIssues?: Array<string>;
  67518. severityOverrides?: Object;
  67519. }
  67520. /**
  67521. * The glTF validator object
  67522. */
  67523. interface IGLTFValidator {
  67524. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  67525. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  67526. }
  67527. }
  67528. declare module BABYLON {
  67529. /** @hidden */
  67530. export var cellPixelShader: {
  67531. name: string;
  67532. shader: string;
  67533. };
  67534. }
  67535. declare module BABYLON {
  67536. /** @hidden */
  67537. export var cellVertexShader: {
  67538. name: string;
  67539. shader: string;
  67540. };
  67541. }
  67542. declare module BABYLON {
  67543. export class CellMaterial extends BABYLON.PushMaterial {
  67544. private _diffuseTexture;
  67545. diffuseTexture: BABYLON.BaseTexture;
  67546. diffuseColor: BABYLON.Color3;
  67547. _computeHighLevel: boolean;
  67548. computeHighLevel: boolean;
  67549. private _disableLighting;
  67550. disableLighting: boolean;
  67551. private _maxSimultaneousLights;
  67552. maxSimultaneousLights: number;
  67553. private _renderId;
  67554. constructor(name: string, scene: BABYLON.Scene);
  67555. needAlphaBlending(): boolean;
  67556. needAlphaTesting(): boolean;
  67557. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67558. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67559. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67560. getAnimatables(): BABYLON.IAnimatable[];
  67561. getActiveTextures(): BABYLON.BaseTexture[];
  67562. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67563. dispose(forceDisposeEffect?: boolean): void;
  67564. getClassName(): string;
  67565. clone(name: string): CellMaterial;
  67566. serialize(): any;
  67567. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  67568. }
  67569. }
  67570. declare module BABYLON {
  67571. export class CustomShaderStructure {
  67572. FragmentStore: string;
  67573. VertexStore: string;
  67574. constructor();
  67575. }
  67576. export class ShaderSpecialParts {
  67577. constructor();
  67578. Fragment_Begin: string;
  67579. Fragment_Definitions: string;
  67580. Fragment_MainBegin: string;
  67581. Fragment_Custom_Diffuse: string;
  67582. Fragment_Before_Lights: string;
  67583. Fragment_Before_Fog: string;
  67584. Fragment_Custom_Alpha: string;
  67585. Fragment_Before_FragColor: string;
  67586. Vertex_Begin: string;
  67587. Vertex_Definitions: string;
  67588. Vertex_MainBegin: string;
  67589. Vertex_Before_PositionUpdated: string;
  67590. Vertex_Before_NormalUpdated: string;
  67591. Vertex_MainEnd: string;
  67592. }
  67593. export class CustomMaterial extends BABYLON.StandardMaterial {
  67594. static ShaderIndexer: number;
  67595. CustomParts: ShaderSpecialParts;
  67596. _isCreatedShader: boolean;
  67597. _createdShaderName: string;
  67598. _customUniform: string[];
  67599. _newUniforms: string[];
  67600. _newUniformInstances: any[];
  67601. _newSamplerInstances: BABYLON.Texture[];
  67602. FragmentShader: string;
  67603. VertexShader: string;
  67604. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  67605. ReviewUniform(name: string, arr: string[]): string[];
  67606. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  67607. constructor(name: string, scene: BABYLON.Scene);
  67608. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  67609. Fragment_Begin(shaderPart: string): CustomMaterial;
  67610. Fragment_Definitions(shaderPart: string): CustomMaterial;
  67611. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  67612. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  67613. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  67614. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  67615. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  67616. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  67617. Vertex_Begin(shaderPart: string): CustomMaterial;
  67618. Vertex_Definitions(shaderPart: string): CustomMaterial;
  67619. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  67620. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  67621. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  67622. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  67623. }
  67624. }
  67625. declare module BABYLON {
  67626. export class ShaderAlebdoParts {
  67627. constructor();
  67628. Fragment_Begin: string;
  67629. Fragment_Definitions: string;
  67630. Fragment_MainBegin: string;
  67631. Fragment_Custom_Albedo: string;
  67632. Fragment_Before_Lights: string;
  67633. Fragment_Custom_MetallicRoughness: string;
  67634. Fragment_Custom_MicroSurface: string;
  67635. Fragment_Before_Fog: string;
  67636. Fragment_Custom_Alpha: string;
  67637. Fragment_Before_FragColor: string;
  67638. Vertex_Begin: string;
  67639. Vertex_Definitions: string;
  67640. Vertex_MainBegin: string;
  67641. Vertex_Before_PositionUpdated: string;
  67642. Vertex_Before_NormalUpdated: string;
  67643. Vertex_MainEnd: string;
  67644. }
  67645. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  67646. static ShaderIndexer: number;
  67647. CustomParts: ShaderAlebdoParts;
  67648. _isCreatedShader: boolean;
  67649. _createdShaderName: string;
  67650. _customUniform: string[];
  67651. _newUniforms: string[];
  67652. _newUniformInstances: any[];
  67653. _newSamplerInstances: BABYLON.Texture[];
  67654. FragmentShader: string;
  67655. VertexShader: string;
  67656. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  67657. ReviewUniform(name: string, arr: string[]): string[];
  67658. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  67659. constructor(name: string, scene: BABYLON.Scene);
  67660. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  67661. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  67662. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  67663. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  67664. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  67665. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  67666. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  67667. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  67668. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  67669. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  67670. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  67671. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  67672. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  67673. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  67674. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  67675. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  67676. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  67677. }
  67678. }
  67679. declare module BABYLON {
  67680. /** @hidden */
  67681. export var firePixelShader: {
  67682. name: string;
  67683. shader: string;
  67684. };
  67685. }
  67686. declare module BABYLON {
  67687. /** @hidden */
  67688. export var fireVertexShader: {
  67689. name: string;
  67690. shader: string;
  67691. };
  67692. }
  67693. declare module BABYLON {
  67694. export class FireMaterial extends BABYLON.PushMaterial {
  67695. private _diffuseTexture;
  67696. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67697. private _distortionTexture;
  67698. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67699. private _opacityTexture;
  67700. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67701. diffuseColor: BABYLON.Color3;
  67702. speed: number;
  67703. private _scaledDiffuse;
  67704. private _renderId;
  67705. private _lastTime;
  67706. constructor(name: string, scene: BABYLON.Scene);
  67707. needAlphaBlending(): boolean;
  67708. needAlphaTesting(): boolean;
  67709. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67710. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67711. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67712. getAnimatables(): BABYLON.IAnimatable[];
  67713. getActiveTextures(): BABYLON.BaseTexture[];
  67714. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67715. getClassName(): string;
  67716. dispose(forceDisposeEffect?: boolean): void;
  67717. clone(name: string): FireMaterial;
  67718. serialize(): any;
  67719. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  67720. }
  67721. }
  67722. declare module BABYLON {
  67723. /** @hidden */
  67724. export var furPixelShader: {
  67725. name: string;
  67726. shader: string;
  67727. };
  67728. }
  67729. declare module BABYLON {
  67730. /** @hidden */
  67731. export var furVertexShader: {
  67732. name: string;
  67733. shader: string;
  67734. };
  67735. }
  67736. declare module BABYLON {
  67737. export class FurMaterial extends BABYLON.PushMaterial {
  67738. private _diffuseTexture;
  67739. diffuseTexture: BABYLON.BaseTexture;
  67740. private _heightTexture;
  67741. heightTexture: BABYLON.BaseTexture;
  67742. diffuseColor: BABYLON.Color3;
  67743. furLength: number;
  67744. furAngle: number;
  67745. furColor: BABYLON.Color3;
  67746. furOffset: number;
  67747. furSpacing: number;
  67748. furGravity: BABYLON.Vector3;
  67749. furSpeed: number;
  67750. furDensity: number;
  67751. furOcclusion: number;
  67752. furTexture: BABYLON.DynamicTexture;
  67753. private _disableLighting;
  67754. disableLighting: boolean;
  67755. private _maxSimultaneousLights;
  67756. maxSimultaneousLights: number;
  67757. highLevelFur: boolean;
  67758. _meshes: BABYLON.AbstractMesh[];
  67759. private _renderId;
  67760. private _furTime;
  67761. constructor(name: string, scene: BABYLON.Scene);
  67762. furTime: number;
  67763. needAlphaBlending(): boolean;
  67764. needAlphaTesting(): boolean;
  67765. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67766. updateFur(): void;
  67767. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67768. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67769. getAnimatables(): BABYLON.IAnimatable[];
  67770. getActiveTextures(): BABYLON.BaseTexture[];
  67771. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67772. dispose(forceDisposeEffect?: boolean): void;
  67773. clone(name: string): FurMaterial;
  67774. serialize(): any;
  67775. getClassName(): string;
  67776. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  67777. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  67778. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  67779. }
  67780. }
  67781. declare module BABYLON {
  67782. /** @hidden */
  67783. export var gradientPixelShader: {
  67784. name: string;
  67785. shader: string;
  67786. };
  67787. }
  67788. declare module BABYLON {
  67789. /** @hidden */
  67790. export var gradientVertexShader: {
  67791. name: string;
  67792. shader: string;
  67793. };
  67794. }
  67795. declare module BABYLON {
  67796. export class GradientMaterial extends BABYLON.PushMaterial {
  67797. private _maxSimultaneousLights;
  67798. maxSimultaneousLights: number;
  67799. topColor: BABYLON.Color3;
  67800. topColorAlpha: number;
  67801. bottomColor: BABYLON.Color3;
  67802. bottomColorAlpha: number;
  67803. offset: number;
  67804. scale: number;
  67805. smoothness: number;
  67806. private _disableLighting;
  67807. disableLighting: boolean;
  67808. private _renderId;
  67809. constructor(name: string, scene: BABYLON.Scene);
  67810. needAlphaBlending(): boolean;
  67811. needAlphaTesting(): boolean;
  67812. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67813. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67814. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67815. getAnimatables(): BABYLON.IAnimatable[];
  67816. dispose(forceDisposeEffect?: boolean): void;
  67817. clone(name: string): GradientMaterial;
  67818. serialize(): any;
  67819. getClassName(): string;
  67820. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  67821. }
  67822. }
  67823. declare module BABYLON {
  67824. /** @hidden */
  67825. export var gridPixelShader: {
  67826. name: string;
  67827. shader: string;
  67828. };
  67829. }
  67830. declare module BABYLON {
  67831. /** @hidden */
  67832. export var gridVertexShader: {
  67833. name: string;
  67834. shader: string;
  67835. };
  67836. }
  67837. declare module BABYLON {
  67838. /**
  67839. * The grid materials allows you to wrap any shape with a grid.
  67840. * Colors are customizable.
  67841. */
  67842. export class GridMaterial extends BABYLON.PushMaterial {
  67843. /**
  67844. * Main color of the grid (e.g. between lines)
  67845. */
  67846. mainColor: BABYLON.Color3;
  67847. /**
  67848. * Color of the grid lines.
  67849. */
  67850. lineColor: BABYLON.Color3;
  67851. /**
  67852. * The scale of the grid compared to unit.
  67853. */
  67854. gridRatio: number;
  67855. /**
  67856. * Allows setting an offset for the grid lines.
  67857. */
  67858. gridOffset: BABYLON.Vector3;
  67859. /**
  67860. * The frequency of thicker lines.
  67861. */
  67862. majorUnitFrequency: number;
  67863. /**
  67864. * The visibility of minor units in the grid.
  67865. */
  67866. minorUnitVisibility: number;
  67867. /**
  67868. * The grid opacity outside of the lines.
  67869. */
  67870. opacity: number;
  67871. /**
  67872. * Determine RBG output is premultiplied by alpha value.
  67873. */
  67874. preMultiplyAlpha: boolean;
  67875. private _opacityTexture;
  67876. opacityTexture: BABYLON.BaseTexture;
  67877. private _gridControl;
  67878. private _renderId;
  67879. /**
  67880. * constructor
  67881. * @param name The name given to the material in order to identify it afterwards.
  67882. * @param scene The scene the material is used in.
  67883. */
  67884. constructor(name: string, scene: BABYLON.Scene);
  67885. /**
  67886. * Returns wehter or not the grid requires alpha blending.
  67887. */
  67888. needAlphaBlending(): boolean;
  67889. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  67890. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67891. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67892. /**
  67893. * Dispose the material and its associated resources.
  67894. * @param forceDisposeEffect will also dispose the used effect when true
  67895. */
  67896. dispose(forceDisposeEffect?: boolean): void;
  67897. clone(name: string): GridMaterial;
  67898. serialize(): any;
  67899. getClassName(): string;
  67900. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  67901. }
  67902. }
  67903. declare module BABYLON {
  67904. /** @hidden */
  67905. export var lavaPixelShader: {
  67906. name: string;
  67907. shader: string;
  67908. };
  67909. }
  67910. declare module BABYLON {
  67911. /** @hidden */
  67912. export var lavaVertexShader: {
  67913. name: string;
  67914. shader: string;
  67915. };
  67916. }
  67917. declare module BABYLON {
  67918. export class LavaMaterial extends BABYLON.PushMaterial {
  67919. private _diffuseTexture;
  67920. diffuseTexture: BABYLON.BaseTexture;
  67921. noiseTexture: BABYLON.BaseTexture;
  67922. fogColor: BABYLON.Color3;
  67923. speed: number;
  67924. movingSpeed: number;
  67925. lowFrequencySpeed: number;
  67926. fogDensity: number;
  67927. private _lastTime;
  67928. diffuseColor: BABYLON.Color3;
  67929. private _disableLighting;
  67930. disableLighting: boolean;
  67931. private _unlit;
  67932. unlit: boolean;
  67933. private _maxSimultaneousLights;
  67934. maxSimultaneousLights: number;
  67935. private _scaledDiffuse;
  67936. private _renderId;
  67937. constructor(name: string, scene: BABYLON.Scene);
  67938. needAlphaBlending(): boolean;
  67939. needAlphaTesting(): boolean;
  67940. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67941. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67942. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67943. getAnimatables(): BABYLON.IAnimatable[];
  67944. getActiveTextures(): BABYLON.BaseTexture[];
  67945. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67946. dispose(forceDisposeEffect?: boolean): void;
  67947. clone(name: string): LavaMaterial;
  67948. serialize(): any;
  67949. getClassName(): string;
  67950. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  67951. }
  67952. }
  67953. declare module BABYLON {
  67954. /** @hidden */
  67955. export var mixPixelShader: {
  67956. name: string;
  67957. shader: string;
  67958. };
  67959. }
  67960. declare module BABYLON {
  67961. /** @hidden */
  67962. export var mixVertexShader: {
  67963. name: string;
  67964. shader: string;
  67965. };
  67966. }
  67967. declare module BABYLON {
  67968. export class MixMaterial extends BABYLON.PushMaterial {
  67969. /**
  67970. * Mix textures
  67971. */
  67972. private _mixTexture1;
  67973. mixTexture1: BABYLON.BaseTexture;
  67974. private _mixTexture2;
  67975. mixTexture2: BABYLON.BaseTexture;
  67976. /**
  67977. * Diffuse textures
  67978. */
  67979. private _diffuseTexture1;
  67980. diffuseTexture1: BABYLON.Texture;
  67981. private _diffuseTexture2;
  67982. diffuseTexture2: BABYLON.Texture;
  67983. private _diffuseTexture3;
  67984. diffuseTexture3: BABYLON.Texture;
  67985. private _diffuseTexture4;
  67986. diffuseTexture4: BABYLON.Texture;
  67987. private _diffuseTexture5;
  67988. diffuseTexture5: BABYLON.Texture;
  67989. private _diffuseTexture6;
  67990. diffuseTexture6: BABYLON.Texture;
  67991. private _diffuseTexture7;
  67992. diffuseTexture7: BABYLON.Texture;
  67993. private _diffuseTexture8;
  67994. diffuseTexture8: BABYLON.Texture;
  67995. /**
  67996. * Uniforms
  67997. */
  67998. diffuseColor: BABYLON.Color3;
  67999. specularColor: BABYLON.Color3;
  68000. specularPower: number;
  68001. private _disableLighting;
  68002. disableLighting: boolean;
  68003. private _maxSimultaneousLights;
  68004. maxSimultaneousLights: number;
  68005. private _renderId;
  68006. constructor(name: string, scene: BABYLON.Scene);
  68007. needAlphaBlending(): boolean;
  68008. needAlphaTesting(): boolean;
  68009. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68010. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68011. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68012. getAnimatables(): BABYLON.IAnimatable[];
  68013. getActiveTextures(): BABYLON.BaseTexture[];
  68014. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68015. dispose(forceDisposeEffect?: boolean): void;
  68016. clone(name: string): MixMaterial;
  68017. serialize(): any;
  68018. getClassName(): string;
  68019. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  68020. }
  68021. }
  68022. declare module BABYLON {
  68023. /** @hidden */
  68024. export var normalPixelShader: {
  68025. name: string;
  68026. shader: string;
  68027. };
  68028. }
  68029. declare module BABYLON {
  68030. /** @hidden */
  68031. export var normalVertexShader: {
  68032. name: string;
  68033. shader: string;
  68034. };
  68035. }
  68036. declare module BABYLON {
  68037. export class NormalMaterial extends BABYLON.PushMaterial {
  68038. private _diffuseTexture;
  68039. diffuseTexture: BABYLON.BaseTexture;
  68040. diffuseColor: BABYLON.Color3;
  68041. private _disableLighting;
  68042. disableLighting: boolean;
  68043. private _maxSimultaneousLights;
  68044. maxSimultaneousLights: number;
  68045. private _renderId;
  68046. constructor(name: string, scene: BABYLON.Scene);
  68047. needAlphaBlending(): boolean;
  68048. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  68049. needAlphaTesting(): boolean;
  68050. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68051. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68052. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68053. getAnimatables(): BABYLON.IAnimatable[];
  68054. getActiveTextures(): BABYLON.BaseTexture[];
  68055. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68056. dispose(forceDisposeEffect?: boolean): void;
  68057. clone(name: string): NormalMaterial;
  68058. serialize(): any;
  68059. getClassName(): string;
  68060. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  68061. }
  68062. }
  68063. declare module BABYLON {
  68064. /** @hidden */
  68065. export var shadowOnlyPixelShader: {
  68066. name: string;
  68067. shader: string;
  68068. };
  68069. }
  68070. declare module BABYLON {
  68071. /** @hidden */
  68072. export var shadowOnlyVertexShader: {
  68073. name: string;
  68074. shader: string;
  68075. };
  68076. }
  68077. declare module BABYLON {
  68078. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  68079. private _renderId;
  68080. private _activeLight;
  68081. constructor(name: string, scene: BABYLON.Scene);
  68082. shadowColor: BABYLON.Color3;
  68083. needAlphaBlending(): boolean;
  68084. needAlphaTesting(): boolean;
  68085. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68086. activeLight: BABYLON.IShadowLight;
  68087. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68088. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68089. clone(name: string): ShadowOnlyMaterial;
  68090. serialize(): any;
  68091. getClassName(): string;
  68092. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  68093. }
  68094. }
  68095. declare module BABYLON {
  68096. /** @hidden */
  68097. export var simplePixelShader: {
  68098. name: string;
  68099. shader: string;
  68100. };
  68101. }
  68102. declare module BABYLON {
  68103. /** @hidden */
  68104. export var simpleVertexShader: {
  68105. name: string;
  68106. shader: string;
  68107. };
  68108. }
  68109. declare module BABYLON {
  68110. export class SimpleMaterial extends BABYLON.PushMaterial {
  68111. private _diffuseTexture;
  68112. diffuseTexture: BABYLON.BaseTexture;
  68113. diffuseColor: BABYLON.Color3;
  68114. private _disableLighting;
  68115. disableLighting: boolean;
  68116. private _maxSimultaneousLights;
  68117. maxSimultaneousLights: number;
  68118. private _renderId;
  68119. constructor(name: string, scene: BABYLON.Scene);
  68120. needAlphaBlending(): boolean;
  68121. needAlphaTesting(): boolean;
  68122. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68123. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68124. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68125. getAnimatables(): BABYLON.IAnimatable[];
  68126. getActiveTextures(): BABYLON.BaseTexture[];
  68127. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68128. dispose(forceDisposeEffect?: boolean): void;
  68129. clone(name: string): SimpleMaterial;
  68130. serialize(): any;
  68131. getClassName(): string;
  68132. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  68133. }
  68134. }
  68135. declare module BABYLON {
  68136. /** @hidden */
  68137. export var skyPixelShader: {
  68138. name: string;
  68139. shader: string;
  68140. };
  68141. }
  68142. declare module BABYLON {
  68143. /** @hidden */
  68144. export var skyVertexShader: {
  68145. name: string;
  68146. shader: string;
  68147. };
  68148. }
  68149. declare module BABYLON {
  68150. /**
  68151. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  68152. * @see https://doc.babylonjs.com/extensions/sky
  68153. */
  68154. export class SkyMaterial extends BABYLON.PushMaterial {
  68155. /**
  68156. * Defines the overall luminance of sky in interval ]0, 1[.
  68157. */
  68158. luminance: number;
  68159. /**
  68160. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  68161. */
  68162. turbidity: number;
  68163. /**
  68164. * Defines the sky appearance (light intensity).
  68165. */
  68166. rayleigh: number;
  68167. /**
  68168. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  68169. */
  68170. mieCoefficient: number;
  68171. /**
  68172. * Defines the amount of haze particles following the Mie scattering theory.
  68173. */
  68174. mieDirectionalG: number;
  68175. /**
  68176. * Defines the distance of the sun according to the active scene camera.
  68177. */
  68178. distance: number;
  68179. /**
  68180. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  68181. * "inclined".
  68182. */
  68183. inclination: number;
  68184. /**
  68185. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  68186. * an object direction and a reference direction.
  68187. */
  68188. azimuth: number;
  68189. /**
  68190. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  68191. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  68192. */
  68193. sunPosition: BABYLON.Vector3;
  68194. /**
  68195. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  68196. * .sunPosition property.
  68197. */
  68198. useSunPosition: boolean;
  68199. /**
  68200. * Defines an offset vector used to get a horizon offset.
  68201. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  68202. */
  68203. cameraOffset: BABYLON.Vector3;
  68204. private _cameraPosition;
  68205. private _renderId;
  68206. /**
  68207. * Instantiates a new sky material.
  68208. * This material allows to create dynamic and texture free
  68209. * effects for skyboxes by taking care of the atmosphere state.
  68210. * @see https://doc.babylonjs.com/extensions/sky
  68211. * @param name Define the name of the material in the scene
  68212. * @param scene Define the scene the material belong to
  68213. */
  68214. constructor(name: string, scene: BABYLON.Scene);
  68215. /**
  68216. * Specifies if the material will require alpha blending
  68217. * @returns a boolean specifying if alpha blending is needed
  68218. */
  68219. needAlphaBlending(): boolean;
  68220. /**
  68221. * Specifies if this material should be rendered in alpha test mode
  68222. * @returns false as the sky material doesn't need alpha testing.
  68223. */
  68224. needAlphaTesting(): boolean;
  68225. /**
  68226. * Get the texture used for alpha test purpose.
  68227. * @returns null as the sky material has no texture.
  68228. */
  68229. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68230. /**
  68231. * Get if the submesh is ready to be used and all its information available.
  68232. * Child classes can use it to update shaders
  68233. * @param mesh defines the mesh to check
  68234. * @param subMesh defines which submesh to check
  68235. * @param useInstances specifies that instances should be used
  68236. * @returns a boolean indicating that the submesh is ready or not
  68237. */
  68238. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68239. /**
  68240. * Binds the submesh to this material by preparing the effect and shader to draw
  68241. * @param world defines the world transformation matrix
  68242. * @param mesh defines the mesh containing the submesh
  68243. * @param subMesh defines the submesh to bind the material to
  68244. */
  68245. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68246. /**
  68247. * Get the list of animatables in the material.
  68248. * @returns the list of animatables object used in the material
  68249. */
  68250. getAnimatables(): BABYLON.IAnimatable[];
  68251. /**
  68252. * Disposes the material
  68253. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  68254. */
  68255. dispose(forceDisposeEffect?: boolean): void;
  68256. /**
  68257. * Makes a duplicate of the material, and gives it a new name
  68258. * @param name defines the new name for the duplicated material
  68259. * @returns the cloned material
  68260. */
  68261. clone(name: string): SkyMaterial;
  68262. /**
  68263. * Serializes this material in a JSON representation
  68264. * @returns the serialized material object
  68265. */
  68266. serialize(): any;
  68267. /**
  68268. * Gets the current class name of the material e.g. "SkyMaterial"
  68269. * Mainly use in serialization.
  68270. * @returns the class name
  68271. */
  68272. getClassName(): string;
  68273. /**
  68274. * Creates a sky material from parsed material data
  68275. * @param source defines the JSON representation of the material
  68276. * @param scene defines the hosting scene
  68277. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68278. * @returns a new sky material
  68279. */
  68280. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  68281. }
  68282. }
  68283. declare module BABYLON {
  68284. /** @hidden */
  68285. export var terrainPixelShader: {
  68286. name: string;
  68287. shader: string;
  68288. };
  68289. }
  68290. declare module BABYLON {
  68291. /** @hidden */
  68292. export var terrainVertexShader: {
  68293. name: string;
  68294. shader: string;
  68295. };
  68296. }
  68297. declare module BABYLON {
  68298. export class TerrainMaterial extends BABYLON.PushMaterial {
  68299. private _mixTexture;
  68300. mixTexture: BABYLON.BaseTexture;
  68301. private _diffuseTexture1;
  68302. diffuseTexture1: BABYLON.Texture;
  68303. private _diffuseTexture2;
  68304. diffuseTexture2: BABYLON.Texture;
  68305. private _diffuseTexture3;
  68306. diffuseTexture3: BABYLON.Texture;
  68307. private _bumpTexture1;
  68308. bumpTexture1: BABYLON.Texture;
  68309. private _bumpTexture2;
  68310. bumpTexture2: BABYLON.Texture;
  68311. private _bumpTexture3;
  68312. bumpTexture3: BABYLON.Texture;
  68313. diffuseColor: BABYLON.Color3;
  68314. specularColor: BABYLON.Color3;
  68315. specularPower: number;
  68316. private _disableLighting;
  68317. disableLighting: boolean;
  68318. private _maxSimultaneousLights;
  68319. maxSimultaneousLights: number;
  68320. private _renderId;
  68321. constructor(name: string, scene: BABYLON.Scene);
  68322. needAlphaBlending(): boolean;
  68323. needAlphaTesting(): boolean;
  68324. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68325. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68326. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68327. getAnimatables(): BABYLON.IAnimatable[];
  68328. getActiveTextures(): BABYLON.BaseTexture[];
  68329. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68330. dispose(forceDisposeEffect?: boolean): void;
  68331. clone(name: string): TerrainMaterial;
  68332. serialize(): any;
  68333. getClassName(): string;
  68334. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  68335. }
  68336. }
  68337. declare module BABYLON {
  68338. /** @hidden */
  68339. export var triplanarPixelShader: {
  68340. name: string;
  68341. shader: string;
  68342. };
  68343. }
  68344. declare module BABYLON {
  68345. /** @hidden */
  68346. export var triplanarVertexShader: {
  68347. name: string;
  68348. shader: string;
  68349. };
  68350. }
  68351. declare module BABYLON {
  68352. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  68353. mixTexture: BABYLON.BaseTexture;
  68354. private _diffuseTextureX;
  68355. diffuseTextureX: BABYLON.BaseTexture;
  68356. private _diffuseTextureY;
  68357. diffuseTextureY: BABYLON.BaseTexture;
  68358. private _diffuseTextureZ;
  68359. diffuseTextureZ: BABYLON.BaseTexture;
  68360. private _normalTextureX;
  68361. normalTextureX: BABYLON.BaseTexture;
  68362. private _normalTextureY;
  68363. normalTextureY: BABYLON.BaseTexture;
  68364. private _normalTextureZ;
  68365. normalTextureZ: BABYLON.BaseTexture;
  68366. tileSize: number;
  68367. diffuseColor: BABYLON.Color3;
  68368. specularColor: BABYLON.Color3;
  68369. specularPower: number;
  68370. private _disableLighting;
  68371. disableLighting: boolean;
  68372. private _maxSimultaneousLights;
  68373. maxSimultaneousLights: number;
  68374. private _renderId;
  68375. constructor(name: string, scene: BABYLON.Scene);
  68376. needAlphaBlending(): boolean;
  68377. needAlphaTesting(): boolean;
  68378. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68379. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68380. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68381. getAnimatables(): BABYLON.IAnimatable[];
  68382. getActiveTextures(): BABYLON.BaseTexture[];
  68383. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68384. dispose(forceDisposeEffect?: boolean): void;
  68385. clone(name: string): TriPlanarMaterial;
  68386. serialize(): any;
  68387. getClassName(): string;
  68388. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  68389. }
  68390. }
  68391. declare module BABYLON {
  68392. /** @hidden */
  68393. export var waterPixelShader: {
  68394. name: string;
  68395. shader: string;
  68396. };
  68397. }
  68398. declare module BABYLON {
  68399. /** @hidden */
  68400. export var waterVertexShader: {
  68401. name: string;
  68402. shader: string;
  68403. };
  68404. }
  68405. declare module BABYLON {
  68406. export class WaterMaterial extends BABYLON.PushMaterial {
  68407. renderTargetSize: BABYLON.Vector2;
  68408. private _bumpTexture;
  68409. bumpTexture: BABYLON.BaseTexture;
  68410. diffuseColor: BABYLON.Color3;
  68411. specularColor: BABYLON.Color3;
  68412. specularPower: number;
  68413. private _disableLighting;
  68414. disableLighting: boolean;
  68415. private _maxSimultaneousLights;
  68416. maxSimultaneousLights: number;
  68417. /**
  68418. * @param {number}: Represents the wind force
  68419. */
  68420. windForce: number;
  68421. /**
  68422. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  68423. */
  68424. windDirection: BABYLON.Vector2;
  68425. /**
  68426. * @param {number}: Wave height, represents the height of the waves
  68427. */
  68428. waveHeight: number;
  68429. /**
  68430. * @param {number}: Bump height, represents the bump height related to the bump map
  68431. */
  68432. bumpHeight: number;
  68433. /**
  68434. * @param {boolean}: Add a smaller moving bump to less steady waves.
  68435. */
  68436. private _bumpSuperimpose;
  68437. bumpSuperimpose: boolean;
  68438. /**
  68439. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  68440. */
  68441. private _fresnelSeparate;
  68442. fresnelSeparate: boolean;
  68443. /**
  68444. * @param {boolean}: bump Waves modify the reflection.
  68445. */
  68446. private _bumpAffectsReflection;
  68447. bumpAffectsReflection: boolean;
  68448. /**
  68449. * @param {number}: The water color blended with the refraction (near)
  68450. */
  68451. waterColor: BABYLON.Color3;
  68452. /**
  68453. * @param {number}: The blend factor related to the water color
  68454. */
  68455. colorBlendFactor: number;
  68456. /**
  68457. * @param {number}: The water color blended with the reflection (far)
  68458. */
  68459. waterColor2: BABYLON.Color3;
  68460. /**
  68461. * @param {number}: The blend factor related to the water color (reflection, far)
  68462. */
  68463. colorBlendFactor2: number;
  68464. /**
  68465. * @param {number}: Represents the maximum length of a wave
  68466. */
  68467. waveLength: number;
  68468. /**
  68469. * @param {number}: Defines the waves speed
  68470. */
  68471. waveSpeed: number;
  68472. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  68473. private _mesh;
  68474. private _refractionRTT;
  68475. private _reflectionRTT;
  68476. private _reflectionTransform;
  68477. private _lastTime;
  68478. private _lastDeltaTime;
  68479. private _renderId;
  68480. private _useLogarithmicDepth;
  68481. private _waitingRenderList;
  68482. /**
  68483. * Gets a boolean indicating that current material needs to register RTT
  68484. */
  68485. readonly hasRenderTargetTextures: boolean;
  68486. /**
  68487. * Constructor
  68488. */
  68489. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  68490. useLogarithmicDepth: boolean;
  68491. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  68492. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  68493. addToRenderList(node: any): void;
  68494. enableRenderTargets(enable: boolean): void;
  68495. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  68496. readonly renderTargetsEnabled: boolean;
  68497. needAlphaBlending(): boolean;
  68498. needAlphaTesting(): boolean;
  68499. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68500. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68501. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68502. private _createRenderTargets;
  68503. getAnimatables(): BABYLON.IAnimatable[];
  68504. getActiveTextures(): BABYLON.BaseTexture[];
  68505. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68506. dispose(forceDisposeEffect?: boolean): void;
  68507. clone(name: string): WaterMaterial;
  68508. serialize(): any;
  68509. getClassName(): string;
  68510. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  68511. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  68512. }
  68513. }
  68514. declare module BABYLON {
  68515. /** @hidden */
  68516. export var asciiartPixelShader: {
  68517. name: string;
  68518. shader: string;
  68519. };
  68520. }
  68521. declare module BABYLON {
  68522. /**
  68523. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  68524. *
  68525. * It basically takes care rendering the font front the given font size to a texture.
  68526. * This is used later on in the postprocess.
  68527. */
  68528. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  68529. private _font;
  68530. private _text;
  68531. private _charSize;
  68532. /**
  68533. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  68534. */
  68535. readonly charSize: number;
  68536. /**
  68537. * Create a new instance of the Ascii Art FontTexture class
  68538. * @param name the name of the texture
  68539. * @param font the font to use, use the W3C CSS notation
  68540. * @param text the caracter set to use in the rendering.
  68541. * @param scene the scene that owns the texture
  68542. */
  68543. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  68544. /**
  68545. * Gets the max char width of a font.
  68546. * @param font the font to use, use the W3C CSS notation
  68547. * @return the max char width
  68548. */
  68549. private getFontWidth;
  68550. /**
  68551. * Gets the max char height of a font.
  68552. * @param font the font to use, use the W3C CSS notation
  68553. * @return the max char height
  68554. */
  68555. private getFontHeight;
  68556. /**
  68557. * Clones the current AsciiArtTexture.
  68558. * @return the clone of the texture.
  68559. */
  68560. clone(): AsciiArtFontTexture;
  68561. /**
  68562. * Parses a json object representing the texture and returns an instance of it.
  68563. * @param source the source JSON representation
  68564. * @param scene the scene to create the texture for
  68565. * @return the parsed texture
  68566. */
  68567. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  68568. }
  68569. /**
  68570. * Option available in the Ascii Art Post Process.
  68571. */
  68572. export interface IAsciiArtPostProcessOptions {
  68573. /**
  68574. * The font to use following the w3c font definition.
  68575. */
  68576. font?: string;
  68577. /**
  68578. * The character set to use in the postprocess.
  68579. */
  68580. characterSet?: string;
  68581. /**
  68582. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  68583. * This number is defined between 0 and 1;
  68584. */
  68585. mixToTile?: number;
  68586. /**
  68587. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  68588. * This number is defined between 0 and 1;
  68589. */
  68590. mixToNormal?: number;
  68591. }
  68592. /**
  68593. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  68594. *
  68595. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68596. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  68597. */
  68598. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  68599. /**
  68600. * The font texture used to render the char in the post process.
  68601. */
  68602. private _asciiArtFontTexture;
  68603. /**
  68604. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  68605. * This number is defined between 0 and 1;
  68606. */
  68607. mixToTile: number;
  68608. /**
  68609. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  68610. * This number is defined between 0 and 1;
  68611. */
  68612. mixToNormal: number;
  68613. /**
  68614. * Instantiates a new Ascii Art Post Process.
  68615. * @param name the name to give to the postprocess
  68616. * @camera the camera to apply the post process to.
  68617. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  68618. */
  68619. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  68620. }
  68621. }
  68622. declare module BABYLON {
  68623. /** @hidden */
  68624. export var digitalrainPixelShader: {
  68625. name: string;
  68626. shader: string;
  68627. };
  68628. }
  68629. declare module BABYLON {
  68630. /**
  68631. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  68632. *
  68633. * It basically takes care rendering the font front the given font size to a texture.
  68634. * This is used later on in the postprocess.
  68635. */
  68636. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  68637. private _font;
  68638. private _text;
  68639. private _charSize;
  68640. /**
  68641. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  68642. */
  68643. readonly charSize: number;
  68644. /**
  68645. * Create a new instance of the Digital Rain FontTexture class
  68646. * @param name the name of the texture
  68647. * @param font the font to use, use the W3C CSS notation
  68648. * @param text the caracter set to use in the rendering.
  68649. * @param scene the scene that owns the texture
  68650. */
  68651. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  68652. /**
  68653. * Gets the max char width of a font.
  68654. * @param font the font to use, use the W3C CSS notation
  68655. * @return the max char width
  68656. */
  68657. private getFontWidth;
  68658. /**
  68659. * Gets the max char height of a font.
  68660. * @param font the font to use, use the W3C CSS notation
  68661. * @return the max char height
  68662. */
  68663. private getFontHeight;
  68664. /**
  68665. * Clones the current DigitalRainFontTexture.
  68666. * @return the clone of the texture.
  68667. */
  68668. clone(): DigitalRainFontTexture;
  68669. /**
  68670. * Parses a json object representing the texture and returns an instance of it.
  68671. * @param source the source JSON representation
  68672. * @param scene the scene to create the texture for
  68673. * @return the parsed texture
  68674. */
  68675. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  68676. }
  68677. /**
  68678. * Option available in the Digital Rain Post Process.
  68679. */
  68680. export interface IDigitalRainPostProcessOptions {
  68681. /**
  68682. * The font to use following the w3c font definition.
  68683. */
  68684. font?: string;
  68685. /**
  68686. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  68687. * This number is defined between 0 and 1;
  68688. */
  68689. mixToTile?: number;
  68690. /**
  68691. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  68692. * This number is defined between 0 and 1;
  68693. */
  68694. mixToNormal?: number;
  68695. }
  68696. /**
  68697. * DigitalRainPostProcess helps rendering everithing in digital rain.
  68698. *
  68699. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68700. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  68701. */
  68702. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  68703. /**
  68704. * The font texture used to render the char in the post process.
  68705. */
  68706. private _digitalRainFontTexture;
  68707. /**
  68708. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  68709. * This number is defined between 0 and 1;
  68710. */
  68711. mixToTile: number;
  68712. /**
  68713. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  68714. * This number is defined between 0 and 1;
  68715. */
  68716. mixToNormal: number;
  68717. /**
  68718. * Instantiates a new Digital Rain Post Process.
  68719. * @param name the name to give to the postprocess
  68720. * @camera the camera to apply the post process to.
  68721. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  68722. */
  68723. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  68724. }
  68725. }
  68726. declare module BABYLON {
  68727. /** @hidden */
  68728. export var oceanPostProcessPixelShader: {
  68729. name: string;
  68730. shader: string;
  68731. };
  68732. }
  68733. declare module BABYLON {
  68734. /**
  68735. * Option available in the Ocean Post Process.
  68736. */
  68737. export interface IOceanPostProcessOptions {
  68738. /**
  68739. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  68740. */
  68741. reflectionSize?: number | {
  68742. width: number;
  68743. height: number;
  68744. } | {
  68745. ratio: number;
  68746. };
  68747. /**
  68748. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  68749. */
  68750. refractionSize?: number | {
  68751. width: number;
  68752. height: number;
  68753. } | {
  68754. ratio: number;
  68755. };
  68756. }
  68757. /**
  68758. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  68759. *
  68760. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68761. * Example usage:
  68762. * var pp = new OceanPostProcess("myOcean", camera);
  68763. * pp.reflectionEnabled = true;
  68764. * pp.refractionEnabled = true;
  68765. */
  68766. export class OceanPostProcess extends BABYLON.PostProcess {
  68767. /**
  68768. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  68769. */
  68770. /**
  68771. * Sets weither or not the real-time reflection is enabled on the ocean.
  68772. * Is set to true, the reflection mirror texture will be used as reflection texture.
  68773. */
  68774. reflectionEnabled: boolean;
  68775. /**
  68776. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  68777. */
  68778. /**
  68779. * Sets weither or not the real-time refraction is enabled on the ocean.
  68780. * Is set to true, the refraction render target texture will be used as refraction texture.
  68781. */
  68782. refractionEnabled: boolean;
  68783. /**
  68784. * Gets wether or not the post-processes is supported by the running hardware.
  68785. * This requires draw buffer supports.
  68786. */
  68787. readonly isSupported: boolean;
  68788. /**
  68789. * This is the reflection mirror texture used to display reflections on the ocean.
  68790. * By default, render list is empty.
  68791. */
  68792. reflectionTexture: BABYLON.MirrorTexture;
  68793. /**
  68794. * This is the refraction render target texture used to display refraction on the ocean.
  68795. * By default, render list is empty.
  68796. */
  68797. refractionTexture: BABYLON.RenderTargetTexture;
  68798. private _time;
  68799. private _cameraRotation;
  68800. private _cameraViewMatrix;
  68801. private _reflectionEnabled;
  68802. private _refractionEnabled;
  68803. private _geometryRenderer;
  68804. /**
  68805. * Instantiates a new Ocean Post Process.
  68806. * @param name the name to give to the postprocess.
  68807. * @camera the camera to apply the post process to.
  68808. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  68809. */
  68810. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  68811. /**
  68812. * Returns the appropriate defines according to the current configuration.
  68813. */
  68814. private _getDefines;
  68815. /**
  68816. * Computes the current camera rotation as the shader requires a camera rotation.
  68817. */
  68818. private _computeCameraRotation;
  68819. }
  68820. }
  68821. declare module BABYLON {
  68822. /** @hidden */
  68823. export var brickProceduralTexturePixelShader: {
  68824. name: string;
  68825. shader: string;
  68826. };
  68827. }
  68828. declare module BABYLON {
  68829. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  68830. private _numberOfBricksHeight;
  68831. private _numberOfBricksWidth;
  68832. private _jointColor;
  68833. private _brickColor;
  68834. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68835. updateShaderUniforms(): void;
  68836. numberOfBricksHeight: number;
  68837. numberOfBricksWidth: number;
  68838. jointColor: BABYLON.Color3;
  68839. brickColor: BABYLON.Color3;
  68840. /**
  68841. * Serializes this brick procedural texture
  68842. * @returns a serialized brick procedural texture object
  68843. */
  68844. serialize(): any;
  68845. /**
  68846. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  68847. * @param parsedTexture defines parsed texture data
  68848. * @param scene defines the current scene
  68849. * @param rootUrl defines the root URL containing brick procedural texture information
  68850. * @returns a parsed Brick Procedural BABYLON.Texture
  68851. */
  68852. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  68853. }
  68854. }
  68855. declare module BABYLON {
  68856. /** @hidden */
  68857. export var cloudProceduralTexturePixelShader: {
  68858. name: string;
  68859. shader: string;
  68860. };
  68861. }
  68862. declare module BABYLON {
  68863. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  68864. private _skyColor;
  68865. private _cloudColor;
  68866. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68867. updateShaderUniforms(): void;
  68868. skyColor: BABYLON.Color4;
  68869. cloudColor: BABYLON.Color4;
  68870. /**
  68871. * Serializes this cloud procedural texture
  68872. * @returns a serialized cloud procedural texture object
  68873. */
  68874. serialize(): any;
  68875. /**
  68876. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  68877. * @param parsedTexture defines parsed texture data
  68878. * @param scene defines the current scene
  68879. * @param rootUrl defines the root URL containing cloud procedural texture information
  68880. * @returns a parsed Cloud Procedural BABYLON.Texture
  68881. */
  68882. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  68883. }
  68884. }
  68885. declare module BABYLON {
  68886. /** @hidden */
  68887. export var fireProceduralTexturePixelShader: {
  68888. name: string;
  68889. shader: string;
  68890. };
  68891. }
  68892. declare module BABYLON {
  68893. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  68894. private _time;
  68895. private _speed;
  68896. private _autoGenerateTime;
  68897. private _fireColors;
  68898. private _alphaThreshold;
  68899. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68900. updateShaderUniforms(): void;
  68901. render(useCameraPostProcess?: boolean): void;
  68902. static readonly PurpleFireColors: BABYLON.Color3[];
  68903. static readonly GreenFireColors: BABYLON.Color3[];
  68904. static readonly RedFireColors: BABYLON.Color3[];
  68905. static readonly BlueFireColors: BABYLON.Color3[];
  68906. autoGenerateTime: boolean;
  68907. fireColors: BABYLON.Color3[];
  68908. time: number;
  68909. speed: BABYLON.Vector2;
  68910. alphaThreshold: number;
  68911. /**
  68912. * Serializes this fire procedural texture
  68913. * @returns a serialized fire procedural texture object
  68914. */
  68915. serialize(): any;
  68916. /**
  68917. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  68918. * @param parsedTexture defines parsed texture data
  68919. * @param scene defines the current scene
  68920. * @param rootUrl defines the root URL containing fire procedural texture information
  68921. * @returns a parsed Fire Procedural BABYLON.Texture
  68922. */
  68923. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  68924. }
  68925. }
  68926. declare module BABYLON {
  68927. /** @hidden */
  68928. export var grassProceduralTexturePixelShader: {
  68929. name: string;
  68930. shader: string;
  68931. };
  68932. }
  68933. declare module BABYLON {
  68934. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  68935. private _grassColors;
  68936. private _groundColor;
  68937. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68938. updateShaderUniforms(): void;
  68939. grassColors: BABYLON.Color3[];
  68940. groundColor: BABYLON.Color3;
  68941. /**
  68942. * Serializes this grass procedural texture
  68943. * @returns a serialized grass procedural texture object
  68944. */
  68945. serialize(): any;
  68946. /**
  68947. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  68948. * @param parsedTexture defines parsed texture data
  68949. * @param scene defines the current scene
  68950. * @param rootUrl defines the root URL containing grass procedural texture information
  68951. * @returns a parsed Grass Procedural BABYLON.Texture
  68952. */
  68953. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  68954. }
  68955. }
  68956. declare module BABYLON {
  68957. /** @hidden */
  68958. export var marbleProceduralTexturePixelShader: {
  68959. name: string;
  68960. shader: string;
  68961. };
  68962. }
  68963. declare module BABYLON {
  68964. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  68965. private _numberOfTilesHeight;
  68966. private _numberOfTilesWidth;
  68967. private _amplitude;
  68968. private _jointColor;
  68969. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68970. updateShaderUniforms(): void;
  68971. numberOfTilesHeight: number;
  68972. amplitude: number;
  68973. numberOfTilesWidth: number;
  68974. jointColor: BABYLON.Color3;
  68975. /**
  68976. * Serializes this marble procedural texture
  68977. * @returns a serialized marble procedural texture object
  68978. */
  68979. serialize(): any;
  68980. /**
  68981. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  68982. * @param parsedTexture defines parsed texture data
  68983. * @param scene defines the current scene
  68984. * @param rootUrl defines the root URL containing marble procedural texture information
  68985. * @returns a parsed Marble Procedural BABYLON.Texture
  68986. */
  68987. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  68988. }
  68989. }
  68990. declare module BABYLON {
  68991. /** @hidden */
  68992. export var normalMapProceduralTexturePixelShader: {
  68993. name: string;
  68994. shader: string;
  68995. };
  68996. }
  68997. declare module BABYLON {
  68998. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  68999. private _baseTexture;
  69000. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69001. updateShaderUniforms(): void;
  69002. render(useCameraPostProcess?: boolean): void;
  69003. resize(size: any, generateMipMaps: any): void;
  69004. baseTexture: BABYLON.Texture;
  69005. /**
  69006. * Serializes this normal map procedural texture
  69007. * @returns a serialized normal map procedural texture object
  69008. */
  69009. serialize(): any;
  69010. /**
  69011. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  69012. * @param parsedTexture defines parsed texture data
  69013. * @param scene defines the current scene
  69014. * @param rootUrl defines the root URL containing normal map procedural texture information
  69015. * @returns a parsed Normal Map Procedural BABYLON.Texture
  69016. */
  69017. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  69018. }
  69019. }
  69020. declare module BABYLON {
  69021. /** @hidden */
  69022. export var perlinNoiseProceduralTexturePixelShader: {
  69023. name: string;
  69024. shader: string;
  69025. };
  69026. }
  69027. declare module BABYLON {
  69028. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  69029. time: number;
  69030. timeScale: number;
  69031. translationSpeed: number;
  69032. private _currentTranslation;
  69033. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69034. updateShaderUniforms(): void;
  69035. render(useCameraPostProcess?: boolean): void;
  69036. resize(size: any, generateMipMaps: any): void;
  69037. /**
  69038. * Serializes this perlin noise procedural texture
  69039. * @returns a serialized perlin noise procedural texture object
  69040. */
  69041. serialize(): any;
  69042. /**
  69043. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  69044. * @param parsedTexture defines parsed texture data
  69045. * @param scene defines the current scene
  69046. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  69047. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  69048. */
  69049. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  69050. }
  69051. }
  69052. declare module BABYLON {
  69053. /** @hidden */
  69054. export var roadProceduralTexturePixelShader: {
  69055. name: string;
  69056. shader: string;
  69057. };
  69058. }
  69059. declare module BABYLON {
  69060. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  69061. private _roadColor;
  69062. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69063. updateShaderUniforms(): void;
  69064. roadColor: BABYLON.Color3;
  69065. /**
  69066. * Serializes this road procedural texture
  69067. * @returns a serialized road procedural texture object
  69068. */
  69069. serialize(): any;
  69070. /**
  69071. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  69072. * @param parsedTexture defines parsed texture data
  69073. * @param scene defines the current scene
  69074. * @param rootUrl defines the root URL containing road procedural texture information
  69075. * @returns a parsed Road Procedural BABYLON.Texture
  69076. */
  69077. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  69078. }
  69079. }
  69080. declare module BABYLON {
  69081. /** @hidden */
  69082. export var starfieldProceduralTexturePixelShader: {
  69083. name: string;
  69084. shader: string;
  69085. };
  69086. }
  69087. declare module BABYLON {
  69088. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  69089. private _time;
  69090. private _alpha;
  69091. private _beta;
  69092. private _zoom;
  69093. private _formuparam;
  69094. private _stepsize;
  69095. private _tile;
  69096. private _brightness;
  69097. private _darkmatter;
  69098. private _distfading;
  69099. private _saturation;
  69100. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69101. updateShaderUniforms(): void;
  69102. time: number;
  69103. alpha: number;
  69104. beta: number;
  69105. formuparam: number;
  69106. stepsize: number;
  69107. zoom: number;
  69108. tile: number;
  69109. brightness: number;
  69110. darkmatter: number;
  69111. distfading: number;
  69112. saturation: number;
  69113. /**
  69114. * Serializes this starfield procedural texture
  69115. * @returns a serialized starfield procedural texture object
  69116. */
  69117. serialize(): any;
  69118. /**
  69119. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  69120. * @param parsedTexture defines parsed texture data
  69121. * @param scene defines the current scene
  69122. * @param rootUrl defines the root URL containing startfield procedural texture information
  69123. * @returns a parsed Starfield Procedural BABYLON.Texture
  69124. */
  69125. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  69126. }
  69127. }
  69128. declare module BABYLON {
  69129. /** @hidden */
  69130. export var woodProceduralTexturePixelShader: {
  69131. name: string;
  69132. shader: string;
  69133. };
  69134. }
  69135. declare module BABYLON {
  69136. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  69137. private _ampScale;
  69138. private _woodColor;
  69139. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69140. updateShaderUniforms(): void;
  69141. ampScale: number;
  69142. woodColor: BABYLON.Color3;
  69143. /**
  69144. * Serializes this wood procedural texture
  69145. * @returns a serialized wood procedural texture object
  69146. */
  69147. serialize(): any;
  69148. /**
  69149. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  69150. * @param parsedTexture defines parsed texture data
  69151. * @param scene defines the current scene
  69152. * @param rootUrl defines the root URL containing wood procedural texture information
  69153. * @returns a parsed Wood Procedural BABYLON.Texture
  69154. */
  69155. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  69156. }
  69157. }