documentation.d.ts 2.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184
  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 Vecto3
  1503. */
  1504. length(): number;
  1505. /**
  1506. * Gets the squared length of the Vector3
  1507. * @returns squared length of the Vector3
  1508. */
  1509. lengthSquared(): number;
  1510. /**
  1511. * Normalize the current Vector3.
  1512. * Please note that this is an in place operation.
  1513. * @returns the current updated Vector3
  1514. */
  1515. normalize(): Vector3;
  1516. /**
  1517. * Reorders the x y z properties of the vector in place
  1518. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1519. * @returns the current updated vector
  1520. */
  1521. reorderInPlace(order: string): this;
  1522. /**
  1523. * Rotates the vector around 0,0,0 by a quaternion
  1524. * @param quaternion the rotation quaternion
  1525. * @param result vector to store the result
  1526. * @returns the resulting vector
  1527. */
  1528. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1529. /**
  1530. * Rotates a vector around a given point
  1531. * @param quaternion the rotation quaternion
  1532. * @param point the point to rotate around
  1533. * @param result vector to store the result
  1534. * @returns the resulting vector
  1535. */
  1536. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1537. /**
  1538. * Normalize the current Vector3 with the given input length.
  1539. * Please note that this is an in place operation.
  1540. * @param len the length of the vector
  1541. * @returns the current updated Vector3
  1542. */
  1543. normalizeFromLength(len: number): Vector3;
  1544. /**
  1545. * Normalize the current Vector3 to a new vector
  1546. * @returns the new Vector3
  1547. */
  1548. normalizeToNew(): Vector3;
  1549. /**
  1550. * Normalize the current Vector3 to the reference
  1551. * @param reference define the Vector3 to update
  1552. * @returns the updated Vector3
  1553. */
  1554. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1555. /**
  1556. * Creates a new Vector3 copied from the current Vector3
  1557. * @returns the new Vector3
  1558. */
  1559. clone(): Vector3;
  1560. /**
  1561. * Copies the given vector coordinates to the current Vector3 ones
  1562. * @param source defines the source Vector3
  1563. * @returns the current updated Vector3
  1564. */
  1565. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1566. /**
  1567. * Copies the given floats to the current Vector3 coordinates
  1568. * @param x defines the x coordinate of the operand
  1569. * @param y defines the y coordinate of the operand
  1570. * @param z defines the z coordinate of the operand
  1571. * @returns the current updated Vector3
  1572. */
  1573. copyFromFloats(x: number, y: number, z: number): Vector3;
  1574. /**
  1575. * Copies the given floats to the current Vector3 coordinates
  1576. * @param x defines the x coordinate of the operand
  1577. * @param y defines the y coordinate of the operand
  1578. * @param z defines the z coordinate of the operand
  1579. * @returns the current updated Vector3
  1580. */
  1581. set(x: number, y: number, z: number): Vector3;
  1582. /**
  1583. * Copies the given float to the current Vector3 coordinates
  1584. * @param v defines the x, y and z coordinates of the operand
  1585. * @returns the current updated Vector3
  1586. */
  1587. setAll(v: number): Vector3;
  1588. /**
  1589. * Get the clip factor between two vectors
  1590. * @param vector0 defines the first operand
  1591. * @param vector1 defines the second operand
  1592. * @param axis defines the axis to use
  1593. * @param size defines the size along the axis
  1594. * @returns the clip factor
  1595. */
  1596. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1597. /**
  1598. * Get angle between two vectors
  1599. * @param vector0 angle between vector0 and vector1
  1600. * @param vector1 angle between vector0 and vector1
  1601. * @param normal direction of the normal
  1602. * @return the angle between vector0 and vector1
  1603. */
  1604. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1605. /**
  1606. * Returns a new Vector3 set from the index "offset" of the given array
  1607. * @param array defines the source array
  1608. * @param offset defines the offset in the source array
  1609. * @returns the new Vector3
  1610. */
  1611. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1612. /**
  1613. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1614. * This function is deprecated. Use FromArray instead
  1615. * @param array defines the source array
  1616. * @param offset defines the offset in the source array
  1617. * @returns the new Vector3
  1618. */
  1619. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1620. /**
  1621. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1622. * @param array defines the source array
  1623. * @param offset defines the offset in the source array
  1624. * @param result defines the Vector3 where to store the result
  1625. */
  1626. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1627. /**
  1628. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1629. * This function is deprecated. Use FromArrayToRef instead.
  1630. * @param array defines the source array
  1631. * @param offset defines the offset in the source array
  1632. * @param result defines the Vector3 where to store the result
  1633. */
  1634. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1635. /**
  1636. * Sets the given vector "result" with the given floats.
  1637. * @param x defines the x coordinate of the source
  1638. * @param y defines the y coordinate of the source
  1639. * @param z defines the z coordinate of the source
  1640. * @param result defines the Vector3 where to store the result
  1641. */
  1642. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1645. * @returns a new empty Vector3
  1646. */
  1647. static Zero(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1650. * @returns a new unit Vector3
  1651. */
  1652. static One(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1655. * @returns a new up Vector3
  1656. */
  1657. static Up(): Vector3;
  1658. /**
  1659. * Gets a up Vector3 that must not be updated
  1660. */
  1661. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1662. /**
  1663. * Gets a zero Vector3 that must not be updated
  1664. */
  1665. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1666. /**
  1667. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1668. * @returns a new down Vector3
  1669. */
  1670. static Down(): Vector3;
  1671. /**
  1672. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1673. * @returns a new forward Vector3
  1674. */
  1675. static Forward(): Vector3;
  1676. /**
  1677. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1678. * @returns a new forward Vector3
  1679. */
  1680. static Backward(): Vector3;
  1681. /**
  1682. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1683. * @returns a new right Vector3
  1684. */
  1685. static Right(): Vector3;
  1686. /**
  1687. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1688. * @returns a new left Vector3
  1689. */
  1690. static Left(): Vector3;
  1691. /**
  1692. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1693. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1694. * @param vector defines the Vector3 to transform
  1695. * @param transformation defines the transformation matrix
  1696. * @returns the transformed Vector3
  1697. */
  1698. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1699. /**
  1700. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1701. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1702. * @param vector defines the Vector3 to transform
  1703. * @param transformation defines the transformation matrix
  1704. * @param result defines the Vector3 where to store the result
  1705. */
  1706. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1707. /**
  1708. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1709. * This method computes tranformed coordinates only, not transformed direction vectors
  1710. * @param x define the x coordinate of the source vector
  1711. * @param y define the y coordinate of the source vector
  1712. * @param z define the z coordinate of the source vector
  1713. * @param transformation defines the transformation matrix
  1714. * @param result defines the Vector3 where to store the result
  1715. */
  1716. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1717. /**
  1718. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1719. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1720. * @param vector defines the Vector3 to transform
  1721. * @param transformation defines the transformation matrix
  1722. * @returns the new Vector3
  1723. */
  1724. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1725. /**
  1726. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1727. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1728. * @param vector defines the Vector3 to transform
  1729. * @param transformation defines the transformation matrix
  1730. * @param result defines the Vector3 where to store the result
  1731. */
  1732. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1733. /**
  1734. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1735. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1736. * @param x define the x coordinate of the source vector
  1737. * @param y define the y coordinate of the source vector
  1738. * @param z define the z coordinate of the source vector
  1739. * @param transformation defines the transformation matrix
  1740. * @param result defines the Vector3 where to store the result
  1741. */
  1742. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1743. /**
  1744. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1745. * @param value1 defines the first control point
  1746. * @param value2 defines the second control point
  1747. * @param value3 defines the third control point
  1748. * @param value4 defines the fourth control point
  1749. * @param amount defines the amount on the spline to use
  1750. * @returns the new Vector3
  1751. */
  1752. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1753. /**
  1754. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1755. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1756. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1757. * @param value defines the current value
  1758. * @param min defines the lower range value
  1759. * @param max defines the upper range value
  1760. * @returns the new Vector3
  1761. */
  1762. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1763. /**
  1764. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1765. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1766. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1767. * @param value defines the current value
  1768. * @param min defines the lower range value
  1769. * @param max defines the upper range value
  1770. * @param result defines the Vector3 where to store the result
  1771. */
  1772. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1773. /**
  1774. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1775. * @param value1 defines the first control point
  1776. * @param tangent1 defines the first tangent vector
  1777. * @param value2 defines the second control point
  1778. * @param tangent2 defines the second tangent vector
  1779. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1780. * @returns the new Vector3
  1781. */
  1782. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1783. /**
  1784. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1785. * @param start defines the start value
  1786. * @param end defines the end value
  1787. * @param amount max defines amount between both (between 0 and 1)
  1788. * @returns the new Vector3
  1789. */
  1790. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1793. * @param start defines the start value
  1794. * @param end defines the end value
  1795. * @param amount max defines amount between both (between 0 and 1)
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1799. /**
  1800. * Returns the dot product (float) between the vectors "left" and "right"
  1801. * @param left defines the left operand
  1802. * @param right defines the right operand
  1803. * @returns the dot product
  1804. */
  1805. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1806. /**
  1807. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1808. * The cross product is then orthogonal to both "left" and "right"
  1809. * @param left defines the left operand
  1810. * @param right defines the right operand
  1811. * @returns the cross product
  1812. */
  1813. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1814. /**
  1815. * Sets the given vector "result" with the cross product of "left" and "right"
  1816. * The cross product is then orthogonal to both "left" and "right"
  1817. * @param left defines the left operand
  1818. * @param right defines the right operand
  1819. * @param result defines the Vector3 where to store the result
  1820. */
  1821. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1822. /**
  1823. * Returns a new Vector3 as the normalization of the given vector
  1824. * @param vector defines the Vector3 to normalize
  1825. * @returns the new Vector3
  1826. */
  1827. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1828. /**
  1829. * Sets the given vector "result" with the normalization of the given first vector
  1830. * @param vector defines the Vector3 to normalize
  1831. * @param result defines the Vector3 where to store the result
  1832. */
  1833. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1834. /**
  1835. * Project a Vector3 onto screen space
  1836. * @param vector defines the Vector3 to project
  1837. * @param world defines the world matrix to use
  1838. * @param transform defines the transform (view x projection) matrix to use
  1839. * @param viewport defines the screen viewport to use
  1840. * @returns the new Vector3
  1841. */
  1842. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1843. /** @hidden */
  1844. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1845. /**
  1846. * Unproject from screen space to object space
  1847. * @param source defines the screen space Vector3 to use
  1848. * @param viewportWidth defines the current width of the viewport
  1849. * @param viewportHeight defines the current height of the viewport
  1850. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1851. * @param transform defines the transform (view x projection) matrix to use
  1852. * @returns the new Vector3
  1853. */
  1854. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param source defines the screen space Vector3 to use
  1858. * @param viewportWidth defines the current width of the viewport
  1859. * @param viewportHeight defines the current height of the viewport
  1860. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1861. * @param view defines the view matrix to use
  1862. * @param projection defines the projection matrix to use
  1863. * @returns the new Vector3
  1864. */
  1865. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1866. /**
  1867. * Unproject from screen space to object space
  1868. * @param source defines the screen space Vector3 to use
  1869. * @param viewportWidth defines the current width of the viewport
  1870. * @param viewportHeight defines the current height of the viewport
  1871. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1872. * @param view defines the view matrix to use
  1873. * @param projection defines the projection matrix to use
  1874. * @param result defines the Vector3 where to store the result
  1875. */
  1876. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1877. /**
  1878. * Unproject from screen space to object space
  1879. * @param sourceX defines the screen space x coordinate to use
  1880. * @param sourceY defines the screen space y coordinate to use
  1881. * @param sourceZ defines the screen space z coordinate to use
  1882. * @param viewportWidth defines the current width of the viewport
  1883. * @param viewportHeight defines the current height of the viewport
  1884. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1885. * @param view defines the view matrix to use
  1886. * @param projection defines the projection matrix to use
  1887. * @param result defines the Vector3 where to store the result
  1888. */
  1889. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1890. /**
  1891. * Gets the minimal coordinate values between two Vector3
  1892. * @param left defines the first operand
  1893. * @param right defines the second operand
  1894. * @returns the new Vector3
  1895. */
  1896. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1897. /**
  1898. * Gets the maximal coordinate values between two Vector3
  1899. * @param left defines the first operand
  1900. * @param right defines the second operand
  1901. * @returns the new Vector3
  1902. */
  1903. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1904. /**
  1905. * Returns the distance between the vectors "value1" and "value2"
  1906. * @param value1 defines the first operand
  1907. * @param value2 defines the second operand
  1908. * @returns the distance
  1909. */
  1910. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1911. /**
  1912. * Returns the squared distance between the vectors "value1" and "value2"
  1913. * @param value1 defines the first operand
  1914. * @param value2 defines the second operand
  1915. * @returns the squared distance
  1916. */
  1917. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1918. /**
  1919. * Returns a new Vector3 located at the center between "value1" and "value2"
  1920. * @param value1 defines the first operand
  1921. * @param value2 defines the second operand
  1922. * @returns the new Vector3
  1923. */
  1924. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1925. /**
  1926. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1927. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1928. * to something in order to rotate it from its local system to the given target system
  1929. * Note: axis1, axis2 and axis3 are normalized during this operation
  1930. * @param axis1 defines the first axis
  1931. * @param axis2 defines the second axis
  1932. * @param axis3 defines the third axis
  1933. * @returns a new Vector3
  1934. */
  1935. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1936. /**
  1937. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1938. * @param axis1 defines the first axis
  1939. * @param axis2 defines the second axis
  1940. * @param axis3 defines the third axis
  1941. * @param ref defines the Vector3 where to store the result
  1942. */
  1943. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1944. }
  1945. /**
  1946. * Vector4 class created for EulerAngle class conversion to Quaternion
  1947. */
  1948. export class Vector4 {
  1949. /** x value of the vector */
  1950. x: number;
  1951. /** y value of the vector */
  1952. y: number;
  1953. /** z value of the vector */
  1954. z: number;
  1955. /** w value of the vector */
  1956. w: number;
  1957. /**
  1958. * Creates a Vector4 object from the given floats.
  1959. * @param x x value of the vector
  1960. * @param y y value of the vector
  1961. * @param z z value of the vector
  1962. * @param w w value of the vector
  1963. */
  1964. constructor(
  1965. /** x value of the vector */
  1966. x: number,
  1967. /** y value of the vector */
  1968. y: number,
  1969. /** z value of the vector */
  1970. z: number,
  1971. /** w value of the vector */
  1972. w: number);
  1973. /**
  1974. * Returns the string with the Vector4 coordinates.
  1975. * @returns a string containing all the vector values
  1976. */
  1977. toString(): string;
  1978. /**
  1979. * Returns the string "Vector4".
  1980. * @returns "Vector4"
  1981. */
  1982. getClassName(): string;
  1983. /**
  1984. * Returns the Vector4 hash code.
  1985. * @returns a unique hash code
  1986. */
  1987. getHashCode(): number;
  1988. /**
  1989. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1990. * @returns the resulting array
  1991. */
  1992. asArray(): number[];
  1993. /**
  1994. * Populates the given array from the given index with the Vector4 coordinates.
  1995. * @param array array to populate
  1996. * @param index index of the array to start at (default: 0)
  1997. * @returns the Vector4.
  1998. */
  1999. toArray(array: FloatArray, index?: number): Vector4;
  2000. /**
  2001. * Adds the given vector to the current Vector4.
  2002. * @param otherVector the vector to add
  2003. * @returns the updated Vector4.
  2004. */
  2005. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2006. /**
  2007. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2008. * @param otherVector the vector to add
  2009. * @returns the resulting vector
  2010. */
  2011. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2012. /**
  2013. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2014. * @param otherVector the vector to add
  2015. * @param result the vector to store the result
  2016. * @returns the current Vector4.
  2017. */
  2018. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2019. /**
  2020. * Subtract in place the given vector from the current Vector4.
  2021. * @param otherVector the vector to subtract
  2022. * @returns the updated Vector4.
  2023. */
  2024. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2025. /**
  2026. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2027. * @param otherVector the vector to add
  2028. * @returns the new vector with the result
  2029. */
  2030. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2031. /**
  2032. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2033. * @param otherVector the vector to subtract
  2034. * @param result the vector to store the result
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2040. */
  2041. /**
  2042. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2043. * @param x value to subtract
  2044. * @param y value to subtract
  2045. * @param z value to subtract
  2046. * @param w value to subtract
  2047. * @returns new vector containing the result
  2048. */
  2049. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2050. /**
  2051. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2052. * @param x value to subtract
  2053. * @param y value to subtract
  2054. * @param z value to subtract
  2055. * @param w value to subtract
  2056. * @param result the vector to store the result in
  2057. * @returns the current Vector4.
  2058. */
  2059. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2060. /**
  2061. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2062. * @returns a new vector with the negated values
  2063. */
  2064. negate(): Vector4;
  2065. /**
  2066. * Multiplies the current Vector4 coordinates by scale (float).
  2067. * @param scale the number to scale with
  2068. * @returns the updated Vector4.
  2069. */
  2070. scaleInPlace(scale: number): Vector4;
  2071. /**
  2072. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2073. * @param scale the number to scale with
  2074. * @returns a new vector with the result
  2075. */
  2076. scale(scale: number): Vector4;
  2077. /**
  2078. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2079. * @param scale the number to scale with
  2080. * @param result a vector to store the result in
  2081. * @returns the current Vector4.
  2082. */
  2083. scaleToRef(scale: number, result: Vector4): Vector4;
  2084. /**
  2085. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2086. * @param scale defines the scale factor
  2087. * @param result defines the Vector4 object where to store the result
  2088. * @returns the unmodified current Vector4
  2089. */
  2090. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2091. /**
  2092. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2093. * @param otherVector the vector to compare against
  2094. * @returns true if they are equal
  2095. */
  2096. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2097. /**
  2098. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2099. * @param otherVector vector to compare against
  2100. * @param epsilon (Default: very small number)
  2101. * @returns true if they are equal
  2102. */
  2103. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2104. /**
  2105. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2106. * @param x x value to compare against
  2107. * @param y y value to compare against
  2108. * @param z z value to compare against
  2109. * @param w w value to compare against
  2110. * @returns true if equal
  2111. */
  2112. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2113. /**
  2114. * Multiplies in place the current Vector4 by the given one.
  2115. * @param otherVector vector to multiple with
  2116. * @returns the updated Vector4.
  2117. */
  2118. multiplyInPlace(otherVector: Vector4): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2121. * @param otherVector vector to multiple with
  2122. * @returns resulting new vector
  2123. */
  2124. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2127. * @param otherVector vector to multiple with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2134. * @param x x value multiply with
  2135. * @param y y value multiply with
  2136. * @param z z value multiply with
  2137. * @param w w value multiply with
  2138. * @returns resulting new vector
  2139. */
  2140. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2141. /**
  2142. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2143. * @param otherVector vector to devide with
  2144. * @returns resulting new vector
  2145. */
  2146. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2147. /**
  2148. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2149. * @param otherVector vector to devide with
  2150. * @param result vector to store the result
  2151. * @returns the current Vector4.
  2152. */
  2153. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2154. /**
  2155. * Divides the current Vector3 coordinates by the given ones.
  2156. * @param otherVector vector to devide with
  2157. * @returns the updated Vector3.
  2158. */
  2159. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2160. /**
  2161. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2162. * @param other defines the second operand
  2163. * @returns the current updated Vector4
  2164. */
  2165. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2166. /**
  2167. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2168. * @param other defines the second operand
  2169. * @returns the current updated Vector4
  2170. */
  2171. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2172. /**
  2173. * Gets a new Vector4 from current Vector4 floored values
  2174. * @returns a new Vector4
  2175. */
  2176. floor(): Vector4;
  2177. /**
  2178. * Gets a new Vector4 from current Vector3 floored values
  2179. * @returns a new Vector4
  2180. */
  2181. fract(): Vector4;
  2182. /**
  2183. * Returns the Vector4 length (float).
  2184. * @returns the length
  2185. */
  2186. length(): number;
  2187. /**
  2188. * Returns the Vector4 squared length (float).
  2189. * @returns the length squared
  2190. */
  2191. lengthSquared(): number;
  2192. /**
  2193. * Normalizes in place the Vector4.
  2194. * @returns the updated Vector4.
  2195. */
  2196. normalize(): Vector4;
  2197. /**
  2198. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2199. * @returns this converted to a new vector3
  2200. */
  2201. toVector3(): Vector3;
  2202. /**
  2203. * Returns a new Vector4 copied from the current one.
  2204. * @returns the new cloned vector
  2205. */
  2206. clone(): Vector4;
  2207. /**
  2208. * Updates the current Vector4 with the given one coordinates.
  2209. * @param source the source vector to copy from
  2210. * @returns the updated Vector4.
  2211. */
  2212. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2213. /**
  2214. * Updates the current Vector4 coordinates with the given floats.
  2215. * @param x float to copy from
  2216. * @param y float to copy from
  2217. * @param z float to copy from
  2218. * @param w float to copy from
  2219. * @returns the updated Vector4.
  2220. */
  2221. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2222. /**
  2223. * Updates the current Vector4 coordinates with the given floats.
  2224. * @param x float to set from
  2225. * @param y float to set from
  2226. * @param z float to set from
  2227. * @param w float to set from
  2228. * @returns the updated Vector4.
  2229. */
  2230. set(x: number, y: number, z: number, w: number): Vector4;
  2231. /**
  2232. * Copies the given float to the current Vector3 coordinates
  2233. * @param v defines the x, y, z and w coordinates of the operand
  2234. * @returns the current updated Vector3
  2235. */
  2236. setAll(v: number): Vector4;
  2237. /**
  2238. * Returns a new Vector4 set from the starting index of the given array.
  2239. * @param array the array to pull values from
  2240. * @param offset the offset into the array to start at
  2241. * @returns the new vector
  2242. */
  2243. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2244. /**
  2245. * Updates the given vector "result" from the starting index of the given array.
  2246. * @param array the array to pull values from
  2247. * @param offset the offset into the array to start at
  2248. * @param result the vector to store the result in
  2249. */
  2250. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2251. /**
  2252. * Updates the given vector "result" from the starting index of the given Float32Array.
  2253. * @param array the array to pull values from
  2254. * @param offset the offset into the array to start at
  2255. * @param result the vector to store the result in
  2256. */
  2257. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2258. /**
  2259. * Updates the given vector "result" coordinates from the given floats.
  2260. * @param x float to set from
  2261. * @param y float to set from
  2262. * @param z float to set from
  2263. * @param w float to set from
  2264. * @param result the vector to the floats in
  2265. */
  2266. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2267. /**
  2268. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2269. * @returns the new vector
  2270. */
  2271. static Zero(): Vector4;
  2272. /**
  2273. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2274. * @returns the new vector
  2275. */
  2276. static One(): Vector4;
  2277. /**
  2278. * Returns a new normalized Vector4 from the given one.
  2279. * @param vector the vector to normalize
  2280. * @returns the vector
  2281. */
  2282. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2283. /**
  2284. * Updates the given vector "result" from the normalization of the given one.
  2285. * @param vector the vector to normalize
  2286. * @param result the vector to store the result in
  2287. */
  2288. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2289. /**
  2290. * Returns a vector with the minimum values from the left and right vectors
  2291. * @param left left vector to minimize
  2292. * @param right right vector to minimize
  2293. * @returns a new vector with the minimum of the left and right vector values
  2294. */
  2295. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2296. /**
  2297. * Returns a vector with the maximum values from the left and right vectors
  2298. * @param left left vector to maximize
  2299. * @param right right vector to maximize
  2300. * @returns a new vector with the maximum of the left and right vector values
  2301. */
  2302. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2303. /**
  2304. * Returns the distance (float) between the vectors "value1" and "value2".
  2305. * @param value1 value to calulate the distance between
  2306. * @param value2 value to calulate the distance between
  2307. * @return the distance between the two vectors
  2308. */
  2309. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2310. /**
  2311. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2312. * @param value1 value to calulate the distance between
  2313. * @param value2 value to calulate the distance between
  2314. * @return the distance between the two vectors squared
  2315. */
  2316. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2317. /**
  2318. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2319. * @param value1 value to calulate the center between
  2320. * @param value2 value to calulate the center between
  2321. * @return the center between the two vectors
  2322. */
  2323. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2324. /**
  2325. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2326. * This methods computes transformed normalized direction vectors only.
  2327. * @param vector the vector to transform
  2328. * @param transformation the transformation matrix to apply
  2329. * @returns the new vector
  2330. */
  2331. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2332. /**
  2333. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2334. * This methods computes transformed normalized direction vectors only.
  2335. * @param vector the vector to transform
  2336. * @param transformation the transformation matrix to apply
  2337. * @param result the vector to store the result in
  2338. */
  2339. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2340. /**
  2341. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2342. * This methods computes transformed normalized direction vectors only.
  2343. * @param x value to transform
  2344. * @param y value to transform
  2345. * @param z value to transform
  2346. * @param w value to transform
  2347. * @param transformation the transformation matrix to apply
  2348. * @param result the vector to store the results in
  2349. */
  2350. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2351. /**
  2352. * Creates a new Vector4 from a Vector3
  2353. * @param source defines the source data
  2354. * @param w defines the 4th component (default is 0)
  2355. * @returns a new Vector4
  2356. */
  2357. static FromVector3(source: Vector3, w?: number): Vector4;
  2358. }
  2359. /**
  2360. * Interface for the size containing width and height
  2361. */
  2362. export interface ISize {
  2363. /**
  2364. * Width
  2365. */
  2366. width: number;
  2367. /**
  2368. * Heighht
  2369. */
  2370. height: number;
  2371. }
  2372. /**
  2373. * Size containing widht and height
  2374. */
  2375. export class Size implements ISize {
  2376. /**
  2377. * Width
  2378. */
  2379. width: number;
  2380. /**
  2381. * Height
  2382. */
  2383. height: number;
  2384. /**
  2385. * Creates a Size object from the given width and height (floats).
  2386. * @param width width of the new size
  2387. * @param height height of the new size
  2388. */
  2389. constructor(width: number, height: number);
  2390. /**
  2391. * Returns a string with the Size width and height
  2392. * @returns a string with the Size width and height
  2393. */
  2394. toString(): string;
  2395. /**
  2396. * "Size"
  2397. * @returns the string "Size"
  2398. */
  2399. getClassName(): string;
  2400. /**
  2401. * Returns the Size hash code.
  2402. * @returns a hash code for a unique width and height
  2403. */
  2404. getHashCode(): number;
  2405. /**
  2406. * Updates the current size from the given one.
  2407. * @param src the given size
  2408. */
  2409. copyFrom(src: Size): void;
  2410. /**
  2411. * Updates in place the current Size from the given floats.
  2412. * @param width width of the new size
  2413. * @param height height of the new size
  2414. * @returns the updated Size.
  2415. */
  2416. copyFromFloats(width: number, height: number): Size;
  2417. /**
  2418. * Updates in place the current Size from the given floats.
  2419. * @param width width to set
  2420. * @param height height to set
  2421. * @returns the updated Size.
  2422. */
  2423. set(width: number, height: number): Size;
  2424. /**
  2425. * Multiplies the width and height by numbers
  2426. * @param w factor to multiple the width by
  2427. * @param h factor to multiple the height by
  2428. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2429. */
  2430. multiplyByFloats(w: number, h: number): Size;
  2431. /**
  2432. * Clones the size
  2433. * @returns a new Size copied from the given one.
  2434. */
  2435. clone(): Size;
  2436. /**
  2437. * True if the current Size and the given one width and height are strictly equal.
  2438. * @param other the other size to compare against
  2439. * @returns True if the current Size and the given one width and height are strictly equal.
  2440. */
  2441. equals(other: Size): boolean;
  2442. /**
  2443. * The surface of the Size : width * height (float).
  2444. */
  2445. readonly surface: number;
  2446. /**
  2447. * Create a new size of zero
  2448. * @returns a new Size set to (0.0, 0.0)
  2449. */
  2450. static Zero(): Size;
  2451. /**
  2452. * Sums the width and height of two sizes
  2453. * @param otherSize size to add to this size
  2454. * @returns a new Size set as the addition result of the current Size and the given one.
  2455. */
  2456. add(otherSize: Size): Size;
  2457. /**
  2458. * Subtracts the width and height of two
  2459. * @param otherSize size to subtract to this size
  2460. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2461. */
  2462. subtract(otherSize: Size): Size;
  2463. /**
  2464. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2465. * @param start starting size to lerp between
  2466. * @param end end size to lerp between
  2467. * @param amount amount to lerp between the start and end values
  2468. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2469. */
  2470. static Lerp(start: Size, end: Size, amount: number): Size;
  2471. }
  2472. /**
  2473. * Class used to store quaternion data
  2474. * @see https://en.wikipedia.org/wiki/Quaternion
  2475. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2476. */
  2477. export class Quaternion {
  2478. /** defines the first component (0 by default) */
  2479. x: number;
  2480. /** defines the second component (0 by default) */
  2481. y: number;
  2482. /** defines the third component (0 by default) */
  2483. z: number;
  2484. /** defines the fourth component (1.0 by default) */
  2485. w: number;
  2486. /**
  2487. * Creates a new Quaternion from the given floats
  2488. * @param x defines the first component (0 by default)
  2489. * @param y defines the second component (0 by default)
  2490. * @param z defines the third component (0 by default)
  2491. * @param w defines the fourth component (1.0 by default)
  2492. */
  2493. constructor(
  2494. /** defines the first component (0 by default) */
  2495. x?: number,
  2496. /** defines the second component (0 by default) */
  2497. y?: number,
  2498. /** defines the third component (0 by default) */
  2499. z?: number,
  2500. /** defines the fourth component (1.0 by default) */
  2501. w?: number);
  2502. /**
  2503. * Gets a string representation for the current quaternion
  2504. * @returns a string with the Quaternion coordinates
  2505. */
  2506. toString(): string;
  2507. /**
  2508. * Gets the class name of the quaternion
  2509. * @returns the string "Quaternion"
  2510. */
  2511. getClassName(): string;
  2512. /**
  2513. * Gets a hash code for this quaternion
  2514. * @returns the quaternion hash code
  2515. */
  2516. getHashCode(): number;
  2517. /**
  2518. * Copy the quaternion to an array
  2519. * @returns a new array populated with 4 elements from the quaternion coordinates
  2520. */
  2521. asArray(): number[];
  2522. /**
  2523. * Check if two quaternions are equals
  2524. * @param otherQuaternion defines the second operand
  2525. * @return true if the current quaternion and the given one coordinates are strictly equals
  2526. */
  2527. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2528. /**
  2529. * Clone the current quaternion
  2530. * @returns a new quaternion copied from the current one
  2531. */
  2532. clone(): Quaternion;
  2533. /**
  2534. * Copy a quaternion to the current one
  2535. * @param other defines the other quaternion
  2536. * @returns the updated current quaternion
  2537. */
  2538. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2539. /**
  2540. * Updates the current quaternion with the given float coordinates
  2541. * @param x defines the x coordinate
  2542. * @param y defines the y coordinate
  2543. * @param z defines the z coordinate
  2544. * @param w defines the w coordinate
  2545. * @returns the updated current quaternion
  2546. */
  2547. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2548. /**
  2549. * Updates the current quaternion from the given float coordinates
  2550. * @param x defines the x coordinate
  2551. * @param y defines the y coordinate
  2552. * @param z defines the z coordinate
  2553. * @param w defines the w coordinate
  2554. * @returns the updated current quaternion
  2555. */
  2556. set(x: number, y: number, z: number, w: number): Quaternion;
  2557. /**
  2558. * Adds two quaternions
  2559. * @param other defines the second operand
  2560. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2561. */
  2562. add(other: DeepImmutable<Quaternion>): Quaternion;
  2563. /**
  2564. * Add a quaternion to the current one
  2565. * @param other defines the quaternion to add
  2566. * @returns the current quaternion
  2567. */
  2568. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2569. /**
  2570. * Subtract two quaternions
  2571. * @param other defines the second operand
  2572. * @returns a new quaternion as the subtraction result of the given one from the current one
  2573. */
  2574. subtract(other: Quaternion): Quaternion;
  2575. /**
  2576. * Multiplies the current quaternion by a scale factor
  2577. * @param value defines the scale factor
  2578. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2579. */
  2580. scale(value: number): Quaternion;
  2581. /**
  2582. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2583. * @param scale defines the scale factor
  2584. * @param result defines the Quaternion object where to store the result
  2585. * @returns the unmodified current quaternion
  2586. */
  2587. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2588. /**
  2589. * Multiplies in place the current quaternion by a scale factor
  2590. * @param value defines the scale factor
  2591. * @returns the current modified quaternion
  2592. */
  2593. scaleInPlace(value: number): Quaternion;
  2594. /**
  2595. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2596. * @param scale defines the scale factor
  2597. * @param result defines the Quaternion object where to store the result
  2598. * @returns the unmodified current quaternion
  2599. */
  2600. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2601. /**
  2602. * Multiplies two quaternions
  2603. * @param q1 defines the second operand
  2604. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2605. */
  2606. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2607. /**
  2608. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2609. * @param q1 defines the second operand
  2610. * @param result defines the target quaternion
  2611. * @returns the current quaternion
  2612. */
  2613. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2614. /**
  2615. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2616. * @param q1 defines the second operand
  2617. * @returns the currentupdated quaternion
  2618. */
  2619. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2620. /**
  2621. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2622. * @param ref defines the target quaternion
  2623. * @returns the current quaternion
  2624. */
  2625. conjugateToRef(ref: Quaternion): Quaternion;
  2626. /**
  2627. * Conjugates in place (1-q) the current quaternion
  2628. * @returns the current updated quaternion
  2629. */
  2630. conjugateInPlace(): Quaternion;
  2631. /**
  2632. * Conjugates in place (1-q) the current quaternion
  2633. * @returns a new quaternion
  2634. */
  2635. conjugate(): Quaternion;
  2636. /**
  2637. * Gets length of current quaternion
  2638. * @returns the quaternion length (float)
  2639. */
  2640. length(): number;
  2641. /**
  2642. * Normalize in place the current quaternion
  2643. * @returns the current updated quaternion
  2644. */
  2645. normalize(): Quaternion;
  2646. /**
  2647. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2648. * @param order is a reserved parameter and is ignore for now
  2649. * @returns a new Vector3 containing the Euler angles
  2650. */
  2651. toEulerAngles(order?: string): Vector3;
  2652. /**
  2653. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2654. * @param result defines the vector which will be filled with the Euler angles
  2655. * @param order is a reserved parameter and is ignore for now
  2656. * @returns the current unchanged quaternion
  2657. */
  2658. toEulerAnglesToRef(result: Vector3): Quaternion;
  2659. /**
  2660. * Updates the given rotation matrix with the current quaternion values
  2661. * @param result defines the target matrix
  2662. * @returns the current unchanged quaternion
  2663. */
  2664. toRotationMatrix(result: Matrix): Quaternion;
  2665. /**
  2666. * Updates the current quaternion from the given rotation matrix values
  2667. * @param matrix defines the source matrix
  2668. * @returns the current updated quaternion
  2669. */
  2670. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2671. /**
  2672. * Creates a new quaternion from a rotation matrix
  2673. * @param matrix defines the source matrix
  2674. * @returns a new quaternion created from the given rotation matrix values
  2675. */
  2676. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2677. /**
  2678. * Updates the given quaternion with the given rotation matrix values
  2679. * @param matrix defines the source matrix
  2680. * @param result defines the target quaternion
  2681. */
  2682. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2683. /**
  2684. * Returns the dot product (float) between the quaternions "left" and "right"
  2685. * @param left defines the left operand
  2686. * @param right defines the right operand
  2687. * @returns the dot product
  2688. */
  2689. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2690. /**
  2691. * Checks if the two quaternions are close to each other
  2692. * @param quat0 defines the first quaternion to check
  2693. * @param quat1 defines the second quaternion to check
  2694. * @returns true if the two quaternions are close to each other
  2695. */
  2696. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2697. /**
  2698. * Creates an empty quaternion
  2699. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2700. */
  2701. static Zero(): Quaternion;
  2702. /**
  2703. * Inverse a given quaternion
  2704. * @param q defines the source quaternion
  2705. * @returns a new quaternion as the inverted current quaternion
  2706. */
  2707. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2708. /**
  2709. * Inverse a given quaternion
  2710. * @param q defines the source quaternion
  2711. * @param result the quaternion the result will be stored in
  2712. * @returns the result quaternion
  2713. */
  2714. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2715. /**
  2716. * Creates an identity quaternion
  2717. * @returns the identity quaternion
  2718. */
  2719. static Identity(): Quaternion;
  2720. /**
  2721. * Gets a boolean indicating if the given quaternion is identity
  2722. * @param quaternion defines the quaternion to check
  2723. * @returns true if the quaternion is identity
  2724. */
  2725. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2726. /**
  2727. * Creates a quaternion from a rotation around an axis
  2728. * @param axis defines the axis to use
  2729. * @param angle defines the angle to use
  2730. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2731. */
  2732. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2733. /**
  2734. * Creates a rotation around an axis and stores it into the given quaternion
  2735. * @param axis defines the axis to use
  2736. * @param angle defines the angle to use
  2737. * @param result defines the target quaternion
  2738. * @returns the target quaternion
  2739. */
  2740. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2741. /**
  2742. * Creates a new quaternion from data stored into an array
  2743. * @param array defines the data source
  2744. * @param offset defines the offset in the source array where the data starts
  2745. * @returns a new quaternion
  2746. */
  2747. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2748. /**
  2749. * Create a quaternion from Euler rotation angles
  2750. * @param x Pitch
  2751. * @param y Yaw
  2752. * @param z Roll
  2753. * @returns the new Quaternion
  2754. */
  2755. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2756. /**
  2757. * Updates a quaternion from Euler rotation angles
  2758. * @param x Pitch
  2759. * @param y Yaw
  2760. * @param z Roll
  2761. * @param result the quaternion to store the result
  2762. * @returns the updated quaternion
  2763. */
  2764. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2765. /**
  2766. * Create a quaternion from Euler rotation vector
  2767. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2768. * @returns the new Quaternion
  2769. */
  2770. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2771. /**
  2772. * Updates a quaternion from Euler rotation vector
  2773. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2774. * @param result the quaternion to store the result
  2775. * @returns the updated quaternion
  2776. */
  2777. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2778. /**
  2779. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2780. * @param yaw defines the rotation around Y axis
  2781. * @param pitch defines the rotation around X axis
  2782. * @param roll defines the rotation around Z axis
  2783. * @returns the new quaternion
  2784. */
  2785. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2786. /**
  2787. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2788. * @param yaw defines the rotation around Y axis
  2789. * @param pitch defines the rotation around X axis
  2790. * @param roll defines the rotation around Z axis
  2791. * @param result defines the target quaternion
  2792. */
  2793. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2794. /**
  2795. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2796. * @param alpha defines the rotation around first axis
  2797. * @param beta defines the rotation around second axis
  2798. * @param gamma defines the rotation around third axis
  2799. * @returns the new quaternion
  2800. */
  2801. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2802. /**
  2803. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2804. * @param alpha defines the rotation around first axis
  2805. * @param beta defines the rotation around second axis
  2806. * @param gamma defines the rotation around third axis
  2807. * @param result defines the target quaternion
  2808. */
  2809. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2810. /**
  2811. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2812. * @param axis1 defines the first axis
  2813. * @param axis2 defines the second axis
  2814. * @param axis3 defines the third axis
  2815. * @returns the new quaternion
  2816. */
  2817. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2818. /**
  2819. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2820. * @param axis1 defines the first axis
  2821. * @param axis2 defines the second axis
  2822. * @param axis3 defines the third axis
  2823. * @param ref defines the target quaternion
  2824. */
  2825. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2826. /**
  2827. * Interpolates between two quaternions
  2828. * @param left defines first quaternion
  2829. * @param right defines second quaternion
  2830. * @param amount defines the gradient to use
  2831. * @returns the new interpolated quaternion
  2832. */
  2833. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2834. /**
  2835. * Interpolates between two quaternions and stores it into a target quaternion
  2836. * @param left defines first quaternion
  2837. * @param right defines second quaternion
  2838. * @param amount defines the gradient to use
  2839. * @param result defines the target quaternion
  2840. */
  2841. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2842. /**
  2843. * Interpolate between two quaternions using Hermite interpolation
  2844. * @param value1 defines first quaternion
  2845. * @param tangent1 defines the incoming tangent
  2846. * @param value2 defines second quaternion
  2847. * @param tangent2 defines the outgoing tangent
  2848. * @param amount defines the target quaternion
  2849. * @returns the new interpolated quaternion
  2850. */
  2851. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2852. }
  2853. /**
  2854. * Class used to store matrix data (4x4)
  2855. */
  2856. export class Matrix {
  2857. private static _updateFlagSeed;
  2858. private static _identityReadOnly;
  2859. private _isIdentity;
  2860. private _isIdentityDirty;
  2861. private _isIdentity3x2;
  2862. private _isIdentity3x2Dirty;
  2863. /**
  2864. * Gets the update flag of the matrix which is an unique number for the matrix.
  2865. * It will be incremented every time the matrix data change.
  2866. * You can use it to speed the comparison between two versions of the same matrix.
  2867. */
  2868. updateFlag: number;
  2869. private readonly _m;
  2870. /**
  2871. * Gets the internal data of the matrix
  2872. */
  2873. readonly m: DeepImmutable<Float32Array>;
  2874. /** @hidden */
  2875. _markAsUpdated(): void;
  2876. /** @hidden */
  2877. private _updateIdentityStatus;
  2878. /**
  2879. * Creates an empty matrix (filled with zeros)
  2880. */
  2881. constructor();
  2882. /**
  2883. * Check if the current matrix is identity
  2884. * @returns true is the matrix is the identity matrix
  2885. */
  2886. isIdentity(): boolean;
  2887. /**
  2888. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2889. * @returns true is the matrix is the identity matrix
  2890. */
  2891. isIdentityAs3x2(): boolean;
  2892. /**
  2893. * Gets the determinant of the matrix
  2894. * @returns the matrix determinant
  2895. */
  2896. determinant(): number;
  2897. /**
  2898. * Returns the matrix as a Float32Array
  2899. * @returns the matrix underlying array
  2900. */
  2901. toArray(): DeepImmutable<Float32Array>;
  2902. /**
  2903. * Returns the matrix as a Float32Array
  2904. * @returns the matrix underlying array.
  2905. */
  2906. asArray(): DeepImmutable<Float32Array>;
  2907. /**
  2908. * Inverts the current matrix in place
  2909. * @returns the current inverted matrix
  2910. */
  2911. invert(): Matrix;
  2912. /**
  2913. * Sets all the matrix elements to zero
  2914. * @returns the current matrix
  2915. */
  2916. reset(): Matrix;
  2917. /**
  2918. * Adds the current matrix with a second one
  2919. * @param other defines the matrix to add
  2920. * @returns a new matrix as the addition of the current matrix and the given one
  2921. */
  2922. add(other: DeepImmutable<Matrix>): Matrix;
  2923. /**
  2924. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2925. * @param other defines the matrix to add
  2926. * @param result defines the target matrix
  2927. * @returns the current matrix
  2928. */
  2929. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2930. /**
  2931. * Adds in place the given matrix to the current matrix
  2932. * @param other defines the second operand
  2933. * @returns the current updated matrix
  2934. */
  2935. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2936. /**
  2937. * Sets the given matrix to the current inverted Matrix
  2938. * @param other defines the target matrix
  2939. * @returns the unmodified current matrix
  2940. */
  2941. invertToRef(other: Matrix): Matrix;
  2942. /**
  2943. * add a value at the specified position in the current Matrix
  2944. * @param index the index of the value within the matrix. between 0 and 15.
  2945. * @param value the value to be added
  2946. * @returns the current updated matrix
  2947. */
  2948. addAtIndex(index: number, value: number): Matrix;
  2949. /**
  2950. * mutiply the specified position in the current Matrix by a value
  2951. * @param index the index of the value within the matrix. between 0 and 15.
  2952. * @param value the value to be added
  2953. * @returns the current updated matrix
  2954. */
  2955. multiplyAtIndex(index: number, value: number): Matrix;
  2956. /**
  2957. * Inserts the translation vector (using 3 floats) in the current matrix
  2958. * @param x defines the 1st component of the translation
  2959. * @param y defines the 2nd component of the translation
  2960. * @param z defines the 3rd component of the translation
  2961. * @returns the current updated matrix
  2962. */
  2963. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2964. /**
  2965. * Adds the translation vector (using 3 floats) in the current matrix
  2966. * @param x defines the 1st component of the translation
  2967. * @param y defines the 2nd component of the translation
  2968. * @param z defines the 3rd component of the translation
  2969. * @returns the current updated matrix
  2970. */
  2971. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2972. /**
  2973. * Inserts the translation vector in the current matrix
  2974. * @param vector3 defines the translation to insert
  2975. * @returns the current updated matrix
  2976. */
  2977. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2978. /**
  2979. * Gets the translation value of the current matrix
  2980. * @returns a new Vector3 as the extracted translation from the matrix
  2981. */
  2982. getTranslation(): Vector3;
  2983. /**
  2984. * Fill a Vector3 with the extracted translation from the matrix
  2985. * @param result defines the Vector3 where to store the translation
  2986. * @returns the current matrix
  2987. */
  2988. getTranslationToRef(result: Vector3): Matrix;
  2989. /**
  2990. * Remove rotation and scaling part from the matrix
  2991. * @returns the updated matrix
  2992. */
  2993. removeRotationAndScaling(): Matrix;
  2994. /**
  2995. * Multiply two matrices
  2996. * @param other defines the second operand
  2997. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2998. */
  2999. multiply(other: DeepImmutable<Matrix>): Matrix;
  3000. /**
  3001. * Copy the current matrix from the given one
  3002. * @param other defines the source matrix
  3003. * @returns the current updated matrix
  3004. */
  3005. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3006. /**
  3007. * Populates the given array from the starting index with the current matrix values
  3008. * @param array defines the target array
  3009. * @param offset defines the offset in the target array where to start storing values
  3010. * @returns the current matrix
  3011. */
  3012. copyToArray(array: Float32Array, offset?: number): Matrix;
  3013. /**
  3014. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3015. * @param other defines the second operand
  3016. * @param result defines the matrix where to store the multiplication
  3017. * @returns the current matrix
  3018. */
  3019. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3020. /**
  3021. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3022. * @param other defines the second operand
  3023. * @param result defines the array where to store the multiplication
  3024. * @param offset defines the offset in the target array where to start storing values
  3025. * @returns the current matrix
  3026. */
  3027. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3028. /**
  3029. * Check equality between this matrix and a second one
  3030. * @param value defines the second matrix to compare
  3031. * @returns true is the current matrix and the given one values are strictly equal
  3032. */
  3033. equals(value: DeepImmutable<Matrix>): boolean;
  3034. /**
  3035. * Clone the current matrix
  3036. * @returns a new matrix from the current matrix
  3037. */
  3038. clone(): Matrix;
  3039. /**
  3040. * Returns the name of the current matrix class
  3041. * @returns the string "Matrix"
  3042. */
  3043. getClassName(): string;
  3044. /**
  3045. * Gets the hash code of the current matrix
  3046. * @returns the hash code
  3047. */
  3048. getHashCode(): number;
  3049. /**
  3050. * Decomposes the current Matrix into a translation, rotation and scaling components
  3051. * @param scale defines the scale vector3 given as a reference to update
  3052. * @param rotation defines the rotation quaternion given as a reference to update
  3053. * @param translation defines the translation vector3 given as a reference to update
  3054. * @returns true if operation was successful
  3055. */
  3056. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3057. /**
  3058. * Gets specific row of the matrix
  3059. * @param index defines the number of the row to get
  3060. * @returns the index-th row of the current matrix as a new Vector4
  3061. */
  3062. getRow(index: number): Nullable<Vector4>;
  3063. /**
  3064. * Sets the index-th row of the current matrix to the vector4 values
  3065. * @param index defines the number of the row to set
  3066. * @param row defines the target vector4
  3067. * @returns the updated current matrix
  3068. */
  3069. setRow(index: number, row: Vector4): Matrix;
  3070. /**
  3071. * Compute the transpose of the matrix
  3072. * @returns the new transposed matrix
  3073. */
  3074. transpose(): Matrix;
  3075. /**
  3076. * Compute the transpose of the matrix and store it in a given matrix
  3077. * @param result defines the target matrix
  3078. * @returns the current matrix
  3079. */
  3080. transposeToRef(result: Matrix): Matrix;
  3081. /**
  3082. * Sets the index-th row of the current matrix with the given 4 x float values
  3083. * @param index defines the row index
  3084. * @param x defines the x component to set
  3085. * @param y defines the y component to set
  3086. * @param z defines the z component to set
  3087. * @param w defines the w component to set
  3088. * @returns the updated current matrix
  3089. */
  3090. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3091. /**
  3092. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3093. * @param scale defines the scale factor
  3094. * @returns a new matrix
  3095. */
  3096. scale(scale: number): Matrix;
  3097. /**
  3098. * Scale the current matrix values by a factor to a given result matrix
  3099. * @param scale defines the scale factor
  3100. * @param result defines the matrix to store the result
  3101. * @returns the current matrix
  3102. */
  3103. scaleToRef(scale: number, result: Matrix): Matrix;
  3104. /**
  3105. * Scale the current matrix values by a factor and add the result to a given matrix
  3106. * @param scale defines the scale factor
  3107. * @param result defines the Matrix to store the result
  3108. * @returns the current matrix
  3109. */
  3110. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3111. /**
  3112. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3113. * @param ref matrix to store the result
  3114. */
  3115. toNormalMatrix(ref: Matrix): void;
  3116. /**
  3117. * Gets only rotation part of the current matrix
  3118. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3119. */
  3120. getRotationMatrix(): Matrix;
  3121. /**
  3122. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3123. * @param result defines the target matrix to store data to
  3124. * @returns the current matrix
  3125. */
  3126. getRotationMatrixToRef(result: Matrix): Matrix;
  3127. /**
  3128. * Toggles model matrix from being right handed to left handed in place and vice versa
  3129. */
  3130. toggleModelMatrixHandInPlace(): void;
  3131. /**
  3132. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3133. */
  3134. toggleProjectionMatrixHandInPlace(): void;
  3135. /**
  3136. * Creates a matrix from an array
  3137. * @param array defines the source array
  3138. * @param offset defines an offset in the source array
  3139. * @returns a new Matrix set from the starting index of the given array
  3140. */
  3141. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3142. /**
  3143. * Copy the content of an array into a given matrix
  3144. * @param array defines the source array
  3145. * @param offset defines an offset in the source array
  3146. * @param result defines the target matrix
  3147. */
  3148. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3149. /**
  3150. * Stores an array into a matrix after having multiplied each component by a given factor
  3151. * @param array defines the source array
  3152. * @param offset defines the offset in the source array
  3153. * @param scale defines the scaling factor
  3154. * @param result defines the target matrix
  3155. */
  3156. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3157. /**
  3158. * Gets an identity matrix that must not be updated
  3159. */
  3160. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3161. /**
  3162. * Stores a list of values (16) inside a given matrix
  3163. * @param initialM11 defines 1st value of 1st row
  3164. * @param initialM12 defines 2nd value of 1st row
  3165. * @param initialM13 defines 3rd value of 1st row
  3166. * @param initialM14 defines 4th value of 1st row
  3167. * @param initialM21 defines 1st value of 2nd row
  3168. * @param initialM22 defines 2nd value of 2nd row
  3169. * @param initialM23 defines 3rd value of 2nd row
  3170. * @param initialM24 defines 4th value of 2nd row
  3171. * @param initialM31 defines 1st value of 3rd row
  3172. * @param initialM32 defines 2nd value of 3rd row
  3173. * @param initialM33 defines 3rd value of 3rd row
  3174. * @param initialM34 defines 4th value of 3rd row
  3175. * @param initialM41 defines 1st value of 4th row
  3176. * @param initialM42 defines 2nd value of 4th row
  3177. * @param initialM43 defines 3rd value of 4th row
  3178. * @param initialM44 defines 4th value of 4th row
  3179. * @param result defines the target matrix
  3180. */
  3181. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3182. /**
  3183. * Creates new matrix from a list of values (16)
  3184. * @param initialM11 defines 1st value of 1st row
  3185. * @param initialM12 defines 2nd value of 1st row
  3186. * @param initialM13 defines 3rd value of 1st row
  3187. * @param initialM14 defines 4th value of 1st row
  3188. * @param initialM21 defines 1st value of 2nd row
  3189. * @param initialM22 defines 2nd value of 2nd row
  3190. * @param initialM23 defines 3rd value of 2nd row
  3191. * @param initialM24 defines 4th value of 2nd row
  3192. * @param initialM31 defines 1st value of 3rd row
  3193. * @param initialM32 defines 2nd value of 3rd row
  3194. * @param initialM33 defines 3rd value of 3rd row
  3195. * @param initialM34 defines 4th value of 3rd row
  3196. * @param initialM41 defines 1st value of 4th row
  3197. * @param initialM42 defines 2nd value of 4th row
  3198. * @param initialM43 defines 3rd value of 4th row
  3199. * @param initialM44 defines 4th value of 4th row
  3200. * @returns the new matrix
  3201. */
  3202. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3203. /**
  3204. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3205. * @param scale defines the scale vector3
  3206. * @param rotation defines the rotation quaternion
  3207. * @param translation defines the translation vector3
  3208. * @returns a new matrix
  3209. */
  3210. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3211. /**
  3212. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3213. * @param scale defines the scale vector3
  3214. * @param rotation defines the rotation quaternion
  3215. * @param translation defines the translation vector3
  3216. * @param result defines the target matrix
  3217. */
  3218. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3219. /**
  3220. * Creates a new identity matrix
  3221. * @returns a new identity matrix
  3222. */
  3223. static Identity(): Matrix;
  3224. /**
  3225. * Creates a new identity matrix and stores the result in a given matrix
  3226. * @param result defines the target matrix
  3227. */
  3228. static IdentityToRef(result: Matrix): void;
  3229. /**
  3230. * Creates a new zero matrix
  3231. * @returns a new zero matrix
  3232. */
  3233. static Zero(): Matrix;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the X axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationX(angle: number): Matrix;
  3240. /**
  3241. * Creates a new matrix as the invert of a given matrix
  3242. * @param source defines the source matrix
  3243. * @returns the new matrix
  3244. */
  3245. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3248. * @param angle defines the angle (in radians) to use
  3249. * @param result defines the target matrix
  3250. */
  3251. static RotationXToRef(angle: number, result: Matrix): void;
  3252. /**
  3253. * Creates a new rotation matrix for "angle" radians around the Y axis
  3254. * @param angle defines the angle (in radians) to use
  3255. * @return the new matrix
  3256. */
  3257. static RotationY(angle: number): Matrix;
  3258. /**
  3259. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3260. * @param angle defines the angle (in radians) to use
  3261. * @param result defines the target matrix
  3262. */
  3263. static RotationYToRef(angle: number, result: Matrix): void;
  3264. /**
  3265. * Creates a new rotation matrix for "angle" radians around the Z axis
  3266. * @param angle defines the angle (in radians) to use
  3267. * @return the new matrix
  3268. */
  3269. static RotationZ(angle: number): Matrix;
  3270. /**
  3271. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3272. * @param angle defines the angle (in radians) to use
  3273. * @param result defines the target matrix
  3274. */
  3275. static RotationZToRef(angle: number, result: Matrix): void;
  3276. /**
  3277. * Creates a new rotation matrix for "angle" radians around the given axis
  3278. * @param axis defines the axis to use
  3279. * @param angle defines the angle (in radians) to use
  3280. * @return the new matrix
  3281. */
  3282. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3283. /**
  3284. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3285. * @param axis defines the axis to use
  3286. * @param angle defines the angle (in radians) to use
  3287. * @param result defines the target matrix
  3288. */
  3289. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3290. /**
  3291. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3292. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3293. * @param from defines the vector to align
  3294. * @param to defines the vector to align to
  3295. * @param result defines the target matrix
  3296. */
  3297. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3298. /**
  3299. * Creates a rotation matrix
  3300. * @param yaw defines the yaw angle in radians (Y axis)
  3301. * @param pitch defines the pitch angle in radians (X axis)
  3302. * @param roll defines the roll angle in radians (X axis)
  3303. * @returns the new rotation matrix
  3304. */
  3305. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3306. /**
  3307. * Creates a rotation matrix and stores it in a given matrix
  3308. * @param yaw defines the yaw angle in radians (Y axis)
  3309. * @param pitch defines the pitch angle in radians (X axis)
  3310. * @param roll defines the roll angle in radians (X axis)
  3311. * @param result defines the target matrix
  3312. */
  3313. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3314. /**
  3315. * Creates a scaling matrix
  3316. * @param x defines the scale factor on X axis
  3317. * @param y defines the scale factor on Y axis
  3318. * @param z defines the scale factor on Z axis
  3319. * @returns the new matrix
  3320. */
  3321. static Scaling(x: number, y: number, z: number): Matrix;
  3322. /**
  3323. * Creates a scaling matrix and stores it in a given matrix
  3324. * @param x defines the scale factor on X axis
  3325. * @param y defines the scale factor on Y axis
  3326. * @param z defines the scale factor on Z axis
  3327. * @param result defines the target matrix
  3328. */
  3329. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3330. /**
  3331. * Creates a translation matrix
  3332. * @param x defines the translation on X axis
  3333. * @param y defines the translation on Y axis
  3334. * @param z defines the translationon Z axis
  3335. * @returns the new matrix
  3336. */
  3337. static Translation(x: number, y: number, z: number): Matrix;
  3338. /**
  3339. * Creates a translation matrix and stores it in a given matrix
  3340. * @param x defines the translation on X axis
  3341. * @param y defines the translation on Y axis
  3342. * @param z defines the translationon Z axis
  3343. * @param result defines the target matrix
  3344. */
  3345. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3346. /**
  3347. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3348. * @param startValue defines the start value
  3349. * @param endValue defines the end value
  3350. * @param gradient defines the gradient factor
  3351. * @returns the new matrix
  3352. */
  3353. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3354. /**
  3355. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3356. * @param startValue defines the start value
  3357. * @param endValue defines the end value
  3358. * @param gradient defines the gradient factor
  3359. * @param result defines the Matrix object where to store data
  3360. */
  3361. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3362. /**
  3363. * Builds a new matrix whose values are computed by:
  3364. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3365. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3366. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3367. * @param startValue defines the first matrix
  3368. * @param endValue defines the second matrix
  3369. * @param gradient defines the gradient between the two matrices
  3370. * @returns the new matrix
  3371. */
  3372. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3373. /**
  3374. * Update a matrix to values which are computed by:
  3375. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3376. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3377. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3378. * @param startValue defines the first matrix
  3379. * @param endValue defines the second matrix
  3380. * @param gradient defines the gradient between the two matrices
  3381. * @param result defines the target matrix
  3382. */
  3383. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3384. /**
  3385. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3386. * This function works in left handed mode
  3387. * @param eye defines the final position of the entity
  3388. * @param target defines where the entity should look at
  3389. * @param up defines the up vector for the entity
  3390. * @returns the new matrix
  3391. */
  3392. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3393. /**
  3394. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3395. * This function works in left handed mode
  3396. * @param eye defines the final position of the entity
  3397. * @param target defines where the entity should look at
  3398. * @param up defines the up vector for the entity
  3399. * @param result defines the target matrix
  3400. */
  3401. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3402. /**
  3403. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3404. * This function works in right handed mode
  3405. * @param eye defines the final position of the entity
  3406. * @param target defines where the entity should look at
  3407. * @param up defines the up vector for the entity
  3408. * @returns the new matrix
  3409. */
  3410. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3411. /**
  3412. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3413. * This function works in right handed mode
  3414. * @param eye defines the final position of the entity
  3415. * @param target defines where the entity should look at
  3416. * @param up defines the up vector for the entity
  3417. * @param result defines the target matrix
  3418. */
  3419. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3420. /**
  3421. * Create a left-handed orthographic projection matrix
  3422. * @param width defines the viewport width
  3423. * @param height defines the viewport height
  3424. * @param znear defines the near clip plane
  3425. * @param zfar defines the far clip plane
  3426. * @returns a new matrix as a left-handed orthographic projection matrix
  3427. */
  3428. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3429. /**
  3430. * Store a left-handed orthographic projection to a given matrix
  3431. * @param width defines the viewport width
  3432. * @param height defines the viewport height
  3433. * @param znear defines the near clip plane
  3434. * @param zfar defines the far clip plane
  3435. * @param result defines the target matrix
  3436. */
  3437. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3438. /**
  3439. * Create a left-handed orthographic projection matrix
  3440. * @param left defines the viewport left coordinate
  3441. * @param right defines the viewport right coordinate
  3442. * @param bottom defines the viewport bottom coordinate
  3443. * @param top defines the viewport top coordinate
  3444. * @param znear defines the near clip plane
  3445. * @param zfar defines the far clip plane
  3446. * @returns a new matrix as a left-handed orthographic projection matrix
  3447. */
  3448. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3449. /**
  3450. * Stores a left-handed orthographic projection into a given matrix
  3451. * @param left defines the viewport left coordinate
  3452. * @param right defines the viewport right coordinate
  3453. * @param bottom defines the viewport bottom coordinate
  3454. * @param top defines the viewport top coordinate
  3455. * @param znear defines the near clip plane
  3456. * @param zfar defines the far clip plane
  3457. * @param result defines the target matrix
  3458. */
  3459. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3460. /**
  3461. * Creates a right-handed orthographic projection matrix
  3462. * @param left defines the viewport left coordinate
  3463. * @param right defines the viewport right coordinate
  3464. * @param bottom defines the viewport bottom coordinate
  3465. * @param top defines the viewport top coordinate
  3466. * @param znear defines the near clip plane
  3467. * @param zfar defines the far clip plane
  3468. * @returns a new matrix as a right-handed orthographic projection matrix
  3469. */
  3470. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3471. /**
  3472. * Stores a right-handed orthographic projection into a given matrix
  3473. * @param left defines the viewport left coordinate
  3474. * @param right defines the viewport right coordinate
  3475. * @param bottom defines the viewport bottom coordinate
  3476. * @param top defines the viewport top coordinate
  3477. * @param znear defines the near clip plane
  3478. * @param zfar defines the far clip plane
  3479. * @param result defines the target matrix
  3480. */
  3481. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3482. /**
  3483. * Creates a left-handed perspective projection matrix
  3484. * @param width defines the viewport width
  3485. * @param height defines the viewport height
  3486. * @param znear defines the near clip plane
  3487. * @param zfar defines the far clip plane
  3488. * @returns a new matrix as a left-handed perspective projection matrix
  3489. */
  3490. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3491. /**
  3492. * Creates a left-handed perspective projection matrix
  3493. * @param fov defines the horizontal field of view
  3494. * @param aspect defines the aspect ratio
  3495. * @param znear defines the near clip plane
  3496. * @param zfar defines the far clip plane
  3497. * @returns a new matrix as a left-handed perspective projection matrix
  3498. */
  3499. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3500. /**
  3501. * Stores a left-handed perspective projection into a given matrix
  3502. * @param fov defines the horizontal field of view
  3503. * @param aspect defines the aspect ratio
  3504. * @param znear defines the near clip plane
  3505. * @param zfar defines the far clip plane
  3506. * @param result defines the target matrix
  3507. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3508. */
  3509. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3510. /**
  3511. * Creates a right-handed perspective projection matrix
  3512. * @param fov defines the horizontal field of view
  3513. * @param aspect defines the aspect ratio
  3514. * @param znear defines the near clip plane
  3515. * @param zfar defines the far clip plane
  3516. * @returns a new matrix as a right-handed perspective projection matrix
  3517. */
  3518. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3519. /**
  3520. * Stores a right-handed perspective projection into a given matrix
  3521. * @param fov defines the horizontal field of view
  3522. * @param aspect defines the aspect ratio
  3523. * @param znear defines the near clip plane
  3524. * @param zfar defines the far clip plane
  3525. * @param result defines the target matrix
  3526. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3527. */
  3528. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3529. /**
  3530. * Stores a perspective projection for WebVR info a given matrix
  3531. * @param fov defines the field of view
  3532. * @param znear defines the near clip plane
  3533. * @param zfar defines the far clip plane
  3534. * @param result defines the target matrix
  3535. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3536. */
  3537. static PerspectiveFovWebVRToRef(fov: {
  3538. upDegrees: number;
  3539. downDegrees: number;
  3540. leftDegrees: number;
  3541. rightDegrees: number;
  3542. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3543. /**
  3544. * Computes a complete transformation matrix
  3545. * @param viewport defines the viewport to use
  3546. * @param world defines the world matrix
  3547. * @param view defines the view matrix
  3548. * @param projection defines the projection matrix
  3549. * @param zmin defines the near clip plane
  3550. * @param zmax defines the far clip plane
  3551. * @returns the transformation matrix
  3552. */
  3553. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3554. /**
  3555. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3556. * @param matrix defines the matrix to use
  3557. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3558. */
  3559. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3560. /**
  3561. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3562. * @param matrix defines the matrix to use
  3563. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3564. */
  3565. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3566. /**
  3567. * Compute the transpose of a given matrix
  3568. * @param matrix defines the matrix to transpose
  3569. * @returns the new matrix
  3570. */
  3571. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3572. /**
  3573. * Compute the transpose of a matrix and store it in a target matrix
  3574. * @param matrix defines the matrix to transpose
  3575. * @param result defines the target matrix
  3576. */
  3577. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3578. /**
  3579. * Computes a reflection matrix from a plane
  3580. * @param plane defines the reflection plane
  3581. * @returns a new matrix
  3582. */
  3583. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3584. /**
  3585. * Computes a reflection matrix from a plane
  3586. * @param plane defines the reflection plane
  3587. * @param result defines the target matrix
  3588. */
  3589. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3590. /**
  3591. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3592. * @param xaxis defines the value of the 1st axis
  3593. * @param yaxis defines the value of the 2nd axis
  3594. * @param zaxis defines the value of the 3rd axis
  3595. * @param result defines the target matrix
  3596. */
  3597. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3598. /**
  3599. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3600. * @param quat defines the quaternion to use
  3601. * @param result defines the target matrix
  3602. */
  3603. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3604. }
  3605. /**
  3606. * Represens a plane by the equation ax + by + cz + d = 0
  3607. */
  3608. export class Plane {
  3609. /**
  3610. * Normal of the plane (a,b,c)
  3611. */
  3612. normal: Vector3;
  3613. /**
  3614. * d component of the plane
  3615. */
  3616. d: number;
  3617. /**
  3618. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3619. * @param a a component of the plane
  3620. * @param b b component of the plane
  3621. * @param c c component of the plane
  3622. * @param d d component of the plane
  3623. */
  3624. constructor(a: number, b: number, c: number, d: number);
  3625. /**
  3626. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3627. */
  3628. asArray(): number[];
  3629. /**
  3630. * @returns a new plane copied from the current Plane.
  3631. */
  3632. clone(): Plane;
  3633. /**
  3634. * @returns the string "Plane".
  3635. */
  3636. getClassName(): string;
  3637. /**
  3638. * @returns the Plane hash code.
  3639. */
  3640. getHashCode(): number;
  3641. /**
  3642. * Normalize the current Plane in place.
  3643. * @returns the updated Plane.
  3644. */
  3645. normalize(): Plane;
  3646. /**
  3647. * Applies a transformation the plane and returns the result
  3648. * @param transformation the transformation matrix to be applied to the plane
  3649. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3650. */
  3651. transform(transformation: DeepImmutable<Matrix>): Plane;
  3652. /**
  3653. * Calcualtte the dot product between the point and the plane normal
  3654. * @param point point to calculate the dot product with
  3655. * @returns the dot product (float) of the point coordinates and the plane normal.
  3656. */
  3657. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3658. /**
  3659. * Updates the current Plane from the plane defined by the three given points.
  3660. * @param point1 one of the points used to contruct the plane
  3661. * @param point2 one of the points used to contruct the plane
  3662. * @param point3 one of the points used to contruct the plane
  3663. * @returns the updated Plane.
  3664. */
  3665. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3666. /**
  3667. * Checks if the plane is facing a given direction
  3668. * @param direction the direction to check if the plane is facing
  3669. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3670. * @returns True is the vector "direction" is the same side than the plane normal.
  3671. */
  3672. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3673. /**
  3674. * Calculates the distance to a point
  3675. * @param point point to calculate distance to
  3676. * @returns the signed distance (float) from the given point to the Plane.
  3677. */
  3678. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3679. /**
  3680. * Creates a plane from an array
  3681. * @param array the array to create a plane from
  3682. * @returns a new Plane from the given array.
  3683. */
  3684. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3685. /**
  3686. * Creates a plane from three points
  3687. * @param point1 point used to create the plane
  3688. * @param point2 point used to create the plane
  3689. * @param point3 point used to create the plane
  3690. * @returns a new Plane defined by the three given points.
  3691. */
  3692. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3693. /**
  3694. * Creates a plane from an origin point and a normal
  3695. * @param origin origin of the plane to be constructed
  3696. * @param normal normal of the plane to be constructed
  3697. * @returns a new Plane the normal vector to this plane at the given origin point.
  3698. * Note : the vector "normal" is updated because normalized.
  3699. */
  3700. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3701. /**
  3702. * Calculates the distance from a plane and a point
  3703. * @param origin origin of the plane to be constructed
  3704. * @param normal normal of the plane to be constructed
  3705. * @param point point to calculate distance to
  3706. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3707. */
  3708. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3709. }
  3710. /**
  3711. * Class used to represent a viewport on screen
  3712. */
  3713. export class Viewport {
  3714. /** viewport left coordinate */
  3715. x: number;
  3716. /** viewport top coordinate */
  3717. y: number;
  3718. /**viewport width */
  3719. width: number;
  3720. /** viewport height */
  3721. height: number;
  3722. /**
  3723. * Creates a Viewport object located at (x, y) and sized (width, height)
  3724. * @param x defines viewport left coordinate
  3725. * @param y defines viewport top coordinate
  3726. * @param width defines the viewport width
  3727. * @param height defines the viewport height
  3728. */
  3729. constructor(
  3730. /** viewport left coordinate */
  3731. x: number,
  3732. /** viewport top coordinate */
  3733. y: number,
  3734. /**viewport width */
  3735. width: number,
  3736. /** viewport height */
  3737. height: number);
  3738. /**
  3739. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3740. * @param renderWidth defines the rendering width
  3741. * @param renderHeight defines the rendering height
  3742. * @returns a new Viewport
  3743. */
  3744. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3745. /**
  3746. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3747. * @param renderWidth defines the rendering width
  3748. * @param renderHeight defines the rendering height
  3749. * @param ref defines the target viewport
  3750. * @returns the current viewport
  3751. */
  3752. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3753. /**
  3754. * Returns a new Viewport copied from the current one
  3755. * @returns a new Viewport
  3756. */
  3757. clone(): Viewport;
  3758. }
  3759. /**
  3760. * Reprasents a camera frustum
  3761. */
  3762. export class Frustum {
  3763. /**
  3764. * Gets the planes representing the frustum
  3765. * @param transform matrix to be applied to the returned planes
  3766. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3767. */
  3768. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3769. /**
  3770. * Gets the near frustum plane transformed by the transform matrix
  3771. * @param transform transformation matrix to be applied to the resulting frustum plane
  3772. * @param frustumPlane the resuling frustum plane
  3773. */
  3774. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3775. /**
  3776. * Gets the far frustum plane transformed by the transform matrix
  3777. * @param transform transformation matrix to be applied to the resulting frustum plane
  3778. * @param frustumPlane the resuling frustum plane
  3779. */
  3780. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3781. /**
  3782. * Gets the left frustum plane transformed by the transform matrix
  3783. * @param transform transformation matrix to be applied to the resulting frustum plane
  3784. * @param frustumPlane the resuling frustum plane
  3785. */
  3786. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3787. /**
  3788. * Gets the right frustum plane transformed by the transform matrix
  3789. * @param transform transformation matrix to be applied to the resulting frustum plane
  3790. * @param frustumPlane the resuling frustum plane
  3791. */
  3792. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3793. /**
  3794. * Gets the top frustum plane transformed by the transform matrix
  3795. * @param transform transformation matrix to be applied to the resulting frustum plane
  3796. * @param frustumPlane the resuling frustum plane
  3797. */
  3798. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3799. /**
  3800. * Gets the bottom frustum plane transformed by the transform matrix
  3801. * @param transform transformation matrix to be applied to the resulting frustum plane
  3802. * @param frustumPlane the resuling frustum plane
  3803. */
  3804. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3805. /**
  3806. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3807. * @param transform transformation matrix to be applied to the resulting frustum planes
  3808. * @param frustumPlanes the resuling frustum planes
  3809. */
  3810. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3811. }
  3812. /** Defines supported spaces */
  3813. export enum Space {
  3814. /** Local (object) space */
  3815. LOCAL = 0,
  3816. /** World space */
  3817. WORLD = 1,
  3818. /** Bone space */
  3819. BONE = 2
  3820. }
  3821. /** Defines the 3 main axes */
  3822. export class Axis {
  3823. /** X axis */
  3824. static X: Vector3;
  3825. /** Y axis */
  3826. static Y: Vector3;
  3827. /** Z axis */
  3828. static Z: Vector3;
  3829. }
  3830. /** Class used to represent a Bezier curve */
  3831. export class BezierCurve {
  3832. /**
  3833. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3834. * @param t defines the time
  3835. * @param x1 defines the left coordinate on X axis
  3836. * @param y1 defines the left coordinate on Y axis
  3837. * @param x2 defines the right coordinate on X axis
  3838. * @param y2 defines the right coordinate on Y axis
  3839. * @returns the interpolated value
  3840. */
  3841. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3842. }
  3843. /**
  3844. * Defines potential orientation for back face culling
  3845. */
  3846. export enum Orientation {
  3847. /**
  3848. * Clockwise
  3849. */
  3850. CW = 0,
  3851. /** Counter clockwise */
  3852. CCW = 1
  3853. }
  3854. /**
  3855. * Defines angle representation
  3856. */
  3857. export class Angle {
  3858. private _radians;
  3859. /**
  3860. * Creates an Angle object of "radians" radians (float).
  3861. * @param radians the angle in radians
  3862. */
  3863. constructor(radians: number);
  3864. /**
  3865. * Get value in degrees
  3866. * @returns the Angle value in degrees (float)
  3867. */
  3868. degrees(): number;
  3869. /**
  3870. * Get value in radians
  3871. * @returns the Angle value in radians (float)
  3872. */
  3873. radians(): number;
  3874. /**
  3875. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3876. * @param a defines first vector
  3877. * @param b defines second vector
  3878. * @returns a new Angle
  3879. */
  3880. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3881. /**
  3882. * Gets a new Angle object from the given float in radians
  3883. * @param radians defines the angle value in radians
  3884. * @returns a new Angle
  3885. */
  3886. static FromRadians(radians: number): Angle;
  3887. /**
  3888. * Gets a new Angle object from the given float in degrees
  3889. * @param degrees defines the angle value in degrees
  3890. * @returns a new Angle
  3891. */
  3892. static FromDegrees(degrees: number): Angle;
  3893. }
  3894. /**
  3895. * This represents an arc in a 2d space.
  3896. */
  3897. export class Arc2 {
  3898. /** Defines the start point of the arc */
  3899. startPoint: Vector2;
  3900. /** Defines the mid point of the arc */
  3901. midPoint: Vector2;
  3902. /** Defines the end point of the arc */
  3903. endPoint: Vector2;
  3904. /**
  3905. * Defines the center point of the arc.
  3906. */
  3907. centerPoint: Vector2;
  3908. /**
  3909. * Defines the radius of the arc.
  3910. */
  3911. radius: number;
  3912. /**
  3913. * Defines the angle of the arc (from mid point to end point).
  3914. */
  3915. angle: Angle;
  3916. /**
  3917. * Defines the start angle of the arc (from start point to middle point).
  3918. */
  3919. startAngle: Angle;
  3920. /**
  3921. * Defines the orientation of the arc (clock wise/counter clock wise).
  3922. */
  3923. orientation: Orientation;
  3924. /**
  3925. * Creates an Arc object from the three given points : start, middle and end.
  3926. * @param startPoint Defines the start point of the arc
  3927. * @param midPoint Defines the midlle point of the arc
  3928. * @param endPoint Defines the end point of the arc
  3929. */
  3930. constructor(
  3931. /** Defines the start point of the arc */
  3932. startPoint: Vector2,
  3933. /** Defines the mid point of the arc */
  3934. midPoint: Vector2,
  3935. /** Defines the end point of the arc */
  3936. endPoint: Vector2);
  3937. }
  3938. /**
  3939. * Represents a 2D path made up of multiple 2D points
  3940. */
  3941. export class Path2 {
  3942. private _points;
  3943. private _length;
  3944. /**
  3945. * If the path start and end point are the same
  3946. */
  3947. closed: boolean;
  3948. /**
  3949. * Creates a Path2 object from the starting 2D coordinates x and y.
  3950. * @param x the starting points x value
  3951. * @param y the starting points y value
  3952. */
  3953. constructor(x: number, y: number);
  3954. /**
  3955. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3956. * @param x the added points x value
  3957. * @param y the added points y value
  3958. * @returns the updated Path2.
  3959. */
  3960. addLineTo(x: number, y: number): Path2;
  3961. /**
  3962. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3963. * @param midX middle point x value
  3964. * @param midY middle point y value
  3965. * @param endX end point x value
  3966. * @param endY end point y value
  3967. * @param numberOfSegments (default: 36)
  3968. * @returns the updated Path2.
  3969. */
  3970. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3971. /**
  3972. * Closes the Path2.
  3973. * @returns the Path2.
  3974. */
  3975. close(): Path2;
  3976. /**
  3977. * Gets the sum of the distance between each sequential point in the path
  3978. * @returns the Path2 total length (float).
  3979. */
  3980. length(): number;
  3981. /**
  3982. * Gets the points which construct the path
  3983. * @returns the Path2 internal array of points.
  3984. */
  3985. getPoints(): Vector2[];
  3986. /**
  3987. * Retreives the point at the distance aways from the starting point
  3988. * @param normalizedLengthPosition the length along the path to retreive the point from
  3989. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3990. */
  3991. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3992. /**
  3993. * Creates a new path starting from an x and y position
  3994. * @param x starting x value
  3995. * @param y starting y value
  3996. * @returns a new Path2 starting at the coordinates (x, y).
  3997. */
  3998. static StartingAt(x: number, y: number): Path2;
  3999. }
  4000. /**
  4001. * Represents a 3D path made up of multiple 3D points
  4002. */
  4003. export class Path3D {
  4004. /**
  4005. * an array of Vector3, the curve axis of the Path3D
  4006. */
  4007. path: Vector3[];
  4008. private _curve;
  4009. private _distances;
  4010. private _tangents;
  4011. private _normals;
  4012. private _binormals;
  4013. private _raw;
  4014. /**
  4015. * new Path3D(path, normal, raw)
  4016. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4017. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4018. * @param path an array of Vector3, the curve axis of the Path3D
  4019. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4020. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4021. */
  4022. constructor(
  4023. /**
  4024. * an array of Vector3, the curve axis of the Path3D
  4025. */
  4026. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4027. /**
  4028. * Returns the Path3D array of successive Vector3 designing its curve.
  4029. * @returns the Path3D array of successive Vector3 designing its curve.
  4030. */
  4031. getCurve(): Vector3[];
  4032. /**
  4033. * Returns an array populated with tangent vectors on each Path3D curve point.
  4034. * @returns an array populated with tangent vectors on each Path3D curve point.
  4035. */
  4036. getTangents(): Vector3[];
  4037. /**
  4038. * Returns an array populated with normal vectors on each Path3D curve point.
  4039. * @returns an array populated with normal vectors on each Path3D curve point.
  4040. */
  4041. getNormals(): Vector3[];
  4042. /**
  4043. * Returns an array populated with binormal vectors on each Path3D curve point.
  4044. * @returns an array populated with binormal vectors on each Path3D curve point.
  4045. */
  4046. getBinormals(): Vector3[];
  4047. /**
  4048. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4049. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4050. */
  4051. getDistances(): number[];
  4052. /**
  4053. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4054. * @param path path which all values are copied into the curves points
  4055. * @param firstNormal which should be projected onto the curve
  4056. * @returns the same object updated.
  4057. */
  4058. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4059. private _compute;
  4060. private _getFirstNonNullVector;
  4061. private _getLastNonNullVector;
  4062. private _normalVector;
  4063. }
  4064. /**
  4065. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4066. * A Curve3 is designed from a series of successive Vector3.
  4067. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4068. */
  4069. export class Curve3 {
  4070. private _points;
  4071. private _length;
  4072. /**
  4073. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4074. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4075. * @param v1 (Vector3) the control point
  4076. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4077. * @param nbPoints (integer) the wanted number of points in the curve
  4078. * @returns the created Curve3
  4079. */
  4080. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4081. /**
  4082. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4083. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4084. * @param v1 (Vector3) the first control point
  4085. * @param v2 (Vector3) the second control point
  4086. * @param v3 (Vector3) the end point of the Cubic Bezier
  4087. * @param nbPoints (integer) the wanted number of points in the curve
  4088. * @returns the created Curve3
  4089. */
  4090. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4091. /**
  4092. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4093. * @param p1 (Vector3) the origin point of the Hermite Spline
  4094. * @param t1 (Vector3) the tangent vector at the origin point
  4095. * @param p2 (Vector3) the end point of the Hermite Spline
  4096. * @param t2 (Vector3) the tangent vector at the end point
  4097. * @param nbPoints (integer) the wanted number of points in the curve
  4098. * @returns the created Curve3
  4099. */
  4100. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4101. /**
  4102. * Returns a Curve3 object along a CatmullRom Spline curve :
  4103. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4104. * @param nbPoints (integer) the wanted number of points between each curve control points
  4105. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4106. * @returns the created Curve3
  4107. */
  4108. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4109. /**
  4110. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4111. * A Curve3 is designed from a series of successive Vector3.
  4112. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4113. * @param points points which make up the curve
  4114. */
  4115. constructor(points: Vector3[]);
  4116. /**
  4117. * @returns the Curve3 stored array of successive Vector3
  4118. */
  4119. getPoints(): Vector3[];
  4120. /**
  4121. * @returns the computed length (float) of the curve.
  4122. */
  4123. length(): number;
  4124. /**
  4125. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4126. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4127. * curveA and curveB keep unchanged.
  4128. * @param curve the curve to continue from this curve
  4129. * @returns the newly constructed curve
  4130. */
  4131. continue(curve: DeepImmutable<Curve3>): Curve3;
  4132. private _computeLength;
  4133. }
  4134. /**
  4135. * Contains position and normal vectors for a vertex
  4136. */
  4137. export class PositionNormalVertex {
  4138. /** the position of the vertex (defaut: 0,0,0) */
  4139. position: Vector3;
  4140. /** the normal of the vertex (defaut: 0,1,0) */
  4141. normal: Vector3;
  4142. /**
  4143. * Creates a PositionNormalVertex
  4144. * @param position the position of the vertex (defaut: 0,0,0)
  4145. * @param normal the normal of the vertex (defaut: 0,1,0)
  4146. */
  4147. constructor(
  4148. /** the position of the vertex (defaut: 0,0,0) */
  4149. position?: Vector3,
  4150. /** the normal of the vertex (defaut: 0,1,0) */
  4151. normal?: Vector3);
  4152. /**
  4153. * Clones the PositionNormalVertex
  4154. * @returns the cloned PositionNormalVertex
  4155. */
  4156. clone(): PositionNormalVertex;
  4157. }
  4158. /**
  4159. * Contains position, normal and uv vectors for a vertex
  4160. */
  4161. export class PositionNormalTextureVertex {
  4162. /** the position of the vertex (defaut: 0,0,0) */
  4163. position: Vector3;
  4164. /** the normal of the vertex (defaut: 0,1,0) */
  4165. normal: Vector3;
  4166. /** the uv of the vertex (default: 0,0) */
  4167. uv: Vector2;
  4168. /**
  4169. * Creates a PositionNormalTextureVertex
  4170. * @param position the position of the vertex (defaut: 0,0,0)
  4171. * @param normal the normal of the vertex (defaut: 0,1,0)
  4172. * @param uv the uv of the vertex (default: 0,0)
  4173. */
  4174. constructor(
  4175. /** the position of the vertex (defaut: 0,0,0) */
  4176. position?: Vector3,
  4177. /** the normal of the vertex (defaut: 0,1,0) */
  4178. normal?: Vector3,
  4179. /** the uv of the vertex (default: 0,0) */
  4180. uv?: Vector2);
  4181. /**
  4182. * Clones the PositionNormalTextureVertex
  4183. * @returns the cloned PositionNormalTextureVertex
  4184. */
  4185. clone(): PositionNormalTextureVertex;
  4186. }
  4187. /**
  4188. * @hidden
  4189. */
  4190. export class Tmp {
  4191. static Color3: Color3[];
  4192. static Color4: Color4[];
  4193. static Vector2: Vector2[];
  4194. static Vector3: Vector3[];
  4195. static Vector4: Vector4[];
  4196. static Quaternion: Quaternion[];
  4197. static Matrix: Matrix[];
  4198. }
  4199. }
  4200. declare module BABYLON {
  4201. /**
  4202. * Class used to enable access to offline support
  4203. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4204. */
  4205. export interface IOfflineProvider {
  4206. /**
  4207. * Gets a boolean indicating if scene must be saved in the database
  4208. */
  4209. enableSceneOffline: boolean;
  4210. /**
  4211. * Gets a boolean indicating if textures must be saved in the database
  4212. */
  4213. enableTexturesOffline: boolean;
  4214. /**
  4215. * Open the offline support and make it available
  4216. * @param successCallback defines the callback to call on success
  4217. * @param errorCallback defines the callback to call on error
  4218. */
  4219. open(successCallback: () => void, errorCallback: () => void): void;
  4220. /**
  4221. * Loads an image from the offline support
  4222. * @param url defines the url to load from
  4223. * @param image defines the target DOM image
  4224. */
  4225. loadImage(url: string, image: HTMLImageElement): void;
  4226. /**
  4227. * Loads a file from offline support
  4228. * @param url defines the URL to load from
  4229. * @param sceneLoaded defines a callback to call on success
  4230. * @param progressCallBack defines a callback to call when progress changed
  4231. * @param errorCallback defines a callback to call on error
  4232. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4233. */
  4234. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4235. }
  4236. }
  4237. declare module BABYLON {
  4238. /**
  4239. * A class serves as a medium between the observable and its observers
  4240. */
  4241. export class EventState {
  4242. /**
  4243. * Create a new EventState
  4244. * @param mask defines the mask associated with this state
  4245. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4246. * @param target defines the original target of the state
  4247. * @param currentTarget defines the current target of the state
  4248. */
  4249. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4250. /**
  4251. * Initialize the current event state
  4252. * @param mask defines the mask associated with this state
  4253. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4254. * @param target defines the original target of the state
  4255. * @param currentTarget defines the current target of the state
  4256. * @returns the current event state
  4257. */
  4258. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4259. /**
  4260. * An Observer can set this property to true to prevent subsequent observers of being notified
  4261. */
  4262. skipNextObservers: boolean;
  4263. /**
  4264. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4265. */
  4266. mask: number;
  4267. /**
  4268. * The object that originally notified the event
  4269. */
  4270. target?: any;
  4271. /**
  4272. * The current object in the bubbling phase
  4273. */
  4274. currentTarget?: any;
  4275. /**
  4276. * This will be populated with the return value of the last function that was executed.
  4277. * If it is the first function in the callback chain it will be the event data.
  4278. */
  4279. lastReturnValue?: any;
  4280. }
  4281. /**
  4282. * Represent an Observer registered to a given Observable object.
  4283. */
  4284. export class Observer<T> {
  4285. /**
  4286. * Defines the callback to call when the observer is notified
  4287. */
  4288. callback: (eventData: T, eventState: EventState) => void;
  4289. /**
  4290. * Defines the mask of the observer (used to filter notifications)
  4291. */
  4292. mask: number;
  4293. /**
  4294. * Defines the current scope used to restore the JS context
  4295. */
  4296. scope: any;
  4297. /** @hidden */
  4298. _willBeUnregistered: boolean;
  4299. /**
  4300. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4301. */
  4302. unregisterOnNextCall: boolean;
  4303. /**
  4304. * Creates a new observer
  4305. * @param callback defines the callback to call when the observer is notified
  4306. * @param mask defines the mask of the observer (used to filter notifications)
  4307. * @param scope defines the current scope used to restore the JS context
  4308. */
  4309. constructor(
  4310. /**
  4311. * Defines the callback to call when the observer is notified
  4312. */
  4313. callback: (eventData: T, eventState: EventState) => void,
  4314. /**
  4315. * Defines the mask of the observer (used to filter notifications)
  4316. */
  4317. mask: number,
  4318. /**
  4319. * Defines the current scope used to restore the JS context
  4320. */
  4321. scope?: any);
  4322. }
  4323. /**
  4324. * Represent a list of observers registered to multiple Observables object.
  4325. */
  4326. export class MultiObserver<T> {
  4327. private _observers;
  4328. private _observables;
  4329. /**
  4330. * Release associated resources
  4331. */
  4332. dispose(): void;
  4333. /**
  4334. * Raise a callback when one of the observable will notify
  4335. * @param observables defines a list of observables to watch
  4336. * @param callback defines the callback to call on notification
  4337. * @param mask defines the mask used to filter notifications
  4338. * @param scope defines the current scope used to restore the JS context
  4339. * @returns the new MultiObserver
  4340. */
  4341. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4342. }
  4343. /**
  4344. * The Observable class is a simple implementation of the Observable pattern.
  4345. *
  4346. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4347. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4348. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4349. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4350. */
  4351. export class Observable<T> {
  4352. private _observers;
  4353. private _eventState;
  4354. private _onObserverAdded;
  4355. /**
  4356. * Creates a new observable
  4357. * @param onObserverAdded defines a callback to call when a new observer is added
  4358. */
  4359. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4360. /**
  4361. * Create a new Observer with the specified callback
  4362. * @param callback the callback that will be executed for that Observer
  4363. * @param mask the mask used to filter observers
  4364. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4365. * @param scope optional scope for the callback to be called from
  4366. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4367. * @returns the new observer created for the callback
  4368. */
  4369. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4370. /**
  4371. * Create a new Observer with the specified callback and unregisters after the next notification
  4372. * @param callback the callback that will be executed for that Observer
  4373. * @returns the new observer created for the callback
  4374. */
  4375. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4376. /**
  4377. * Remove an Observer from the Observable object
  4378. * @param observer the instance of the Observer to remove
  4379. * @returns false if it doesn't belong to this Observable
  4380. */
  4381. remove(observer: Nullable<Observer<T>>): boolean;
  4382. /**
  4383. * Remove a callback from the Observable object
  4384. * @param callback the callback to remove
  4385. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4386. * @returns false if it doesn't belong to this Observable
  4387. */
  4388. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4389. private _deferUnregister;
  4390. private _remove;
  4391. /**
  4392. * Moves the observable to the top of the observer list making it get called first when notified
  4393. * @param observer the observer to move
  4394. */
  4395. makeObserverTopPriority(observer: Observer<T>): void;
  4396. /**
  4397. * Moves the observable to the bottom of the observer list making it get called last when notified
  4398. * @param observer the observer to move
  4399. */
  4400. makeObserverBottomPriority(observer: Observer<T>): void;
  4401. /**
  4402. * Notify all Observers by calling their respective callback with the given data
  4403. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4404. * @param eventData defines the data to send to all observers
  4405. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4406. * @param target defines the original target of the state
  4407. * @param currentTarget defines the current target of the state
  4408. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4409. */
  4410. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4411. /**
  4412. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4413. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4414. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4415. * and it is crucial that all callbacks will be executed.
  4416. * The order of the callbacks is kept, callbacks are not executed parallel.
  4417. *
  4418. * @param eventData The data to be sent to each callback
  4419. * @param mask is used to filter observers defaults to -1
  4420. * @param target defines the callback target (see EventState)
  4421. * @param currentTarget defines he current object in the bubbling phase
  4422. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4423. */
  4424. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4425. /**
  4426. * Notify a specific observer
  4427. * @param observer defines the observer to notify
  4428. * @param eventData defines the data to be sent to each callback
  4429. * @param mask is used to filter observers defaults to -1
  4430. */
  4431. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4432. /**
  4433. * Gets a boolean indicating if the observable has at least one observer
  4434. * @returns true is the Observable has at least one Observer registered
  4435. */
  4436. hasObservers(): boolean;
  4437. /**
  4438. * Clear the list of observers
  4439. */
  4440. clear(): void;
  4441. /**
  4442. * Clone the current observable
  4443. * @returns a new observable
  4444. */
  4445. clone(): Observable<T>;
  4446. /**
  4447. * Does this observable handles observer registered with a given mask
  4448. * @param mask defines the mask to be tested
  4449. * @return whether or not one observer registered with the given mask is handeled
  4450. **/
  4451. hasSpecificMask(mask?: number): boolean;
  4452. }
  4453. }
  4454. declare module BABYLON {
  4455. /**
  4456. * Class used to help managing file picking and drag'n'drop
  4457. * File Storage
  4458. */
  4459. export class FilesInputStore {
  4460. /**
  4461. * List of files ready to be loaded
  4462. */
  4463. static FilesToLoad: {
  4464. [key: string]: File;
  4465. };
  4466. }
  4467. }
  4468. declare module BABYLON {
  4469. /** Defines the cross module used constants to avoid circular dependncies */
  4470. export class Constants {
  4471. /** Defines that alpha blending is disabled */
  4472. static readonly ALPHA_DISABLE: number;
  4473. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4474. static readonly ALPHA_ADD: number;
  4475. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4476. static readonly ALPHA_COMBINE: number;
  4477. /** Defines that alpha blending to DEST - SRC * DEST */
  4478. static readonly ALPHA_SUBTRACT: number;
  4479. /** Defines that alpha blending to SRC * DEST */
  4480. static readonly ALPHA_MULTIPLY: number;
  4481. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4482. static readonly ALPHA_MAXIMIZED: number;
  4483. /** Defines that alpha blending to SRC + DEST */
  4484. static readonly ALPHA_ONEONE: number;
  4485. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4486. static readonly ALPHA_PREMULTIPLIED: number;
  4487. /**
  4488. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4489. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4490. */
  4491. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4492. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4493. static readonly ALPHA_INTERPOLATE: number;
  4494. /**
  4495. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4496. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4497. */
  4498. static readonly ALPHA_SCREENMODE: number;
  4499. /** Defines that the ressource is not delayed*/
  4500. static readonly DELAYLOADSTATE_NONE: number;
  4501. /** Defines that the ressource was successfully delay loaded */
  4502. static readonly DELAYLOADSTATE_LOADED: number;
  4503. /** Defines that the ressource is currently delay loading */
  4504. static readonly DELAYLOADSTATE_LOADING: number;
  4505. /** Defines that the ressource is delayed and has not started loading */
  4506. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4507. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4508. static readonly NEVER: number;
  4509. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4510. static readonly ALWAYS: number;
  4511. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4512. static readonly LESS: number;
  4513. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4514. static readonly EQUAL: number;
  4515. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4516. static readonly LEQUAL: number;
  4517. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4518. static readonly GREATER: number;
  4519. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4520. static readonly GEQUAL: number;
  4521. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4522. static readonly NOTEQUAL: number;
  4523. /** Passed to stencilOperation to specify that stencil value must be kept */
  4524. static readonly KEEP: number;
  4525. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4526. static readonly REPLACE: number;
  4527. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4528. static readonly INCR: number;
  4529. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4530. static readonly DECR: number;
  4531. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4532. static readonly INVERT: number;
  4533. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4534. static readonly INCR_WRAP: number;
  4535. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4536. static readonly DECR_WRAP: number;
  4537. /** Texture is not repeating outside of 0..1 UVs */
  4538. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4539. /** Texture is repeating outside of 0..1 UVs */
  4540. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4541. /** Texture is repeating and mirrored */
  4542. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4543. /** ALPHA */
  4544. static readonly TEXTUREFORMAT_ALPHA: number;
  4545. /** LUMINANCE */
  4546. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4547. /** LUMINANCE_ALPHA */
  4548. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4549. /** RGB */
  4550. static readonly TEXTUREFORMAT_RGB: number;
  4551. /** RGBA */
  4552. static readonly TEXTUREFORMAT_RGBA: number;
  4553. /** RED */
  4554. static readonly TEXTUREFORMAT_RED: number;
  4555. /** RED (2nd reference) */
  4556. static readonly TEXTUREFORMAT_R: number;
  4557. /** RG */
  4558. static readonly TEXTUREFORMAT_RG: number;
  4559. /** RED_INTEGER */
  4560. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4561. /** RED_INTEGER (2nd reference) */
  4562. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4563. /** RG_INTEGER */
  4564. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4565. /** RGB_INTEGER */
  4566. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4567. /** RGBA_INTEGER */
  4568. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4569. /** UNSIGNED_BYTE */
  4570. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4571. /** UNSIGNED_BYTE (2nd reference) */
  4572. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4573. /** FLOAT */
  4574. static readonly TEXTURETYPE_FLOAT: number;
  4575. /** HALF_FLOAT */
  4576. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4577. /** BYTE */
  4578. static readonly TEXTURETYPE_BYTE: number;
  4579. /** SHORT */
  4580. static readonly TEXTURETYPE_SHORT: number;
  4581. /** UNSIGNED_SHORT */
  4582. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4583. /** INT */
  4584. static readonly TEXTURETYPE_INT: number;
  4585. /** UNSIGNED_INT */
  4586. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4587. /** UNSIGNED_SHORT_4_4_4_4 */
  4588. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4589. /** UNSIGNED_SHORT_5_5_5_1 */
  4590. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4591. /** UNSIGNED_SHORT_5_6_5 */
  4592. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4593. /** UNSIGNED_INT_2_10_10_10_REV */
  4594. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4595. /** UNSIGNED_INT_24_8 */
  4596. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4597. /** UNSIGNED_INT_10F_11F_11F_REV */
  4598. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4599. /** UNSIGNED_INT_5_9_9_9_REV */
  4600. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4601. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4602. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4603. /** nearest is mag = nearest and min = nearest and mip = linear */
  4604. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4605. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4606. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4607. /** Trilinear is mag = linear and min = linear and mip = linear */
  4608. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4609. /** nearest is mag = nearest and min = nearest and mip = linear */
  4610. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4611. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4612. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4613. /** Trilinear is mag = linear and min = linear and mip = linear */
  4614. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4615. /** mag = nearest and min = nearest and mip = nearest */
  4616. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4617. /** mag = nearest and min = linear and mip = nearest */
  4618. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4619. /** mag = nearest and min = linear and mip = linear */
  4620. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4621. /** mag = nearest and min = linear and mip = none */
  4622. static readonly TEXTURE_NEAREST_LINEAR: number;
  4623. /** mag = nearest and min = nearest and mip = none */
  4624. static readonly TEXTURE_NEAREST_NEAREST: number;
  4625. /** mag = linear and min = nearest and mip = nearest */
  4626. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4627. /** mag = linear and min = nearest and mip = linear */
  4628. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4629. /** mag = linear and min = linear and mip = none */
  4630. static readonly TEXTURE_LINEAR_LINEAR: number;
  4631. /** mag = linear and min = nearest and mip = none */
  4632. static readonly TEXTURE_LINEAR_NEAREST: number;
  4633. /** Explicit coordinates mode */
  4634. static readonly TEXTURE_EXPLICIT_MODE: number;
  4635. /** Spherical coordinates mode */
  4636. static readonly TEXTURE_SPHERICAL_MODE: number;
  4637. /** Planar coordinates mode */
  4638. static readonly TEXTURE_PLANAR_MODE: number;
  4639. /** Cubic coordinates mode */
  4640. static readonly TEXTURE_CUBIC_MODE: number;
  4641. /** Projection coordinates mode */
  4642. static readonly TEXTURE_PROJECTION_MODE: number;
  4643. /** Skybox coordinates mode */
  4644. static readonly TEXTURE_SKYBOX_MODE: number;
  4645. /** Inverse Cubic coordinates mode */
  4646. static readonly TEXTURE_INVCUBIC_MODE: number;
  4647. /** Equirectangular coordinates mode */
  4648. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4649. /** Equirectangular Fixed coordinates mode */
  4650. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4651. /** Equirectangular Fixed Mirrored coordinates mode */
  4652. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4653. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4654. static readonly SCALEMODE_FLOOR: number;
  4655. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4656. static readonly SCALEMODE_NEAREST: number;
  4657. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4658. static readonly SCALEMODE_CEILING: number;
  4659. /**
  4660. * The dirty texture flag value
  4661. */
  4662. static readonly MATERIAL_TextureDirtyFlag: number;
  4663. /**
  4664. * The dirty light flag value
  4665. */
  4666. static readonly MATERIAL_LightDirtyFlag: number;
  4667. /**
  4668. * The dirty fresnel flag value
  4669. */
  4670. static readonly MATERIAL_FresnelDirtyFlag: number;
  4671. /**
  4672. * The dirty attribute flag value
  4673. */
  4674. static readonly MATERIAL_AttributesDirtyFlag: number;
  4675. /**
  4676. * The dirty misc flag value
  4677. */
  4678. static readonly MATERIAL_MiscDirtyFlag: number;
  4679. /**
  4680. * The all dirty flag value
  4681. */
  4682. static readonly MATERIAL_AllDirtyFlag: number;
  4683. /**
  4684. * Returns the triangle fill mode
  4685. */
  4686. static readonly MATERIAL_TriangleFillMode: number;
  4687. /**
  4688. * Returns the wireframe mode
  4689. */
  4690. static readonly MATERIAL_WireFrameFillMode: number;
  4691. /**
  4692. * Returns the point fill mode
  4693. */
  4694. static readonly MATERIAL_PointFillMode: number;
  4695. /**
  4696. * Returns the point list draw mode
  4697. */
  4698. static readonly MATERIAL_PointListDrawMode: number;
  4699. /**
  4700. * Returns the line list draw mode
  4701. */
  4702. static readonly MATERIAL_LineListDrawMode: number;
  4703. /**
  4704. * Returns the line loop draw mode
  4705. */
  4706. static readonly MATERIAL_LineLoopDrawMode: number;
  4707. /**
  4708. * Returns the line strip draw mode
  4709. */
  4710. static readonly MATERIAL_LineStripDrawMode: number;
  4711. /**
  4712. * Returns the triangle strip draw mode
  4713. */
  4714. static readonly MATERIAL_TriangleStripDrawMode: number;
  4715. /**
  4716. * Returns the triangle fan draw mode
  4717. */
  4718. static readonly MATERIAL_TriangleFanDrawMode: number;
  4719. /**
  4720. * Stores the clock-wise side orientation
  4721. */
  4722. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4723. /**
  4724. * Stores the counter clock-wise side orientation
  4725. */
  4726. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4727. /**
  4728. * Nothing
  4729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4730. */
  4731. static readonly ACTION_NothingTrigger: number;
  4732. /**
  4733. * On pick
  4734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4735. */
  4736. static readonly ACTION_OnPickTrigger: number;
  4737. /**
  4738. * On left pick
  4739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4740. */
  4741. static readonly ACTION_OnLeftPickTrigger: number;
  4742. /**
  4743. * On right pick
  4744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4745. */
  4746. static readonly ACTION_OnRightPickTrigger: number;
  4747. /**
  4748. * On center pick
  4749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4750. */
  4751. static readonly ACTION_OnCenterPickTrigger: number;
  4752. /**
  4753. * On pick down
  4754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4755. */
  4756. static readonly ACTION_OnPickDownTrigger: number;
  4757. /**
  4758. * On double pick
  4759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4760. */
  4761. static readonly ACTION_OnDoublePickTrigger: number;
  4762. /**
  4763. * On pick up
  4764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4765. */
  4766. static readonly ACTION_OnPickUpTrigger: number;
  4767. /**
  4768. * On pick out.
  4769. * This trigger will only be raised if you also declared a OnPickDown
  4770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4771. */
  4772. static readonly ACTION_OnPickOutTrigger: number;
  4773. /**
  4774. * On long press
  4775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4776. */
  4777. static readonly ACTION_OnLongPressTrigger: number;
  4778. /**
  4779. * On pointer over
  4780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4781. */
  4782. static readonly ACTION_OnPointerOverTrigger: number;
  4783. /**
  4784. * On pointer out
  4785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4786. */
  4787. static readonly ACTION_OnPointerOutTrigger: number;
  4788. /**
  4789. * On every frame
  4790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4791. */
  4792. static readonly ACTION_OnEveryFrameTrigger: number;
  4793. /**
  4794. * On intersection enter
  4795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4796. */
  4797. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4798. /**
  4799. * On intersection exit
  4800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4801. */
  4802. static readonly ACTION_OnIntersectionExitTrigger: number;
  4803. /**
  4804. * On key down
  4805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4806. */
  4807. static readonly ACTION_OnKeyDownTrigger: number;
  4808. /**
  4809. * On key up
  4810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4811. */
  4812. static readonly ACTION_OnKeyUpTrigger: number;
  4813. /**
  4814. * Billboard mode will only apply to Y axis
  4815. */
  4816. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4817. /**
  4818. * Billboard mode will apply to all axes
  4819. */
  4820. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4821. /**
  4822. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4823. */
  4824. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4825. /**
  4826. * Gets or sets base Assets URL
  4827. */
  4828. static readonly PARTICLES_BaseAssetsUrl: string;
  4829. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4830. * Test order :
  4831. * Is the bounding sphere outside the frustum ?
  4832. * If not, are the bounding box vertices outside the frustum ?
  4833. * It not, then the cullable object is in the frustum.
  4834. */
  4835. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4836. /** Culling strategy : Bounding Sphere Only.
  4837. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4838. * It's also less accurate than the standard because some not visible objects can still be selected.
  4839. * Test : is the bounding sphere outside the frustum ?
  4840. * If not, then the cullable object is in the frustum.
  4841. */
  4842. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4843. /** Culling strategy : Optimistic Inclusion.
  4844. * This in an inclusion test first, then the standard exclusion test.
  4845. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4846. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4847. * Anyway, it's as accurate as the standard strategy.
  4848. * Test :
  4849. * Is the cullable object bounding sphere center in the frustum ?
  4850. * If not, apply the default culling strategy.
  4851. */
  4852. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4853. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4854. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4855. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4856. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4857. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4858. * Test :
  4859. * Is the cullable object bounding sphere center in the frustum ?
  4860. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4861. */
  4862. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4863. /**
  4864. * No logging while loading
  4865. */
  4866. static readonly SCENELOADER_NO_LOGGING: number;
  4867. /**
  4868. * Minimal logging while loading
  4869. */
  4870. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4871. /**
  4872. * Summary logging while loading
  4873. */
  4874. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4875. /**
  4876. * Detailled logging while loading
  4877. */
  4878. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4879. }
  4880. }
  4881. declare module BABYLON {
  4882. /**
  4883. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4884. * Babylon.js
  4885. */
  4886. export class DomManagement {
  4887. /**
  4888. * Checks if the window object exists
  4889. * @returns true if the window object exists
  4890. */
  4891. static IsWindowObjectExist(): boolean;
  4892. /**
  4893. * Extracts text content from a DOM element hierarchy
  4894. * @param element defines the root element
  4895. * @returns a string
  4896. */
  4897. static GetDOMTextContent(element: HTMLElement): string;
  4898. }
  4899. }
  4900. declare module BABYLON {
  4901. /**
  4902. * Logger used througouht the application to allow configuration of
  4903. * the log level required for the messages.
  4904. */
  4905. export class Logger {
  4906. /**
  4907. * No log
  4908. */
  4909. static readonly NoneLogLevel: number;
  4910. /**
  4911. * Only message logs
  4912. */
  4913. static readonly MessageLogLevel: number;
  4914. /**
  4915. * Only warning logs
  4916. */
  4917. static readonly WarningLogLevel: number;
  4918. /**
  4919. * Only error logs
  4920. */
  4921. static readonly ErrorLogLevel: number;
  4922. /**
  4923. * All logs
  4924. */
  4925. static readonly AllLogLevel: number;
  4926. private static _LogCache;
  4927. /**
  4928. * Gets a value indicating the number of loading errors
  4929. * @ignorenaming
  4930. */
  4931. static errorsCount: number;
  4932. /**
  4933. * Callback called when a new log is added
  4934. */
  4935. static OnNewCacheEntry: (entry: string) => void;
  4936. private static _AddLogEntry;
  4937. private static _FormatMessage;
  4938. private static _LogDisabled;
  4939. private static _LogEnabled;
  4940. private static _WarnDisabled;
  4941. private static _WarnEnabled;
  4942. private static _ErrorDisabled;
  4943. private static _ErrorEnabled;
  4944. /**
  4945. * Log a message to the console
  4946. */
  4947. static Log: (message: string) => void;
  4948. /**
  4949. * Write a warning message to the console
  4950. */
  4951. static Warn: (message: string) => void;
  4952. /**
  4953. * Write an error message to the console
  4954. */
  4955. static Error: (message: string) => void;
  4956. /**
  4957. * Gets current log cache (list of logs)
  4958. */
  4959. static readonly LogCache: string;
  4960. /**
  4961. * Clears the log cache
  4962. */
  4963. static ClearLogCache(): void;
  4964. /**
  4965. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4966. */
  4967. static LogLevels: number;
  4968. }
  4969. }
  4970. declare module BABYLON {
  4971. /** @hidden */
  4972. export class _TypeStore {
  4973. /** @hidden */
  4974. static RegisteredTypes: {
  4975. [key: string]: Object;
  4976. };
  4977. /** @hidden */
  4978. static GetClass(fqdn: string): any;
  4979. }
  4980. }
  4981. declare module BABYLON {
  4982. /**
  4983. * Class containing a set of static utilities functions for deep copy.
  4984. */
  4985. export class DeepCopier {
  4986. /**
  4987. * Tries to copy an object by duplicating every property
  4988. * @param source defines the source object
  4989. * @param destination defines the target object
  4990. * @param doNotCopyList defines a list of properties to avoid
  4991. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4992. */
  4993. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4994. }
  4995. }
  4996. declare module BABYLON {
  4997. /**
  4998. * Class containing a set of static utilities functions for precision date
  4999. */
  5000. export class PrecisionDate {
  5001. /**
  5002. * Gets either window.performance.now() if supported or Date.now() else
  5003. */
  5004. static readonly Now: number;
  5005. }
  5006. }
  5007. declare module BABYLON {
  5008. /** @hidden */
  5009. export class _DevTools {
  5010. static WarnImport(name: string): string;
  5011. }
  5012. }
  5013. declare module BABYLON {
  5014. /**
  5015. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5016. */
  5017. export class WebRequest {
  5018. private _xhr;
  5019. /**
  5020. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5021. * i.e. when loading files, where the server/service expects an Authorization header
  5022. */
  5023. static CustomRequestHeaders: {
  5024. [key: string]: string;
  5025. };
  5026. /**
  5027. * Add callback functions in this array to update all the requests before they get sent to the network
  5028. */
  5029. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5030. private _injectCustomRequestHeaders;
  5031. /**
  5032. * Gets or sets a function to be called when loading progress changes
  5033. */
  5034. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5035. /**
  5036. * Returns client's state
  5037. */
  5038. readonly readyState: number;
  5039. /**
  5040. * Returns client's status
  5041. */
  5042. readonly status: number;
  5043. /**
  5044. * Returns client's status as a text
  5045. */
  5046. readonly statusText: string;
  5047. /**
  5048. * Returns client's response
  5049. */
  5050. readonly response: any;
  5051. /**
  5052. * Returns client's response url
  5053. */
  5054. readonly responseURL: string;
  5055. /**
  5056. * Returns client's response as text
  5057. */
  5058. readonly responseText: string;
  5059. /**
  5060. * Gets or sets the expected response type
  5061. */
  5062. responseType: XMLHttpRequestResponseType;
  5063. /** @hidden */
  5064. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5065. /** @hidden */
  5066. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5067. /**
  5068. * Cancels any network activity
  5069. */
  5070. abort(): void;
  5071. /**
  5072. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5073. * @param body defines an optional request body
  5074. */
  5075. send(body?: Document | BodyInit | null): void;
  5076. /**
  5077. * Sets the request method, request URL
  5078. * @param method defines the method to use (GET, POST, etc..)
  5079. * @param url defines the url to connect with
  5080. */
  5081. open(method: string, url: string): void;
  5082. }
  5083. }
  5084. declare module BABYLON {
  5085. /**
  5086. * Class used to evalaute queries containing `and` and `or` operators
  5087. */
  5088. export class AndOrNotEvaluator {
  5089. /**
  5090. * Evaluate a query
  5091. * @param query defines the query to evaluate
  5092. * @param evaluateCallback defines the callback used to filter result
  5093. * @returns true if the query matches
  5094. */
  5095. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5096. private static _HandleParenthesisContent;
  5097. private static _SimplifyNegation;
  5098. }
  5099. }
  5100. declare module BABYLON {
  5101. /**
  5102. * Class used to store custom tags
  5103. */
  5104. export class Tags {
  5105. /**
  5106. * Adds support for tags on the given object
  5107. * @param obj defines the object to use
  5108. */
  5109. static EnableFor(obj: any): void;
  5110. /**
  5111. * Removes tags support
  5112. * @param obj defines the object to use
  5113. */
  5114. static DisableFor(obj: any): void;
  5115. /**
  5116. * Gets a boolean indicating if the given object has tags
  5117. * @param obj defines the object to use
  5118. * @returns a boolean
  5119. */
  5120. static HasTags(obj: any): boolean;
  5121. /**
  5122. * Gets the tags available on a given object
  5123. * @param obj defines the object to use
  5124. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5125. * @returns the tags
  5126. */
  5127. static GetTags(obj: any, asString?: boolean): any;
  5128. /**
  5129. * Adds tags to an object
  5130. * @param obj defines the object to use
  5131. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5132. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5133. */
  5134. static AddTagsTo(obj: any, tagsString: string): void;
  5135. /**
  5136. * @hidden
  5137. */
  5138. static _AddTagTo(obj: any, tag: string): void;
  5139. /**
  5140. * Removes specific tags from a specific object
  5141. * @param obj defines the object to use
  5142. * @param tagsString defines the tags to remove
  5143. */
  5144. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5145. /**
  5146. * @hidden
  5147. */
  5148. static _RemoveTagFrom(obj: any, tag: string): void;
  5149. /**
  5150. * Defines if tags hosted on an object match a given query
  5151. * @param obj defines the object to use
  5152. * @param tagsQuery defines the tag query
  5153. * @returns a boolean
  5154. */
  5155. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5156. }
  5157. }
  5158. declare module BABYLON {
  5159. /**
  5160. * Manages the defines for the Material
  5161. */
  5162. export class MaterialDefines {
  5163. /** @hidden */
  5164. protected _keys: string[];
  5165. private _isDirty;
  5166. /** @hidden */
  5167. _renderId: number;
  5168. /** @hidden */
  5169. _areLightsDirty: boolean;
  5170. /** @hidden */
  5171. _areAttributesDirty: boolean;
  5172. /** @hidden */
  5173. _areTexturesDirty: boolean;
  5174. /** @hidden */
  5175. _areFresnelDirty: boolean;
  5176. /** @hidden */
  5177. _areMiscDirty: boolean;
  5178. /** @hidden */
  5179. _areImageProcessingDirty: boolean;
  5180. /** @hidden */
  5181. _normals: boolean;
  5182. /** @hidden */
  5183. _uvs: boolean;
  5184. /** @hidden */
  5185. _needNormals: boolean;
  5186. /** @hidden */
  5187. _needUVs: boolean;
  5188. [id: string]: any;
  5189. /**
  5190. * Specifies if the material needs to be re-calculated
  5191. */
  5192. readonly isDirty: boolean;
  5193. /**
  5194. * Marks the material to indicate that it has been re-calculated
  5195. */
  5196. markAsProcessed(): void;
  5197. /**
  5198. * Marks the material to indicate that it needs to be re-calculated
  5199. */
  5200. markAsUnprocessed(): void;
  5201. /**
  5202. * Marks the material to indicate all of its defines need to be re-calculated
  5203. */
  5204. markAllAsDirty(): void;
  5205. /**
  5206. * Marks the material to indicate that image processing needs to be re-calculated
  5207. */
  5208. markAsImageProcessingDirty(): void;
  5209. /**
  5210. * Marks the material to indicate the lights need to be re-calculated
  5211. */
  5212. markAsLightDirty(): void;
  5213. /**
  5214. * Marks the attribute state as changed
  5215. */
  5216. markAsAttributesDirty(): void;
  5217. /**
  5218. * Marks the texture state as changed
  5219. */
  5220. markAsTexturesDirty(): void;
  5221. /**
  5222. * Marks the fresnel state as changed
  5223. */
  5224. markAsFresnelDirty(): void;
  5225. /**
  5226. * Marks the misc state as changed
  5227. */
  5228. markAsMiscDirty(): void;
  5229. /**
  5230. * Rebuilds the material defines
  5231. */
  5232. rebuild(): void;
  5233. /**
  5234. * Specifies if two material defines are equal
  5235. * @param other - A material define instance to compare to
  5236. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5237. */
  5238. isEqual(other: MaterialDefines): boolean;
  5239. /**
  5240. * Clones this instance's defines to another instance
  5241. * @param other - material defines to clone values to
  5242. */
  5243. cloneTo(other: MaterialDefines): void;
  5244. /**
  5245. * Resets the material define values
  5246. */
  5247. reset(): void;
  5248. /**
  5249. * Converts the material define values to a string
  5250. * @returns - String of material define information
  5251. */
  5252. toString(): string;
  5253. }
  5254. }
  5255. declare module BABYLON {
  5256. /**
  5257. * Class used to store and describe the pipeline context associated with an effect
  5258. */
  5259. export interface IPipelineContext {
  5260. /**
  5261. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5262. */
  5263. isAsync: boolean;
  5264. /**
  5265. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5266. */
  5267. isReady: boolean;
  5268. /** @hidden */
  5269. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5270. }
  5271. }
  5272. declare module BABYLON {
  5273. /**
  5274. * Class used to store gfx data (like WebGLBuffer)
  5275. */
  5276. export class DataBuffer {
  5277. /**
  5278. * Gets or sets the number of objects referencing this buffer
  5279. */
  5280. references: number;
  5281. /** Gets or sets the size of the underlying buffer */
  5282. capacity: number;
  5283. /**
  5284. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5285. */
  5286. is32Bits: boolean;
  5287. /**
  5288. * Gets the underlying buffer
  5289. */
  5290. readonly underlyingResource: any;
  5291. }
  5292. }
  5293. declare module BABYLON {
  5294. /**
  5295. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5296. */
  5297. export class PerformanceMonitor {
  5298. private _enabled;
  5299. private _rollingFrameTime;
  5300. private _lastFrameTimeMs;
  5301. /**
  5302. * constructor
  5303. * @param frameSampleSize The number of samples required to saturate the sliding window
  5304. */
  5305. constructor(frameSampleSize?: number);
  5306. /**
  5307. * Samples current frame
  5308. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5309. */
  5310. sampleFrame(timeMs?: number): void;
  5311. /**
  5312. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5313. */
  5314. readonly averageFrameTime: number;
  5315. /**
  5316. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5317. */
  5318. readonly averageFrameTimeVariance: number;
  5319. /**
  5320. * Returns the frame time of the most recent frame
  5321. */
  5322. readonly instantaneousFrameTime: number;
  5323. /**
  5324. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5325. */
  5326. readonly averageFPS: number;
  5327. /**
  5328. * Returns the average framerate in frames per second using the most recent frame time
  5329. */
  5330. readonly instantaneousFPS: number;
  5331. /**
  5332. * Returns true if enough samples have been taken to completely fill the sliding window
  5333. */
  5334. readonly isSaturated: boolean;
  5335. /**
  5336. * Enables contributions to the sliding window sample set
  5337. */
  5338. enable(): void;
  5339. /**
  5340. * Disables contributions to the sliding window sample set
  5341. * Samples will not be interpolated over the disabled period
  5342. */
  5343. disable(): void;
  5344. /**
  5345. * Returns true if sampling is enabled
  5346. */
  5347. readonly isEnabled: boolean;
  5348. /**
  5349. * Resets performance monitor
  5350. */
  5351. reset(): void;
  5352. }
  5353. /**
  5354. * RollingAverage
  5355. *
  5356. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5357. */
  5358. export class RollingAverage {
  5359. /**
  5360. * Current average
  5361. */
  5362. average: number;
  5363. /**
  5364. * Current variance
  5365. */
  5366. variance: number;
  5367. protected _samples: Array<number>;
  5368. protected _sampleCount: number;
  5369. protected _pos: number;
  5370. protected _m2: number;
  5371. /**
  5372. * constructor
  5373. * @param length The number of samples required to saturate the sliding window
  5374. */
  5375. constructor(length: number);
  5376. /**
  5377. * Adds a sample to the sample set
  5378. * @param v The sample value
  5379. */
  5380. add(v: number): void;
  5381. /**
  5382. * Returns previously added values or null if outside of history or outside the sliding window domain
  5383. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5384. * @return Value previously recorded with add() or null if outside of range
  5385. */
  5386. history(i: number): number;
  5387. /**
  5388. * Returns true if enough samples have been taken to completely fill the sliding window
  5389. * @return true if sample-set saturated
  5390. */
  5391. isSaturated(): boolean;
  5392. /**
  5393. * Resets the rolling average (equivalent to 0 samples taken so far)
  5394. */
  5395. reset(): void;
  5396. /**
  5397. * Wraps a value around the sample range boundaries
  5398. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5399. * @return Wrapped position in sample range
  5400. */
  5401. protected _wrapPosition(i: number): number;
  5402. }
  5403. }
  5404. declare module BABYLON {
  5405. /**
  5406. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5407. * The underlying implementation relies on an associative array to ensure the best performances.
  5408. * The value can be anything including 'null' but except 'undefined'
  5409. */
  5410. export class StringDictionary<T> {
  5411. /**
  5412. * This will clear this dictionary and copy the content from the 'source' one.
  5413. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5414. * @param source the dictionary to take the content from and copy to this dictionary
  5415. */
  5416. copyFrom(source: StringDictionary<T>): void;
  5417. /**
  5418. * Get a value based from its key
  5419. * @param key the given key to get the matching value from
  5420. * @return the value if found, otherwise undefined is returned
  5421. */
  5422. get(key: string): T | undefined;
  5423. /**
  5424. * Get a value from its key or add it if it doesn't exist.
  5425. * This method will ensure you that a given key/data will be present in the dictionary.
  5426. * @param key the given key to get the matching value from
  5427. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5428. * The factory will only be invoked if there's no data for the given key.
  5429. * @return the value corresponding to the key.
  5430. */
  5431. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5432. /**
  5433. * Get a value from its key if present in the dictionary otherwise add it
  5434. * @param key the key to get the value from
  5435. * @param val if there's no such key/value pair in the dictionary add it with this value
  5436. * @return the value corresponding to the key
  5437. */
  5438. getOrAdd(key: string, val: T): T;
  5439. /**
  5440. * Check if there's a given key in the dictionary
  5441. * @param key the key to check for
  5442. * @return true if the key is present, false otherwise
  5443. */
  5444. contains(key: string): boolean;
  5445. /**
  5446. * Add a new key and its corresponding value
  5447. * @param key the key to add
  5448. * @param value the value corresponding to the key
  5449. * @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
  5450. */
  5451. add(key: string, value: T): boolean;
  5452. /**
  5453. * Update a specific value associated to a key
  5454. * @param key defines the key to use
  5455. * @param value defines the value to store
  5456. * @returns true if the value was updated (or false if the key was not found)
  5457. */
  5458. set(key: string, value: T): boolean;
  5459. /**
  5460. * Get the element of the given key and remove it from the dictionary
  5461. * @param key defines the key to search
  5462. * @returns the value associated with the key or null if not found
  5463. */
  5464. getAndRemove(key: string): Nullable<T>;
  5465. /**
  5466. * Remove a key/value from the dictionary.
  5467. * @param key the key to remove
  5468. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5469. */
  5470. remove(key: string): boolean;
  5471. /**
  5472. * Clear the whole content of the dictionary
  5473. */
  5474. clear(): void;
  5475. /**
  5476. * Gets the current count
  5477. */
  5478. readonly count: number;
  5479. /**
  5480. * Execute a callback on each key/val of the dictionary.
  5481. * Note that you can remove any element in this dictionary in the callback implementation
  5482. * @param callback the callback to execute on a given key/value pair
  5483. */
  5484. forEach(callback: (key: string, val: T) => void): void;
  5485. /**
  5486. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5487. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5488. * Note that you can remove any element in this dictionary in the callback implementation
  5489. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5490. * @returns the first item
  5491. */
  5492. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5493. private _count;
  5494. private _data;
  5495. }
  5496. }
  5497. declare module BABYLON {
  5498. /**
  5499. * Helper class that provides a small promise polyfill
  5500. */
  5501. export class PromisePolyfill {
  5502. /**
  5503. * Static function used to check if the polyfill is required
  5504. * If this is the case then the function will inject the polyfill to window.Promise
  5505. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5506. */
  5507. static Apply(force?: boolean): void;
  5508. }
  5509. }
  5510. declare module BABYLON {
  5511. /**
  5512. * Class used to store data that will be store in GPU memory
  5513. */
  5514. export class Buffer {
  5515. private _engine;
  5516. private _buffer;
  5517. /** @hidden */
  5518. _data: Nullable<DataArray>;
  5519. private _updatable;
  5520. private _instanced;
  5521. /**
  5522. * Gets the byte stride.
  5523. */
  5524. readonly byteStride: number;
  5525. /**
  5526. * Constructor
  5527. * @param engine the engine
  5528. * @param data the data to use for this buffer
  5529. * @param updatable whether the data is updatable
  5530. * @param stride the stride (optional)
  5531. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5532. * @param instanced whether the buffer is instanced (optional)
  5533. * @param useBytes set to true if the stride in in bytes (optional)
  5534. */
  5535. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5536. /**
  5537. * Create a new VertexBuffer based on the current buffer
  5538. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5539. * @param offset defines offset in the buffer (0 by default)
  5540. * @param size defines the size in floats of attributes (position is 3 for instance)
  5541. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5542. * @param instanced defines if the vertex buffer contains indexed data
  5543. * @param useBytes defines if the offset and stride are in bytes
  5544. * @returns the new vertex buffer
  5545. */
  5546. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5547. /**
  5548. * Gets a boolean indicating if the Buffer is updatable?
  5549. * @returns true if the buffer is updatable
  5550. */
  5551. isUpdatable(): boolean;
  5552. /**
  5553. * Gets current buffer's data
  5554. * @returns a DataArray or null
  5555. */
  5556. getData(): Nullable<DataArray>;
  5557. /**
  5558. * Gets underlying native buffer
  5559. * @returns underlying native buffer
  5560. */
  5561. getBuffer(): Nullable<DataBuffer>;
  5562. /**
  5563. * Gets the stride in float32 units (i.e. byte stride / 4).
  5564. * May not be an integer if the byte stride is not divisible by 4.
  5565. * DEPRECATED. Use byteStride instead.
  5566. * @returns the stride in float32 units
  5567. */
  5568. getStrideSize(): number;
  5569. /**
  5570. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5571. * @param data defines the data to store
  5572. */
  5573. create(data?: Nullable<DataArray>): void;
  5574. /** @hidden */
  5575. _rebuild(): void;
  5576. /**
  5577. * Update current buffer data
  5578. * @param data defines the data to store
  5579. */
  5580. update(data: DataArray): void;
  5581. /**
  5582. * Updates the data directly.
  5583. * @param data the new data
  5584. * @param offset the new offset
  5585. * @param vertexCount the vertex count (optional)
  5586. * @param useBytes set to true if the offset is in bytes
  5587. */
  5588. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5589. /**
  5590. * Release all resources
  5591. */
  5592. dispose(): void;
  5593. }
  5594. /**
  5595. * Specialized buffer used to store vertex data
  5596. */
  5597. export class VertexBuffer {
  5598. /** @hidden */
  5599. _buffer: Buffer;
  5600. private _kind;
  5601. private _size;
  5602. private _ownsBuffer;
  5603. private _instanced;
  5604. private _instanceDivisor;
  5605. /**
  5606. * The byte type.
  5607. */
  5608. static readonly BYTE: number;
  5609. /**
  5610. * The unsigned byte type.
  5611. */
  5612. static readonly UNSIGNED_BYTE: number;
  5613. /**
  5614. * The short type.
  5615. */
  5616. static readonly SHORT: number;
  5617. /**
  5618. * The unsigned short type.
  5619. */
  5620. static readonly UNSIGNED_SHORT: number;
  5621. /**
  5622. * The integer type.
  5623. */
  5624. static readonly INT: number;
  5625. /**
  5626. * The unsigned integer type.
  5627. */
  5628. static readonly UNSIGNED_INT: number;
  5629. /**
  5630. * The float type.
  5631. */
  5632. static readonly FLOAT: number;
  5633. /**
  5634. * Gets or sets the instance divisor when in instanced mode
  5635. */
  5636. instanceDivisor: number;
  5637. /**
  5638. * Gets the byte stride.
  5639. */
  5640. readonly byteStride: number;
  5641. /**
  5642. * Gets the byte offset.
  5643. */
  5644. readonly byteOffset: number;
  5645. /**
  5646. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5647. */
  5648. readonly normalized: boolean;
  5649. /**
  5650. * Gets the data type of each component in the array.
  5651. */
  5652. readonly type: number;
  5653. /**
  5654. * Constructor
  5655. * @param engine the engine
  5656. * @param data the data to use for this vertex buffer
  5657. * @param kind the vertex buffer kind
  5658. * @param updatable whether the data is updatable
  5659. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5660. * @param stride the stride (optional)
  5661. * @param instanced whether the buffer is instanced (optional)
  5662. * @param offset the offset of the data (optional)
  5663. * @param size the number of components (optional)
  5664. * @param type the type of the component (optional)
  5665. * @param normalized whether the data contains normalized data (optional)
  5666. * @param useBytes set to true if stride and offset are in bytes (optional)
  5667. */
  5668. 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);
  5669. /** @hidden */
  5670. _rebuild(): void;
  5671. /**
  5672. * Returns the kind of the VertexBuffer (string)
  5673. * @returns a string
  5674. */
  5675. getKind(): string;
  5676. /**
  5677. * Gets a boolean indicating if the VertexBuffer is updatable?
  5678. * @returns true if the buffer is updatable
  5679. */
  5680. isUpdatable(): boolean;
  5681. /**
  5682. * Gets current buffer's data
  5683. * @returns a DataArray or null
  5684. */
  5685. getData(): Nullable<DataArray>;
  5686. /**
  5687. * Gets underlying native buffer
  5688. * @returns underlying native buffer
  5689. */
  5690. getBuffer(): Nullable<DataBuffer>;
  5691. /**
  5692. * Gets the stride in float32 units (i.e. byte stride / 4).
  5693. * May not be an integer if the byte stride is not divisible by 4.
  5694. * DEPRECATED. Use byteStride instead.
  5695. * @returns the stride in float32 units
  5696. */
  5697. getStrideSize(): number;
  5698. /**
  5699. * Returns the offset as a multiple of the type byte length.
  5700. * DEPRECATED. Use byteOffset instead.
  5701. * @returns the offset in bytes
  5702. */
  5703. getOffset(): number;
  5704. /**
  5705. * Returns the number of components per vertex attribute (integer)
  5706. * @returns the size in float
  5707. */
  5708. getSize(): number;
  5709. /**
  5710. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5711. * @returns true if this buffer is instanced
  5712. */
  5713. getIsInstanced(): boolean;
  5714. /**
  5715. * Returns the instancing divisor, zero for non-instanced (integer).
  5716. * @returns a number
  5717. */
  5718. getInstanceDivisor(): number;
  5719. /**
  5720. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5721. * @param data defines the data to store
  5722. */
  5723. create(data?: DataArray): void;
  5724. /**
  5725. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5726. * This function will create a new buffer if the current one is not updatable
  5727. * @param data defines the data to store
  5728. */
  5729. update(data: DataArray): void;
  5730. /**
  5731. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5732. * Returns the directly updated WebGLBuffer.
  5733. * @param data the new data
  5734. * @param offset the new offset
  5735. * @param useBytes set to true if the offset is in bytes
  5736. */
  5737. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5738. /**
  5739. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5740. */
  5741. dispose(): void;
  5742. /**
  5743. * Enumerates each value of this vertex buffer as numbers.
  5744. * @param count the number of values to enumerate
  5745. * @param callback the callback function called for each value
  5746. */
  5747. forEach(count: number, callback: (value: number, index: number) => void): void;
  5748. /**
  5749. * Positions
  5750. */
  5751. static readonly PositionKind: string;
  5752. /**
  5753. * Normals
  5754. */
  5755. static readonly NormalKind: string;
  5756. /**
  5757. * Tangents
  5758. */
  5759. static readonly TangentKind: string;
  5760. /**
  5761. * Texture coordinates
  5762. */
  5763. static readonly UVKind: string;
  5764. /**
  5765. * Texture coordinates 2
  5766. */
  5767. static readonly UV2Kind: string;
  5768. /**
  5769. * Texture coordinates 3
  5770. */
  5771. static readonly UV3Kind: string;
  5772. /**
  5773. * Texture coordinates 4
  5774. */
  5775. static readonly UV4Kind: string;
  5776. /**
  5777. * Texture coordinates 5
  5778. */
  5779. static readonly UV5Kind: string;
  5780. /**
  5781. * Texture coordinates 6
  5782. */
  5783. static readonly UV6Kind: string;
  5784. /**
  5785. * Colors
  5786. */
  5787. static readonly ColorKind: string;
  5788. /**
  5789. * Matrix indices (for bones)
  5790. */
  5791. static readonly MatricesIndicesKind: string;
  5792. /**
  5793. * Matrix weights (for bones)
  5794. */
  5795. static readonly MatricesWeightsKind: string;
  5796. /**
  5797. * Additional matrix indices (for bones)
  5798. */
  5799. static readonly MatricesIndicesExtraKind: string;
  5800. /**
  5801. * Additional matrix weights (for bones)
  5802. */
  5803. static readonly MatricesWeightsExtraKind: string;
  5804. /**
  5805. * Deduces the stride given a kind.
  5806. * @param kind The kind string to deduce
  5807. * @returns The deduced stride
  5808. */
  5809. static DeduceStride(kind: string): number;
  5810. /**
  5811. * Gets the byte length of the given type.
  5812. * @param type the type
  5813. * @returns the number of bytes
  5814. */
  5815. static GetTypeByteLength(type: number): number;
  5816. /**
  5817. * Enumerates each value of the given parameters as numbers.
  5818. * @param data the data to enumerate
  5819. * @param byteOffset the byte offset of the data
  5820. * @param byteStride the byte stride of the data
  5821. * @param componentCount the number of components per element
  5822. * @param componentType the type of the component
  5823. * @param count the total number of components
  5824. * @param normalized whether the data is normalized
  5825. * @param callback the callback function called for each value
  5826. */
  5827. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5828. private static _GetFloatValue;
  5829. }
  5830. }
  5831. declare module BABYLON {
  5832. /**
  5833. * Class representing spherical harmonics coefficients to the 3rd degree
  5834. */
  5835. export class SphericalHarmonics {
  5836. /**
  5837. * Defines whether or not the harmonics have been prescaled for rendering.
  5838. */
  5839. preScaled: boolean;
  5840. /**
  5841. * The l0,0 coefficients of the spherical harmonics
  5842. */
  5843. l00: Vector3;
  5844. /**
  5845. * The l1,-1 coefficients of the spherical harmonics
  5846. */
  5847. l1_1: Vector3;
  5848. /**
  5849. * The l1,0 coefficients of the spherical harmonics
  5850. */
  5851. l10: Vector3;
  5852. /**
  5853. * The l1,1 coefficients of the spherical harmonics
  5854. */
  5855. l11: Vector3;
  5856. /**
  5857. * The l2,-2 coefficients of the spherical harmonics
  5858. */
  5859. l2_2: Vector3;
  5860. /**
  5861. * The l2,-1 coefficients of the spherical harmonics
  5862. */
  5863. l2_1: Vector3;
  5864. /**
  5865. * The l2,0 coefficients of the spherical harmonics
  5866. */
  5867. l20: Vector3;
  5868. /**
  5869. * The l2,1 coefficients of the spherical harmonics
  5870. */
  5871. l21: Vector3;
  5872. /**
  5873. * The l2,2 coefficients of the spherical harmonics
  5874. */
  5875. l22: Vector3;
  5876. /**
  5877. * Adds a light to the spherical harmonics
  5878. * @param direction the direction of the light
  5879. * @param color the color of the light
  5880. * @param deltaSolidAngle the delta solid angle of the light
  5881. */
  5882. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5883. /**
  5884. * Scales the spherical harmonics by the given amount
  5885. * @param scale the amount to scale
  5886. */
  5887. scaleInPlace(scale: number): void;
  5888. /**
  5889. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5890. *
  5891. * ```
  5892. * E_lm = A_l * L_lm
  5893. * ```
  5894. *
  5895. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5896. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5897. * the scaling factors are given in equation 9.
  5898. */
  5899. convertIncidentRadianceToIrradiance(): void;
  5900. /**
  5901. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5902. *
  5903. * ```
  5904. * L = (1/pi) * E * rho
  5905. * ```
  5906. *
  5907. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5908. */
  5909. convertIrradianceToLambertianRadiance(): void;
  5910. /**
  5911. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5912. * required operations at run time.
  5913. *
  5914. * This is simply done by scaling back the SH with Ylm constants parameter.
  5915. * The trigonometric part being applied by the shader at run time.
  5916. */
  5917. preScaleForRendering(): void;
  5918. /**
  5919. * Constructs a spherical harmonics from an array.
  5920. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5921. * @returns the spherical harmonics
  5922. */
  5923. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5924. /**
  5925. * Gets the spherical harmonics from polynomial
  5926. * @param polynomial the spherical polynomial
  5927. * @returns the spherical harmonics
  5928. */
  5929. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5930. }
  5931. /**
  5932. * Class representing spherical polynomial coefficients to the 3rd degree
  5933. */
  5934. export class SphericalPolynomial {
  5935. private _harmonics;
  5936. /**
  5937. * The spherical harmonics used to create the polynomials.
  5938. */
  5939. readonly preScaledHarmonics: SphericalHarmonics;
  5940. /**
  5941. * The x coefficients of the spherical polynomial
  5942. */
  5943. x: Vector3;
  5944. /**
  5945. * The y coefficients of the spherical polynomial
  5946. */
  5947. y: Vector3;
  5948. /**
  5949. * The z coefficients of the spherical polynomial
  5950. */
  5951. z: Vector3;
  5952. /**
  5953. * The xx coefficients of the spherical polynomial
  5954. */
  5955. xx: Vector3;
  5956. /**
  5957. * The yy coefficients of the spherical polynomial
  5958. */
  5959. yy: Vector3;
  5960. /**
  5961. * The zz coefficients of the spherical polynomial
  5962. */
  5963. zz: Vector3;
  5964. /**
  5965. * The xy coefficients of the spherical polynomial
  5966. */
  5967. xy: Vector3;
  5968. /**
  5969. * The yz coefficients of the spherical polynomial
  5970. */
  5971. yz: Vector3;
  5972. /**
  5973. * The zx coefficients of the spherical polynomial
  5974. */
  5975. zx: Vector3;
  5976. /**
  5977. * Adds an ambient color to the spherical polynomial
  5978. * @param color the color to add
  5979. */
  5980. addAmbient(color: Color3): void;
  5981. /**
  5982. * Scales the spherical polynomial by the given amount
  5983. * @param scale the amount to scale
  5984. */
  5985. scaleInPlace(scale: number): void;
  5986. /**
  5987. * Gets the spherical polynomial from harmonics
  5988. * @param harmonics the spherical harmonics
  5989. * @returns the spherical polynomial
  5990. */
  5991. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5992. /**
  5993. * Constructs a spherical polynomial from an array.
  5994. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5995. * @returns the spherical polynomial
  5996. */
  5997. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5998. }
  5999. }
  6000. declare module BABYLON {
  6001. /**
  6002. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6003. */
  6004. export interface CubeMapInfo {
  6005. /**
  6006. * The pixel array for the front face.
  6007. * This is stored in format, left to right, up to down format.
  6008. */
  6009. front: Nullable<ArrayBufferView>;
  6010. /**
  6011. * The pixel array for the back face.
  6012. * This is stored in format, left to right, up to down format.
  6013. */
  6014. back: Nullable<ArrayBufferView>;
  6015. /**
  6016. * The pixel array for the left face.
  6017. * This is stored in format, left to right, up to down format.
  6018. */
  6019. left: Nullable<ArrayBufferView>;
  6020. /**
  6021. * The pixel array for the right face.
  6022. * This is stored in format, left to right, up to down format.
  6023. */
  6024. right: Nullable<ArrayBufferView>;
  6025. /**
  6026. * The pixel array for the up face.
  6027. * This is stored in format, left to right, up to down format.
  6028. */
  6029. up: Nullable<ArrayBufferView>;
  6030. /**
  6031. * The pixel array for the down face.
  6032. * This is stored in format, left to right, up to down format.
  6033. */
  6034. down: Nullable<ArrayBufferView>;
  6035. /**
  6036. * The size of the cubemap stored.
  6037. *
  6038. * Each faces will be size * size pixels.
  6039. */
  6040. size: number;
  6041. /**
  6042. * The format of the texture.
  6043. *
  6044. * RGBA, RGB.
  6045. */
  6046. format: number;
  6047. /**
  6048. * The type of the texture data.
  6049. *
  6050. * UNSIGNED_INT, FLOAT.
  6051. */
  6052. type: number;
  6053. /**
  6054. * Specifies whether the texture is in gamma space.
  6055. */
  6056. gammaSpace: boolean;
  6057. }
  6058. /**
  6059. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6060. */
  6061. export class PanoramaToCubeMapTools {
  6062. private static FACE_FRONT;
  6063. private static FACE_BACK;
  6064. private static FACE_RIGHT;
  6065. private static FACE_LEFT;
  6066. private static FACE_DOWN;
  6067. private static FACE_UP;
  6068. /**
  6069. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6070. *
  6071. * @param float32Array The source data.
  6072. * @param inputWidth The width of the input panorama.
  6073. * @param inputHeight The height of the input panorama.
  6074. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6075. * @return The cubemap data
  6076. */
  6077. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6078. private static CreateCubemapTexture;
  6079. private static CalcProjectionSpherical;
  6080. }
  6081. }
  6082. declare module BABYLON {
  6083. /**
  6084. * Helper class dealing with the extraction of spherical polynomial dataArray
  6085. * from a cube map.
  6086. */
  6087. export class CubeMapToSphericalPolynomialTools {
  6088. private static FileFaces;
  6089. /**
  6090. * Converts a texture to the according Spherical Polynomial data.
  6091. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6092. *
  6093. * @param texture The texture to extract the information from.
  6094. * @return The Spherical Polynomial data.
  6095. */
  6096. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6097. /**
  6098. * Converts a cubemap to the according Spherical Polynomial data.
  6099. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6100. *
  6101. * @param cubeInfo The Cube map to extract the information from.
  6102. * @return The Spherical Polynomial data.
  6103. */
  6104. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6105. }
  6106. }
  6107. declare module BABYLON {
  6108. /**
  6109. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6110. * during the life time of the application.
  6111. */
  6112. export class EngineStore {
  6113. /** Gets the list of created engines */
  6114. static Instances: Engine[];
  6115. /** @hidden */
  6116. static _LastCreatedScene: Nullable<Scene>;
  6117. /**
  6118. * Gets the latest created engine
  6119. */
  6120. static readonly LastCreatedEngine: Nullable<Engine>;
  6121. /**
  6122. * Gets the latest created scene
  6123. */
  6124. static readonly LastCreatedScene: Nullable<Scene>;
  6125. }
  6126. }
  6127. declare module BABYLON {
  6128. /**
  6129. * Define options used to create a render target texture
  6130. */
  6131. export class RenderTargetCreationOptions {
  6132. /**
  6133. * Specifies is mipmaps must be generated
  6134. */
  6135. generateMipMaps?: boolean;
  6136. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6137. generateDepthBuffer?: boolean;
  6138. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6139. generateStencilBuffer?: boolean;
  6140. /** Defines texture type (int by default) */
  6141. type?: number;
  6142. /** Defines sampling mode (trilinear by default) */
  6143. samplingMode?: number;
  6144. /** Defines format (RGBA by default) */
  6145. format?: number;
  6146. }
  6147. }
  6148. declare module BABYLON {
  6149. /**
  6150. * @hidden
  6151. **/
  6152. export class _AlphaState {
  6153. private _isAlphaBlendDirty;
  6154. private _isBlendFunctionParametersDirty;
  6155. private _isBlendEquationParametersDirty;
  6156. private _isBlendConstantsDirty;
  6157. private _alphaBlend;
  6158. private _blendFunctionParameters;
  6159. private _blendEquationParameters;
  6160. private _blendConstants;
  6161. /**
  6162. * Initializes the state.
  6163. */
  6164. constructor();
  6165. readonly isDirty: boolean;
  6166. alphaBlend: boolean;
  6167. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6168. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6169. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6170. reset(): void;
  6171. apply(gl: WebGLRenderingContext): void;
  6172. }
  6173. }
  6174. declare module BABYLON {
  6175. /**
  6176. * @hidden
  6177. **/
  6178. export class _DepthCullingState {
  6179. private _isDepthTestDirty;
  6180. private _isDepthMaskDirty;
  6181. private _isDepthFuncDirty;
  6182. private _isCullFaceDirty;
  6183. private _isCullDirty;
  6184. private _isZOffsetDirty;
  6185. private _isFrontFaceDirty;
  6186. private _depthTest;
  6187. private _depthMask;
  6188. private _depthFunc;
  6189. private _cull;
  6190. private _cullFace;
  6191. private _zOffset;
  6192. private _frontFace;
  6193. /**
  6194. * Initializes the state.
  6195. */
  6196. constructor();
  6197. readonly isDirty: boolean;
  6198. zOffset: number;
  6199. cullFace: Nullable<number>;
  6200. cull: Nullable<boolean>;
  6201. depthFunc: Nullable<number>;
  6202. depthMask: boolean;
  6203. depthTest: boolean;
  6204. frontFace: Nullable<number>;
  6205. reset(): void;
  6206. apply(gl: WebGLRenderingContext): void;
  6207. }
  6208. }
  6209. declare module BABYLON {
  6210. /**
  6211. * @hidden
  6212. **/
  6213. export class _StencilState {
  6214. /** 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 */
  6215. static readonly ALWAYS: number;
  6216. /** Passed to stencilOperation to specify that stencil value must be kept */
  6217. static readonly KEEP: number;
  6218. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6219. static readonly REPLACE: number;
  6220. private _isStencilTestDirty;
  6221. private _isStencilMaskDirty;
  6222. private _isStencilFuncDirty;
  6223. private _isStencilOpDirty;
  6224. private _stencilTest;
  6225. private _stencilMask;
  6226. private _stencilFunc;
  6227. private _stencilFuncRef;
  6228. private _stencilFuncMask;
  6229. private _stencilOpStencilFail;
  6230. private _stencilOpDepthFail;
  6231. private _stencilOpStencilDepthPass;
  6232. readonly isDirty: boolean;
  6233. stencilFunc: number;
  6234. stencilFuncRef: number;
  6235. stencilFuncMask: number;
  6236. stencilOpStencilFail: number;
  6237. stencilOpDepthFail: number;
  6238. stencilOpStencilDepthPass: number;
  6239. stencilMask: number;
  6240. stencilTest: boolean;
  6241. constructor();
  6242. reset(): void;
  6243. apply(gl: WebGLRenderingContext): void;
  6244. }
  6245. }
  6246. declare module BABYLON {
  6247. /**
  6248. * @hidden
  6249. **/
  6250. export class _TimeToken {
  6251. _startTimeQuery: Nullable<WebGLQuery>;
  6252. _endTimeQuery: Nullable<WebGLQuery>;
  6253. _timeElapsedQuery: Nullable<WebGLQuery>;
  6254. _timeElapsedQueryEnded: boolean;
  6255. }
  6256. }
  6257. declare module BABYLON {
  6258. /**
  6259. * Class used to store data associated with WebGL texture data for the engine
  6260. * This class should not be used directly
  6261. */
  6262. export class InternalTexture {
  6263. /** hidden */
  6264. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6265. /**
  6266. * The source of the texture data is unknown
  6267. */
  6268. static DATASOURCE_UNKNOWN: number;
  6269. /**
  6270. * Texture data comes from an URL
  6271. */
  6272. static DATASOURCE_URL: number;
  6273. /**
  6274. * Texture data is only used for temporary storage
  6275. */
  6276. static DATASOURCE_TEMP: number;
  6277. /**
  6278. * Texture data comes from raw data (ArrayBuffer)
  6279. */
  6280. static DATASOURCE_RAW: number;
  6281. /**
  6282. * Texture content is dynamic (video or dynamic texture)
  6283. */
  6284. static DATASOURCE_DYNAMIC: number;
  6285. /**
  6286. * Texture content is generated by rendering to it
  6287. */
  6288. static DATASOURCE_RENDERTARGET: number;
  6289. /**
  6290. * Texture content is part of a multi render target process
  6291. */
  6292. static DATASOURCE_MULTIRENDERTARGET: number;
  6293. /**
  6294. * Texture data comes from a cube data file
  6295. */
  6296. static DATASOURCE_CUBE: number;
  6297. /**
  6298. * Texture data comes from a raw cube data
  6299. */
  6300. static DATASOURCE_CUBERAW: number;
  6301. /**
  6302. * Texture data come from a prefiltered cube data file
  6303. */
  6304. static DATASOURCE_CUBEPREFILTERED: number;
  6305. /**
  6306. * Texture content is raw 3D data
  6307. */
  6308. static DATASOURCE_RAW3D: number;
  6309. /**
  6310. * Texture content is a depth texture
  6311. */
  6312. static DATASOURCE_DEPTHTEXTURE: number;
  6313. /**
  6314. * Texture data comes from a raw cube data encoded with RGBD
  6315. */
  6316. static DATASOURCE_CUBERAW_RGBD: number;
  6317. /**
  6318. * Defines if the texture is ready
  6319. */
  6320. isReady: boolean;
  6321. /**
  6322. * Defines if the texture is a cube texture
  6323. */
  6324. isCube: boolean;
  6325. /**
  6326. * Defines if the texture contains 3D data
  6327. */
  6328. is3D: boolean;
  6329. /**
  6330. * Defines if the texture contains multiview data
  6331. */
  6332. isMultiview: boolean;
  6333. /**
  6334. * Gets the URL used to load this texture
  6335. */
  6336. url: string;
  6337. /**
  6338. * Gets the sampling mode of the texture
  6339. */
  6340. samplingMode: number;
  6341. /**
  6342. * Gets a boolean indicating if the texture needs mipmaps generation
  6343. */
  6344. generateMipMaps: boolean;
  6345. /**
  6346. * Gets the number of samples used by the texture (WebGL2+ only)
  6347. */
  6348. samples: number;
  6349. /**
  6350. * Gets the type of the texture (int, float...)
  6351. */
  6352. type: number;
  6353. /**
  6354. * Gets the format of the texture (RGB, RGBA...)
  6355. */
  6356. format: number;
  6357. /**
  6358. * Observable called when the texture is loaded
  6359. */
  6360. onLoadedObservable: Observable<InternalTexture>;
  6361. /**
  6362. * Gets the width of the texture
  6363. */
  6364. width: number;
  6365. /**
  6366. * Gets the height of the texture
  6367. */
  6368. height: number;
  6369. /**
  6370. * Gets the depth of the texture
  6371. */
  6372. depth: number;
  6373. /**
  6374. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6375. */
  6376. baseWidth: number;
  6377. /**
  6378. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6379. */
  6380. baseHeight: number;
  6381. /**
  6382. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6383. */
  6384. baseDepth: number;
  6385. /**
  6386. * Gets a boolean indicating if the texture is inverted on Y axis
  6387. */
  6388. invertY: boolean;
  6389. /** @hidden */
  6390. _invertVScale: boolean;
  6391. /** @hidden */
  6392. _associatedChannel: number;
  6393. /** @hidden */
  6394. _dataSource: number;
  6395. /** @hidden */
  6396. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6397. /** @hidden */
  6398. _bufferView: Nullable<ArrayBufferView>;
  6399. /** @hidden */
  6400. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6401. /** @hidden */
  6402. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6403. /** @hidden */
  6404. _size: number;
  6405. /** @hidden */
  6406. _extension: string;
  6407. /** @hidden */
  6408. _files: Nullable<string[]>;
  6409. /** @hidden */
  6410. _workingCanvas: Nullable<HTMLCanvasElement>;
  6411. /** @hidden */
  6412. _workingContext: Nullable<CanvasRenderingContext2D>;
  6413. /** @hidden */
  6414. _framebuffer: Nullable<WebGLFramebuffer>;
  6415. /** @hidden */
  6416. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6417. /** @hidden */
  6418. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6419. /** @hidden */
  6420. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6421. /** @hidden */
  6422. _attachments: Nullable<number[]>;
  6423. /** @hidden */
  6424. _cachedCoordinatesMode: Nullable<number>;
  6425. /** @hidden */
  6426. _cachedWrapU: Nullable<number>;
  6427. /** @hidden */
  6428. _cachedWrapV: Nullable<number>;
  6429. /** @hidden */
  6430. _cachedWrapR: Nullable<number>;
  6431. /** @hidden */
  6432. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6433. /** @hidden */
  6434. _isDisabled: boolean;
  6435. /** @hidden */
  6436. _compression: Nullable<string>;
  6437. /** @hidden */
  6438. _generateStencilBuffer: boolean;
  6439. /** @hidden */
  6440. _generateDepthBuffer: boolean;
  6441. /** @hidden */
  6442. _comparisonFunction: number;
  6443. /** @hidden */
  6444. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6445. /** @hidden */
  6446. _lodGenerationScale: number;
  6447. /** @hidden */
  6448. _lodGenerationOffset: number;
  6449. /** @hidden */
  6450. _colorTextureArray: Nullable<WebGLTexture>;
  6451. /** @hidden */
  6452. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6453. /** @hidden */
  6454. _lodTextureHigh: Nullable<BaseTexture>;
  6455. /** @hidden */
  6456. _lodTextureMid: Nullable<BaseTexture>;
  6457. /** @hidden */
  6458. _lodTextureLow: Nullable<BaseTexture>;
  6459. /** @hidden */
  6460. _isRGBD: boolean;
  6461. /** @hidden */
  6462. _webGLTexture: Nullable<WebGLTexture>;
  6463. /** @hidden */
  6464. _references: number;
  6465. private _engine;
  6466. /**
  6467. * Gets the Engine the texture belongs to.
  6468. * @returns The babylon engine
  6469. */
  6470. getEngine(): Engine;
  6471. /**
  6472. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6473. */
  6474. readonly dataSource: number;
  6475. /**
  6476. * Creates a new InternalTexture
  6477. * @param engine defines the engine to use
  6478. * @param dataSource defines the type of data that will be used
  6479. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6480. */
  6481. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6482. /**
  6483. * Increments the number of references (ie. the number of Texture that point to it)
  6484. */
  6485. incrementReferences(): void;
  6486. /**
  6487. * Change the size of the texture (not the size of the content)
  6488. * @param width defines the new width
  6489. * @param height defines the new height
  6490. * @param depth defines the new depth (1 by default)
  6491. */
  6492. updateSize(width: int, height: int, depth?: int): void;
  6493. /** @hidden */
  6494. _rebuild(): void;
  6495. /** @hidden */
  6496. _swapAndDie(target: InternalTexture): void;
  6497. /**
  6498. * Dispose the current allocated resources
  6499. */
  6500. dispose(): void;
  6501. }
  6502. }
  6503. declare module BABYLON {
  6504. /**
  6505. * This represents the main contract an easing function should follow.
  6506. * Easing functions are used throughout the animation system.
  6507. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6508. */
  6509. export interface IEasingFunction {
  6510. /**
  6511. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6512. * of the easing function.
  6513. * The link below provides some of the most common examples of easing functions.
  6514. * @see https://easings.net/
  6515. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6516. * @returns the corresponding value on the curve defined by the easing function
  6517. */
  6518. ease(gradient: number): number;
  6519. }
  6520. /**
  6521. * Base class used for every default easing function.
  6522. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6523. */
  6524. export class EasingFunction implements IEasingFunction {
  6525. /**
  6526. * Interpolation follows the mathematical formula associated with the easing function.
  6527. */
  6528. static readonly EASINGMODE_EASEIN: number;
  6529. /**
  6530. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6531. */
  6532. static readonly EASINGMODE_EASEOUT: number;
  6533. /**
  6534. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6535. */
  6536. static readonly EASINGMODE_EASEINOUT: number;
  6537. private _easingMode;
  6538. /**
  6539. * Sets the easing mode of the current function.
  6540. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6541. */
  6542. setEasingMode(easingMode: number): void;
  6543. /**
  6544. * Gets the current easing mode.
  6545. * @returns the easing mode
  6546. */
  6547. getEasingMode(): number;
  6548. /**
  6549. * @hidden
  6550. */
  6551. easeInCore(gradient: number): number;
  6552. /**
  6553. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6554. * of the easing function.
  6555. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6556. * @returns the corresponding value on the curve defined by the easing function
  6557. */
  6558. ease(gradient: number): number;
  6559. }
  6560. /**
  6561. * Easing function with a circle shape (see link below).
  6562. * @see https://easings.net/#easeInCirc
  6563. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6564. */
  6565. export class CircleEase extends EasingFunction implements IEasingFunction {
  6566. /** @hidden */
  6567. easeInCore(gradient: number): number;
  6568. }
  6569. /**
  6570. * Easing function with a ease back shape (see link below).
  6571. * @see https://easings.net/#easeInBack
  6572. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6573. */
  6574. export class BackEase extends EasingFunction implements IEasingFunction {
  6575. /** Defines the amplitude of the function */
  6576. amplitude: number;
  6577. /**
  6578. * Instantiates a back ease easing
  6579. * @see https://easings.net/#easeInBack
  6580. * @param amplitude Defines the amplitude of the function
  6581. */
  6582. constructor(
  6583. /** Defines the amplitude of the function */
  6584. amplitude?: number);
  6585. /** @hidden */
  6586. easeInCore(gradient: number): number;
  6587. }
  6588. /**
  6589. * Easing function with a bouncing shape (see link below).
  6590. * @see https://easings.net/#easeInBounce
  6591. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6592. */
  6593. export class BounceEase extends EasingFunction implements IEasingFunction {
  6594. /** Defines the number of bounces */
  6595. bounces: number;
  6596. /** Defines the amplitude of the bounce */
  6597. bounciness: number;
  6598. /**
  6599. * Instantiates a bounce easing
  6600. * @see https://easings.net/#easeInBounce
  6601. * @param bounces Defines the number of bounces
  6602. * @param bounciness Defines the amplitude of the bounce
  6603. */
  6604. constructor(
  6605. /** Defines the number of bounces */
  6606. bounces?: number,
  6607. /** Defines the amplitude of the bounce */
  6608. bounciness?: number);
  6609. /** @hidden */
  6610. easeInCore(gradient: number): number;
  6611. }
  6612. /**
  6613. * Easing function with a power of 3 shape (see link below).
  6614. * @see https://easings.net/#easeInCubic
  6615. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6616. */
  6617. export class CubicEase extends EasingFunction implements IEasingFunction {
  6618. /** @hidden */
  6619. easeInCore(gradient: number): number;
  6620. }
  6621. /**
  6622. * Easing function with an elastic shape (see link below).
  6623. * @see https://easings.net/#easeInElastic
  6624. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6625. */
  6626. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6627. /** Defines the number of oscillations*/
  6628. oscillations: number;
  6629. /** Defines the amplitude of the oscillations*/
  6630. springiness: number;
  6631. /**
  6632. * Instantiates an elastic easing function
  6633. * @see https://easings.net/#easeInElastic
  6634. * @param oscillations Defines the number of oscillations
  6635. * @param springiness Defines the amplitude of the oscillations
  6636. */
  6637. constructor(
  6638. /** Defines the number of oscillations*/
  6639. oscillations?: number,
  6640. /** Defines the amplitude of the oscillations*/
  6641. springiness?: number);
  6642. /** @hidden */
  6643. easeInCore(gradient: number): number;
  6644. }
  6645. /**
  6646. * Easing function with an exponential shape (see link below).
  6647. * @see https://easings.net/#easeInExpo
  6648. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6649. */
  6650. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6651. /** Defines the exponent of the function */
  6652. exponent: number;
  6653. /**
  6654. * Instantiates an exponential easing function
  6655. * @see https://easings.net/#easeInExpo
  6656. * @param exponent Defines the exponent of the function
  6657. */
  6658. constructor(
  6659. /** Defines the exponent of the function */
  6660. exponent?: number);
  6661. /** @hidden */
  6662. easeInCore(gradient: number): number;
  6663. }
  6664. /**
  6665. * Easing function with a power shape (see link below).
  6666. * @see https://easings.net/#easeInQuad
  6667. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6668. */
  6669. export class PowerEase extends EasingFunction implements IEasingFunction {
  6670. /** Defines the power of the function */
  6671. power: number;
  6672. /**
  6673. * Instantiates an power base easing function
  6674. * @see https://easings.net/#easeInQuad
  6675. * @param power Defines the power of the function
  6676. */
  6677. constructor(
  6678. /** Defines the power of the function */
  6679. power?: number);
  6680. /** @hidden */
  6681. easeInCore(gradient: number): number;
  6682. }
  6683. /**
  6684. * Easing function with a power of 2 shape (see link below).
  6685. * @see https://easings.net/#easeInQuad
  6686. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6687. */
  6688. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6689. /** @hidden */
  6690. easeInCore(gradient: number): number;
  6691. }
  6692. /**
  6693. * Easing function with a power of 4 shape (see link below).
  6694. * @see https://easings.net/#easeInQuart
  6695. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6696. */
  6697. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6698. /** @hidden */
  6699. easeInCore(gradient: number): number;
  6700. }
  6701. /**
  6702. * Easing function with a power of 5 shape (see link below).
  6703. * @see https://easings.net/#easeInQuint
  6704. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6705. */
  6706. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6707. /** @hidden */
  6708. easeInCore(gradient: number): number;
  6709. }
  6710. /**
  6711. * Easing function with a sin shape (see link below).
  6712. * @see https://easings.net/#easeInSine
  6713. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6714. */
  6715. export class SineEase extends EasingFunction implements IEasingFunction {
  6716. /** @hidden */
  6717. easeInCore(gradient: number): number;
  6718. }
  6719. /**
  6720. * Easing function with a bezier shape (see link below).
  6721. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6722. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6723. */
  6724. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6725. /** Defines the x component of the start tangent in the bezier curve */
  6726. x1: number;
  6727. /** Defines the y component of the start tangent in the bezier curve */
  6728. y1: number;
  6729. /** Defines the x component of the end tangent in the bezier curve */
  6730. x2: number;
  6731. /** Defines the y component of the end tangent in the bezier curve */
  6732. y2: number;
  6733. /**
  6734. * Instantiates a bezier function
  6735. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6736. * @param x1 Defines the x component of the start tangent in the bezier curve
  6737. * @param y1 Defines the y component of the start tangent in the bezier curve
  6738. * @param x2 Defines the x component of the end tangent in the bezier curve
  6739. * @param y2 Defines the y component of the end tangent in the bezier curve
  6740. */
  6741. constructor(
  6742. /** Defines the x component of the start tangent in the bezier curve */
  6743. x1?: number,
  6744. /** Defines the y component of the start tangent in the bezier curve */
  6745. y1?: number,
  6746. /** Defines the x component of the end tangent in the bezier curve */
  6747. x2?: number,
  6748. /** Defines the y component of the end tangent in the bezier curve */
  6749. y2?: number);
  6750. /** @hidden */
  6751. easeInCore(gradient: number): number;
  6752. }
  6753. }
  6754. declare module BABYLON {
  6755. /**
  6756. * Defines an interface which represents an animation key frame
  6757. */
  6758. export interface IAnimationKey {
  6759. /**
  6760. * Frame of the key frame
  6761. */
  6762. frame: number;
  6763. /**
  6764. * Value at the specifies key frame
  6765. */
  6766. value: any;
  6767. /**
  6768. * The input tangent for the cubic hermite spline
  6769. */
  6770. inTangent?: any;
  6771. /**
  6772. * The output tangent for the cubic hermite spline
  6773. */
  6774. outTangent?: any;
  6775. /**
  6776. * The animation interpolation type
  6777. */
  6778. interpolation?: AnimationKeyInterpolation;
  6779. }
  6780. /**
  6781. * Enum for the animation key frame interpolation type
  6782. */
  6783. export enum AnimationKeyInterpolation {
  6784. /**
  6785. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6786. */
  6787. STEP = 1
  6788. }
  6789. }
  6790. declare module BABYLON {
  6791. /**
  6792. * Represents the range of an animation
  6793. */
  6794. export class AnimationRange {
  6795. /**The name of the animation range**/
  6796. name: string;
  6797. /**The starting frame of the animation */
  6798. from: number;
  6799. /**The ending frame of the animation*/
  6800. to: number;
  6801. /**
  6802. * Initializes the range of an animation
  6803. * @param name The name of the animation range
  6804. * @param from The starting frame of the animation
  6805. * @param to The ending frame of the animation
  6806. */
  6807. constructor(
  6808. /**The name of the animation range**/
  6809. name: string,
  6810. /**The starting frame of the animation */
  6811. from: number,
  6812. /**The ending frame of the animation*/
  6813. to: number);
  6814. /**
  6815. * Makes a copy of the animation range
  6816. * @returns A copy of the animation range
  6817. */
  6818. clone(): AnimationRange;
  6819. }
  6820. }
  6821. declare module BABYLON {
  6822. /**
  6823. * Composed of a frame, and an action function
  6824. */
  6825. export class AnimationEvent {
  6826. /** The frame for which the event is triggered **/
  6827. frame: number;
  6828. /** The event to perform when triggered **/
  6829. action: (currentFrame: number) => void;
  6830. /** Specifies if the event should be triggered only once**/
  6831. onlyOnce?: boolean | undefined;
  6832. /**
  6833. * Specifies if the animation event is done
  6834. */
  6835. isDone: boolean;
  6836. /**
  6837. * Initializes the animation event
  6838. * @param frame The frame for which the event is triggered
  6839. * @param action The event to perform when triggered
  6840. * @param onlyOnce Specifies if the event should be triggered only once
  6841. */
  6842. constructor(
  6843. /** The frame for which the event is triggered **/
  6844. frame: number,
  6845. /** The event to perform when triggered **/
  6846. action: (currentFrame: number) => void,
  6847. /** Specifies if the event should be triggered only once**/
  6848. onlyOnce?: boolean | undefined);
  6849. /** @hidden */
  6850. _clone(): AnimationEvent;
  6851. }
  6852. }
  6853. declare module BABYLON {
  6854. /**
  6855. * Interface used to define a behavior
  6856. */
  6857. export interface Behavior<T> {
  6858. /** gets or sets behavior's name */
  6859. name: string;
  6860. /**
  6861. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6862. */
  6863. init(): void;
  6864. /**
  6865. * Called when the behavior is attached to a target
  6866. * @param target defines the target where the behavior is attached to
  6867. */
  6868. attach(target: T): void;
  6869. /**
  6870. * Called when the behavior is detached from its target
  6871. */
  6872. detach(): void;
  6873. }
  6874. /**
  6875. * Interface implemented by classes supporting behaviors
  6876. */
  6877. export interface IBehaviorAware<T> {
  6878. /**
  6879. * Attach a behavior
  6880. * @param behavior defines the behavior to attach
  6881. * @returns the current host
  6882. */
  6883. addBehavior(behavior: Behavior<T>): T;
  6884. /**
  6885. * Remove a behavior from the current object
  6886. * @param behavior defines the behavior to detach
  6887. * @returns the current host
  6888. */
  6889. removeBehavior(behavior: Behavior<T>): T;
  6890. /**
  6891. * Gets a behavior using its name to search
  6892. * @param name defines the name to search
  6893. * @returns the behavior or null if not found
  6894. */
  6895. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6896. }
  6897. }
  6898. declare module BABYLON {
  6899. /**
  6900. * @hidden
  6901. */
  6902. export class IntersectionInfo {
  6903. bu: Nullable<number>;
  6904. bv: Nullable<number>;
  6905. distance: number;
  6906. faceId: number;
  6907. subMeshId: number;
  6908. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6909. }
  6910. }
  6911. declare module BABYLON {
  6912. /**
  6913. * Class used to store bounding sphere information
  6914. */
  6915. export class BoundingSphere {
  6916. /**
  6917. * Gets the center of the bounding sphere in local space
  6918. */
  6919. readonly center: Vector3;
  6920. /**
  6921. * Radius of the bounding sphere in local space
  6922. */
  6923. radius: number;
  6924. /**
  6925. * Gets the center of the bounding sphere in world space
  6926. */
  6927. readonly centerWorld: Vector3;
  6928. /**
  6929. * Radius of the bounding sphere in world space
  6930. */
  6931. radiusWorld: number;
  6932. /**
  6933. * Gets the minimum vector in local space
  6934. */
  6935. readonly minimum: Vector3;
  6936. /**
  6937. * Gets the maximum vector in local space
  6938. */
  6939. readonly maximum: Vector3;
  6940. private _worldMatrix;
  6941. private static readonly TmpVector3;
  6942. /**
  6943. * Creates a new bounding sphere
  6944. * @param min defines the minimum vector (in local space)
  6945. * @param max defines the maximum vector (in local space)
  6946. * @param worldMatrix defines the new world matrix
  6947. */
  6948. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6949. /**
  6950. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6951. * @param min defines the new minimum vector (in local space)
  6952. * @param max defines the new maximum vector (in local space)
  6953. * @param worldMatrix defines the new world matrix
  6954. */
  6955. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6956. /**
  6957. * Scale the current bounding sphere by applying a scale factor
  6958. * @param factor defines the scale factor to apply
  6959. * @returns the current bounding box
  6960. */
  6961. scale(factor: number): BoundingSphere;
  6962. /**
  6963. * Gets the world matrix of the bounding box
  6964. * @returns a matrix
  6965. */
  6966. getWorldMatrix(): DeepImmutable<Matrix>;
  6967. /** @hidden */
  6968. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6969. /**
  6970. * Tests if the bounding sphere is intersecting the frustum planes
  6971. * @param frustumPlanes defines the frustum planes to test
  6972. * @returns true if there is an intersection
  6973. */
  6974. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6975. /**
  6976. * Tests if the bounding sphere center is in between the frustum planes.
  6977. * Used for optimistic fast inclusion.
  6978. * @param frustumPlanes defines the frustum planes to test
  6979. * @returns true if the sphere center is in between the frustum planes
  6980. */
  6981. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6982. /**
  6983. * Tests if a point is inside the bounding sphere
  6984. * @param point defines the point to test
  6985. * @returns true if the point is inside the bounding sphere
  6986. */
  6987. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6988. /**
  6989. * Checks if two sphere intersct
  6990. * @param sphere0 sphere 0
  6991. * @param sphere1 sphere 1
  6992. * @returns true if the speres intersect
  6993. */
  6994. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6995. }
  6996. }
  6997. declare module BABYLON {
  6998. /**
  6999. * Class used to store bounding box information
  7000. */
  7001. export class BoundingBox implements ICullable {
  7002. /**
  7003. * Gets the 8 vectors representing the bounding box in local space
  7004. */
  7005. readonly vectors: Vector3[];
  7006. /**
  7007. * Gets the center of the bounding box in local space
  7008. */
  7009. readonly center: Vector3;
  7010. /**
  7011. * Gets the center of the bounding box in world space
  7012. */
  7013. readonly centerWorld: Vector3;
  7014. /**
  7015. * Gets the extend size in local space
  7016. */
  7017. readonly extendSize: Vector3;
  7018. /**
  7019. * Gets the extend size in world space
  7020. */
  7021. readonly extendSizeWorld: Vector3;
  7022. /**
  7023. * Gets the OBB (object bounding box) directions
  7024. */
  7025. readonly directions: Vector3[];
  7026. /**
  7027. * Gets the 8 vectors representing the bounding box in world space
  7028. */
  7029. readonly vectorsWorld: Vector3[];
  7030. /**
  7031. * Gets the minimum vector in world space
  7032. */
  7033. readonly minimumWorld: Vector3;
  7034. /**
  7035. * Gets the maximum vector in world space
  7036. */
  7037. readonly maximumWorld: Vector3;
  7038. /**
  7039. * Gets the minimum vector in local space
  7040. */
  7041. readonly minimum: Vector3;
  7042. /**
  7043. * Gets the maximum vector in local space
  7044. */
  7045. readonly maximum: Vector3;
  7046. private _worldMatrix;
  7047. private static readonly TmpVector3;
  7048. /**
  7049. * @hidden
  7050. */
  7051. _tag: number;
  7052. /**
  7053. * Creates a new bounding box
  7054. * @param min defines the minimum vector (in local space)
  7055. * @param max defines the maximum vector (in local space)
  7056. * @param worldMatrix defines the new world matrix
  7057. */
  7058. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7059. /**
  7060. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7061. * @param min defines the new minimum vector (in local space)
  7062. * @param max defines the new maximum vector (in local space)
  7063. * @param worldMatrix defines the new world matrix
  7064. */
  7065. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7066. /**
  7067. * Scale the current bounding box by applying a scale factor
  7068. * @param factor defines the scale factor to apply
  7069. * @returns the current bounding box
  7070. */
  7071. scale(factor: number): BoundingBox;
  7072. /**
  7073. * Gets the world matrix of the bounding box
  7074. * @returns a matrix
  7075. */
  7076. getWorldMatrix(): DeepImmutable<Matrix>;
  7077. /** @hidden */
  7078. _update(world: DeepImmutable<Matrix>): void;
  7079. /**
  7080. * Tests if the bounding box is intersecting the frustum planes
  7081. * @param frustumPlanes defines the frustum planes to test
  7082. * @returns true if there is an intersection
  7083. */
  7084. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7085. /**
  7086. * Tests if the bounding box is entirely inside the frustum planes
  7087. * @param frustumPlanes defines the frustum planes to test
  7088. * @returns true if there is an inclusion
  7089. */
  7090. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7091. /**
  7092. * Tests if a point is inside the bounding box
  7093. * @param point defines the point to test
  7094. * @returns true if the point is inside the bounding box
  7095. */
  7096. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7097. /**
  7098. * Tests if the bounding box intersects with a bounding sphere
  7099. * @param sphere defines the sphere to test
  7100. * @returns true if there is an intersection
  7101. */
  7102. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7103. /**
  7104. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7105. * @param min defines the min vector to use
  7106. * @param max defines the max vector to use
  7107. * @returns true if there is an intersection
  7108. */
  7109. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7110. /**
  7111. * Tests if two bounding boxes are intersections
  7112. * @param box0 defines the first box to test
  7113. * @param box1 defines the second box to test
  7114. * @returns true if there is an intersection
  7115. */
  7116. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7117. /**
  7118. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7119. * @param minPoint defines the minimum vector of the bounding box
  7120. * @param maxPoint defines the maximum vector of the bounding box
  7121. * @param sphereCenter defines the sphere center
  7122. * @param sphereRadius defines the sphere radius
  7123. * @returns true if there is an intersection
  7124. */
  7125. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7126. /**
  7127. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7128. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7129. * @param frustumPlanes defines the frustum planes to test
  7130. * @return true if there is an inclusion
  7131. */
  7132. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7133. /**
  7134. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7135. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7136. * @param frustumPlanes defines the frustum planes to test
  7137. * @return true if there is an intersection
  7138. */
  7139. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7140. }
  7141. }
  7142. declare module BABYLON {
  7143. /** @hidden */
  7144. export class Collider {
  7145. /** Define if a collision was found */
  7146. collisionFound: boolean;
  7147. /**
  7148. * Define last intersection point in local space
  7149. */
  7150. intersectionPoint: Vector3;
  7151. /**
  7152. * Define last collided mesh
  7153. */
  7154. collidedMesh: Nullable<AbstractMesh>;
  7155. private _collisionPoint;
  7156. private _planeIntersectionPoint;
  7157. private _tempVector;
  7158. private _tempVector2;
  7159. private _tempVector3;
  7160. private _tempVector4;
  7161. private _edge;
  7162. private _baseToVertex;
  7163. private _destinationPoint;
  7164. private _slidePlaneNormal;
  7165. private _displacementVector;
  7166. /** @hidden */
  7167. _radius: Vector3;
  7168. /** @hidden */
  7169. _retry: number;
  7170. private _velocity;
  7171. private _basePoint;
  7172. private _epsilon;
  7173. /** @hidden */
  7174. _velocityWorldLength: number;
  7175. /** @hidden */
  7176. _basePointWorld: Vector3;
  7177. private _velocityWorld;
  7178. private _normalizedVelocity;
  7179. /** @hidden */
  7180. _initialVelocity: Vector3;
  7181. /** @hidden */
  7182. _initialPosition: Vector3;
  7183. private _nearestDistance;
  7184. private _collisionMask;
  7185. collisionMask: number;
  7186. /**
  7187. * Gets the plane normal used to compute the sliding response (in local space)
  7188. */
  7189. readonly slidePlaneNormal: Vector3;
  7190. /** @hidden */
  7191. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7192. /** @hidden */
  7193. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7194. /** @hidden */
  7195. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7196. /** @hidden */
  7197. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7198. /** @hidden */
  7199. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7200. /** @hidden */
  7201. _getResponse(pos: Vector3, vel: Vector3): void;
  7202. }
  7203. }
  7204. declare module BABYLON {
  7205. /**
  7206. * Interface for cullable objects
  7207. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7208. */
  7209. export interface ICullable {
  7210. /**
  7211. * Checks if the object or part of the object is in the frustum
  7212. * @param frustumPlanes Camera near/planes
  7213. * @returns true if the object is in frustum otherwise false
  7214. */
  7215. isInFrustum(frustumPlanes: Plane[]): boolean;
  7216. /**
  7217. * Checks if a cullable object (mesh...) is in the camera frustum
  7218. * Unlike isInFrustum this cheks the full bounding box
  7219. * @param frustumPlanes Camera near/planes
  7220. * @returns true if the object is in frustum otherwise false
  7221. */
  7222. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7223. }
  7224. /**
  7225. * Info for a bounding data of a mesh
  7226. */
  7227. export class BoundingInfo implements ICullable {
  7228. /**
  7229. * Bounding box for the mesh
  7230. */
  7231. readonly boundingBox: BoundingBox;
  7232. /**
  7233. * Bounding sphere for the mesh
  7234. */
  7235. readonly boundingSphere: BoundingSphere;
  7236. private _isLocked;
  7237. private static readonly TmpVector3;
  7238. /**
  7239. * Constructs bounding info
  7240. * @param minimum min vector of the bounding box/sphere
  7241. * @param maximum max vector of the bounding box/sphere
  7242. * @param worldMatrix defines the new world matrix
  7243. */
  7244. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7245. /**
  7246. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7247. * @param min defines the new minimum vector (in local space)
  7248. * @param max defines the new maximum vector (in local space)
  7249. * @param worldMatrix defines the new world matrix
  7250. */
  7251. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7252. /**
  7253. * min vector of the bounding box/sphere
  7254. */
  7255. readonly minimum: Vector3;
  7256. /**
  7257. * max vector of the bounding box/sphere
  7258. */
  7259. readonly maximum: Vector3;
  7260. /**
  7261. * If the info is locked and won't be updated to avoid perf overhead
  7262. */
  7263. isLocked: boolean;
  7264. /**
  7265. * Updates the bounding sphere and box
  7266. * @param world world matrix to be used to update
  7267. */
  7268. update(world: DeepImmutable<Matrix>): void;
  7269. /**
  7270. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7271. * @param center New center of the bounding info
  7272. * @param extend New extend of the bounding info
  7273. * @returns the current bounding info
  7274. */
  7275. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7276. /**
  7277. * Scale the current bounding info by applying a scale factor
  7278. * @param factor defines the scale factor to apply
  7279. * @returns the current bounding info
  7280. */
  7281. scale(factor: number): BoundingInfo;
  7282. /**
  7283. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7284. * @param frustumPlanes defines the frustum to test
  7285. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7286. * @returns true if the bounding info is in the frustum planes
  7287. */
  7288. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7289. /**
  7290. * Gets the world distance between the min and max points of the bounding box
  7291. */
  7292. readonly diagonalLength: number;
  7293. /**
  7294. * Checks if a cullable object (mesh...) is in the camera frustum
  7295. * Unlike isInFrustum this cheks the full bounding box
  7296. * @param frustumPlanes Camera near/planes
  7297. * @returns true if the object is in frustum otherwise false
  7298. */
  7299. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7300. /** @hidden */
  7301. _checkCollision(collider: Collider): boolean;
  7302. /**
  7303. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7304. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7305. * @param point the point to check intersection with
  7306. * @returns if the point intersects
  7307. */
  7308. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7309. /**
  7310. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7311. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7312. * @param boundingInfo the bounding info to check intersection with
  7313. * @param precise if the intersection should be done using OBB
  7314. * @returns if the bounding info intersects
  7315. */
  7316. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7317. }
  7318. }
  7319. declare module BABYLON {
  7320. /**
  7321. * Defines an array and its length.
  7322. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7323. */
  7324. export interface ISmartArrayLike<T> {
  7325. /**
  7326. * The data of the array.
  7327. */
  7328. data: Array<T>;
  7329. /**
  7330. * The active length of the array.
  7331. */
  7332. length: number;
  7333. }
  7334. /**
  7335. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7336. */
  7337. export class SmartArray<T> implements ISmartArrayLike<T> {
  7338. /**
  7339. * The full set of data from the array.
  7340. */
  7341. data: Array<T>;
  7342. /**
  7343. * The active length of the array.
  7344. */
  7345. length: number;
  7346. protected _id: number;
  7347. /**
  7348. * Instantiates a Smart Array.
  7349. * @param capacity defines the default capacity of the array.
  7350. */
  7351. constructor(capacity: number);
  7352. /**
  7353. * Pushes a value at the end of the active data.
  7354. * @param value defines the object to push in the array.
  7355. */
  7356. push(value: T): void;
  7357. /**
  7358. * Iterates over the active data and apply the lambda to them.
  7359. * @param func defines the action to apply on each value.
  7360. */
  7361. forEach(func: (content: T) => void): void;
  7362. /**
  7363. * Sorts the full sets of data.
  7364. * @param compareFn defines the comparison function to apply.
  7365. */
  7366. sort(compareFn: (a: T, b: T) => number): void;
  7367. /**
  7368. * Resets the active data to an empty array.
  7369. */
  7370. reset(): void;
  7371. /**
  7372. * Releases all the data from the array as well as the array.
  7373. */
  7374. dispose(): void;
  7375. /**
  7376. * Concats the active data with a given array.
  7377. * @param array defines the data to concatenate with.
  7378. */
  7379. concat(array: any): void;
  7380. /**
  7381. * Returns the position of a value in the active data.
  7382. * @param value defines the value to find the index for
  7383. * @returns the index if found in the active data otherwise -1
  7384. */
  7385. indexOf(value: T): number;
  7386. /**
  7387. * Returns whether an element is part of the active data.
  7388. * @param value defines the value to look for
  7389. * @returns true if found in the active data otherwise false
  7390. */
  7391. contains(value: T): boolean;
  7392. private static _GlobalId;
  7393. }
  7394. /**
  7395. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7396. * The data in this array can only be present once
  7397. */
  7398. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7399. private _duplicateId;
  7400. /**
  7401. * Pushes a value at the end of the active data.
  7402. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7403. * @param value defines the object to push in the array.
  7404. */
  7405. push(value: T): void;
  7406. /**
  7407. * Pushes a value at the end of the active data.
  7408. * If the data is already present, it won t be added again
  7409. * @param value defines the object to push in the array.
  7410. * @returns true if added false if it was already present
  7411. */
  7412. pushNoDuplicate(value: T): boolean;
  7413. /**
  7414. * Resets the active data to an empty array.
  7415. */
  7416. reset(): void;
  7417. /**
  7418. * Concats the active data with a given array.
  7419. * This ensures no dupplicate will be present in the result.
  7420. * @param array defines the data to concatenate with.
  7421. */
  7422. concatWithNoDuplicate(array: any): void;
  7423. }
  7424. }
  7425. declare module BABYLON {
  7426. /**
  7427. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7428. * separate meshes. This can be use to improve performances.
  7429. * @see http://doc.babylonjs.com/how_to/multi_materials
  7430. */
  7431. export class MultiMaterial extends Material {
  7432. private _subMaterials;
  7433. /**
  7434. * Gets or Sets the list of Materials used within the multi material.
  7435. * They need to be ordered according to the submeshes order in the associated mesh
  7436. */
  7437. subMaterials: Nullable<Material>[];
  7438. /**
  7439. * Function used to align with Node.getChildren()
  7440. * @returns the list of Materials used within the multi material
  7441. */
  7442. getChildren(): Nullable<Material>[];
  7443. /**
  7444. * Instantiates a new Multi Material
  7445. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7446. * separate meshes. This can be use to improve performances.
  7447. * @see http://doc.babylonjs.com/how_to/multi_materials
  7448. * @param name Define the name in the scene
  7449. * @param scene Define the scene the material belongs to
  7450. */
  7451. constructor(name: string, scene: Scene);
  7452. private _hookArray;
  7453. /**
  7454. * Get one of the submaterial by its index in the submaterials array
  7455. * @param index The index to look the sub material at
  7456. * @returns The Material if the index has been defined
  7457. */
  7458. getSubMaterial(index: number): Nullable<Material>;
  7459. /**
  7460. * Get the list of active textures for the whole sub materials list.
  7461. * @returns All the textures that will be used during the rendering
  7462. */
  7463. getActiveTextures(): BaseTexture[];
  7464. /**
  7465. * Gets the current class name of the material e.g. "MultiMaterial"
  7466. * Mainly use in serialization.
  7467. * @returns the class name
  7468. */
  7469. getClassName(): string;
  7470. /**
  7471. * Checks if the material is ready to render the requested sub mesh
  7472. * @param mesh Define the mesh the submesh belongs to
  7473. * @param subMesh Define the sub mesh to look readyness for
  7474. * @param useInstances Define whether or not the material is used with instances
  7475. * @returns true if ready, otherwise false
  7476. */
  7477. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7478. /**
  7479. * Clones the current material and its related sub materials
  7480. * @param name Define the name of the newly cloned material
  7481. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7482. * @returns the cloned material
  7483. */
  7484. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7485. /**
  7486. * Serializes the materials into a JSON representation.
  7487. * @returns the JSON representation
  7488. */
  7489. serialize(): any;
  7490. /**
  7491. * Dispose the material and release its associated resources
  7492. * @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)
  7493. * @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)
  7494. * @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)
  7495. */
  7496. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7497. /**
  7498. * Creates a MultiMaterial from parsed MultiMaterial data.
  7499. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7500. * @param scene defines the hosting scene
  7501. * @returns a new MultiMaterial
  7502. */
  7503. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7504. }
  7505. }
  7506. declare module BABYLON {
  7507. /**
  7508. * Class used to represent data loading progression
  7509. */
  7510. export class SceneLoaderFlags {
  7511. private static _ForceFullSceneLoadingForIncremental;
  7512. private static _ShowLoadingScreen;
  7513. private static _CleanBoneMatrixWeights;
  7514. private static _loggingLevel;
  7515. /**
  7516. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7517. */
  7518. static ForceFullSceneLoadingForIncremental: boolean;
  7519. /**
  7520. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7521. */
  7522. static ShowLoadingScreen: boolean;
  7523. /**
  7524. * Defines the current logging level (while loading the scene)
  7525. * @ignorenaming
  7526. */
  7527. static loggingLevel: number;
  7528. /**
  7529. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7530. */
  7531. static CleanBoneMatrixWeights: boolean;
  7532. }
  7533. }
  7534. declare module BABYLON {
  7535. /**
  7536. * 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.
  7537. * @see https://doc.babylonjs.com/how_to/transformnode
  7538. */
  7539. export class TransformNode extends Node {
  7540. /**
  7541. * Object will not rotate to face the camera
  7542. */
  7543. static BILLBOARDMODE_NONE: number;
  7544. /**
  7545. * Object will rotate to face the camera but only on the x axis
  7546. */
  7547. static BILLBOARDMODE_X: number;
  7548. /**
  7549. * Object will rotate to face the camera but only on the y axis
  7550. */
  7551. static BILLBOARDMODE_Y: number;
  7552. /**
  7553. * Object will rotate to face the camera but only on the z axis
  7554. */
  7555. static BILLBOARDMODE_Z: number;
  7556. /**
  7557. * Object will rotate to face the camera
  7558. */
  7559. static BILLBOARDMODE_ALL: number;
  7560. private _forward;
  7561. private _forwardInverted;
  7562. private _up;
  7563. private _right;
  7564. private _rightInverted;
  7565. private _position;
  7566. private _rotation;
  7567. private _rotationQuaternion;
  7568. protected _scaling: Vector3;
  7569. protected _isDirty: boolean;
  7570. private _transformToBoneReferal;
  7571. private _billboardMode;
  7572. /**
  7573. * Gets or sets the billboard mode. Default is 0.
  7574. *
  7575. * | Value | Type | Description |
  7576. * | --- | --- | --- |
  7577. * | 0 | BILLBOARDMODE_NONE | |
  7578. * | 1 | BILLBOARDMODE_X | |
  7579. * | 2 | BILLBOARDMODE_Y | |
  7580. * | 4 | BILLBOARDMODE_Z | |
  7581. * | 7 | BILLBOARDMODE_ALL | |
  7582. *
  7583. */
  7584. billboardMode: number;
  7585. private _preserveParentRotationForBillboard;
  7586. /**
  7587. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7588. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7589. */
  7590. preserveParentRotationForBillboard: boolean;
  7591. /**
  7592. * 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
  7593. */
  7594. scalingDeterminant: number;
  7595. private _infiniteDistance;
  7596. /**
  7597. * Gets or sets the distance of the object to max, often used by skybox
  7598. */
  7599. infiniteDistance: boolean;
  7600. /**
  7601. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7602. * By default the system will update normals to compensate
  7603. */
  7604. ignoreNonUniformScaling: boolean;
  7605. /**
  7606. * 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
  7607. */
  7608. reIntegrateRotationIntoRotationQuaternion: boolean;
  7609. /** @hidden */
  7610. _poseMatrix: Nullable<Matrix>;
  7611. /** @hidden */
  7612. _localMatrix: Matrix;
  7613. private _usePivotMatrix;
  7614. private _absolutePosition;
  7615. private _pivotMatrix;
  7616. private _pivotMatrixInverse;
  7617. protected _postMultiplyPivotMatrix: boolean;
  7618. protected _isWorldMatrixFrozen: boolean;
  7619. /** @hidden */
  7620. _indexInSceneTransformNodesArray: number;
  7621. /**
  7622. * An event triggered after the world matrix is updated
  7623. */
  7624. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7625. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7626. /**
  7627. * Gets a string identifying the name of the class
  7628. * @returns "TransformNode" string
  7629. */
  7630. getClassName(): string;
  7631. /**
  7632. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7633. */
  7634. position: Vector3;
  7635. /**
  7636. * 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)).
  7637. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7638. */
  7639. rotation: Vector3;
  7640. /**
  7641. * 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)).
  7642. */
  7643. scaling: Vector3;
  7644. /**
  7645. * 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).
  7646. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7647. */
  7648. rotationQuaternion: Nullable<Quaternion>;
  7649. /**
  7650. * The forward direction of that transform in world space.
  7651. */
  7652. readonly forward: Vector3;
  7653. /**
  7654. * The up direction of that transform in world space.
  7655. */
  7656. readonly up: Vector3;
  7657. /**
  7658. * The right direction of that transform in world space.
  7659. */
  7660. readonly right: Vector3;
  7661. /**
  7662. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7663. * @param matrix the matrix to copy the pose from
  7664. * @returns this TransformNode.
  7665. */
  7666. updatePoseMatrix(matrix: Matrix): TransformNode;
  7667. /**
  7668. * Returns the mesh Pose matrix.
  7669. * @returns the pose matrix
  7670. */
  7671. getPoseMatrix(): Matrix;
  7672. /** @hidden */
  7673. _isSynchronized(): boolean;
  7674. /** @hidden */
  7675. _initCache(): void;
  7676. /**
  7677. * Flag the transform node as dirty (Forcing it to update everything)
  7678. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7679. * @returns this transform node
  7680. */
  7681. markAsDirty(property: string): TransformNode;
  7682. /**
  7683. * Returns the current mesh absolute position.
  7684. * Returns a Vector3.
  7685. */
  7686. readonly absolutePosition: Vector3;
  7687. /**
  7688. * Sets a new matrix to apply before all other transformation
  7689. * @param matrix defines the transform matrix
  7690. * @returns the current TransformNode
  7691. */
  7692. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7693. /**
  7694. * Sets a new pivot matrix to the current node
  7695. * @param matrix defines the new pivot matrix to use
  7696. * @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
  7697. * @returns the current TransformNode
  7698. */
  7699. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7700. /**
  7701. * Returns the mesh pivot matrix.
  7702. * Default : Identity.
  7703. * @returns the matrix
  7704. */
  7705. getPivotMatrix(): Matrix;
  7706. /**
  7707. * Prevents the World matrix to be computed any longer.
  7708. * @returns the TransformNode.
  7709. */
  7710. freezeWorldMatrix(): TransformNode;
  7711. /**
  7712. * Allows back the World matrix computation.
  7713. * @returns the TransformNode.
  7714. */
  7715. unfreezeWorldMatrix(): this;
  7716. /**
  7717. * True if the World matrix has been frozen.
  7718. */
  7719. readonly isWorldMatrixFrozen: boolean;
  7720. /**
  7721. * Retuns the mesh absolute position in the World.
  7722. * @returns a Vector3.
  7723. */
  7724. getAbsolutePosition(): Vector3;
  7725. /**
  7726. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7727. * @param absolutePosition the absolute position to set
  7728. * @returns the TransformNode.
  7729. */
  7730. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7731. /**
  7732. * Sets the mesh position in its local space.
  7733. * @param vector3 the position to set in localspace
  7734. * @returns the TransformNode.
  7735. */
  7736. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7737. /**
  7738. * Returns the mesh position in the local space from the current World matrix values.
  7739. * @returns a new Vector3.
  7740. */
  7741. getPositionExpressedInLocalSpace(): Vector3;
  7742. /**
  7743. * Translates the mesh along the passed Vector3 in its local space.
  7744. * @param vector3 the distance to translate in localspace
  7745. * @returns the TransformNode.
  7746. */
  7747. locallyTranslate(vector3: Vector3): TransformNode;
  7748. private static _lookAtVectorCache;
  7749. /**
  7750. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7751. * @param targetPoint the position (must be in same space as current mesh) to look at
  7752. * @param yawCor optional yaw (y-axis) correction in radians
  7753. * @param pitchCor optional pitch (x-axis) correction in radians
  7754. * @param rollCor optional roll (z-axis) correction in radians
  7755. * @param space the choosen space of the target
  7756. * @returns the TransformNode.
  7757. */
  7758. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7759. /**
  7760. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7761. * This Vector3 is expressed in the World space.
  7762. * @param localAxis axis to rotate
  7763. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7764. */
  7765. getDirection(localAxis: Vector3): Vector3;
  7766. /**
  7767. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7768. * localAxis is expressed in the mesh local space.
  7769. * result is computed in the Wordl space from the mesh World matrix.
  7770. * @param localAxis axis to rotate
  7771. * @param result the resulting transformnode
  7772. * @returns this TransformNode.
  7773. */
  7774. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7775. /**
  7776. * Sets this transform node rotation to the given local axis.
  7777. * @param localAxis the axis in local space
  7778. * @param yawCor optional yaw (y-axis) correction in radians
  7779. * @param pitchCor optional pitch (x-axis) correction in radians
  7780. * @param rollCor optional roll (z-axis) correction in radians
  7781. * @returns this TransformNode
  7782. */
  7783. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7784. /**
  7785. * Sets a new pivot point to the current node
  7786. * @param point defines the new pivot point to use
  7787. * @param space defines if the point is in world or local space (local by default)
  7788. * @returns the current TransformNode
  7789. */
  7790. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7791. /**
  7792. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7793. * @returns the pivot point
  7794. */
  7795. getPivotPoint(): Vector3;
  7796. /**
  7797. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7798. * @param result the vector3 to store the result
  7799. * @returns this TransformNode.
  7800. */
  7801. getPivotPointToRef(result: Vector3): TransformNode;
  7802. /**
  7803. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7804. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7805. */
  7806. getAbsolutePivotPoint(): Vector3;
  7807. /**
  7808. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7809. * @param result vector3 to store the result
  7810. * @returns this TransformNode.
  7811. */
  7812. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7813. /**
  7814. * Defines the passed node as the parent of the current node.
  7815. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7816. * @see https://doc.babylonjs.com/how_to/parenting
  7817. * @param node the node ot set as the parent
  7818. * @returns this TransformNode.
  7819. */
  7820. setParent(node: Nullable<Node>): TransformNode;
  7821. private _nonUniformScaling;
  7822. /**
  7823. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7824. */
  7825. readonly nonUniformScaling: boolean;
  7826. /** @hidden */
  7827. _updateNonUniformScalingState(value: boolean): boolean;
  7828. /**
  7829. * Attach the current TransformNode to another TransformNode associated with a bone
  7830. * @param bone Bone affecting the TransformNode
  7831. * @param affectedTransformNode TransformNode associated with the bone
  7832. * @returns this object
  7833. */
  7834. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7835. /**
  7836. * Detach the transform node if its associated with a bone
  7837. * @returns this object
  7838. */
  7839. detachFromBone(): TransformNode;
  7840. private static _rotationAxisCache;
  7841. /**
  7842. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7843. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7844. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7845. * The passed axis is also normalized.
  7846. * @param axis the axis to rotate around
  7847. * @param amount the amount to rotate in radians
  7848. * @param space Space to rotate in (Default: local)
  7849. * @returns the TransformNode.
  7850. */
  7851. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7852. /**
  7853. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7854. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7855. * The passed axis is also normalized. .
  7856. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7857. * @param point the point to rotate around
  7858. * @param axis the axis to rotate around
  7859. * @param amount the amount to rotate in radians
  7860. * @returns the TransformNode
  7861. */
  7862. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7863. /**
  7864. * Translates the mesh along the axis vector for the passed distance in the given space.
  7865. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7866. * @param axis the axis to translate in
  7867. * @param distance the distance to translate
  7868. * @param space Space to rotate in (Default: local)
  7869. * @returns the TransformNode.
  7870. */
  7871. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7872. /**
  7873. * Adds a rotation step to the mesh current rotation.
  7874. * x, y, z are Euler angles expressed in radians.
  7875. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7876. * This means this rotation is made in the mesh local space only.
  7877. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7878. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7879. * ```javascript
  7880. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7881. * ```
  7882. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7883. * 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.
  7884. * @param x Rotation to add
  7885. * @param y Rotation to add
  7886. * @param z Rotation to add
  7887. * @returns the TransformNode.
  7888. */
  7889. addRotation(x: number, y: number, z: number): TransformNode;
  7890. /**
  7891. * @hidden
  7892. */
  7893. protected _getEffectiveParent(): Nullable<Node>;
  7894. /**
  7895. * Computes the world matrix of the node
  7896. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7897. * @returns the world matrix
  7898. */
  7899. computeWorldMatrix(force?: boolean): Matrix;
  7900. protected _afterComputeWorldMatrix(): void;
  7901. /**
  7902. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7903. * @param func callback function to add
  7904. *
  7905. * @returns the TransformNode.
  7906. */
  7907. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7908. /**
  7909. * Removes a registered callback function.
  7910. * @param func callback function to remove
  7911. * @returns the TransformNode.
  7912. */
  7913. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7914. /**
  7915. * Gets the position of the current mesh in camera space
  7916. * @param camera defines the camera to use
  7917. * @returns a position
  7918. */
  7919. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7920. /**
  7921. * Returns the distance from the mesh to the active camera
  7922. * @param camera defines the camera to use
  7923. * @returns the distance
  7924. */
  7925. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7926. /**
  7927. * Clone the current transform node
  7928. * @param name Name of the new clone
  7929. * @param newParent New parent for the clone
  7930. * @param doNotCloneChildren Do not clone children hierarchy
  7931. * @returns the new transform node
  7932. */
  7933. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7934. /**
  7935. * Serializes the objects information.
  7936. * @param currentSerializationObject defines the object to serialize in
  7937. * @returns the serialized object
  7938. */
  7939. serialize(currentSerializationObject?: any): any;
  7940. /**
  7941. * Returns a new TransformNode object parsed from the source provided.
  7942. * @param parsedTransformNode is the source.
  7943. * @param scene the scne the object belongs to
  7944. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7945. * @returns a new TransformNode object parsed from the source provided.
  7946. */
  7947. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7948. /**
  7949. * Get all child-transformNodes of this node
  7950. * @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
  7951. * @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
  7952. * @returns an array of TransformNode
  7953. */
  7954. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7955. /**
  7956. * Releases resources associated with this transform node.
  7957. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7958. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7959. */
  7960. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7961. }
  7962. }
  7963. declare module BABYLON {
  7964. /**
  7965. * Class used to override all child animations of a given target
  7966. */
  7967. export class AnimationPropertiesOverride {
  7968. /**
  7969. * Gets or sets a value indicating if animation blending must be used
  7970. */
  7971. enableBlending: boolean;
  7972. /**
  7973. * Gets or sets the blending speed to use when enableBlending is true
  7974. */
  7975. blendingSpeed: number;
  7976. /**
  7977. * Gets or sets the default loop mode to use
  7978. */
  7979. loopMode: number;
  7980. }
  7981. }
  7982. declare module BABYLON {
  7983. /**
  7984. * Class used to store bone information
  7985. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7986. */
  7987. export class Bone extends Node {
  7988. /**
  7989. * defines the bone name
  7990. */
  7991. name: string;
  7992. private static _tmpVecs;
  7993. private static _tmpQuat;
  7994. private static _tmpMats;
  7995. /**
  7996. * Gets the list of child bones
  7997. */
  7998. children: Bone[];
  7999. /** Gets the animations associated with this bone */
  8000. animations: Animation[];
  8001. /**
  8002. * Gets or sets bone length
  8003. */
  8004. length: number;
  8005. /**
  8006. * @hidden Internal only
  8007. * Set this value to map this bone to a different index in the transform matrices
  8008. * Set this value to -1 to exclude the bone from the transform matrices
  8009. */
  8010. _index: Nullable<number>;
  8011. private _skeleton;
  8012. private _localMatrix;
  8013. private _restPose;
  8014. private _baseMatrix;
  8015. private _absoluteTransform;
  8016. private _invertedAbsoluteTransform;
  8017. private _parent;
  8018. private _scalingDeterminant;
  8019. private _worldTransform;
  8020. private _localScaling;
  8021. private _localRotation;
  8022. private _localPosition;
  8023. private _needToDecompose;
  8024. private _needToCompose;
  8025. /** @hidden */
  8026. _linkedTransformNode: Nullable<TransformNode>;
  8027. /** @hidden */
  8028. _waitingTransformNodeId: Nullable<string>;
  8029. /** @hidden */
  8030. /** @hidden */
  8031. _matrix: Matrix;
  8032. /**
  8033. * Create a new bone
  8034. * @param name defines the bone name
  8035. * @param skeleton defines the parent skeleton
  8036. * @param parentBone defines the parent (can be null if the bone is the root)
  8037. * @param localMatrix defines the local matrix
  8038. * @param restPose defines the rest pose matrix
  8039. * @param baseMatrix defines the base matrix
  8040. * @param index defines index of the bone in the hiearchy
  8041. */
  8042. constructor(
  8043. /**
  8044. * defines the bone name
  8045. */
  8046. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8047. /**
  8048. * Gets the current object class name.
  8049. * @return the class name
  8050. */
  8051. getClassName(): string;
  8052. /**
  8053. * Gets the parent skeleton
  8054. * @returns a skeleton
  8055. */
  8056. getSkeleton(): Skeleton;
  8057. /**
  8058. * Gets parent bone
  8059. * @returns a bone or null if the bone is the root of the bone hierarchy
  8060. */
  8061. getParent(): Nullable<Bone>;
  8062. /**
  8063. * Returns an array containing the root bones
  8064. * @returns an array containing the root bones
  8065. */
  8066. getChildren(): Array<Bone>;
  8067. /**
  8068. * Sets the parent bone
  8069. * @param parent defines the parent (can be null if the bone is the root)
  8070. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8071. */
  8072. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8073. /**
  8074. * Gets the local matrix
  8075. * @returns a matrix
  8076. */
  8077. getLocalMatrix(): Matrix;
  8078. /**
  8079. * Gets the base matrix (initial matrix which remains unchanged)
  8080. * @returns a matrix
  8081. */
  8082. getBaseMatrix(): Matrix;
  8083. /**
  8084. * Gets the rest pose matrix
  8085. * @returns a matrix
  8086. */
  8087. getRestPose(): Matrix;
  8088. /**
  8089. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8090. */
  8091. getWorldMatrix(): Matrix;
  8092. /**
  8093. * Sets the local matrix to rest pose matrix
  8094. */
  8095. returnToRest(): void;
  8096. /**
  8097. * Gets the inverse of the absolute transform matrix.
  8098. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8099. * @returns a matrix
  8100. */
  8101. getInvertedAbsoluteTransform(): Matrix;
  8102. /**
  8103. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8104. * @returns a matrix
  8105. */
  8106. getAbsoluteTransform(): Matrix;
  8107. /**
  8108. * Links with the given transform node.
  8109. * The local matrix of this bone is copied from the transform node every frame.
  8110. * @param transformNode defines the transform node to link to
  8111. */
  8112. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8113. /** Gets or sets current position (in local space) */
  8114. position: Vector3;
  8115. /** Gets or sets current rotation (in local space) */
  8116. rotation: Vector3;
  8117. /** Gets or sets current rotation quaternion (in local space) */
  8118. rotationQuaternion: Quaternion;
  8119. /** Gets or sets current scaling (in local space) */
  8120. scaling: Vector3;
  8121. /**
  8122. * Gets the animation properties override
  8123. */
  8124. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8125. private _decompose;
  8126. private _compose;
  8127. /**
  8128. * Update the base and local matrices
  8129. * @param matrix defines the new base or local matrix
  8130. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8131. * @param updateLocalMatrix defines if the local matrix should be updated
  8132. */
  8133. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8134. /** @hidden */
  8135. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8136. /**
  8137. * Flag the bone as dirty (Forcing it to update everything)
  8138. */
  8139. markAsDirty(): void;
  8140. private _markAsDirtyAndCompose;
  8141. private _markAsDirtyAndDecompose;
  8142. /**
  8143. * Translate the bone in local or world space
  8144. * @param vec The amount to translate the bone
  8145. * @param space The space that the translation is in
  8146. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8147. */
  8148. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8149. /**
  8150. * Set the postion of the bone in local or world space
  8151. * @param position The position to set the bone
  8152. * @param space The space that the position is in
  8153. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8154. */
  8155. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8156. /**
  8157. * Set the absolute position of the bone (world space)
  8158. * @param position The position to set the bone
  8159. * @param mesh The mesh that this bone is attached to
  8160. */
  8161. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8162. /**
  8163. * Scale the bone on the x, y and z axes (in local space)
  8164. * @param x The amount to scale the bone on the x axis
  8165. * @param y The amount to scale the bone on the y axis
  8166. * @param z The amount to scale the bone on the z axis
  8167. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8168. */
  8169. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8170. /**
  8171. * Set the bone scaling in local space
  8172. * @param scale defines the scaling vector
  8173. */
  8174. setScale(scale: Vector3): void;
  8175. /**
  8176. * Gets the current scaling in local space
  8177. * @returns the current scaling vector
  8178. */
  8179. getScale(): Vector3;
  8180. /**
  8181. * Gets the current scaling in local space and stores it in a target vector
  8182. * @param result defines the target vector
  8183. */
  8184. getScaleToRef(result: Vector3): void;
  8185. /**
  8186. * Set the yaw, pitch, and roll of the bone in local or world space
  8187. * @param yaw The rotation of the bone on the y axis
  8188. * @param pitch The rotation of the bone on the x axis
  8189. * @param roll The rotation of the bone on the z axis
  8190. * @param space The space that the axes of rotation are in
  8191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8192. */
  8193. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8194. /**
  8195. * Add a rotation to the bone on an axis in local or world space
  8196. * @param axis The axis to rotate the bone on
  8197. * @param amount The amount to rotate the bone
  8198. * @param space The space that the axis is in
  8199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8200. */
  8201. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8202. /**
  8203. * Set the rotation of the bone to a particular axis angle in local or world space
  8204. * @param axis The axis to rotate the bone on
  8205. * @param angle The angle that the bone should be rotated to
  8206. * @param space The space that the axis is in
  8207. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8208. */
  8209. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8210. /**
  8211. * Set the euler rotation of the bone in local of world space
  8212. * @param rotation The euler rotation that the bone should be set to
  8213. * @param space The space that the rotation is in
  8214. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8215. */
  8216. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8217. /**
  8218. * Set the quaternion rotation of the bone in local of world space
  8219. * @param quat The quaternion rotation that the bone should be set to
  8220. * @param space The space that the rotation is in
  8221. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8222. */
  8223. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8224. /**
  8225. * Set the rotation matrix of the bone in local of world space
  8226. * @param rotMat The rotation matrix that the bone should be set to
  8227. * @param space The space that the rotation is in
  8228. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8229. */
  8230. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8231. private _rotateWithMatrix;
  8232. private _getNegativeRotationToRef;
  8233. /**
  8234. * Get the position of the bone in local or world space
  8235. * @param space The space that the returned position is in
  8236. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8237. * @returns The position of the bone
  8238. */
  8239. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8240. /**
  8241. * Copy the position of the bone to a vector3 in local or world space
  8242. * @param space The space that the returned position is in
  8243. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8244. * @param result The vector3 to copy the position to
  8245. */
  8246. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8247. /**
  8248. * Get the absolute position of the bone (world space)
  8249. * @param mesh The mesh that this bone is attached to
  8250. * @returns The absolute position of the bone
  8251. */
  8252. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8253. /**
  8254. * Copy the absolute position of the bone (world space) to the result param
  8255. * @param mesh The mesh that this bone is attached to
  8256. * @param result The vector3 to copy the absolute position to
  8257. */
  8258. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8259. /**
  8260. * Compute the absolute transforms of this bone and its children
  8261. */
  8262. computeAbsoluteTransforms(): void;
  8263. /**
  8264. * Get the world direction from an axis that is in the local space of the bone
  8265. * @param localAxis The local direction that is used to compute the world direction
  8266. * @param mesh The mesh that this bone is attached to
  8267. * @returns The world direction
  8268. */
  8269. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8270. /**
  8271. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8272. * @param localAxis The local direction that is used to compute the world direction
  8273. * @param mesh The mesh that this bone is attached to
  8274. * @param result The vector3 that the world direction will be copied to
  8275. */
  8276. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8277. /**
  8278. * Get the euler rotation of the bone in local or world space
  8279. * @param space The space that the rotation should be in
  8280. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8281. * @returns The euler rotation
  8282. */
  8283. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8284. /**
  8285. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8286. * @param space The space that the rotation should be in
  8287. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8288. * @param result The vector3 that the rotation should be copied to
  8289. */
  8290. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8291. /**
  8292. * Get the quaternion rotation of the bone in either local or world space
  8293. * @param space The space that the rotation should be in
  8294. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8295. * @returns The quaternion rotation
  8296. */
  8297. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8298. /**
  8299. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8300. * @param space The space that the rotation should be in
  8301. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8302. * @param result The quaternion that the rotation should be copied to
  8303. */
  8304. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8305. /**
  8306. * Get the rotation matrix of the bone in local or world space
  8307. * @param space The space that the rotation should be in
  8308. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8309. * @returns The rotation matrix
  8310. */
  8311. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8312. /**
  8313. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8314. * @param space The space that the rotation should be in
  8315. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8316. * @param result The quaternion that the rotation should be copied to
  8317. */
  8318. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8319. /**
  8320. * Get the world position of a point that is in the local space of the bone
  8321. * @param position The local position
  8322. * @param mesh The mesh that this bone is attached to
  8323. * @returns The world position
  8324. */
  8325. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8326. /**
  8327. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8328. * @param position The local position
  8329. * @param mesh The mesh that this bone is attached to
  8330. * @param result The vector3 that the world position should be copied to
  8331. */
  8332. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8333. /**
  8334. * Get the local position of a point that is in world space
  8335. * @param position The world position
  8336. * @param mesh The mesh that this bone is attached to
  8337. * @returns The local position
  8338. */
  8339. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8340. /**
  8341. * Get the local position of a point that is in world space and copy it to the result param
  8342. * @param position The world position
  8343. * @param mesh The mesh that this bone is attached to
  8344. * @param result The vector3 that the local position should be copied to
  8345. */
  8346. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8347. }
  8348. }
  8349. declare module BABYLON {
  8350. /**
  8351. * Enum that determines the text-wrapping mode to use.
  8352. */
  8353. export enum InspectableType {
  8354. /**
  8355. * Checkbox for booleans
  8356. */
  8357. Checkbox = 0,
  8358. /**
  8359. * Sliders for numbers
  8360. */
  8361. Slider = 1,
  8362. /**
  8363. * Vector3
  8364. */
  8365. Vector3 = 2,
  8366. /**
  8367. * Quaternions
  8368. */
  8369. Quaternion = 3,
  8370. /**
  8371. * Color3
  8372. */
  8373. Color3 = 4
  8374. }
  8375. /**
  8376. * Interface used to define custom inspectable properties.
  8377. * This interface is used by the inspector to display custom property grids
  8378. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8379. */
  8380. export interface IInspectable {
  8381. /**
  8382. * Gets the label to display
  8383. */
  8384. label: string;
  8385. /**
  8386. * Gets the name of the property to edit
  8387. */
  8388. propertyName: string;
  8389. /**
  8390. * Gets the type of the editor to use
  8391. */
  8392. type: InspectableType;
  8393. /**
  8394. * Gets the minimum value of the property when using in "slider" mode
  8395. */
  8396. min?: number;
  8397. /**
  8398. * Gets the maximum value of the property when using in "slider" mode
  8399. */
  8400. max?: number;
  8401. /**
  8402. * Gets the setp to use when using in "slider" mode
  8403. */
  8404. step?: number;
  8405. }
  8406. }
  8407. declare module BABYLON {
  8408. /**
  8409. * This represents the required contract to create a new type of texture loader.
  8410. */
  8411. export interface IInternalTextureLoader {
  8412. /**
  8413. * Defines wether the loader supports cascade loading the different faces.
  8414. */
  8415. supportCascades: boolean;
  8416. /**
  8417. * This returns if the loader support the current file information.
  8418. * @param extension defines the file extension of the file being loaded
  8419. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8420. * @param fallback defines the fallback internal texture if any
  8421. * @param isBase64 defines whether the texture is encoded as a base64
  8422. * @param isBuffer defines whether the texture data are stored as a buffer
  8423. * @returns true if the loader can load the specified file
  8424. */
  8425. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8426. /**
  8427. * Transform the url before loading if required.
  8428. * @param rootUrl the url of the texture
  8429. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8430. * @returns the transformed texture
  8431. */
  8432. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8433. /**
  8434. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8435. * @param rootUrl the url of the texture
  8436. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8437. * @returns the fallback texture
  8438. */
  8439. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8440. /**
  8441. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8442. * @param data contains the texture data
  8443. * @param texture defines the BabylonJS internal texture
  8444. * @param createPolynomials will be true if polynomials have been requested
  8445. * @param onLoad defines the callback to trigger once the texture is ready
  8446. * @param onError defines the callback to trigger in case of error
  8447. */
  8448. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8449. /**
  8450. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8451. * @param data contains the texture data
  8452. * @param texture defines the BabylonJS internal texture
  8453. * @param callback defines the method to call once ready to upload
  8454. */
  8455. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8456. }
  8457. }
  8458. declare module BABYLON {
  8459. interface Engine {
  8460. /**
  8461. * Creates a depth stencil cube texture.
  8462. * This is only available in WebGL 2.
  8463. * @param size The size of face edge in the cube texture.
  8464. * @param options The options defining the cube texture.
  8465. * @returns The cube texture
  8466. */
  8467. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8468. /**
  8469. * Creates a cube texture
  8470. * @param rootUrl defines the url where the files to load is located
  8471. * @param scene defines the current scene
  8472. * @param files defines the list of files to load (1 per face)
  8473. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8474. * @param onLoad defines an optional callback raised when the texture is loaded
  8475. * @param onError defines an optional callback raised if there is an issue to load the texture
  8476. * @param format defines the format of the data
  8477. * @param forcedExtension defines the extension to use to pick the right loader
  8478. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8479. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8480. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8481. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8482. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8483. * @returns the cube texture as an InternalTexture
  8484. */
  8485. 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;
  8486. /**
  8487. * Creates a cube texture
  8488. * @param rootUrl defines the url where the files to load is located
  8489. * @param scene defines the current scene
  8490. * @param files defines the list of files to load (1 per face)
  8491. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8492. * @param onLoad defines an optional callback raised when the texture is loaded
  8493. * @param onError defines an optional callback raised if there is an issue to load the texture
  8494. * @param format defines the format of the data
  8495. * @param forcedExtension defines the extension to use to pick the right loader
  8496. * @returns the cube texture as an InternalTexture
  8497. */
  8498. 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;
  8499. /**
  8500. * Creates a cube texture
  8501. * @param rootUrl defines the url where the files to load is located
  8502. * @param scene defines the current scene
  8503. * @param files defines the list of files to load (1 per face)
  8504. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8505. * @param onLoad defines an optional callback raised when the texture is loaded
  8506. * @param onError defines an optional callback raised if there is an issue to load the texture
  8507. * @param format defines the format of the data
  8508. * @param forcedExtension defines the extension to use to pick the right loader
  8509. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8510. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8511. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8512. * @returns the cube texture as an InternalTexture
  8513. */
  8514. 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;
  8515. /** @hidden */
  8516. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8517. /** @hidden */
  8518. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8519. /** @hidden */
  8520. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8521. /** @hidden */
  8522. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8523. }
  8524. }
  8525. declare module BABYLON {
  8526. /**
  8527. * Class for creating a cube texture
  8528. */
  8529. export class CubeTexture extends BaseTexture {
  8530. private _delayedOnLoad;
  8531. /**
  8532. * The url of the texture
  8533. */
  8534. url: string;
  8535. /**
  8536. * Gets or sets the center of the bounding box associated with the cube texture.
  8537. * It must define where the camera used to render the texture was set
  8538. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8539. */
  8540. boundingBoxPosition: Vector3;
  8541. private _boundingBoxSize;
  8542. /**
  8543. * Gets or sets the size of the bounding box associated with the cube texture
  8544. * When defined, the cubemap will switch to local mode
  8545. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8546. * @example https://www.babylonjs-playground.com/#RNASML
  8547. */
  8548. /**
  8549. * Returns the bounding box size
  8550. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8551. */
  8552. boundingBoxSize: Vector3;
  8553. protected _rotationY: number;
  8554. /**
  8555. * Sets texture matrix rotation angle around Y axis in radians.
  8556. */
  8557. /**
  8558. * Gets texture matrix rotation angle around Y axis radians.
  8559. */
  8560. rotationY: number;
  8561. /**
  8562. * Are mip maps generated for this texture or not.
  8563. */
  8564. readonly noMipmap: boolean;
  8565. private _noMipmap;
  8566. private _files;
  8567. private _extensions;
  8568. private _textureMatrix;
  8569. private _format;
  8570. private _createPolynomials;
  8571. /** @hidden */
  8572. _prefiltered: boolean;
  8573. /**
  8574. * Creates a cube texture from an array of image urls
  8575. * @param files defines an array of image urls
  8576. * @param scene defines the hosting scene
  8577. * @param noMipmap specifies if mip maps are not used
  8578. * @returns a cube texture
  8579. */
  8580. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8581. /**
  8582. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8583. * @param url defines the url of the prefiltered texture
  8584. * @param scene defines the scene the texture is attached to
  8585. * @param forcedExtension defines the extension of the file if different from the url
  8586. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8587. * @return the prefiltered texture
  8588. */
  8589. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8590. /**
  8591. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8592. * as prefiltered data.
  8593. * @param rootUrl defines the url of the texture or the root name of the six images
  8594. * @param scene defines the scene the texture is attached to
  8595. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8596. * @param noMipmap defines if mipmaps should be created or not
  8597. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8598. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8599. * @param onError defines a callback triggered in case of error during load
  8600. * @param format defines the internal format to use for the texture once loaded
  8601. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8602. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8603. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8604. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8605. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8606. * @return the cube texture
  8607. */
  8608. 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);
  8609. /**
  8610. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8611. */
  8612. readonly isPrefiltered: boolean;
  8613. /**
  8614. * Get the current class name of the texture useful for serialization or dynamic coding.
  8615. * @returns "CubeTexture"
  8616. */
  8617. getClassName(): string;
  8618. /**
  8619. * Update the url (and optional buffer) of this texture if url was null during construction.
  8620. * @param url the url of the texture
  8621. * @param forcedExtension defines the extension to use
  8622. * @param onLoad callback called when the texture is loaded (defaults to null)
  8623. */
  8624. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8625. /**
  8626. * Delays loading of the cube texture
  8627. * @param forcedExtension defines the extension to use
  8628. */
  8629. delayLoad(forcedExtension?: string): void;
  8630. /**
  8631. * Returns the reflection texture matrix
  8632. * @returns the reflection texture matrix
  8633. */
  8634. getReflectionTextureMatrix(): Matrix;
  8635. /**
  8636. * Sets the reflection texture matrix
  8637. * @param value Reflection texture matrix
  8638. */
  8639. setReflectionTextureMatrix(value: Matrix): void;
  8640. /**
  8641. * Parses text to create a cube texture
  8642. * @param parsedTexture define the serialized text to read from
  8643. * @param scene defines the hosting scene
  8644. * @param rootUrl defines the root url of the cube texture
  8645. * @returns a cube texture
  8646. */
  8647. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8648. /**
  8649. * Makes a clone, or deep copy, of the cube texture
  8650. * @returns a new cube texture
  8651. */
  8652. clone(): CubeTexture;
  8653. }
  8654. }
  8655. declare module BABYLON {
  8656. /** @hidden */
  8657. export var postprocessVertexShader: {
  8658. name: string;
  8659. shader: string;
  8660. };
  8661. }
  8662. declare module BABYLON {
  8663. /**
  8664. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8665. * This is the base of the follow, arc rotate cameras and Free camera
  8666. * @see http://doc.babylonjs.com/features/cameras
  8667. */
  8668. export class TargetCamera extends Camera {
  8669. private static _RigCamTransformMatrix;
  8670. private static _TargetTransformMatrix;
  8671. private static _TargetFocalPoint;
  8672. /**
  8673. * Define the current direction the camera is moving to
  8674. */
  8675. cameraDirection: Vector3;
  8676. /**
  8677. * Define the current rotation the camera is rotating to
  8678. */
  8679. cameraRotation: Vector2;
  8680. /**
  8681. * When set, the up vector of the camera will be updated by the rotation of the camera
  8682. */
  8683. updateUpVectorFromRotation: boolean;
  8684. private _tmpQuaternion;
  8685. /**
  8686. * Define the current rotation of the camera
  8687. */
  8688. rotation: Vector3;
  8689. /**
  8690. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8691. */
  8692. rotationQuaternion: Quaternion;
  8693. /**
  8694. * Define the current speed of the camera
  8695. */
  8696. speed: number;
  8697. /**
  8698. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8699. * around all axis.
  8700. */
  8701. noRotationConstraint: boolean;
  8702. /**
  8703. * Define the current target of the camera as an object or a position.
  8704. */
  8705. lockedTarget: any;
  8706. /** @hidden */
  8707. _currentTarget: Vector3;
  8708. /** @hidden */
  8709. _initialFocalDistance: number;
  8710. /** @hidden */
  8711. _viewMatrix: Matrix;
  8712. /** @hidden */
  8713. _camMatrix: Matrix;
  8714. /** @hidden */
  8715. _cameraTransformMatrix: Matrix;
  8716. /** @hidden */
  8717. _cameraRotationMatrix: Matrix;
  8718. /** @hidden */
  8719. _referencePoint: Vector3;
  8720. /** @hidden */
  8721. _transformedReferencePoint: Vector3;
  8722. protected _globalCurrentTarget: Vector3;
  8723. protected _globalCurrentUpVector: Vector3;
  8724. /** @hidden */
  8725. _reset: () => void;
  8726. private _defaultUp;
  8727. /**
  8728. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8729. * This is the base of the follow, arc rotate cameras and Free camera
  8730. * @see http://doc.babylonjs.com/features/cameras
  8731. * @param name Defines the name of the camera in the scene
  8732. * @param position Defines the start position of the camera in the scene
  8733. * @param scene Defines the scene the camera belongs to
  8734. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8735. */
  8736. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8737. /**
  8738. * Gets the position in front of the camera at a given distance.
  8739. * @param distance The distance from the camera we want the position to be
  8740. * @returns the position
  8741. */
  8742. getFrontPosition(distance: number): Vector3;
  8743. /** @hidden */
  8744. _getLockedTargetPosition(): Nullable<Vector3>;
  8745. private _storedPosition;
  8746. private _storedRotation;
  8747. private _storedRotationQuaternion;
  8748. /**
  8749. * Store current camera state of the camera (fov, position, rotation, etc..)
  8750. * @returns the camera
  8751. */
  8752. storeState(): Camera;
  8753. /**
  8754. * Restored camera state. You must call storeState() first
  8755. * @returns whether it was successful or not
  8756. * @hidden
  8757. */
  8758. _restoreStateValues(): boolean;
  8759. /** @hidden */
  8760. _initCache(): void;
  8761. /** @hidden */
  8762. _updateCache(ignoreParentClass?: boolean): void;
  8763. /** @hidden */
  8764. _isSynchronizedViewMatrix(): boolean;
  8765. /** @hidden */
  8766. _computeLocalCameraSpeed(): number;
  8767. /**
  8768. * Defines the target the camera should look at.
  8769. * This will automatically adapt alpha beta and radius to fit within the new target.
  8770. * @param target Defines the new target as a Vector or a mesh
  8771. */
  8772. setTarget(target: Vector3): void;
  8773. /**
  8774. * Return the current target position of the camera. This value is expressed in local space.
  8775. * @returns the target position
  8776. */
  8777. getTarget(): Vector3;
  8778. /** @hidden */
  8779. _decideIfNeedsToMove(): boolean;
  8780. /** @hidden */
  8781. _updatePosition(): void;
  8782. /** @hidden */
  8783. _checkInputs(): void;
  8784. protected _updateCameraRotationMatrix(): void;
  8785. /**
  8786. * 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)
  8787. * @returns the current camera
  8788. */
  8789. private _rotateUpVectorWithCameraRotationMatrix;
  8790. private _cachedRotationZ;
  8791. private _cachedQuaternionRotationZ;
  8792. /** @hidden */
  8793. _getViewMatrix(): Matrix;
  8794. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8795. /**
  8796. * @hidden
  8797. */
  8798. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8799. /**
  8800. * @hidden
  8801. */
  8802. _updateRigCameras(): void;
  8803. private _getRigCamPositionAndTarget;
  8804. /**
  8805. * Gets the current object class name.
  8806. * @return the class name
  8807. */
  8808. getClassName(): string;
  8809. }
  8810. }
  8811. declare module BABYLON {
  8812. /**
  8813. * @ignore
  8814. * This is a list of all the different input types that are available in the application.
  8815. * Fo instance: ArcRotateCameraGamepadInput...
  8816. */
  8817. export var CameraInputTypes: {};
  8818. /**
  8819. * This is the contract to implement in order to create a new input class.
  8820. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8821. */
  8822. export interface ICameraInput<TCamera extends Camera> {
  8823. /**
  8824. * Defines the camera the input is attached to.
  8825. */
  8826. camera: Nullable<TCamera>;
  8827. /**
  8828. * Gets the class name of the current intput.
  8829. * @returns the class name
  8830. */
  8831. getClassName(): string;
  8832. /**
  8833. * Get the friendly name associated with the input class.
  8834. * @returns the input friendly name
  8835. */
  8836. getSimpleName(): string;
  8837. /**
  8838. * Attach the input controls to a specific dom element to get the input from.
  8839. * @param element Defines the element the controls should be listened from
  8840. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8841. */
  8842. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8843. /**
  8844. * Detach the current controls from the specified dom element.
  8845. * @param element Defines the element to stop listening the inputs from
  8846. */
  8847. detachControl(element: Nullable<HTMLElement>): void;
  8848. /**
  8849. * Update the current camera state depending on the inputs that have been used this frame.
  8850. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8851. */
  8852. checkInputs?: () => void;
  8853. }
  8854. /**
  8855. * Represents a map of input types to input instance or input index to input instance.
  8856. */
  8857. export interface CameraInputsMap<TCamera extends Camera> {
  8858. /**
  8859. * Accessor to the input by input type.
  8860. */
  8861. [name: string]: ICameraInput<TCamera>;
  8862. /**
  8863. * Accessor to the input by input index.
  8864. */
  8865. [idx: number]: ICameraInput<TCamera>;
  8866. }
  8867. /**
  8868. * This represents the input manager used within a camera.
  8869. * It helps dealing with all the different kind of input attached to a camera.
  8870. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8871. */
  8872. export class CameraInputsManager<TCamera extends Camera> {
  8873. /**
  8874. * Defines the list of inputs attahed to the camera.
  8875. */
  8876. attached: CameraInputsMap<TCamera>;
  8877. /**
  8878. * Defines the dom element the camera is collecting inputs from.
  8879. * This is null if the controls have not been attached.
  8880. */
  8881. attachedElement: Nullable<HTMLElement>;
  8882. /**
  8883. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8884. */
  8885. noPreventDefault: boolean;
  8886. /**
  8887. * Defined the camera the input manager belongs to.
  8888. */
  8889. camera: TCamera;
  8890. /**
  8891. * Update the current camera state depending on the inputs that have been used this frame.
  8892. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8893. */
  8894. checkInputs: () => void;
  8895. /**
  8896. * Instantiate a new Camera Input Manager.
  8897. * @param camera Defines the camera the input manager blongs to
  8898. */
  8899. constructor(camera: TCamera);
  8900. /**
  8901. * Add an input method to a camera
  8902. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8903. * @param input camera input method
  8904. */
  8905. add(input: ICameraInput<TCamera>): void;
  8906. /**
  8907. * Remove a specific input method from a camera
  8908. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8909. * @param inputToRemove camera input method
  8910. */
  8911. remove(inputToRemove: ICameraInput<TCamera>): void;
  8912. /**
  8913. * Remove a specific input type from a camera
  8914. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8915. * @param inputType the type of the input to remove
  8916. */
  8917. removeByType(inputType: string): void;
  8918. private _addCheckInputs;
  8919. /**
  8920. * Attach the input controls to the currently attached dom element to listen the events from.
  8921. * @param input Defines the input to attach
  8922. */
  8923. attachInput(input: ICameraInput<TCamera>): void;
  8924. /**
  8925. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8926. * @param element Defines the dom element to collect the events from
  8927. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8928. */
  8929. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8930. /**
  8931. * Detach the current manager inputs controls from a specific dom element.
  8932. * @param element Defines the dom element to collect the events from
  8933. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8934. */
  8935. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8936. /**
  8937. * Rebuild the dynamic inputCheck function from the current list of
  8938. * defined inputs in the manager.
  8939. */
  8940. rebuildInputCheck(): void;
  8941. /**
  8942. * Remove all attached input methods from a camera
  8943. */
  8944. clear(): void;
  8945. /**
  8946. * Serialize the current input manager attached to a camera.
  8947. * This ensures than once parsed,
  8948. * the input associated to the camera will be identical to the current ones
  8949. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8950. */
  8951. serialize(serializedCamera: any): void;
  8952. /**
  8953. * Parses an input manager serialized JSON to restore the previous list of inputs
  8954. * and states associated to a camera.
  8955. * @param parsedCamera Defines the JSON to parse
  8956. */
  8957. parse(parsedCamera: any): void;
  8958. }
  8959. }
  8960. declare module BABYLON {
  8961. /**
  8962. * Gather the list of keyboard event types as constants.
  8963. */
  8964. export class KeyboardEventTypes {
  8965. /**
  8966. * The keydown event is fired when a key becomes active (pressed).
  8967. */
  8968. static readonly KEYDOWN: number;
  8969. /**
  8970. * The keyup event is fired when a key has been released.
  8971. */
  8972. static readonly KEYUP: number;
  8973. }
  8974. /**
  8975. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8976. */
  8977. export class KeyboardInfo {
  8978. /**
  8979. * Defines the type of event (KeyboardEventTypes)
  8980. */
  8981. type: number;
  8982. /**
  8983. * Defines the related dom event
  8984. */
  8985. event: KeyboardEvent;
  8986. /**
  8987. * Instantiates a new keyboard info.
  8988. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8989. * @param type Defines the type of event (KeyboardEventTypes)
  8990. * @param event Defines the related dom event
  8991. */
  8992. constructor(
  8993. /**
  8994. * Defines the type of event (KeyboardEventTypes)
  8995. */
  8996. type: number,
  8997. /**
  8998. * Defines the related dom event
  8999. */
  9000. event: KeyboardEvent);
  9001. }
  9002. /**
  9003. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9004. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9005. */
  9006. export class KeyboardInfoPre extends KeyboardInfo {
  9007. /**
  9008. * Defines the type of event (KeyboardEventTypes)
  9009. */
  9010. type: number;
  9011. /**
  9012. * Defines the related dom event
  9013. */
  9014. event: KeyboardEvent;
  9015. /**
  9016. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9017. */
  9018. skipOnPointerObservable: boolean;
  9019. /**
  9020. * Instantiates a new keyboard pre info.
  9021. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9022. * @param type Defines the type of event (KeyboardEventTypes)
  9023. * @param event Defines the related dom event
  9024. */
  9025. constructor(
  9026. /**
  9027. * Defines the type of event (KeyboardEventTypes)
  9028. */
  9029. type: number,
  9030. /**
  9031. * Defines the related dom event
  9032. */
  9033. event: KeyboardEvent);
  9034. }
  9035. }
  9036. declare module BABYLON {
  9037. /**
  9038. * Manage the keyboard inputs to control the movement of a free camera.
  9039. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9040. */
  9041. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9042. /**
  9043. * Defines the camera the input is attached to.
  9044. */
  9045. camera: FreeCamera;
  9046. /**
  9047. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9048. */
  9049. keysUp: number[];
  9050. /**
  9051. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9052. */
  9053. keysDown: number[];
  9054. /**
  9055. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9056. */
  9057. keysLeft: number[];
  9058. /**
  9059. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9060. */
  9061. keysRight: number[];
  9062. private _keys;
  9063. private _onCanvasBlurObserver;
  9064. private _onKeyboardObserver;
  9065. private _engine;
  9066. private _scene;
  9067. /**
  9068. * Attach the input controls to a specific dom element to get the input from.
  9069. * @param element Defines the element the controls should be listened from
  9070. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9071. */
  9072. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9073. /**
  9074. * Detach the current controls from the specified dom element.
  9075. * @param element Defines the element to stop listening the inputs from
  9076. */
  9077. detachControl(element: Nullable<HTMLElement>): void;
  9078. /**
  9079. * Update the current camera state depending on the inputs that have been used this frame.
  9080. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9081. */
  9082. checkInputs(): void;
  9083. /**
  9084. * Gets the class name of the current intput.
  9085. * @returns the class name
  9086. */
  9087. getClassName(): string;
  9088. /** @hidden */
  9089. _onLostFocus(): void;
  9090. /**
  9091. * Get the friendly name associated with the input class.
  9092. * @returns the input friendly name
  9093. */
  9094. getSimpleName(): string;
  9095. }
  9096. }
  9097. declare module BABYLON {
  9098. /**
  9099. * Interface describing all the common properties and methods a shadow light needs to implement.
  9100. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9101. * as well as binding the different shadow properties to the effects.
  9102. */
  9103. export interface IShadowLight extends Light {
  9104. /**
  9105. * The light id in the scene (used in scene.findLighById for instance)
  9106. */
  9107. id: string;
  9108. /**
  9109. * The position the shdow will be casted from.
  9110. */
  9111. position: Vector3;
  9112. /**
  9113. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9114. */
  9115. direction: Vector3;
  9116. /**
  9117. * The transformed position. Position of the light in world space taking parenting in account.
  9118. */
  9119. transformedPosition: Vector3;
  9120. /**
  9121. * The transformed direction. Direction of the light in world space taking parenting in account.
  9122. */
  9123. transformedDirection: Vector3;
  9124. /**
  9125. * The friendly name of the light in the scene.
  9126. */
  9127. name: string;
  9128. /**
  9129. * Defines the shadow projection clipping minimum z value.
  9130. */
  9131. shadowMinZ: number;
  9132. /**
  9133. * Defines the shadow projection clipping maximum z value.
  9134. */
  9135. shadowMaxZ: number;
  9136. /**
  9137. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9138. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9139. */
  9140. computeTransformedInformation(): boolean;
  9141. /**
  9142. * Gets the scene the light belongs to.
  9143. * @returns The scene
  9144. */
  9145. getScene(): Scene;
  9146. /**
  9147. * Callback defining a custom Projection Matrix Builder.
  9148. * This can be used to override the default projection matrix computation.
  9149. */
  9150. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9151. /**
  9152. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9153. * @param matrix The materix to updated with the projection information
  9154. * @param viewMatrix The transform matrix of the light
  9155. * @param renderList The list of mesh to render in the map
  9156. * @returns The current light
  9157. */
  9158. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9159. /**
  9160. * Gets the current depth scale used in ESM.
  9161. * @returns The scale
  9162. */
  9163. getDepthScale(): number;
  9164. /**
  9165. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9166. * @returns true if a cube texture needs to be use
  9167. */
  9168. needCube(): boolean;
  9169. /**
  9170. * Detects if the projection matrix requires to be recomputed this frame.
  9171. * @returns true if it requires to be recomputed otherwise, false.
  9172. */
  9173. needProjectionMatrixCompute(): boolean;
  9174. /**
  9175. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9176. */
  9177. forceProjectionMatrixCompute(): void;
  9178. /**
  9179. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9180. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9181. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9182. */
  9183. getShadowDirection(faceIndex?: number): Vector3;
  9184. /**
  9185. * Gets the minZ used for shadow according to both the scene and the light.
  9186. * @param activeCamera The camera we are returning the min for
  9187. * @returns the depth min z
  9188. */
  9189. getDepthMinZ(activeCamera: Camera): number;
  9190. /**
  9191. * Gets the maxZ used for shadow according to both the scene and the light.
  9192. * @param activeCamera The camera we are returning the max for
  9193. * @returns the depth max z
  9194. */
  9195. getDepthMaxZ(activeCamera: Camera): number;
  9196. }
  9197. /**
  9198. * Base implementation IShadowLight
  9199. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9200. */
  9201. export abstract class ShadowLight extends Light implements IShadowLight {
  9202. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9203. protected _position: Vector3;
  9204. protected _setPosition(value: Vector3): void;
  9205. /**
  9206. * Sets the position the shadow will be casted from. Also use as the light position for both
  9207. * point and spot lights.
  9208. */
  9209. /**
  9210. * Sets the position the shadow will be casted from. Also use as the light position for both
  9211. * point and spot lights.
  9212. */
  9213. position: Vector3;
  9214. protected _direction: Vector3;
  9215. protected _setDirection(value: Vector3): void;
  9216. /**
  9217. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9218. * Also use as the light direction on spot and directional lights.
  9219. */
  9220. /**
  9221. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9222. * Also use as the light direction on spot and directional lights.
  9223. */
  9224. direction: Vector3;
  9225. private _shadowMinZ;
  9226. /**
  9227. * Gets the shadow projection clipping minimum z value.
  9228. */
  9229. /**
  9230. * Sets the shadow projection clipping minimum z value.
  9231. */
  9232. shadowMinZ: number;
  9233. private _shadowMaxZ;
  9234. /**
  9235. * Sets the shadow projection clipping maximum z value.
  9236. */
  9237. /**
  9238. * Gets the shadow projection clipping maximum z value.
  9239. */
  9240. shadowMaxZ: number;
  9241. /**
  9242. * Callback defining a custom Projection Matrix Builder.
  9243. * This can be used to override the default projection matrix computation.
  9244. */
  9245. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9246. /**
  9247. * The transformed position. Position of the light in world space taking parenting in account.
  9248. */
  9249. transformedPosition: Vector3;
  9250. /**
  9251. * The transformed direction. Direction of the light in world space taking parenting in account.
  9252. */
  9253. transformedDirection: Vector3;
  9254. private _needProjectionMatrixCompute;
  9255. /**
  9256. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9257. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9258. */
  9259. computeTransformedInformation(): boolean;
  9260. /**
  9261. * Return the depth scale used for the shadow map.
  9262. * @returns the depth scale.
  9263. */
  9264. getDepthScale(): number;
  9265. /**
  9266. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9267. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9268. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9269. */
  9270. getShadowDirection(faceIndex?: number): Vector3;
  9271. /**
  9272. * Returns the ShadowLight absolute position in the World.
  9273. * @returns the position vector in world space
  9274. */
  9275. getAbsolutePosition(): Vector3;
  9276. /**
  9277. * Sets the ShadowLight direction toward the passed target.
  9278. * @param target The point to target in local space
  9279. * @returns the updated ShadowLight direction
  9280. */
  9281. setDirectionToTarget(target: Vector3): Vector3;
  9282. /**
  9283. * Returns the light rotation in euler definition.
  9284. * @returns the x y z rotation in local space.
  9285. */
  9286. getRotation(): Vector3;
  9287. /**
  9288. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9289. * @returns true if a cube texture needs to be use
  9290. */
  9291. needCube(): boolean;
  9292. /**
  9293. * Detects if the projection matrix requires to be recomputed this frame.
  9294. * @returns true if it requires to be recomputed otherwise, false.
  9295. */
  9296. needProjectionMatrixCompute(): boolean;
  9297. /**
  9298. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9299. */
  9300. forceProjectionMatrixCompute(): void;
  9301. /** @hidden */
  9302. _initCache(): void;
  9303. /** @hidden */
  9304. _isSynchronized(): boolean;
  9305. /**
  9306. * Computes the world matrix of the node
  9307. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9308. * @returns the world matrix
  9309. */
  9310. computeWorldMatrix(force?: boolean): Matrix;
  9311. /**
  9312. * Gets the minZ used for shadow according to both the scene and the light.
  9313. * @param activeCamera The camera we are returning the min for
  9314. * @returns the depth min z
  9315. */
  9316. getDepthMinZ(activeCamera: Camera): number;
  9317. /**
  9318. * Gets the maxZ used for shadow according to both the scene and the light.
  9319. * @param activeCamera The camera we are returning the max for
  9320. * @returns the depth max z
  9321. */
  9322. getDepthMaxZ(activeCamera: Camera): number;
  9323. /**
  9324. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9325. * @param matrix The materix to updated with the projection information
  9326. * @param viewMatrix The transform matrix of the light
  9327. * @param renderList The list of mesh to render in the map
  9328. * @returns The current light
  9329. */
  9330. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9331. }
  9332. }
  9333. declare module BABYLON {
  9334. /**
  9335. * "Static Class" containing the most commonly used helper while dealing with material for
  9336. * rendering purpose.
  9337. *
  9338. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9339. *
  9340. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9341. */
  9342. export class MaterialHelper {
  9343. /**
  9344. * Bind the current view position to an effect.
  9345. * @param effect The effect to be bound
  9346. * @param scene The scene the eyes position is used from
  9347. */
  9348. static BindEyePosition(effect: Effect, scene: Scene): void;
  9349. /**
  9350. * Helps preparing the defines values about the UVs in used in the effect.
  9351. * UVs are shared as much as we can accross channels in the shaders.
  9352. * @param texture The texture we are preparing the UVs for
  9353. * @param defines The defines to update
  9354. * @param key The channel key "diffuse", "specular"... used in the shader
  9355. */
  9356. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9357. /**
  9358. * Binds a texture matrix value to its corrsponding uniform
  9359. * @param texture The texture to bind the matrix for
  9360. * @param uniformBuffer The uniform buffer receivin the data
  9361. * @param key The channel key "diffuse", "specular"... used in the shader
  9362. */
  9363. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9364. /**
  9365. * Gets the current status of the fog (should it be enabled?)
  9366. * @param mesh defines the mesh to evaluate for fog support
  9367. * @param scene defines the hosting scene
  9368. * @returns true if fog must be enabled
  9369. */
  9370. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9371. /**
  9372. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9373. * @param mesh defines the current mesh
  9374. * @param scene defines the current scene
  9375. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9376. * @param pointsCloud defines if point cloud rendering has to be turned on
  9377. * @param fogEnabled defines if fog has to be turned on
  9378. * @param alphaTest defines if alpha testing has to be turned on
  9379. * @param defines defines the current list of defines
  9380. */
  9381. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9382. /**
  9383. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9384. * @param scene defines the current scene
  9385. * @param engine defines the current engine
  9386. * @param defines specifies the list of active defines
  9387. * @param useInstances defines if instances have to be turned on
  9388. * @param useClipPlane defines if clip plane have to be turned on
  9389. */
  9390. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9391. /**
  9392. * Prepares the defines for bones
  9393. * @param mesh The mesh containing the geometry data we will draw
  9394. * @param defines The defines to update
  9395. */
  9396. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9397. /**
  9398. * Prepares the defines for morph targets
  9399. * @param mesh The mesh containing the geometry data we will draw
  9400. * @param defines The defines to update
  9401. */
  9402. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9403. /**
  9404. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9405. * @param mesh The mesh containing the geometry data we will draw
  9406. * @param defines The defines to update
  9407. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9408. * @param useBones Precise whether bones should be used or not (override mesh info)
  9409. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9410. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9411. * @returns false if defines are considered not dirty and have not been checked
  9412. */
  9413. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9414. /**
  9415. * Prepares the defines related to multiview
  9416. * @param scene The scene we are intending to draw
  9417. * @param defines The defines to update
  9418. */
  9419. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9420. /**
  9421. * Prepares the defines related to the light information passed in parameter
  9422. * @param scene The scene we are intending to draw
  9423. * @param mesh The mesh the effect is compiling for
  9424. * @param defines The defines to update
  9425. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9426. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9427. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9428. * @returns true if normals will be required for the rest of the effect
  9429. */
  9430. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9431. /**
  9432. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9433. * that won t be acctive due to defines being turned off.
  9434. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9435. * @param samplersList The samplers list
  9436. * @param defines The defines helping in the list generation
  9437. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9438. */
  9439. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9440. /**
  9441. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9442. * @param defines The defines to update while falling back
  9443. * @param fallbacks The authorized effect fallbacks
  9444. * @param maxSimultaneousLights The maximum number of lights allowed
  9445. * @param rank the current rank of the Effect
  9446. * @returns The newly affected rank
  9447. */
  9448. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9449. /**
  9450. * Prepares the list of attributes required for morph targets according to the effect defines.
  9451. * @param attribs The current list of supported attribs
  9452. * @param mesh The mesh to prepare the morph targets attributes for
  9453. * @param defines The current Defines of the effect
  9454. */
  9455. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9456. /**
  9457. * Prepares the list of attributes required for bones according to the effect defines.
  9458. * @param attribs The current list of supported attribs
  9459. * @param mesh The mesh to prepare the bones attributes for
  9460. * @param defines The current Defines of the effect
  9461. * @param fallbacks The current efffect fallback strategy
  9462. */
  9463. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9464. /**
  9465. * Prepares the list of attributes required for instances according to the effect defines.
  9466. * @param attribs The current list of supported attribs
  9467. * @param defines The current Defines of the effect
  9468. */
  9469. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9470. /**
  9471. * Binds the light shadow information to the effect for the given mesh.
  9472. * @param light The light containing the generator
  9473. * @param scene The scene the lights belongs to
  9474. * @param mesh The mesh we are binding the information to render
  9475. * @param lightIndex The light index in the effect used to render the mesh
  9476. * @param effect The effect we are binding the data to
  9477. */
  9478. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9479. /**
  9480. * Binds the light information to the effect.
  9481. * @param light The light containing the generator
  9482. * @param effect The effect we are binding the data to
  9483. * @param lightIndex The light index in the effect used to render
  9484. */
  9485. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9486. /**
  9487. * Binds the lights information from the scene to the effect for the given mesh.
  9488. * @param scene The scene the lights belongs to
  9489. * @param mesh The mesh we are binding the information to render
  9490. * @param effect The effect we are binding the data to
  9491. * @param defines The generated defines for the effect
  9492. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9493. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9494. */
  9495. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9496. private static _tempFogColor;
  9497. /**
  9498. * Binds the fog information from the scene to the effect for the given mesh.
  9499. * @param scene The scene the lights belongs to
  9500. * @param mesh The mesh we are binding the information to render
  9501. * @param effect The effect we are binding the data to
  9502. * @param linearSpace Defines if the fog effect is applied in linear space
  9503. */
  9504. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9505. /**
  9506. * Binds the bones information from the mesh to the effect.
  9507. * @param mesh The mesh we are binding the information to render
  9508. * @param effect The effect we are binding the data to
  9509. */
  9510. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9511. /**
  9512. * Binds the morph targets information from the mesh to the effect.
  9513. * @param abstractMesh The mesh we are binding the information to render
  9514. * @param effect The effect we are binding the data to
  9515. */
  9516. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9517. /**
  9518. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9519. * @param defines The generated defines used in the effect
  9520. * @param effect The effect we are binding the data to
  9521. * @param scene The scene we are willing to render with logarithmic scale for
  9522. */
  9523. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9524. /**
  9525. * Binds the clip plane information from the scene to the effect.
  9526. * @param scene The scene the clip plane information are extracted from
  9527. * @param effect The effect we are binding the data to
  9528. */
  9529. static BindClipPlane(effect: Effect, scene: Scene): void;
  9530. }
  9531. }
  9532. declare module BABYLON {
  9533. /** @hidden */
  9534. export var kernelBlurVaryingDeclaration: {
  9535. name: string;
  9536. shader: string;
  9537. };
  9538. }
  9539. declare module BABYLON {
  9540. /** @hidden */
  9541. export var kernelBlurFragment: {
  9542. name: string;
  9543. shader: string;
  9544. };
  9545. }
  9546. declare module BABYLON {
  9547. /** @hidden */
  9548. export var kernelBlurFragment2: {
  9549. name: string;
  9550. shader: string;
  9551. };
  9552. }
  9553. declare module BABYLON {
  9554. /** @hidden */
  9555. export var kernelBlurPixelShader: {
  9556. name: string;
  9557. shader: string;
  9558. };
  9559. }
  9560. declare module BABYLON {
  9561. /** @hidden */
  9562. export var kernelBlurVertex: {
  9563. name: string;
  9564. shader: string;
  9565. };
  9566. }
  9567. declare module BABYLON {
  9568. /** @hidden */
  9569. export var kernelBlurVertexShader: {
  9570. name: string;
  9571. shader: string;
  9572. };
  9573. }
  9574. declare module BABYLON {
  9575. /**
  9576. * The Blur Post Process which blurs an image based on a kernel and direction.
  9577. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9578. */
  9579. export class BlurPostProcess extends PostProcess {
  9580. /** The direction in which to blur the image. */
  9581. direction: Vector2;
  9582. private blockCompilation;
  9583. protected _kernel: number;
  9584. protected _idealKernel: number;
  9585. protected _packedFloat: boolean;
  9586. private _staticDefines;
  9587. /**
  9588. * Sets the length in pixels of the blur sample region
  9589. */
  9590. /**
  9591. * Gets the length in pixels of the blur sample region
  9592. */
  9593. kernel: number;
  9594. /**
  9595. * Sets wether or not the blur needs to unpack/repack floats
  9596. */
  9597. /**
  9598. * Gets wether or not the blur is unpacking/repacking floats
  9599. */
  9600. packedFloat: boolean;
  9601. /**
  9602. * Creates a new instance BlurPostProcess
  9603. * @param name The name of the effect.
  9604. * @param direction The direction in which to blur the image.
  9605. * @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.
  9606. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9607. * @param camera The camera to apply the render pass to.
  9608. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9609. * @param engine The engine which the post process will be applied. (default: current engine)
  9610. * @param reusable If the post process can be reused on the same frame. (default: false)
  9611. * @param textureType Type of textures used when performing the post process. (default: 0)
  9612. * @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)
  9613. */
  9614. constructor(name: string,
  9615. /** The direction in which to blur the image. */
  9616. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9617. /**
  9618. * Updates the effect with the current post process compile time values and recompiles the shader.
  9619. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9620. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9621. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9622. * @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
  9623. * @param onCompiled Called when the shader has been compiled.
  9624. * @param onError Called if there is an error when compiling a shader.
  9625. */
  9626. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9627. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9628. /**
  9629. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9630. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9631. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9632. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9633. * The gaps between physical kernels are compensated for in the weighting of the samples
  9634. * @param idealKernel Ideal blur kernel.
  9635. * @return Nearest best kernel.
  9636. */
  9637. protected _nearestBestKernel(idealKernel: number): number;
  9638. /**
  9639. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9640. * @param x The point on the Gaussian distribution to sample.
  9641. * @return the value of the Gaussian function at x.
  9642. */
  9643. protected _gaussianWeight(x: number): number;
  9644. /**
  9645. * Generates a string that can be used as a floating point number in GLSL.
  9646. * @param x Value to print.
  9647. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9648. * @return GLSL float string.
  9649. */
  9650. protected _glslFloat(x: number, decimalFigures?: number): string;
  9651. }
  9652. }
  9653. declare module BABYLON {
  9654. /** @hidden */
  9655. export var shadowMapPixelShader: {
  9656. name: string;
  9657. shader: string;
  9658. };
  9659. }
  9660. declare module BABYLON {
  9661. /** @hidden */
  9662. export var bonesDeclaration: {
  9663. name: string;
  9664. shader: string;
  9665. };
  9666. }
  9667. declare module BABYLON {
  9668. /** @hidden */
  9669. export var morphTargetsVertexGlobalDeclaration: {
  9670. name: string;
  9671. shader: string;
  9672. };
  9673. }
  9674. declare module BABYLON {
  9675. /** @hidden */
  9676. export var morphTargetsVertexDeclaration: {
  9677. name: string;
  9678. shader: string;
  9679. };
  9680. }
  9681. declare module BABYLON {
  9682. /** @hidden */
  9683. export var instancesDeclaration: {
  9684. name: string;
  9685. shader: string;
  9686. };
  9687. }
  9688. declare module BABYLON {
  9689. /** @hidden */
  9690. export var helperFunctions: {
  9691. name: string;
  9692. shader: string;
  9693. };
  9694. }
  9695. declare module BABYLON {
  9696. /** @hidden */
  9697. export var morphTargetsVertex: {
  9698. name: string;
  9699. shader: string;
  9700. };
  9701. }
  9702. declare module BABYLON {
  9703. /** @hidden */
  9704. export var instancesVertex: {
  9705. name: string;
  9706. shader: string;
  9707. };
  9708. }
  9709. declare module BABYLON {
  9710. /** @hidden */
  9711. export var bonesVertex: {
  9712. name: string;
  9713. shader: string;
  9714. };
  9715. }
  9716. declare module BABYLON {
  9717. /** @hidden */
  9718. export var shadowMapVertexShader: {
  9719. name: string;
  9720. shader: string;
  9721. };
  9722. }
  9723. declare module BABYLON {
  9724. /** @hidden */
  9725. export var depthBoxBlurPixelShader: {
  9726. name: string;
  9727. shader: string;
  9728. };
  9729. }
  9730. declare module BABYLON {
  9731. /**
  9732. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9733. */
  9734. export interface ICustomShaderOptions {
  9735. /**
  9736. * Gets or sets the custom shader name to use
  9737. */
  9738. shaderName: string;
  9739. /**
  9740. * The list of attribute names used in the shader
  9741. */
  9742. attributes?: string[];
  9743. /**
  9744. * The list of unifrom names used in the shader
  9745. */
  9746. uniforms?: string[];
  9747. /**
  9748. * The list of sampler names used in the shader
  9749. */
  9750. samplers?: string[];
  9751. /**
  9752. * The list of defines used in the shader
  9753. */
  9754. defines?: string[];
  9755. }
  9756. /**
  9757. * Interface to implement to create a shadow generator compatible with BJS.
  9758. */
  9759. export interface IShadowGenerator {
  9760. /**
  9761. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9762. * @returns The render target texture if present otherwise, null
  9763. */
  9764. getShadowMap(): Nullable<RenderTargetTexture>;
  9765. /**
  9766. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9767. * @returns The render target texture if the shadow map is present otherwise, null
  9768. */
  9769. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9770. /**
  9771. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9772. * @param subMesh The submesh we want to render in the shadow map
  9773. * @param useInstances Defines wether will draw in the map using instances
  9774. * @returns true if ready otherwise, false
  9775. */
  9776. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9777. /**
  9778. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9779. * @param defines Defines of the material we want to update
  9780. * @param lightIndex Index of the light in the enabled light list of the material
  9781. */
  9782. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9783. /**
  9784. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9785. * defined in the generator but impacting the effect).
  9786. * It implies the unifroms available on the materials are the standard BJS ones.
  9787. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9788. * @param effect The effect we are binfing the information for
  9789. */
  9790. bindShadowLight(lightIndex: string, effect: Effect): void;
  9791. /**
  9792. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9793. * (eq to shadow prjection matrix * light transform matrix)
  9794. * @returns The transform matrix used to create the shadow map
  9795. */
  9796. getTransformMatrix(): Matrix;
  9797. /**
  9798. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9799. * Cube and 2D textures for instance.
  9800. */
  9801. recreateShadowMap(): void;
  9802. /**
  9803. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9804. * @param onCompiled Callback triggered at the and of the effects compilation
  9805. * @param options Sets of optional options forcing the compilation with different modes
  9806. */
  9807. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9808. useInstances: boolean;
  9809. }>): void;
  9810. /**
  9811. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9812. * @param options Sets of optional options forcing the compilation with different modes
  9813. * @returns A promise that resolves when the compilation completes
  9814. */
  9815. forceCompilationAsync(options?: Partial<{
  9816. useInstances: boolean;
  9817. }>): Promise<void>;
  9818. /**
  9819. * Serializes the shadow generator setup to a json object.
  9820. * @returns The serialized JSON object
  9821. */
  9822. serialize(): any;
  9823. /**
  9824. * Disposes the Shadow map and related Textures and effects.
  9825. */
  9826. dispose(): void;
  9827. }
  9828. /**
  9829. * Default implementation IShadowGenerator.
  9830. * This is the main object responsible of generating shadows in the framework.
  9831. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9832. */
  9833. export class ShadowGenerator implements IShadowGenerator {
  9834. /**
  9835. * Shadow generator mode None: no filtering applied.
  9836. */
  9837. static readonly FILTER_NONE: number;
  9838. /**
  9839. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9840. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9841. */
  9842. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9843. /**
  9844. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9845. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9846. */
  9847. static readonly FILTER_POISSONSAMPLING: number;
  9848. /**
  9849. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9850. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9851. */
  9852. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9853. /**
  9854. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9855. * edge artifacts on steep falloff.
  9856. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9857. */
  9858. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9859. /**
  9860. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9861. * edge artifacts on steep falloff.
  9862. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9863. */
  9864. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9865. /**
  9866. * Shadow generator mode PCF: Percentage Closer Filtering
  9867. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9868. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9869. */
  9870. static readonly FILTER_PCF: number;
  9871. /**
  9872. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9873. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9874. * Contact Hardening
  9875. */
  9876. static readonly FILTER_PCSS: number;
  9877. /**
  9878. * Reserved for PCF and PCSS
  9879. * Highest Quality.
  9880. *
  9881. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9882. *
  9883. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9884. */
  9885. static readonly QUALITY_HIGH: number;
  9886. /**
  9887. * Reserved for PCF and PCSS
  9888. * Good tradeoff for quality/perf cross devices
  9889. *
  9890. * Execute PCF on a 3*3 kernel.
  9891. *
  9892. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9893. */
  9894. static readonly QUALITY_MEDIUM: number;
  9895. /**
  9896. * Reserved for PCF and PCSS
  9897. * The lowest quality but the fastest.
  9898. *
  9899. * Execute PCF on a 1*1 kernel.
  9900. *
  9901. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9902. */
  9903. static readonly QUALITY_LOW: number;
  9904. /** Gets or sets the custom shader name to use */
  9905. customShaderOptions: ICustomShaderOptions;
  9906. /**
  9907. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9908. */
  9909. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9910. /**
  9911. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9912. */
  9913. onAfterShadowMapRenderObservable: Observable<Effect>;
  9914. /**
  9915. * Observable triggered before a mesh is rendered in the shadow map.
  9916. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9917. */
  9918. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9919. /**
  9920. * Observable triggered after a mesh is rendered in the shadow map.
  9921. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9922. */
  9923. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9924. private _bias;
  9925. /**
  9926. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9927. */
  9928. /**
  9929. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9930. */
  9931. bias: number;
  9932. private _normalBias;
  9933. /**
  9934. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9935. */
  9936. /**
  9937. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9938. */
  9939. normalBias: number;
  9940. private _blurBoxOffset;
  9941. /**
  9942. * Gets the blur box offset: offset applied during the blur pass.
  9943. * Only useful if useKernelBlur = false
  9944. */
  9945. /**
  9946. * Sets the blur box offset: offset applied during the blur pass.
  9947. * Only useful if useKernelBlur = false
  9948. */
  9949. blurBoxOffset: number;
  9950. private _blurScale;
  9951. /**
  9952. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9953. * 2 means half of the size.
  9954. */
  9955. /**
  9956. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9957. * 2 means half of the size.
  9958. */
  9959. blurScale: number;
  9960. private _blurKernel;
  9961. /**
  9962. * Gets the blur kernel: kernel size of the blur pass.
  9963. * Only useful if useKernelBlur = true
  9964. */
  9965. /**
  9966. * Sets the blur kernel: kernel size of the blur pass.
  9967. * Only useful if useKernelBlur = true
  9968. */
  9969. blurKernel: number;
  9970. private _useKernelBlur;
  9971. /**
  9972. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9973. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9974. */
  9975. /**
  9976. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9977. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9978. */
  9979. useKernelBlur: boolean;
  9980. private _depthScale;
  9981. /**
  9982. * Gets the depth scale used in ESM mode.
  9983. */
  9984. /**
  9985. * Sets the depth scale used in ESM mode.
  9986. * This can override the scale stored on the light.
  9987. */
  9988. depthScale: number;
  9989. private _filter;
  9990. /**
  9991. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9992. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9993. */
  9994. /**
  9995. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9996. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9997. */
  9998. filter: number;
  9999. /**
  10000. * Gets if the current filter is set to Poisson Sampling.
  10001. */
  10002. /**
  10003. * Sets the current filter to Poisson Sampling.
  10004. */
  10005. usePoissonSampling: boolean;
  10006. /**
  10007. * Gets if the current filter is set to ESM.
  10008. */
  10009. /**
  10010. * Sets the current filter is to ESM.
  10011. */
  10012. useExponentialShadowMap: boolean;
  10013. /**
  10014. * Gets if the current filter is set to filtered ESM.
  10015. */
  10016. /**
  10017. * Gets if the current filter is set to filtered ESM.
  10018. */
  10019. useBlurExponentialShadowMap: boolean;
  10020. /**
  10021. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10022. * exponential to prevent steep falloff artifacts).
  10023. */
  10024. /**
  10025. * Sets the current filter to "close ESM" (using the inverse of the
  10026. * exponential to prevent steep falloff artifacts).
  10027. */
  10028. useCloseExponentialShadowMap: boolean;
  10029. /**
  10030. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10031. * exponential to prevent steep falloff artifacts).
  10032. */
  10033. /**
  10034. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10035. * exponential to prevent steep falloff artifacts).
  10036. */
  10037. useBlurCloseExponentialShadowMap: boolean;
  10038. /**
  10039. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10040. */
  10041. /**
  10042. * Sets the current filter to "PCF" (percentage closer filtering).
  10043. */
  10044. usePercentageCloserFiltering: boolean;
  10045. private _filteringQuality;
  10046. /**
  10047. * Gets the PCF or PCSS Quality.
  10048. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10049. */
  10050. /**
  10051. * Sets the PCF or PCSS Quality.
  10052. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10053. */
  10054. filteringQuality: number;
  10055. /**
  10056. * Gets if the current filter is set to "PCSS" (contact hardening).
  10057. */
  10058. /**
  10059. * Sets the current filter to "PCSS" (contact hardening).
  10060. */
  10061. useContactHardeningShadow: boolean;
  10062. private _contactHardeningLightSizeUVRatio;
  10063. /**
  10064. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10065. * Using a ratio helps keeping shape stability independently of the map size.
  10066. *
  10067. * It does not account for the light projection as it was having too much
  10068. * instability during the light setup or during light position changes.
  10069. *
  10070. * Only valid if useContactHardeningShadow is true.
  10071. */
  10072. /**
  10073. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10074. * Using a ratio helps keeping shape stability independently of the map size.
  10075. *
  10076. * It does not account for the light projection as it was having too much
  10077. * instability during the light setup or during light position changes.
  10078. *
  10079. * Only valid if useContactHardeningShadow is true.
  10080. */
  10081. contactHardeningLightSizeUVRatio: number;
  10082. private _darkness;
  10083. /** Gets or sets the actual darkness of a shadow */
  10084. darkness: number;
  10085. /**
  10086. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10087. * 0 means strongest and 1 would means no shadow.
  10088. * @returns the darkness.
  10089. */
  10090. getDarkness(): number;
  10091. /**
  10092. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10093. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10094. * @returns the shadow generator allowing fluent coding.
  10095. */
  10096. setDarkness(darkness: number): ShadowGenerator;
  10097. private _transparencyShadow;
  10098. /** Gets or sets the ability to have transparent shadow */
  10099. transparencyShadow: boolean;
  10100. /**
  10101. * Sets the ability to have transparent shadow (boolean).
  10102. * @param transparent True if transparent else False
  10103. * @returns the shadow generator allowing fluent coding
  10104. */
  10105. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10106. private _shadowMap;
  10107. private _shadowMap2;
  10108. /**
  10109. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10110. * @returns The render target texture if present otherwise, null
  10111. */
  10112. getShadowMap(): Nullable<RenderTargetTexture>;
  10113. /**
  10114. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10115. * @returns The render target texture if the shadow map is present otherwise, null
  10116. */
  10117. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10118. /**
  10119. * Gets the class name of that object
  10120. * @returns "ShadowGenerator"
  10121. */
  10122. getClassName(): string;
  10123. /**
  10124. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10125. * @param mesh Mesh to add
  10126. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10127. * @returns the Shadow Generator itself
  10128. */
  10129. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10130. /**
  10131. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10132. * @param mesh Mesh to remove
  10133. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10134. * @returns the Shadow Generator itself
  10135. */
  10136. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10137. /**
  10138. * Controls the extent to which the shadows fade out at the edge of the frustum
  10139. * Used only by directionals and spots
  10140. */
  10141. frustumEdgeFalloff: number;
  10142. private _light;
  10143. /**
  10144. * Returns the associated light object.
  10145. * @returns the light generating the shadow
  10146. */
  10147. getLight(): IShadowLight;
  10148. /**
  10149. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10150. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10151. * It might on the other hand introduce peter panning.
  10152. */
  10153. forceBackFacesOnly: boolean;
  10154. private _scene;
  10155. private _lightDirection;
  10156. private _effect;
  10157. private _viewMatrix;
  10158. private _projectionMatrix;
  10159. private _transformMatrix;
  10160. private _cachedPosition;
  10161. private _cachedDirection;
  10162. private _cachedDefines;
  10163. private _currentRenderID;
  10164. private _boxBlurPostprocess;
  10165. private _kernelBlurXPostprocess;
  10166. private _kernelBlurYPostprocess;
  10167. private _blurPostProcesses;
  10168. private _mapSize;
  10169. private _currentFaceIndex;
  10170. private _currentFaceIndexCache;
  10171. private _textureType;
  10172. private _defaultTextureMatrix;
  10173. /** @hidden */
  10174. static _SceneComponentInitialization: (scene: Scene) => void;
  10175. /**
  10176. * Creates a ShadowGenerator object.
  10177. * A ShadowGenerator is the required tool to use the shadows.
  10178. * Each light casting shadows needs to use its own ShadowGenerator.
  10179. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10180. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10181. * @param light The light object generating the shadows.
  10182. * @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.
  10183. */
  10184. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10185. private _initializeGenerator;
  10186. private _initializeShadowMap;
  10187. private _initializeBlurRTTAndPostProcesses;
  10188. private _renderForShadowMap;
  10189. private _renderSubMeshForShadowMap;
  10190. private _applyFilterValues;
  10191. /**
  10192. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10193. * @param onCompiled Callback triggered at the and of the effects compilation
  10194. * @param options Sets of optional options forcing the compilation with different modes
  10195. */
  10196. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10197. useInstances: boolean;
  10198. }>): void;
  10199. /**
  10200. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10201. * @param options Sets of optional options forcing the compilation with different modes
  10202. * @returns A promise that resolves when the compilation completes
  10203. */
  10204. forceCompilationAsync(options?: Partial<{
  10205. useInstances: boolean;
  10206. }>): Promise<void>;
  10207. /**
  10208. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10209. * @param subMesh The submesh we want to render in the shadow map
  10210. * @param useInstances Defines wether will draw in the map using instances
  10211. * @returns true if ready otherwise, false
  10212. */
  10213. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10214. /**
  10215. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10216. * @param defines Defines of the material we want to update
  10217. * @param lightIndex Index of the light in the enabled light list of the material
  10218. */
  10219. prepareDefines(defines: any, lightIndex: number): void;
  10220. /**
  10221. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10222. * defined in the generator but impacting the effect).
  10223. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10224. * @param effect The effect we are binfing the information for
  10225. */
  10226. bindShadowLight(lightIndex: string, effect: Effect): void;
  10227. /**
  10228. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10229. * (eq to shadow prjection matrix * light transform matrix)
  10230. * @returns The transform matrix used to create the shadow map
  10231. */
  10232. getTransformMatrix(): Matrix;
  10233. /**
  10234. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10235. * Cube and 2D textures for instance.
  10236. */
  10237. recreateShadowMap(): void;
  10238. private _disposeBlurPostProcesses;
  10239. private _disposeRTTandPostProcesses;
  10240. /**
  10241. * Disposes the ShadowGenerator.
  10242. * Returns nothing.
  10243. */
  10244. dispose(): void;
  10245. /**
  10246. * Serializes the shadow generator setup to a json object.
  10247. * @returns The serialized JSON object
  10248. */
  10249. serialize(): any;
  10250. /**
  10251. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10252. * @param parsedShadowGenerator The JSON object to parse
  10253. * @param scene The scene to create the shadow map for
  10254. * @returns The parsed shadow generator
  10255. */
  10256. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10257. }
  10258. }
  10259. declare module BABYLON {
  10260. /**
  10261. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10262. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10263. * 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.
  10264. */
  10265. export abstract class Light extends Node {
  10266. /**
  10267. * Falloff Default: light is falling off following the material specification:
  10268. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10269. */
  10270. static readonly FALLOFF_DEFAULT: number;
  10271. /**
  10272. * Falloff Physical: light is falling off following the inverse squared distance law.
  10273. */
  10274. static readonly FALLOFF_PHYSICAL: number;
  10275. /**
  10276. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10277. * to enhance interoperability with other engines.
  10278. */
  10279. static readonly FALLOFF_GLTF: number;
  10280. /**
  10281. * Falloff Standard: light is falling off like in the standard material
  10282. * to enhance interoperability with other materials.
  10283. */
  10284. static readonly FALLOFF_STANDARD: number;
  10285. /**
  10286. * If every light affecting the material is in this lightmapMode,
  10287. * material.lightmapTexture adds or multiplies
  10288. * (depends on material.useLightmapAsShadowmap)
  10289. * after every other light calculations.
  10290. */
  10291. static readonly LIGHTMAP_DEFAULT: number;
  10292. /**
  10293. * material.lightmapTexture as only diffuse lighting from this light
  10294. * adds only specular lighting from this light
  10295. * adds dynamic shadows
  10296. */
  10297. static readonly LIGHTMAP_SPECULAR: number;
  10298. /**
  10299. * material.lightmapTexture as only lighting
  10300. * no light calculation from this light
  10301. * only adds dynamic shadows from this light
  10302. */
  10303. static readonly LIGHTMAP_SHADOWSONLY: number;
  10304. /**
  10305. * Each light type uses the default quantity according to its type:
  10306. * point/spot lights use luminous intensity
  10307. * directional lights use illuminance
  10308. */
  10309. static readonly INTENSITYMODE_AUTOMATIC: number;
  10310. /**
  10311. * lumen (lm)
  10312. */
  10313. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10314. /**
  10315. * candela (lm/sr)
  10316. */
  10317. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10318. /**
  10319. * lux (lm/m^2)
  10320. */
  10321. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10322. /**
  10323. * nit (cd/m^2)
  10324. */
  10325. static readonly INTENSITYMODE_LUMINANCE: number;
  10326. /**
  10327. * Light type const id of the point light.
  10328. */
  10329. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10330. /**
  10331. * Light type const id of the directional light.
  10332. */
  10333. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10334. /**
  10335. * Light type const id of the spot light.
  10336. */
  10337. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10338. /**
  10339. * Light type const id of the hemispheric light.
  10340. */
  10341. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10342. /**
  10343. * Diffuse gives the basic color to an object.
  10344. */
  10345. diffuse: Color3;
  10346. /**
  10347. * Specular produces a highlight color on an object.
  10348. * Note: This is note affecting PBR materials.
  10349. */
  10350. specular: Color3;
  10351. /**
  10352. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10353. * falling off base on range or angle.
  10354. * This can be set to any values in Light.FALLOFF_x.
  10355. *
  10356. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10357. * other types of materials.
  10358. */
  10359. falloffType: number;
  10360. /**
  10361. * Strength of the light.
  10362. * Note: By default it is define in the framework own unit.
  10363. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10364. */
  10365. intensity: number;
  10366. private _range;
  10367. protected _inverseSquaredRange: number;
  10368. /**
  10369. * Defines how far from the source the light is impacting in scene units.
  10370. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10371. */
  10372. /**
  10373. * Defines how far from the source the light is impacting in scene units.
  10374. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10375. */
  10376. range: number;
  10377. /**
  10378. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10379. * of light.
  10380. */
  10381. private _photometricScale;
  10382. private _intensityMode;
  10383. /**
  10384. * Gets the photometric scale used to interpret the intensity.
  10385. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10386. */
  10387. /**
  10388. * Sets the photometric scale used to interpret the intensity.
  10389. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10390. */
  10391. intensityMode: number;
  10392. private _radius;
  10393. /**
  10394. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10395. */
  10396. /**
  10397. * sets the light radius used by PBR Materials to simulate soft area lights.
  10398. */
  10399. radius: number;
  10400. private _renderPriority;
  10401. /**
  10402. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10403. * exceeding the number allowed of the materials.
  10404. */
  10405. renderPriority: number;
  10406. private _shadowEnabled;
  10407. /**
  10408. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10409. * the current shadow generator.
  10410. */
  10411. /**
  10412. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10413. * the current shadow generator.
  10414. */
  10415. shadowEnabled: boolean;
  10416. private _includedOnlyMeshes;
  10417. /**
  10418. * Gets the only meshes impacted by this light.
  10419. */
  10420. /**
  10421. * Sets the only meshes impacted by this light.
  10422. */
  10423. includedOnlyMeshes: AbstractMesh[];
  10424. private _excludedMeshes;
  10425. /**
  10426. * Gets the meshes not impacted by this light.
  10427. */
  10428. /**
  10429. * Sets the meshes not impacted by this light.
  10430. */
  10431. excludedMeshes: AbstractMesh[];
  10432. private _excludeWithLayerMask;
  10433. /**
  10434. * Gets the layer id use to find what meshes are not impacted by the light.
  10435. * Inactive if 0
  10436. */
  10437. /**
  10438. * Sets the layer id use to find what meshes are not impacted by the light.
  10439. * Inactive if 0
  10440. */
  10441. excludeWithLayerMask: number;
  10442. private _includeOnlyWithLayerMask;
  10443. /**
  10444. * Gets the layer id use to find what meshes are impacted by the light.
  10445. * Inactive if 0
  10446. */
  10447. /**
  10448. * Sets the layer id use to find what meshes are impacted by the light.
  10449. * Inactive if 0
  10450. */
  10451. includeOnlyWithLayerMask: number;
  10452. private _lightmapMode;
  10453. /**
  10454. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10455. */
  10456. /**
  10457. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10458. */
  10459. lightmapMode: number;
  10460. /**
  10461. * Shadow generator associted to the light.
  10462. * @hidden Internal use only.
  10463. */
  10464. _shadowGenerator: Nullable<IShadowGenerator>;
  10465. /**
  10466. * @hidden Internal use only.
  10467. */
  10468. _excludedMeshesIds: string[];
  10469. /**
  10470. * @hidden Internal use only.
  10471. */
  10472. _includedOnlyMeshesIds: string[];
  10473. /**
  10474. * The current light unifom buffer.
  10475. * @hidden Internal use only.
  10476. */
  10477. _uniformBuffer: UniformBuffer;
  10478. /**
  10479. * Creates a Light object in the scene.
  10480. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10481. * @param name The firendly name of the light
  10482. * @param scene The scene the light belongs too
  10483. */
  10484. constructor(name: string, scene: Scene);
  10485. protected abstract _buildUniformLayout(): void;
  10486. /**
  10487. * Sets the passed Effect "effect" with the Light information.
  10488. * @param effect The effect to update
  10489. * @param lightIndex The index of the light in the effect to update
  10490. * @returns The light
  10491. */
  10492. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10493. /**
  10494. * Returns the string "Light".
  10495. * @returns the class name
  10496. */
  10497. getClassName(): string;
  10498. /** @hidden */
  10499. readonly _isLight: boolean;
  10500. /**
  10501. * Converts the light information to a readable string for debug purpose.
  10502. * @param fullDetails Supports for multiple levels of logging within scene loading
  10503. * @returns the human readable light info
  10504. */
  10505. toString(fullDetails?: boolean): string;
  10506. /** @hidden */
  10507. protected _syncParentEnabledState(): void;
  10508. /**
  10509. * Set the enabled state of this node.
  10510. * @param value - the new enabled state
  10511. */
  10512. setEnabled(value: boolean): void;
  10513. /**
  10514. * Returns the Light associated shadow generator if any.
  10515. * @return the associated shadow generator.
  10516. */
  10517. getShadowGenerator(): Nullable<IShadowGenerator>;
  10518. /**
  10519. * Returns a Vector3, the absolute light position in the World.
  10520. * @returns the world space position of the light
  10521. */
  10522. getAbsolutePosition(): Vector3;
  10523. /**
  10524. * Specifies if the light will affect the passed mesh.
  10525. * @param mesh The mesh to test against the light
  10526. * @return true the mesh is affected otherwise, false.
  10527. */
  10528. canAffectMesh(mesh: AbstractMesh): boolean;
  10529. /**
  10530. * Sort function to order lights for rendering.
  10531. * @param a First Light object to compare to second.
  10532. * @param b Second Light object to compare first.
  10533. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10534. */
  10535. static CompareLightsPriority(a: Light, b: Light): number;
  10536. /**
  10537. * Releases resources associated with this node.
  10538. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10539. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10540. */
  10541. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10542. /**
  10543. * Returns the light type ID (integer).
  10544. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10545. */
  10546. getTypeID(): number;
  10547. /**
  10548. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10549. * @returns the scaled intensity in intensity mode unit
  10550. */
  10551. getScaledIntensity(): number;
  10552. /**
  10553. * Returns a new Light object, named "name", from the current one.
  10554. * @param name The name of the cloned light
  10555. * @returns the new created light
  10556. */
  10557. clone(name: string): Nullable<Light>;
  10558. /**
  10559. * Serializes the current light into a Serialization object.
  10560. * @returns the serialized object.
  10561. */
  10562. serialize(): any;
  10563. /**
  10564. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10565. * This new light is named "name" and added to the passed scene.
  10566. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10567. * @param name The friendly name of the light
  10568. * @param scene The scene the new light will belong to
  10569. * @returns the constructor function
  10570. */
  10571. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10572. /**
  10573. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10574. * @param parsedLight The JSON representation of the light
  10575. * @param scene The scene to create the parsed light in
  10576. * @returns the created light after parsing
  10577. */
  10578. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10579. private _hookArrayForExcluded;
  10580. private _hookArrayForIncludedOnly;
  10581. private _resyncMeshes;
  10582. /**
  10583. * Forces the meshes to update their light related information in their rendering used effects
  10584. * @hidden Internal Use Only
  10585. */
  10586. _markMeshesAsLightDirty(): void;
  10587. /**
  10588. * Recomputes the cached photometric scale if needed.
  10589. */
  10590. private _computePhotometricScale;
  10591. /**
  10592. * Returns the Photometric Scale according to the light type and intensity mode.
  10593. */
  10594. private _getPhotometricScale;
  10595. /**
  10596. * Reorder the light in the scene according to their defined priority.
  10597. * @hidden Internal Use Only
  10598. */
  10599. _reorderLightsInScene(): void;
  10600. /**
  10601. * Prepares the list of defines specific to the light type.
  10602. * @param defines the list of defines
  10603. * @param lightIndex defines the index of the light for the effect
  10604. */
  10605. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10606. }
  10607. }
  10608. declare module BABYLON {
  10609. /**
  10610. * Interface used to define Action
  10611. */
  10612. export interface IAction {
  10613. /**
  10614. * Trigger for the action
  10615. */
  10616. trigger: number;
  10617. /** Options of the trigger */
  10618. triggerOptions: any;
  10619. /**
  10620. * Gets the trigger parameters
  10621. * @returns the trigger parameters
  10622. */
  10623. getTriggerParameter(): any;
  10624. /**
  10625. * Internal only - executes current action event
  10626. * @hidden
  10627. */
  10628. _executeCurrent(evt?: ActionEvent): void;
  10629. /**
  10630. * Serialize placeholder for child classes
  10631. * @param parent of child
  10632. * @returns the serialized object
  10633. */
  10634. serialize(parent: any): any;
  10635. /**
  10636. * Internal only
  10637. * @hidden
  10638. */
  10639. _prepare(): void;
  10640. /**
  10641. * Internal only - manager for action
  10642. * @hidden
  10643. */
  10644. _actionManager: AbstractActionManager;
  10645. /**
  10646. * Adds action to chain of actions, may be a DoNothingAction
  10647. * @param action defines the next action to execute
  10648. * @returns The action passed in
  10649. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10650. */
  10651. then(action: IAction): IAction;
  10652. }
  10653. /**
  10654. * The action to be carried out following a trigger
  10655. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10656. */
  10657. export class Action implements IAction {
  10658. /** the trigger, with or without parameters, for the action */
  10659. triggerOptions: any;
  10660. /**
  10661. * Trigger for the action
  10662. */
  10663. trigger: number;
  10664. /**
  10665. * Internal only - manager for action
  10666. * @hidden
  10667. */
  10668. _actionManager: ActionManager;
  10669. private _nextActiveAction;
  10670. private _child;
  10671. private _condition?;
  10672. private _triggerParameter;
  10673. /**
  10674. * An event triggered prior to action being executed.
  10675. */
  10676. onBeforeExecuteObservable: Observable<Action>;
  10677. /**
  10678. * Creates a new Action
  10679. * @param triggerOptions the trigger, with or without parameters, for the action
  10680. * @param condition an optional determinant of action
  10681. */
  10682. constructor(
  10683. /** the trigger, with or without parameters, for the action */
  10684. triggerOptions: any, condition?: Condition);
  10685. /**
  10686. * Internal only
  10687. * @hidden
  10688. */
  10689. _prepare(): void;
  10690. /**
  10691. * Gets the trigger parameters
  10692. * @returns the trigger parameters
  10693. */
  10694. getTriggerParameter(): any;
  10695. /**
  10696. * Internal only - executes current action event
  10697. * @hidden
  10698. */
  10699. _executeCurrent(evt?: ActionEvent): void;
  10700. /**
  10701. * Execute placeholder for child classes
  10702. * @param evt optional action event
  10703. */
  10704. execute(evt?: ActionEvent): void;
  10705. /**
  10706. * Skips to next active action
  10707. */
  10708. skipToNextActiveAction(): void;
  10709. /**
  10710. * Adds action to chain of actions, may be a DoNothingAction
  10711. * @param action defines the next action to execute
  10712. * @returns The action passed in
  10713. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10714. */
  10715. then(action: Action): Action;
  10716. /**
  10717. * Internal only
  10718. * @hidden
  10719. */
  10720. _getProperty(propertyPath: string): string;
  10721. /**
  10722. * Internal only
  10723. * @hidden
  10724. */
  10725. _getEffectiveTarget(target: any, propertyPath: string): any;
  10726. /**
  10727. * Serialize placeholder for child classes
  10728. * @param parent of child
  10729. * @returns the serialized object
  10730. */
  10731. serialize(parent: any): any;
  10732. /**
  10733. * Internal only called by serialize
  10734. * @hidden
  10735. */
  10736. protected _serialize(serializedAction: any, parent?: any): any;
  10737. /**
  10738. * Internal only
  10739. * @hidden
  10740. */
  10741. static _SerializeValueAsString: (value: any) => string;
  10742. /**
  10743. * Internal only
  10744. * @hidden
  10745. */
  10746. static _GetTargetProperty: (target: Scene | Node) => {
  10747. name: string;
  10748. targetType: string;
  10749. value: string;
  10750. };
  10751. }
  10752. }
  10753. declare module BABYLON {
  10754. /**
  10755. * A Condition applied to an Action
  10756. */
  10757. export class Condition {
  10758. /**
  10759. * Internal only - manager for action
  10760. * @hidden
  10761. */
  10762. _actionManager: ActionManager;
  10763. /**
  10764. * Internal only
  10765. * @hidden
  10766. */
  10767. _evaluationId: number;
  10768. /**
  10769. * Internal only
  10770. * @hidden
  10771. */
  10772. _currentResult: boolean;
  10773. /**
  10774. * Creates a new Condition
  10775. * @param actionManager the manager of the action the condition is applied to
  10776. */
  10777. constructor(actionManager: ActionManager);
  10778. /**
  10779. * Check if the current condition is valid
  10780. * @returns a boolean
  10781. */
  10782. isValid(): boolean;
  10783. /**
  10784. * Internal only
  10785. * @hidden
  10786. */
  10787. _getProperty(propertyPath: string): string;
  10788. /**
  10789. * Internal only
  10790. * @hidden
  10791. */
  10792. _getEffectiveTarget(target: any, propertyPath: string): any;
  10793. /**
  10794. * Serialize placeholder for child classes
  10795. * @returns the serialized object
  10796. */
  10797. serialize(): any;
  10798. /**
  10799. * Internal only
  10800. * @hidden
  10801. */
  10802. protected _serialize(serializedCondition: any): any;
  10803. }
  10804. /**
  10805. * Defines specific conditional operators as extensions of Condition
  10806. */
  10807. export class ValueCondition extends Condition {
  10808. /** path to specify the property of the target the conditional operator uses */
  10809. propertyPath: string;
  10810. /** the value compared by the conditional operator against the current value of the property */
  10811. value: any;
  10812. /** the conditional operator, default ValueCondition.IsEqual */
  10813. operator: number;
  10814. /**
  10815. * Internal only
  10816. * @hidden
  10817. */
  10818. private static _IsEqual;
  10819. /**
  10820. * Internal only
  10821. * @hidden
  10822. */
  10823. private static _IsDifferent;
  10824. /**
  10825. * Internal only
  10826. * @hidden
  10827. */
  10828. private static _IsGreater;
  10829. /**
  10830. * Internal only
  10831. * @hidden
  10832. */
  10833. private static _IsLesser;
  10834. /**
  10835. * returns the number for IsEqual
  10836. */
  10837. static readonly IsEqual: number;
  10838. /**
  10839. * Returns the number for IsDifferent
  10840. */
  10841. static readonly IsDifferent: number;
  10842. /**
  10843. * Returns the number for IsGreater
  10844. */
  10845. static readonly IsGreater: number;
  10846. /**
  10847. * Returns the number for IsLesser
  10848. */
  10849. static readonly IsLesser: number;
  10850. /**
  10851. * Internal only The action manager for the condition
  10852. * @hidden
  10853. */
  10854. _actionManager: ActionManager;
  10855. /**
  10856. * Internal only
  10857. * @hidden
  10858. */
  10859. private _target;
  10860. /**
  10861. * Internal only
  10862. * @hidden
  10863. */
  10864. private _effectiveTarget;
  10865. /**
  10866. * Internal only
  10867. * @hidden
  10868. */
  10869. private _property;
  10870. /**
  10871. * Creates a new ValueCondition
  10872. * @param actionManager manager for the action the condition applies to
  10873. * @param target for the action
  10874. * @param propertyPath path to specify the property of the target the conditional operator uses
  10875. * @param value the value compared by the conditional operator against the current value of the property
  10876. * @param operator the conditional operator, default ValueCondition.IsEqual
  10877. */
  10878. constructor(actionManager: ActionManager, target: any,
  10879. /** path to specify the property of the target the conditional operator uses */
  10880. propertyPath: string,
  10881. /** the value compared by the conditional operator against the current value of the property */
  10882. value: any,
  10883. /** the conditional operator, default ValueCondition.IsEqual */
  10884. operator?: number);
  10885. /**
  10886. * Compares the given value with the property value for the specified conditional operator
  10887. * @returns the result of the comparison
  10888. */
  10889. isValid(): boolean;
  10890. /**
  10891. * Serialize the ValueCondition into a JSON compatible object
  10892. * @returns serialization object
  10893. */
  10894. serialize(): any;
  10895. /**
  10896. * Gets the name of the conditional operator for the ValueCondition
  10897. * @param operator the conditional operator
  10898. * @returns the name
  10899. */
  10900. static GetOperatorName(operator: number): string;
  10901. }
  10902. /**
  10903. * Defines a predicate condition as an extension of Condition
  10904. */
  10905. export class PredicateCondition extends Condition {
  10906. /** defines the predicate function used to validate the condition */
  10907. predicate: () => boolean;
  10908. /**
  10909. * Internal only - manager for action
  10910. * @hidden
  10911. */
  10912. _actionManager: ActionManager;
  10913. /**
  10914. * Creates a new PredicateCondition
  10915. * @param actionManager manager for the action the condition applies to
  10916. * @param predicate defines the predicate function used to validate the condition
  10917. */
  10918. constructor(actionManager: ActionManager,
  10919. /** defines the predicate function used to validate the condition */
  10920. predicate: () => boolean);
  10921. /**
  10922. * @returns the validity of the predicate condition
  10923. */
  10924. isValid(): boolean;
  10925. }
  10926. /**
  10927. * Defines a state condition as an extension of Condition
  10928. */
  10929. export class StateCondition extends Condition {
  10930. /** Value to compare with target state */
  10931. value: string;
  10932. /**
  10933. * Internal only - manager for action
  10934. * @hidden
  10935. */
  10936. _actionManager: ActionManager;
  10937. /**
  10938. * Internal only
  10939. * @hidden
  10940. */
  10941. private _target;
  10942. /**
  10943. * Creates a new StateCondition
  10944. * @param actionManager manager for the action the condition applies to
  10945. * @param target of the condition
  10946. * @param value to compare with target state
  10947. */
  10948. constructor(actionManager: ActionManager, target: any,
  10949. /** Value to compare with target state */
  10950. value: string);
  10951. /**
  10952. * Gets a boolean indicating if the current condition is met
  10953. * @returns the validity of the state
  10954. */
  10955. isValid(): boolean;
  10956. /**
  10957. * Serialize the StateCondition into a JSON compatible object
  10958. * @returns serialization object
  10959. */
  10960. serialize(): any;
  10961. }
  10962. }
  10963. declare module BABYLON {
  10964. /**
  10965. * This defines an action responsible to toggle a boolean once triggered.
  10966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10967. */
  10968. export class SwitchBooleanAction extends Action {
  10969. /**
  10970. * The path to the boolean property in the target object
  10971. */
  10972. propertyPath: string;
  10973. private _target;
  10974. private _effectiveTarget;
  10975. private _property;
  10976. /**
  10977. * Instantiate the action
  10978. * @param triggerOptions defines the trigger options
  10979. * @param target defines the object containing the boolean
  10980. * @param propertyPath defines the path to the boolean property in the target object
  10981. * @param condition defines the trigger related conditions
  10982. */
  10983. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10984. /** @hidden */
  10985. _prepare(): void;
  10986. /**
  10987. * Execute the action toggle the boolean value.
  10988. */
  10989. execute(): void;
  10990. /**
  10991. * Serializes the actions and its related information.
  10992. * @param parent defines the object to serialize in
  10993. * @returns the serialized object
  10994. */
  10995. serialize(parent: any): any;
  10996. }
  10997. /**
  10998. * This defines an action responsible to set a the state field of the target
  10999. * to a desired value once triggered.
  11000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11001. */
  11002. export class SetStateAction extends Action {
  11003. /**
  11004. * The value to store in the state field.
  11005. */
  11006. value: string;
  11007. private _target;
  11008. /**
  11009. * Instantiate the action
  11010. * @param triggerOptions defines the trigger options
  11011. * @param target defines the object containing the state property
  11012. * @param value defines the value to store in the state field
  11013. * @param condition defines the trigger related conditions
  11014. */
  11015. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  11016. /**
  11017. * Execute the action and store the value on the target state property.
  11018. */
  11019. execute(): void;
  11020. /**
  11021. * Serializes the actions and its related information.
  11022. * @param parent defines the object to serialize in
  11023. * @returns the serialized object
  11024. */
  11025. serialize(parent: any): any;
  11026. }
  11027. /**
  11028. * This defines an action responsible to set a property of the target
  11029. * to a desired value once triggered.
  11030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11031. */
  11032. export class SetValueAction extends Action {
  11033. /**
  11034. * The path of the property to set in the target.
  11035. */
  11036. propertyPath: string;
  11037. /**
  11038. * The value to set in the property
  11039. */
  11040. value: any;
  11041. private _target;
  11042. private _effectiveTarget;
  11043. private _property;
  11044. /**
  11045. * Instantiate the action
  11046. * @param triggerOptions defines the trigger options
  11047. * @param target defines the object containing the property
  11048. * @param propertyPath defines the path of the property to set in the target
  11049. * @param value defines the value to set in the property
  11050. * @param condition defines the trigger related conditions
  11051. */
  11052. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11053. /** @hidden */
  11054. _prepare(): void;
  11055. /**
  11056. * Execute the action and set the targetted property to the desired value.
  11057. */
  11058. execute(): void;
  11059. /**
  11060. * Serializes the actions and its related information.
  11061. * @param parent defines the object to serialize in
  11062. * @returns the serialized object
  11063. */
  11064. serialize(parent: any): any;
  11065. }
  11066. /**
  11067. * This defines an action responsible to increment the target value
  11068. * to a desired value once triggered.
  11069. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11070. */
  11071. export class IncrementValueAction extends Action {
  11072. /**
  11073. * The path of the property to increment in the target.
  11074. */
  11075. propertyPath: string;
  11076. /**
  11077. * The value we should increment the property by.
  11078. */
  11079. value: any;
  11080. private _target;
  11081. private _effectiveTarget;
  11082. private _property;
  11083. /**
  11084. * Instantiate the action
  11085. * @param triggerOptions defines the trigger options
  11086. * @param target defines the object containing the property
  11087. * @param propertyPath defines the path of the property to increment in the target
  11088. * @param value defines the value value we should increment the property by
  11089. * @param condition defines the trigger related conditions
  11090. */
  11091. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11092. /** @hidden */
  11093. _prepare(): void;
  11094. /**
  11095. * Execute the action and increment the target of the value amount.
  11096. */
  11097. execute(): void;
  11098. /**
  11099. * Serializes the actions and its related information.
  11100. * @param parent defines the object to serialize in
  11101. * @returns the serialized object
  11102. */
  11103. serialize(parent: any): any;
  11104. }
  11105. /**
  11106. * This defines an action responsible to start an animation once triggered.
  11107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11108. */
  11109. export class PlayAnimationAction extends Action {
  11110. /**
  11111. * Where the animation should start (animation frame)
  11112. */
  11113. from: number;
  11114. /**
  11115. * Where the animation should stop (animation frame)
  11116. */
  11117. to: number;
  11118. /**
  11119. * Define if the animation should loop or stop after the first play.
  11120. */
  11121. loop?: boolean;
  11122. private _target;
  11123. /**
  11124. * Instantiate the action
  11125. * @param triggerOptions defines the trigger options
  11126. * @param target defines the target animation or animation name
  11127. * @param from defines from where the animation should start (animation frame)
  11128. * @param end defines where the animation should stop (animation frame)
  11129. * @param loop defines if the animation should loop or stop after the first play
  11130. * @param condition defines the trigger related conditions
  11131. */
  11132. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11133. /** @hidden */
  11134. _prepare(): void;
  11135. /**
  11136. * Execute the action and play the animation.
  11137. */
  11138. execute(): void;
  11139. /**
  11140. * Serializes the actions and its related information.
  11141. * @param parent defines the object to serialize in
  11142. * @returns the serialized object
  11143. */
  11144. serialize(parent: any): any;
  11145. }
  11146. /**
  11147. * This defines an action responsible to stop an animation once triggered.
  11148. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11149. */
  11150. export class StopAnimationAction extends Action {
  11151. private _target;
  11152. /**
  11153. * Instantiate the action
  11154. * @param triggerOptions defines the trigger options
  11155. * @param target defines the target animation or animation name
  11156. * @param condition defines the trigger related conditions
  11157. */
  11158. constructor(triggerOptions: any, target: any, condition?: Condition);
  11159. /** @hidden */
  11160. _prepare(): void;
  11161. /**
  11162. * Execute the action and stop the animation.
  11163. */
  11164. execute(): void;
  11165. /**
  11166. * Serializes the actions and its related information.
  11167. * @param parent defines the object to serialize in
  11168. * @returns the serialized object
  11169. */
  11170. serialize(parent: any): any;
  11171. }
  11172. /**
  11173. * This defines an action responsible that does nothing once triggered.
  11174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11175. */
  11176. export class DoNothingAction extends Action {
  11177. /**
  11178. * Instantiate the action
  11179. * @param triggerOptions defines the trigger options
  11180. * @param condition defines the trigger related conditions
  11181. */
  11182. constructor(triggerOptions?: any, condition?: Condition);
  11183. /**
  11184. * Execute the action and do nothing.
  11185. */
  11186. execute(): void;
  11187. /**
  11188. * Serializes the actions and its related information.
  11189. * @param parent defines the object to serialize in
  11190. * @returns the serialized object
  11191. */
  11192. serialize(parent: any): any;
  11193. }
  11194. /**
  11195. * This defines an action responsible to trigger several actions once triggered.
  11196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11197. */
  11198. export class CombineAction extends Action {
  11199. /**
  11200. * The list of aggregated animations to run.
  11201. */
  11202. children: Action[];
  11203. /**
  11204. * Instantiate the action
  11205. * @param triggerOptions defines the trigger options
  11206. * @param children defines the list of aggregated animations to run
  11207. * @param condition defines the trigger related conditions
  11208. */
  11209. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11210. /** @hidden */
  11211. _prepare(): void;
  11212. /**
  11213. * Execute the action and executes all the aggregated actions.
  11214. */
  11215. execute(evt: ActionEvent): void;
  11216. /**
  11217. * Serializes the actions and its related information.
  11218. * @param parent defines the object to serialize in
  11219. * @returns the serialized object
  11220. */
  11221. serialize(parent: any): any;
  11222. }
  11223. /**
  11224. * This defines an action responsible to run code (external event) once triggered.
  11225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11226. */
  11227. export class ExecuteCodeAction extends Action {
  11228. /**
  11229. * The callback function to run.
  11230. */
  11231. func: (evt: ActionEvent) => void;
  11232. /**
  11233. * Instantiate the action
  11234. * @param triggerOptions defines the trigger options
  11235. * @param func defines the callback function to run
  11236. * @param condition defines the trigger related conditions
  11237. */
  11238. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11239. /**
  11240. * Execute the action and run the attached code.
  11241. */
  11242. execute(evt: ActionEvent): void;
  11243. }
  11244. /**
  11245. * This defines an action responsible to set the parent property of the target once triggered.
  11246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11247. */
  11248. export class SetParentAction extends Action {
  11249. private _parent;
  11250. private _target;
  11251. /**
  11252. * Instantiate the action
  11253. * @param triggerOptions defines the trigger options
  11254. * @param target defines the target containing the parent property
  11255. * @param parent defines from where the animation should start (animation frame)
  11256. * @param condition defines the trigger related conditions
  11257. */
  11258. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11259. /** @hidden */
  11260. _prepare(): void;
  11261. /**
  11262. * Execute the action and set the parent property.
  11263. */
  11264. execute(): void;
  11265. /**
  11266. * Serializes the actions and its related information.
  11267. * @param parent defines the object to serialize in
  11268. * @returns the serialized object
  11269. */
  11270. serialize(parent: any): any;
  11271. }
  11272. }
  11273. declare module BABYLON {
  11274. /**
  11275. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11276. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11277. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11278. */
  11279. export class ActionManager extends AbstractActionManager {
  11280. /**
  11281. * Nothing
  11282. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11283. */
  11284. static readonly NothingTrigger: number;
  11285. /**
  11286. * On pick
  11287. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11288. */
  11289. static readonly OnPickTrigger: number;
  11290. /**
  11291. * On left pick
  11292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11293. */
  11294. static readonly OnLeftPickTrigger: number;
  11295. /**
  11296. * On right pick
  11297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11298. */
  11299. static readonly OnRightPickTrigger: number;
  11300. /**
  11301. * On center pick
  11302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11303. */
  11304. static readonly OnCenterPickTrigger: number;
  11305. /**
  11306. * On pick down
  11307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11308. */
  11309. static readonly OnPickDownTrigger: number;
  11310. /**
  11311. * On double pick
  11312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11313. */
  11314. static readonly OnDoublePickTrigger: number;
  11315. /**
  11316. * On pick up
  11317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11318. */
  11319. static readonly OnPickUpTrigger: number;
  11320. /**
  11321. * On pick out.
  11322. * This trigger will only be raised if you also declared a OnPickDown
  11323. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11324. */
  11325. static readonly OnPickOutTrigger: number;
  11326. /**
  11327. * On long press
  11328. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11329. */
  11330. static readonly OnLongPressTrigger: number;
  11331. /**
  11332. * On pointer over
  11333. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11334. */
  11335. static readonly OnPointerOverTrigger: number;
  11336. /**
  11337. * On pointer out
  11338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11339. */
  11340. static readonly OnPointerOutTrigger: number;
  11341. /**
  11342. * On every frame
  11343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11344. */
  11345. static readonly OnEveryFrameTrigger: number;
  11346. /**
  11347. * On intersection enter
  11348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11349. */
  11350. static readonly OnIntersectionEnterTrigger: number;
  11351. /**
  11352. * On intersection exit
  11353. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11354. */
  11355. static readonly OnIntersectionExitTrigger: number;
  11356. /**
  11357. * On key down
  11358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11359. */
  11360. static readonly OnKeyDownTrigger: number;
  11361. /**
  11362. * On key up
  11363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11364. */
  11365. static readonly OnKeyUpTrigger: number;
  11366. private _scene;
  11367. /**
  11368. * Creates a new action manager
  11369. * @param scene defines the hosting scene
  11370. */
  11371. constructor(scene: Scene);
  11372. /**
  11373. * Releases all associated resources
  11374. */
  11375. dispose(): void;
  11376. /**
  11377. * Gets hosting scene
  11378. * @returns the hosting scene
  11379. */
  11380. getScene(): Scene;
  11381. /**
  11382. * Does this action manager handles actions of any of the given triggers
  11383. * @param triggers defines the triggers to be tested
  11384. * @return a boolean indicating whether one (or more) of the triggers is handled
  11385. */
  11386. hasSpecificTriggers(triggers: number[]): boolean;
  11387. /**
  11388. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11389. * speed.
  11390. * @param triggerA defines the trigger to be tested
  11391. * @param triggerB defines the trigger to be tested
  11392. * @return a boolean indicating whether one (or more) of the triggers is handled
  11393. */
  11394. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11395. /**
  11396. * Does this action manager handles actions of a given trigger
  11397. * @param trigger defines the trigger to be tested
  11398. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11399. * @return whether the trigger is handled
  11400. */
  11401. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11402. /**
  11403. * Does this action manager has pointer triggers
  11404. */
  11405. readonly hasPointerTriggers: boolean;
  11406. /**
  11407. * Does this action manager has pick triggers
  11408. */
  11409. readonly hasPickTriggers: boolean;
  11410. /**
  11411. * Registers an action to this action manager
  11412. * @param action defines the action to be registered
  11413. * @return the action amended (prepared) after registration
  11414. */
  11415. registerAction(action: IAction): Nullable<IAction>;
  11416. /**
  11417. * Unregisters an action to this action manager
  11418. * @param action defines the action to be unregistered
  11419. * @return a boolean indicating whether the action has been unregistered
  11420. */
  11421. unregisterAction(action: IAction): Boolean;
  11422. /**
  11423. * Process a specific trigger
  11424. * @param trigger defines the trigger to process
  11425. * @param evt defines the event details to be processed
  11426. */
  11427. processTrigger(trigger: number, evt?: IActionEvent): void;
  11428. /** @hidden */
  11429. _getEffectiveTarget(target: any, propertyPath: string): any;
  11430. /** @hidden */
  11431. _getProperty(propertyPath: string): string;
  11432. /**
  11433. * Serialize this manager to a JSON object
  11434. * @param name defines the property name to store this manager
  11435. * @returns a JSON representation of this manager
  11436. */
  11437. serialize(name: string): any;
  11438. /**
  11439. * Creates a new ActionManager from a JSON data
  11440. * @param parsedActions defines the JSON data to read from
  11441. * @param object defines the hosting mesh
  11442. * @param scene defines the hosting scene
  11443. */
  11444. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11445. /**
  11446. * Get a trigger name by index
  11447. * @param trigger defines the trigger index
  11448. * @returns a trigger name
  11449. */
  11450. static GetTriggerName(trigger: number): string;
  11451. }
  11452. }
  11453. declare module BABYLON {
  11454. /**
  11455. * Class representing a ray with position and direction
  11456. */
  11457. export class Ray {
  11458. /** origin point */
  11459. origin: Vector3;
  11460. /** direction */
  11461. direction: Vector3;
  11462. /** length of the ray */
  11463. length: number;
  11464. private static readonly TmpVector3;
  11465. private _tmpRay;
  11466. /**
  11467. * Creates a new ray
  11468. * @param origin origin point
  11469. * @param direction direction
  11470. * @param length length of the ray
  11471. */
  11472. constructor(
  11473. /** origin point */
  11474. origin: Vector3,
  11475. /** direction */
  11476. direction: Vector3,
  11477. /** length of the ray */
  11478. length?: number);
  11479. /**
  11480. * Checks if the ray intersects a box
  11481. * @param minimum bound of the box
  11482. * @param maximum bound of the box
  11483. * @param intersectionTreshold extra extend to be added to the box in all direction
  11484. * @returns if the box was hit
  11485. */
  11486. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11487. /**
  11488. * Checks if the ray intersects a box
  11489. * @param box the bounding box to check
  11490. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11491. * @returns if the box was hit
  11492. */
  11493. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11494. /**
  11495. * If the ray hits a sphere
  11496. * @param sphere the bounding sphere to check
  11497. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11498. * @returns true if it hits the sphere
  11499. */
  11500. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11501. /**
  11502. * If the ray hits a triange
  11503. * @param vertex0 triangle vertex
  11504. * @param vertex1 triangle vertex
  11505. * @param vertex2 triangle vertex
  11506. * @returns intersection information if hit
  11507. */
  11508. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11509. /**
  11510. * Checks if ray intersects a plane
  11511. * @param plane the plane to check
  11512. * @returns the distance away it was hit
  11513. */
  11514. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11515. /**
  11516. * Checks if ray intersects a mesh
  11517. * @param mesh the mesh to check
  11518. * @param fastCheck if only the bounding box should checked
  11519. * @returns picking info of the intersecton
  11520. */
  11521. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11522. /**
  11523. * Checks if ray intersects a mesh
  11524. * @param meshes the meshes to check
  11525. * @param fastCheck if only the bounding box should checked
  11526. * @param results array to store result in
  11527. * @returns Array of picking infos
  11528. */
  11529. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11530. private _comparePickingInfo;
  11531. private static smallnum;
  11532. private static rayl;
  11533. /**
  11534. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11535. * @param sega the first point of the segment to test the intersection against
  11536. * @param segb the second point of the segment to test the intersection against
  11537. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11538. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11539. */
  11540. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11541. /**
  11542. * Update the ray from viewport position
  11543. * @param x position
  11544. * @param y y position
  11545. * @param viewportWidth viewport width
  11546. * @param viewportHeight viewport height
  11547. * @param world world matrix
  11548. * @param view view matrix
  11549. * @param projection projection matrix
  11550. * @returns this ray updated
  11551. */
  11552. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11553. /**
  11554. * Creates a ray with origin and direction of 0,0,0
  11555. * @returns the new ray
  11556. */
  11557. static Zero(): Ray;
  11558. /**
  11559. * Creates a new ray from screen space and viewport
  11560. * @param x position
  11561. * @param y y position
  11562. * @param viewportWidth viewport width
  11563. * @param viewportHeight viewport height
  11564. * @param world world matrix
  11565. * @param view view matrix
  11566. * @param projection projection matrix
  11567. * @returns new ray
  11568. */
  11569. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11570. /**
  11571. * 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
  11572. * transformed to the given world matrix.
  11573. * @param origin The origin point
  11574. * @param end The end point
  11575. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11576. * @returns the new ray
  11577. */
  11578. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11579. /**
  11580. * Transforms a ray by a matrix
  11581. * @param ray ray to transform
  11582. * @param matrix matrix to apply
  11583. * @returns the resulting new ray
  11584. */
  11585. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11586. /**
  11587. * Transforms a ray by a matrix
  11588. * @param ray ray to transform
  11589. * @param matrix matrix to apply
  11590. * @param result ray to store result in
  11591. */
  11592. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11593. /**
  11594. * Unproject a ray from screen space to object space
  11595. * @param sourceX defines the screen space x coordinate to use
  11596. * @param sourceY defines the screen space y coordinate to use
  11597. * @param viewportWidth defines the current width of the viewport
  11598. * @param viewportHeight defines the current height of the viewport
  11599. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11600. * @param view defines the view matrix to use
  11601. * @param projection defines the projection matrix to use
  11602. */
  11603. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11604. }
  11605. /**
  11606. * Type used to define predicate used to select faces when a mesh intersection is detected
  11607. */
  11608. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11609. interface Scene {
  11610. /** @hidden */
  11611. _tempPickingRay: Nullable<Ray>;
  11612. /** @hidden */
  11613. _cachedRayForTransform: Ray;
  11614. /** @hidden */
  11615. _pickWithRayInverseMatrix: Matrix;
  11616. /** @hidden */
  11617. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11618. /** @hidden */
  11619. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11620. }
  11621. }
  11622. declare module BABYLON {
  11623. /**
  11624. * Groups all the scene component constants in one place to ease maintenance.
  11625. * @hidden
  11626. */
  11627. export class SceneComponentConstants {
  11628. static readonly NAME_EFFECTLAYER: string;
  11629. static readonly NAME_LAYER: string;
  11630. static readonly NAME_LENSFLARESYSTEM: string;
  11631. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11632. static readonly NAME_PARTICLESYSTEM: string;
  11633. static readonly NAME_GAMEPAD: string;
  11634. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11635. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11636. static readonly NAME_DEPTHRENDERER: string;
  11637. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11638. static readonly NAME_SPRITE: string;
  11639. static readonly NAME_OUTLINERENDERER: string;
  11640. static readonly NAME_PROCEDURALTEXTURE: string;
  11641. static readonly NAME_SHADOWGENERATOR: string;
  11642. static readonly NAME_OCTREE: string;
  11643. static readonly NAME_PHYSICSENGINE: string;
  11644. static readonly NAME_AUDIO: string;
  11645. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11646. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11647. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11648. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11649. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11650. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11651. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11652. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11653. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11654. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11655. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11656. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11657. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11658. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11659. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11660. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11661. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11662. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11663. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11664. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11665. static readonly STEP_AFTERRENDER_AUDIO: number;
  11666. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11667. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11668. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11669. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11670. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11671. static readonly STEP_POINTERMOVE_SPRITE: number;
  11672. static readonly STEP_POINTERDOWN_SPRITE: number;
  11673. static readonly STEP_POINTERUP_SPRITE: number;
  11674. }
  11675. /**
  11676. * This represents a scene component.
  11677. *
  11678. * This is used to decouple the dependency the scene is having on the different workloads like
  11679. * layers, post processes...
  11680. */
  11681. export interface ISceneComponent {
  11682. /**
  11683. * The name of the component. Each component must have a unique name.
  11684. */
  11685. name: string;
  11686. /**
  11687. * The scene the component belongs to.
  11688. */
  11689. scene: Scene;
  11690. /**
  11691. * Register the component to one instance of a scene.
  11692. */
  11693. register(): void;
  11694. /**
  11695. * Rebuilds the elements related to this component in case of
  11696. * context lost for instance.
  11697. */
  11698. rebuild(): void;
  11699. /**
  11700. * Disposes the component and the associated ressources.
  11701. */
  11702. dispose(): void;
  11703. }
  11704. /**
  11705. * This represents a SERIALIZABLE scene component.
  11706. *
  11707. * This extends Scene Component to add Serialization methods on top.
  11708. */
  11709. export interface ISceneSerializableComponent extends ISceneComponent {
  11710. /**
  11711. * Adds all the elements from the container to the scene
  11712. * @param container the container holding the elements
  11713. */
  11714. addFromContainer(container: AbstractScene): void;
  11715. /**
  11716. * Removes all the elements in the container from the scene
  11717. * @param container contains the elements to remove
  11718. * @param dispose if the removed element should be disposed (default: false)
  11719. */
  11720. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11721. /**
  11722. * Serializes the component data to the specified json object
  11723. * @param serializationObject The object to serialize to
  11724. */
  11725. serialize(serializationObject: any): void;
  11726. }
  11727. /**
  11728. * Strong typing of a Mesh related stage step action
  11729. */
  11730. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11731. /**
  11732. * Strong typing of a Evaluate Sub Mesh related stage step action
  11733. */
  11734. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11735. /**
  11736. * Strong typing of a Active Mesh related stage step action
  11737. */
  11738. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11739. /**
  11740. * Strong typing of a Camera related stage step action
  11741. */
  11742. export type CameraStageAction = (camera: Camera) => void;
  11743. /**
  11744. * Strong typing of a Camera Frame buffer related stage step action
  11745. */
  11746. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11747. /**
  11748. * Strong typing of a Render Target related stage step action
  11749. */
  11750. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11751. /**
  11752. * Strong typing of a RenderingGroup related stage step action
  11753. */
  11754. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11755. /**
  11756. * Strong typing of a Mesh Render related stage step action
  11757. */
  11758. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11759. /**
  11760. * Strong typing of a simple stage step action
  11761. */
  11762. export type SimpleStageAction = () => void;
  11763. /**
  11764. * Strong typing of a render target action.
  11765. */
  11766. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11767. /**
  11768. * Strong typing of a pointer move action.
  11769. */
  11770. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11771. /**
  11772. * Strong typing of a pointer up/down action.
  11773. */
  11774. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11775. /**
  11776. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11777. * @hidden
  11778. */
  11779. export class Stage<T extends Function> extends Array<{
  11780. index: number;
  11781. component: ISceneComponent;
  11782. action: T;
  11783. }> {
  11784. /**
  11785. * Hide ctor from the rest of the world.
  11786. * @param items The items to add.
  11787. */
  11788. private constructor();
  11789. /**
  11790. * Creates a new Stage.
  11791. * @returns A new instance of a Stage
  11792. */
  11793. static Create<T extends Function>(): Stage<T>;
  11794. /**
  11795. * Registers a step in an ordered way in the targeted stage.
  11796. * @param index Defines the position to register the step in
  11797. * @param component Defines the component attached to the step
  11798. * @param action Defines the action to launch during the step
  11799. */
  11800. registerStep(index: number, component: ISceneComponent, action: T): void;
  11801. /**
  11802. * Clears all the steps from the stage.
  11803. */
  11804. clear(): void;
  11805. }
  11806. }
  11807. declare module BABYLON {
  11808. interface Scene {
  11809. /** @hidden */
  11810. _pointerOverSprite: Nullable<Sprite>;
  11811. /** @hidden */
  11812. _pickedDownSprite: Nullable<Sprite>;
  11813. /** @hidden */
  11814. _tempSpritePickingRay: Nullable<Ray>;
  11815. /**
  11816. * All of the sprite managers added to this scene
  11817. * @see http://doc.babylonjs.com/babylon101/sprites
  11818. */
  11819. spriteManagers: Array<ISpriteManager>;
  11820. /**
  11821. * An event triggered when sprites rendering is about to start
  11822. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11823. */
  11824. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11825. /**
  11826. * An event triggered when sprites rendering is done
  11827. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11828. */
  11829. onAfterSpritesRenderingObservable: Observable<Scene>;
  11830. /** @hidden */
  11831. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11832. /** Launch a ray to try to pick a sprite in the scene
  11833. * @param x position on screen
  11834. * @param y position on screen
  11835. * @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
  11836. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11837. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11838. * @returns a PickingInfo
  11839. */
  11840. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11841. /** Use the given ray to pick a sprite in the scene
  11842. * @param ray The ray (in world space) to use to pick meshes
  11843. * @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
  11844. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11845. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11846. * @returns a PickingInfo
  11847. */
  11848. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11849. /**
  11850. * Force the sprite under the pointer
  11851. * @param sprite defines the sprite to use
  11852. */
  11853. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11854. /**
  11855. * Gets the sprite under the pointer
  11856. * @returns a Sprite or null if no sprite is under the pointer
  11857. */
  11858. getPointerOverSprite(): Nullable<Sprite>;
  11859. }
  11860. /**
  11861. * Defines the sprite scene component responsible to manage sprites
  11862. * in a given scene.
  11863. */
  11864. export class SpriteSceneComponent implements ISceneComponent {
  11865. /**
  11866. * The component name helpfull to identify the component in the list of scene components.
  11867. */
  11868. readonly name: string;
  11869. /**
  11870. * The scene the component belongs to.
  11871. */
  11872. scene: Scene;
  11873. /** @hidden */
  11874. private _spritePredicate;
  11875. /**
  11876. * Creates a new instance of the component for the given scene
  11877. * @param scene Defines the scene to register the component in
  11878. */
  11879. constructor(scene: Scene);
  11880. /**
  11881. * Registers the component in a given scene
  11882. */
  11883. register(): void;
  11884. /**
  11885. * Rebuilds the elements related to this component in case of
  11886. * context lost for instance.
  11887. */
  11888. rebuild(): void;
  11889. /**
  11890. * Disposes the component and the associated ressources.
  11891. */
  11892. dispose(): void;
  11893. private _pickSpriteButKeepRay;
  11894. private _pointerMove;
  11895. private _pointerDown;
  11896. private _pointerUp;
  11897. }
  11898. }
  11899. declare module BABYLON {
  11900. /** @hidden */
  11901. export var fogFragmentDeclaration: {
  11902. name: string;
  11903. shader: string;
  11904. };
  11905. }
  11906. declare module BABYLON {
  11907. /** @hidden */
  11908. export var fogFragment: {
  11909. name: string;
  11910. shader: string;
  11911. };
  11912. }
  11913. declare module BABYLON {
  11914. /** @hidden */
  11915. export var spritesPixelShader: {
  11916. name: string;
  11917. shader: string;
  11918. };
  11919. }
  11920. declare module BABYLON {
  11921. /** @hidden */
  11922. export var fogVertexDeclaration: {
  11923. name: string;
  11924. shader: string;
  11925. };
  11926. }
  11927. declare module BABYLON {
  11928. /** @hidden */
  11929. export var spritesVertexShader: {
  11930. name: string;
  11931. shader: string;
  11932. };
  11933. }
  11934. declare module BABYLON {
  11935. /**
  11936. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11937. */
  11938. export interface ISpriteManager extends IDisposable {
  11939. /**
  11940. * Restricts the camera to viewing objects with the same layerMask.
  11941. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11942. */
  11943. layerMask: number;
  11944. /**
  11945. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11946. */
  11947. isPickable: boolean;
  11948. /**
  11949. * Specifies the rendering group id for this mesh (0 by default)
  11950. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11951. */
  11952. renderingGroupId: number;
  11953. /**
  11954. * Defines the list of sprites managed by the manager.
  11955. */
  11956. sprites: Array<Sprite>;
  11957. /**
  11958. * Tests the intersection of a sprite with a specific ray.
  11959. * @param ray The ray we are sending to test the collision
  11960. * @param camera The camera space we are sending rays in
  11961. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11962. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11963. * @returns picking info or null.
  11964. */
  11965. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11966. /**
  11967. * Renders the list of sprites on screen.
  11968. */
  11969. render(): void;
  11970. }
  11971. /**
  11972. * Class used to manage multiple sprites on the same spritesheet
  11973. * @see http://doc.babylonjs.com/babylon101/sprites
  11974. */
  11975. export class SpriteManager implements ISpriteManager {
  11976. /** defines the manager's name */
  11977. name: string;
  11978. /** Gets the list of sprites */
  11979. sprites: Sprite[];
  11980. /** Gets or sets the rendering group id (0 by default) */
  11981. renderingGroupId: number;
  11982. /** Gets or sets camera layer mask */
  11983. layerMask: number;
  11984. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11985. fogEnabled: boolean;
  11986. /** Gets or sets a boolean indicating if the sprites are pickable */
  11987. isPickable: boolean;
  11988. /** Defines the default width of a cell in the spritesheet */
  11989. cellWidth: number;
  11990. /** Defines the default height of a cell in the spritesheet */
  11991. cellHeight: number;
  11992. /**
  11993. * An event triggered when the manager is disposed.
  11994. */
  11995. onDisposeObservable: Observable<SpriteManager>;
  11996. private _onDisposeObserver;
  11997. /**
  11998. * Callback called when the manager is disposed
  11999. */
  12000. onDispose: () => void;
  12001. private _capacity;
  12002. private _spriteTexture;
  12003. private _epsilon;
  12004. private _scene;
  12005. private _vertexData;
  12006. private _buffer;
  12007. private _vertexBuffers;
  12008. private _indexBuffer;
  12009. private _effectBase;
  12010. private _effectFog;
  12011. /**
  12012. * Gets or sets the spritesheet texture
  12013. */
  12014. texture: Texture;
  12015. /**
  12016. * Creates a new sprite manager
  12017. * @param name defines the manager's name
  12018. * @param imgUrl defines the sprite sheet url
  12019. * @param capacity defines the maximum allowed number of sprites
  12020. * @param cellSize defines the size of a sprite cell
  12021. * @param scene defines the hosting scene
  12022. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12023. * @param samplingMode defines the smapling mode to use with spritesheet
  12024. */
  12025. constructor(
  12026. /** defines the manager's name */
  12027. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  12028. private _appendSpriteVertex;
  12029. /**
  12030. * Intersects the sprites with a ray
  12031. * @param ray defines the ray to intersect with
  12032. * @param camera defines the current active camera
  12033. * @param predicate defines a predicate used to select candidate sprites
  12034. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12035. * @returns null if no hit or a PickingInfo
  12036. */
  12037. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12038. /**
  12039. * Render all child sprites
  12040. */
  12041. render(): void;
  12042. /**
  12043. * Release associated resources
  12044. */
  12045. dispose(): void;
  12046. }
  12047. }
  12048. declare module BABYLON {
  12049. /**
  12050. * Class used to represent a sprite
  12051. * @see http://doc.babylonjs.com/babylon101/sprites
  12052. */
  12053. export class Sprite {
  12054. /** defines the name */
  12055. name: string;
  12056. /** Gets or sets the current world position */
  12057. position: Vector3;
  12058. /** Gets or sets the main color */
  12059. color: Color4;
  12060. /** Gets or sets the width */
  12061. width: number;
  12062. /** Gets or sets the height */
  12063. height: number;
  12064. /** Gets or sets rotation angle */
  12065. angle: number;
  12066. /** Gets or sets the cell index in the sprite sheet */
  12067. cellIndex: number;
  12068. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12069. invertU: number;
  12070. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12071. invertV: number;
  12072. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12073. disposeWhenFinishedAnimating: boolean;
  12074. /** Gets the list of attached animations */
  12075. animations: Animation[];
  12076. /** Gets or sets a boolean indicating if the sprite can be picked */
  12077. isPickable: boolean;
  12078. /**
  12079. * Gets or sets the associated action manager
  12080. */
  12081. actionManager: Nullable<ActionManager>;
  12082. private _animationStarted;
  12083. private _loopAnimation;
  12084. private _fromIndex;
  12085. private _toIndex;
  12086. private _delay;
  12087. private _direction;
  12088. private _manager;
  12089. private _time;
  12090. private _onAnimationEnd;
  12091. /**
  12092. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12093. */
  12094. isVisible: boolean;
  12095. /**
  12096. * Gets or sets the sprite size
  12097. */
  12098. size: number;
  12099. /**
  12100. * Creates a new Sprite
  12101. * @param name defines the name
  12102. * @param manager defines the manager
  12103. */
  12104. constructor(
  12105. /** defines the name */
  12106. name: string, manager: ISpriteManager);
  12107. /**
  12108. * Starts an animation
  12109. * @param from defines the initial key
  12110. * @param to defines the end key
  12111. * @param loop defines if the animation must loop
  12112. * @param delay defines the start delay (in ms)
  12113. * @param onAnimationEnd defines a callback to call when animation ends
  12114. */
  12115. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12116. /** Stops current animation (if any) */
  12117. stopAnimation(): void;
  12118. /** @hidden */
  12119. _animate(deltaTime: number): void;
  12120. /** Release associated resources */
  12121. dispose(): void;
  12122. }
  12123. }
  12124. declare module BABYLON {
  12125. /**
  12126. * Information about the result of picking within a scene
  12127. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12128. */
  12129. export class PickingInfo {
  12130. /** @hidden */
  12131. _pickingUnavailable: boolean;
  12132. /**
  12133. * If the pick collided with an object
  12134. */
  12135. hit: boolean;
  12136. /**
  12137. * Distance away where the pick collided
  12138. */
  12139. distance: number;
  12140. /**
  12141. * The location of pick collision
  12142. */
  12143. pickedPoint: Nullable<Vector3>;
  12144. /**
  12145. * The mesh corresponding the the pick collision
  12146. */
  12147. pickedMesh: Nullable<AbstractMesh>;
  12148. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12149. bu: number;
  12150. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12151. bv: number;
  12152. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12153. faceId: number;
  12154. /** Id of the the submesh that was picked */
  12155. subMeshId: number;
  12156. /** If a sprite was picked, this will be the sprite the pick collided with */
  12157. pickedSprite: Nullable<Sprite>;
  12158. /**
  12159. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12160. */
  12161. originMesh: Nullable<AbstractMesh>;
  12162. /**
  12163. * The ray that was used to perform the picking.
  12164. */
  12165. ray: Nullable<Ray>;
  12166. /**
  12167. * Gets the normal correspodning to the face the pick collided with
  12168. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12169. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12170. * @returns The normal correspodning to the face the pick collided with
  12171. */
  12172. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12173. /**
  12174. * Gets the texture coordinates of where the pick occured
  12175. * @returns the vector containing the coordnates of the texture
  12176. */
  12177. getTextureCoordinates(): Nullable<Vector2>;
  12178. }
  12179. }
  12180. declare module BABYLON {
  12181. /**
  12182. * Gather the list of pointer event types as constants.
  12183. */
  12184. export class PointerEventTypes {
  12185. /**
  12186. * 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.
  12187. */
  12188. static readonly POINTERDOWN: number;
  12189. /**
  12190. * The pointerup event is fired when a pointer is no longer active.
  12191. */
  12192. static readonly POINTERUP: number;
  12193. /**
  12194. * The pointermove event is fired when a pointer changes coordinates.
  12195. */
  12196. static readonly POINTERMOVE: number;
  12197. /**
  12198. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12199. */
  12200. static readonly POINTERWHEEL: number;
  12201. /**
  12202. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12203. */
  12204. static readonly POINTERPICK: number;
  12205. /**
  12206. * The pointertap event is fired when a the object has been touched and released without drag.
  12207. */
  12208. static readonly POINTERTAP: number;
  12209. /**
  12210. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12211. */
  12212. static readonly POINTERDOUBLETAP: number;
  12213. }
  12214. /**
  12215. * Base class of pointer info types.
  12216. */
  12217. export class PointerInfoBase {
  12218. /**
  12219. * Defines the type of event (PointerEventTypes)
  12220. */
  12221. type: number;
  12222. /**
  12223. * Defines the related dom event
  12224. */
  12225. event: PointerEvent | MouseWheelEvent;
  12226. /**
  12227. * Instantiates the base class of pointers info.
  12228. * @param type Defines the type of event (PointerEventTypes)
  12229. * @param event Defines the related dom event
  12230. */
  12231. constructor(
  12232. /**
  12233. * Defines the type of event (PointerEventTypes)
  12234. */
  12235. type: number,
  12236. /**
  12237. * Defines the related dom event
  12238. */
  12239. event: PointerEvent | MouseWheelEvent);
  12240. }
  12241. /**
  12242. * This class is used to store pointer related info for the onPrePointerObservable event.
  12243. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12244. */
  12245. export class PointerInfoPre extends PointerInfoBase {
  12246. /**
  12247. * Ray from a pointer if availible (eg. 6dof controller)
  12248. */
  12249. ray: Nullable<Ray>;
  12250. /**
  12251. * Defines the local position of the pointer on the canvas.
  12252. */
  12253. localPosition: Vector2;
  12254. /**
  12255. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12256. */
  12257. skipOnPointerObservable: boolean;
  12258. /**
  12259. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12260. * @param type Defines the type of event (PointerEventTypes)
  12261. * @param event Defines the related dom event
  12262. * @param localX Defines the local x coordinates of the pointer when the event occured
  12263. * @param localY Defines the local y coordinates of the pointer when the event occured
  12264. */
  12265. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12266. }
  12267. /**
  12268. * This type contains all the data related to a pointer event in Babylon.js.
  12269. * 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.
  12270. */
  12271. export class PointerInfo extends PointerInfoBase {
  12272. /**
  12273. * Defines the picking info associated to the info (if any)\
  12274. */
  12275. pickInfo: Nullable<PickingInfo>;
  12276. /**
  12277. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12278. * @param type Defines the type of event (PointerEventTypes)
  12279. * @param event Defines the related dom event
  12280. * @param pickInfo Defines the picking info associated to the info (if any)\
  12281. */
  12282. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12283. /**
  12284. * Defines the picking info associated to the info (if any)\
  12285. */
  12286. pickInfo: Nullable<PickingInfo>);
  12287. }
  12288. /**
  12289. * Data relating to a touch event on the screen.
  12290. */
  12291. export interface PointerTouch {
  12292. /**
  12293. * X coordinate of touch.
  12294. */
  12295. x: number;
  12296. /**
  12297. * Y coordinate of touch.
  12298. */
  12299. y: number;
  12300. /**
  12301. * Id of touch. Unique for each finger.
  12302. */
  12303. pointerId: number;
  12304. /**
  12305. * Event type passed from DOM.
  12306. */
  12307. type: any;
  12308. }
  12309. }
  12310. declare module BABYLON {
  12311. /**
  12312. * Manage the mouse inputs to control the movement of a free camera.
  12313. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12314. */
  12315. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12316. /**
  12317. * Define if touch is enabled in the mouse input
  12318. */
  12319. touchEnabled: boolean;
  12320. /**
  12321. * Defines the camera the input is attached to.
  12322. */
  12323. camera: FreeCamera;
  12324. /**
  12325. * Defines the buttons associated with the input to handle camera move.
  12326. */
  12327. buttons: number[];
  12328. /**
  12329. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12330. */
  12331. angularSensibility: number;
  12332. private _pointerInput;
  12333. private _onMouseMove;
  12334. private _observer;
  12335. private previousPosition;
  12336. /**
  12337. * Observable for when a pointer move event occurs containing the move offset
  12338. */
  12339. onPointerMovedObservable: Observable<{
  12340. offsetX: number;
  12341. offsetY: number;
  12342. }>;
  12343. /**
  12344. * @hidden
  12345. * If the camera should be rotated automatically based on pointer movement
  12346. */
  12347. _allowCameraRotation: boolean;
  12348. /**
  12349. * Manage the mouse inputs to control the movement of a free camera.
  12350. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12351. * @param touchEnabled Defines if touch is enabled or not
  12352. */
  12353. constructor(
  12354. /**
  12355. * Define if touch is enabled in the mouse input
  12356. */
  12357. touchEnabled?: boolean);
  12358. /**
  12359. * Attach the input controls to a specific dom element to get the input from.
  12360. * @param element Defines the element the controls should be listened from
  12361. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12362. */
  12363. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12364. /**
  12365. * Called on JS contextmenu event.
  12366. * Override this method to provide functionality.
  12367. */
  12368. protected onContextMenu(evt: PointerEvent): void;
  12369. /**
  12370. * Detach the current controls from the specified dom element.
  12371. * @param element Defines the element to stop listening the inputs from
  12372. */
  12373. detachControl(element: Nullable<HTMLElement>): void;
  12374. /**
  12375. * Gets the class name of the current intput.
  12376. * @returns the class name
  12377. */
  12378. getClassName(): string;
  12379. /**
  12380. * Get the friendly name associated with the input class.
  12381. * @returns the input friendly name
  12382. */
  12383. getSimpleName(): string;
  12384. }
  12385. }
  12386. declare module BABYLON {
  12387. /**
  12388. * Manage the touch inputs to control the movement of a free camera.
  12389. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12390. */
  12391. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12392. /**
  12393. * Defines the camera the input is attached to.
  12394. */
  12395. camera: FreeCamera;
  12396. /**
  12397. * Defines the touch sensibility for rotation.
  12398. * The higher the faster.
  12399. */
  12400. touchAngularSensibility: number;
  12401. /**
  12402. * Defines the touch sensibility for move.
  12403. * The higher the faster.
  12404. */
  12405. touchMoveSensibility: number;
  12406. private _offsetX;
  12407. private _offsetY;
  12408. private _pointerPressed;
  12409. private _pointerInput;
  12410. private _observer;
  12411. private _onLostFocus;
  12412. /**
  12413. * Attach the input controls to a specific dom element to get the input from.
  12414. * @param element Defines the element the controls should be listened from
  12415. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12416. */
  12417. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12418. /**
  12419. * Detach the current controls from the specified dom element.
  12420. * @param element Defines the element to stop listening the inputs from
  12421. */
  12422. detachControl(element: Nullable<HTMLElement>): void;
  12423. /**
  12424. * Update the current camera state depending on the inputs that have been used this frame.
  12425. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12426. */
  12427. checkInputs(): void;
  12428. /**
  12429. * Gets the class name of the current intput.
  12430. * @returns the class name
  12431. */
  12432. getClassName(): string;
  12433. /**
  12434. * Get the friendly name associated with the input class.
  12435. * @returns the input friendly name
  12436. */
  12437. getSimpleName(): string;
  12438. }
  12439. }
  12440. declare module BABYLON {
  12441. /**
  12442. * Default Inputs manager for the FreeCamera.
  12443. * It groups all the default supported inputs for ease of use.
  12444. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12445. */
  12446. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12447. /**
  12448. * @hidden
  12449. */
  12450. _mouseInput: Nullable<FreeCameraMouseInput>;
  12451. /**
  12452. * Instantiates a new FreeCameraInputsManager.
  12453. * @param camera Defines the camera the inputs belong to
  12454. */
  12455. constructor(camera: FreeCamera);
  12456. /**
  12457. * Add keyboard input support to the input manager.
  12458. * @returns the current input manager
  12459. */
  12460. addKeyboard(): FreeCameraInputsManager;
  12461. /**
  12462. * Add mouse input support to the input manager.
  12463. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12464. * @returns the current input manager
  12465. */
  12466. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12467. /**
  12468. * Removes the mouse input support from the manager
  12469. * @returns the current input manager
  12470. */
  12471. removeMouse(): FreeCameraInputsManager;
  12472. /**
  12473. * Add touch input support to the input manager.
  12474. * @returns the current input manager
  12475. */
  12476. addTouch(): FreeCameraInputsManager;
  12477. /**
  12478. * Remove all attached input methods from a camera
  12479. */
  12480. clear(): void;
  12481. }
  12482. }
  12483. declare module BABYLON {
  12484. /**
  12485. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12486. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12487. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12488. */
  12489. export class FreeCamera extends TargetCamera {
  12490. /**
  12491. * Define the collision ellipsoid of the camera.
  12492. * This is helpful to simulate a camera body like the player body around the camera
  12493. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12494. */
  12495. ellipsoid: Vector3;
  12496. /**
  12497. * Define an offset for the position of the ellipsoid around the camera.
  12498. * This can be helpful to determine the center of the body near the gravity center of the body
  12499. * instead of its head.
  12500. */
  12501. ellipsoidOffset: Vector3;
  12502. /**
  12503. * Enable or disable collisions of the camera with the rest of the scene objects.
  12504. */
  12505. checkCollisions: boolean;
  12506. /**
  12507. * Enable or disable gravity on the camera.
  12508. */
  12509. applyGravity: boolean;
  12510. /**
  12511. * Define the input manager associated to the camera.
  12512. */
  12513. inputs: FreeCameraInputsManager;
  12514. /**
  12515. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12516. * Higher values reduce sensitivity.
  12517. */
  12518. /**
  12519. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12520. * Higher values reduce sensitivity.
  12521. */
  12522. angularSensibility: number;
  12523. /**
  12524. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12525. */
  12526. keysUp: number[];
  12527. /**
  12528. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12529. */
  12530. keysDown: number[];
  12531. /**
  12532. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12533. */
  12534. keysLeft: number[];
  12535. /**
  12536. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12537. */
  12538. keysRight: number[];
  12539. /**
  12540. * Event raised when the camera collide with a mesh in the scene.
  12541. */
  12542. onCollide: (collidedMesh: AbstractMesh) => void;
  12543. private _collider;
  12544. private _needMoveForGravity;
  12545. private _oldPosition;
  12546. private _diffPosition;
  12547. private _newPosition;
  12548. /** @hidden */
  12549. _localDirection: Vector3;
  12550. /** @hidden */
  12551. _transformedDirection: Vector3;
  12552. /**
  12553. * Instantiates a Free Camera.
  12554. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12555. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12556. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12557. * @param name Define the name of the camera in the scene
  12558. * @param position Define the start position of the camera in the scene
  12559. * @param scene Define the scene the camera belongs to
  12560. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12561. */
  12562. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12563. /**
  12564. * Attached controls to the current camera.
  12565. * @param element Defines the element the controls should be listened from
  12566. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12567. */
  12568. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12569. /**
  12570. * Detach the current controls from the camera.
  12571. * The camera will stop reacting to inputs.
  12572. * @param element Defines the element to stop listening the inputs from
  12573. */
  12574. detachControl(element: HTMLElement): void;
  12575. private _collisionMask;
  12576. /**
  12577. * Define a collision mask to limit the list of object the camera can collide with
  12578. */
  12579. collisionMask: number;
  12580. /** @hidden */
  12581. _collideWithWorld(displacement: Vector3): void;
  12582. private _onCollisionPositionChange;
  12583. /** @hidden */
  12584. _checkInputs(): void;
  12585. /** @hidden */
  12586. _decideIfNeedsToMove(): boolean;
  12587. /** @hidden */
  12588. _updatePosition(): void;
  12589. /**
  12590. * Destroy the camera and release the current resources hold by it.
  12591. */
  12592. dispose(): void;
  12593. /**
  12594. * Gets the current object class name.
  12595. * @return the class name
  12596. */
  12597. getClassName(): string;
  12598. }
  12599. }
  12600. declare module BABYLON {
  12601. /**
  12602. * Represents a gamepad control stick position
  12603. */
  12604. export class StickValues {
  12605. /**
  12606. * The x component of the control stick
  12607. */
  12608. x: number;
  12609. /**
  12610. * The y component of the control stick
  12611. */
  12612. y: number;
  12613. /**
  12614. * Initializes the gamepad x and y control stick values
  12615. * @param x The x component of the gamepad control stick value
  12616. * @param y The y component of the gamepad control stick value
  12617. */
  12618. constructor(
  12619. /**
  12620. * The x component of the control stick
  12621. */
  12622. x: number,
  12623. /**
  12624. * The y component of the control stick
  12625. */
  12626. y: number);
  12627. }
  12628. /**
  12629. * An interface which manages callbacks for gamepad button changes
  12630. */
  12631. export interface GamepadButtonChanges {
  12632. /**
  12633. * Called when a gamepad has been changed
  12634. */
  12635. changed: boolean;
  12636. /**
  12637. * Called when a gamepad press event has been triggered
  12638. */
  12639. pressChanged: boolean;
  12640. /**
  12641. * Called when a touch event has been triggered
  12642. */
  12643. touchChanged: boolean;
  12644. /**
  12645. * Called when a value has changed
  12646. */
  12647. valueChanged: boolean;
  12648. }
  12649. /**
  12650. * Represents a gamepad
  12651. */
  12652. export class Gamepad {
  12653. /**
  12654. * The id of the gamepad
  12655. */
  12656. id: string;
  12657. /**
  12658. * The index of the gamepad
  12659. */
  12660. index: number;
  12661. /**
  12662. * The browser gamepad
  12663. */
  12664. browserGamepad: any;
  12665. /**
  12666. * Specifies what type of gamepad this represents
  12667. */
  12668. type: number;
  12669. private _leftStick;
  12670. private _rightStick;
  12671. /** @hidden */
  12672. _isConnected: boolean;
  12673. private _leftStickAxisX;
  12674. private _leftStickAxisY;
  12675. private _rightStickAxisX;
  12676. private _rightStickAxisY;
  12677. /**
  12678. * Triggered when the left control stick has been changed
  12679. */
  12680. private _onleftstickchanged;
  12681. /**
  12682. * Triggered when the right control stick has been changed
  12683. */
  12684. private _onrightstickchanged;
  12685. /**
  12686. * Represents a gamepad controller
  12687. */
  12688. static GAMEPAD: number;
  12689. /**
  12690. * Represents a generic controller
  12691. */
  12692. static GENERIC: number;
  12693. /**
  12694. * Represents an XBox controller
  12695. */
  12696. static XBOX: number;
  12697. /**
  12698. * Represents a pose-enabled controller
  12699. */
  12700. static POSE_ENABLED: number;
  12701. /**
  12702. * Specifies whether the left control stick should be Y-inverted
  12703. */
  12704. protected _invertLeftStickY: boolean;
  12705. /**
  12706. * Specifies if the gamepad has been connected
  12707. */
  12708. readonly isConnected: boolean;
  12709. /**
  12710. * Initializes the gamepad
  12711. * @param id The id of the gamepad
  12712. * @param index The index of the gamepad
  12713. * @param browserGamepad The browser gamepad
  12714. * @param leftStickX The x component of the left joystick
  12715. * @param leftStickY The y component of the left joystick
  12716. * @param rightStickX The x component of the right joystick
  12717. * @param rightStickY The y component of the right joystick
  12718. */
  12719. constructor(
  12720. /**
  12721. * The id of the gamepad
  12722. */
  12723. id: string,
  12724. /**
  12725. * The index of the gamepad
  12726. */
  12727. index: number,
  12728. /**
  12729. * The browser gamepad
  12730. */
  12731. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12732. /**
  12733. * Callback triggered when the left joystick has changed
  12734. * @param callback
  12735. */
  12736. onleftstickchanged(callback: (values: StickValues) => void): void;
  12737. /**
  12738. * Callback triggered when the right joystick has changed
  12739. * @param callback
  12740. */
  12741. onrightstickchanged(callback: (values: StickValues) => void): void;
  12742. /**
  12743. * Gets the left joystick
  12744. */
  12745. /**
  12746. * Sets the left joystick values
  12747. */
  12748. leftStick: StickValues;
  12749. /**
  12750. * Gets the right joystick
  12751. */
  12752. /**
  12753. * Sets the right joystick value
  12754. */
  12755. rightStick: StickValues;
  12756. /**
  12757. * Updates the gamepad joystick positions
  12758. */
  12759. update(): void;
  12760. /**
  12761. * Disposes the gamepad
  12762. */
  12763. dispose(): void;
  12764. }
  12765. /**
  12766. * Represents a generic gamepad
  12767. */
  12768. export class GenericPad extends Gamepad {
  12769. private _buttons;
  12770. private _onbuttondown;
  12771. private _onbuttonup;
  12772. /**
  12773. * Observable triggered when a button has been pressed
  12774. */
  12775. onButtonDownObservable: Observable<number>;
  12776. /**
  12777. * Observable triggered when a button has been released
  12778. */
  12779. onButtonUpObservable: Observable<number>;
  12780. /**
  12781. * Callback triggered when a button has been pressed
  12782. * @param callback Called when a button has been pressed
  12783. */
  12784. onbuttondown(callback: (buttonPressed: number) => void): void;
  12785. /**
  12786. * Callback triggered when a button has been released
  12787. * @param callback Called when a button has been released
  12788. */
  12789. onbuttonup(callback: (buttonReleased: number) => void): void;
  12790. /**
  12791. * Initializes the generic gamepad
  12792. * @param id The id of the generic gamepad
  12793. * @param index The index of the generic gamepad
  12794. * @param browserGamepad The browser gamepad
  12795. */
  12796. constructor(id: string, index: number, browserGamepad: any);
  12797. private _setButtonValue;
  12798. /**
  12799. * Updates the generic gamepad
  12800. */
  12801. update(): void;
  12802. /**
  12803. * Disposes the generic gamepad
  12804. */
  12805. dispose(): void;
  12806. }
  12807. }
  12808. declare module BABYLON {
  12809. /**
  12810. * Defines the types of pose enabled controllers that are supported
  12811. */
  12812. export enum PoseEnabledControllerType {
  12813. /**
  12814. * HTC Vive
  12815. */
  12816. VIVE = 0,
  12817. /**
  12818. * Oculus Rift
  12819. */
  12820. OCULUS = 1,
  12821. /**
  12822. * Windows mixed reality
  12823. */
  12824. WINDOWS = 2,
  12825. /**
  12826. * Samsung gear VR
  12827. */
  12828. GEAR_VR = 3,
  12829. /**
  12830. * Google Daydream
  12831. */
  12832. DAYDREAM = 4,
  12833. /**
  12834. * Generic
  12835. */
  12836. GENERIC = 5
  12837. }
  12838. /**
  12839. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12840. */
  12841. export interface MutableGamepadButton {
  12842. /**
  12843. * Value of the button/trigger
  12844. */
  12845. value: number;
  12846. /**
  12847. * If the button/trigger is currently touched
  12848. */
  12849. touched: boolean;
  12850. /**
  12851. * If the button/trigger is currently pressed
  12852. */
  12853. pressed: boolean;
  12854. }
  12855. /**
  12856. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12857. * @hidden
  12858. */
  12859. export interface ExtendedGamepadButton extends GamepadButton {
  12860. /**
  12861. * If the button/trigger is currently pressed
  12862. */
  12863. readonly pressed: boolean;
  12864. /**
  12865. * If the button/trigger is currently touched
  12866. */
  12867. readonly touched: boolean;
  12868. /**
  12869. * Value of the button/trigger
  12870. */
  12871. readonly value: number;
  12872. }
  12873. /** @hidden */
  12874. export interface _GamePadFactory {
  12875. /**
  12876. * Returns wether or not the current gamepad can be created for this type of controller.
  12877. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12878. * @returns true if it can be created, otherwise false
  12879. */
  12880. canCreate(gamepadInfo: any): boolean;
  12881. /**
  12882. * Creates a new instance of the Gamepad.
  12883. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12884. * @returns the new gamepad instance
  12885. */
  12886. create(gamepadInfo: any): Gamepad;
  12887. }
  12888. /**
  12889. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12890. */
  12891. export class PoseEnabledControllerHelper {
  12892. /** @hidden */
  12893. static _ControllerFactories: _GamePadFactory[];
  12894. /** @hidden */
  12895. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12896. /**
  12897. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12898. * @param vrGamepad the gamepad to initialized
  12899. * @returns a vr controller of the type the gamepad identified as
  12900. */
  12901. static InitiateController(vrGamepad: any): Gamepad;
  12902. }
  12903. /**
  12904. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12905. */
  12906. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12907. private _deviceRoomPosition;
  12908. private _deviceRoomRotationQuaternion;
  12909. /**
  12910. * The device position in babylon space
  12911. */
  12912. devicePosition: Vector3;
  12913. /**
  12914. * The device rotation in babylon space
  12915. */
  12916. deviceRotationQuaternion: Quaternion;
  12917. /**
  12918. * The scale factor of the device in babylon space
  12919. */
  12920. deviceScaleFactor: number;
  12921. /**
  12922. * (Likely devicePosition should be used instead) The device position in its room space
  12923. */
  12924. position: Vector3;
  12925. /**
  12926. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12927. */
  12928. rotationQuaternion: Quaternion;
  12929. /**
  12930. * The type of controller (Eg. Windows mixed reality)
  12931. */
  12932. controllerType: PoseEnabledControllerType;
  12933. protected _calculatedPosition: Vector3;
  12934. private _calculatedRotation;
  12935. /**
  12936. * The raw pose from the device
  12937. */
  12938. rawPose: DevicePose;
  12939. private _trackPosition;
  12940. private _maxRotationDistFromHeadset;
  12941. private _draggedRoomRotation;
  12942. /**
  12943. * @hidden
  12944. */
  12945. _disableTrackPosition(fixedPosition: Vector3): void;
  12946. /**
  12947. * Internal, the mesh attached to the controller
  12948. * @hidden
  12949. */
  12950. _mesh: Nullable<AbstractMesh>;
  12951. private _poseControlledCamera;
  12952. private _leftHandSystemQuaternion;
  12953. /**
  12954. * Internal, matrix used to convert room space to babylon space
  12955. * @hidden
  12956. */
  12957. _deviceToWorld: Matrix;
  12958. /**
  12959. * Node to be used when casting a ray from the controller
  12960. * @hidden
  12961. */
  12962. _pointingPoseNode: Nullable<TransformNode>;
  12963. /**
  12964. * Name of the child mesh that can be used to cast a ray from the controller
  12965. */
  12966. static readonly POINTING_POSE: string;
  12967. /**
  12968. * Creates a new PoseEnabledController from a gamepad
  12969. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12970. */
  12971. constructor(browserGamepad: any);
  12972. private _workingMatrix;
  12973. /**
  12974. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12975. */
  12976. update(): void;
  12977. /**
  12978. * Updates only the pose device and mesh without doing any button event checking
  12979. */
  12980. protected _updatePoseAndMesh(): void;
  12981. /**
  12982. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12983. * @param poseData raw pose fromthe device
  12984. */
  12985. updateFromDevice(poseData: DevicePose): void;
  12986. /**
  12987. * @hidden
  12988. */
  12989. _meshAttachedObservable: Observable<AbstractMesh>;
  12990. /**
  12991. * Attaches a mesh to the controller
  12992. * @param mesh the mesh to be attached
  12993. */
  12994. attachToMesh(mesh: AbstractMesh): void;
  12995. /**
  12996. * Attaches the controllers mesh to a camera
  12997. * @param camera the camera the mesh should be attached to
  12998. */
  12999. attachToPoseControlledCamera(camera: TargetCamera): void;
  13000. /**
  13001. * Disposes of the controller
  13002. */
  13003. dispose(): void;
  13004. /**
  13005. * The mesh that is attached to the controller
  13006. */
  13007. readonly mesh: Nullable<AbstractMesh>;
  13008. /**
  13009. * Gets the ray of the controller in the direction the controller is pointing
  13010. * @param length the length the resulting ray should be
  13011. * @returns a ray in the direction the controller is pointing
  13012. */
  13013. getForwardRay(length?: number): Ray;
  13014. }
  13015. }
  13016. declare module BABYLON {
  13017. /**
  13018. * Defines the WebVRController object that represents controllers tracked in 3D space
  13019. */
  13020. export abstract class WebVRController extends PoseEnabledController {
  13021. /**
  13022. * Internal, the default controller model for the controller
  13023. */
  13024. protected _defaultModel: AbstractMesh;
  13025. /**
  13026. * Fired when the trigger state has changed
  13027. */
  13028. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13029. /**
  13030. * Fired when the main button state has changed
  13031. */
  13032. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13033. /**
  13034. * Fired when the secondary button state has changed
  13035. */
  13036. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13037. /**
  13038. * Fired when the pad state has changed
  13039. */
  13040. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13041. /**
  13042. * Fired when controllers stick values have changed
  13043. */
  13044. onPadValuesChangedObservable: Observable<StickValues>;
  13045. /**
  13046. * Array of button availible on the controller
  13047. */
  13048. protected _buttons: Array<MutableGamepadButton>;
  13049. private _onButtonStateChange;
  13050. /**
  13051. * Fired when a controller button's state has changed
  13052. * @param callback the callback containing the button that was modified
  13053. */
  13054. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13055. /**
  13056. * X and Y axis corrisponding to the controllers joystick
  13057. */
  13058. pad: StickValues;
  13059. /**
  13060. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13061. */
  13062. hand: string;
  13063. /**
  13064. * The default controller model for the controller
  13065. */
  13066. readonly defaultModel: AbstractMesh;
  13067. /**
  13068. * Creates a new WebVRController from a gamepad
  13069. * @param vrGamepad the gamepad that the WebVRController should be created from
  13070. */
  13071. constructor(vrGamepad: any);
  13072. /**
  13073. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13074. */
  13075. update(): void;
  13076. /**
  13077. * Function to be called when a button is modified
  13078. */
  13079. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13080. /**
  13081. * Loads a mesh and attaches it to the controller
  13082. * @param scene the scene the mesh should be added to
  13083. * @param meshLoaded callback for when the mesh has been loaded
  13084. */
  13085. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13086. private _setButtonValue;
  13087. private _changes;
  13088. private _checkChanges;
  13089. /**
  13090. * Disposes of th webVRCOntroller
  13091. */
  13092. dispose(): void;
  13093. }
  13094. }
  13095. declare module BABYLON {
  13096. /**
  13097. * The HemisphericLight simulates the ambient environment light,
  13098. * so the passed direction is the light reflection direction, not the incoming direction.
  13099. */
  13100. export class HemisphericLight extends Light {
  13101. /**
  13102. * The groundColor is the light in the opposite direction to the one specified during creation.
  13103. * 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.
  13104. */
  13105. groundColor: Color3;
  13106. /**
  13107. * The light reflection direction, not the incoming direction.
  13108. */
  13109. direction: Vector3;
  13110. /**
  13111. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13112. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13113. * The HemisphericLight can't cast shadows.
  13114. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13115. * @param name The friendly name of the light
  13116. * @param direction The direction of the light reflection
  13117. * @param scene The scene the light belongs to
  13118. */
  13119. constructor(name: string, direction: Vector3, scene: Scene);
  13120. protected _buildUniformLayout(): void;
  13121. /**
  13122. * Returns the string "HemisphericLight".
  13123. * @return The class name
  13124. */
  13125. getClassName(): string;
  13126. /**
  13127. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13128. * Returns the updated direction.
  13129. * @param target The target the direction should point to
  13130. * @return The computed direction
  13131. */
  13132. setDirectionToTarget(target: Vector3): Vector3;
  13133. /**
  13134. * Returns the shadow generator associated to the light.
  13135. * @returns Always null for hemispheric lights because it does not support shadows.
  13136. */
  13137. getShadowGenerator(): Nullable<IShadowGenerator>;
  13138. /**
  13139. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13140. * @param effect The effect to update
  13141. * @param lightIndex The index of the light in the effect to update
  13142. * @returns The hemispheric light
  13143. */
  13144. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13145. /**
  13146. * Computes the world matrix of the node
  13147. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13148. * @param useWasUpdatedFlag defines a reserved property
  13149. * @returns the world matrix
  13150. */
  13151. computeWorldMatrix(): Matrix;
  13152. /**
  13153. * Returns the integer 3.
  13154. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13155. */
  13156. getTypeID(): number;
  13157. /**
  13158. * Prepares the list of defines specific to the light type.
  13159. * @param defines the list of defines
  13160. * @param lightIndex defines the index of the light for the effect
  13161. */
  13162. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13163. }
  13164. }
  13165. declare module BABYLON {
  13166. /** @hidden */
  13167. export var vrMultiviewToSingleviewPixelShader: {
  13168. name: string;
  13169. shader: string;
  13170. };
  13171. }
  13172. declare module BABYLON {
  13173. /**
  13174. * Renders to multiple views with a single draw call
  13175. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13176. */
  13177. export class MultiviewRenderTarget extends RenderTargetTexture {
  13178. /**
  13179. * Creates a multiview render target
  13180. * @param scene scene used with the render target
  13181. * @param size the size of the render target (used for each view)
  13182. */
  13183. constructor(scene: Scene, size?: number | {
  13184. width: number;
  13185. height: number;
  13186. } | {
  13187. ratio: number;
  13188. });
  13189. /**
  13190. * @hidden
  13191. * @param faceIndex the face index, if its a cube texture
  13192. */
  13193. _bindFrameBuffer(faceIndex?: number): void;
  13194. /**
  13195. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13196. * @returns the view count
  13197. */
  13198. getViewCount(): number;
  13199. }
  13200. }
  13201. declare module BABYLON {
  13202. interface Engine {
  13203. /**
  13204. * Creates a new multiview render target
  13205. * @param width defines the width of the texture
  13206. * @param height defines the height of the texture
  13207. * @returns the created multiview texture
  13208. */
  13209. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13210. /**
  13211. * Binds a multiview framebuffer to be drawn to
  13212. * @param multiviewTexture texture to bind
  13213. */
  13214. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13215. }
  13216. interface Camera {
  13217. /**
  13218. * @hidden
  13219. * 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)
  13220. */
  13221. _useMultiviewToSingleView: boolean;
  13222. /**
  13223. * @hidden
  13224. * 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)
  13225. */
  13226. _multiviewTexture: Nullable<RenderTargetTexture>;
  13227. /**
  13228. * @hidden
  13229. * ensures the multiview texture of the camera exists and has the specified width/height
  13230. * @param width height to set on the multiview texture
  13231. * @param height width to set on the multiview texture
  13232. */
  13233. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13234. }
  13235. interface Scene {
  13236. /** @hidden */
  13237. _transformMatrixR: Matrix;
  13238. /** @hidden */
  13239. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13240. /** @hidden */
  13241. _createMultiviewUbo(): void;
  13242. /** @hidden */
  13243. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13244. /** @hidden */
  13245. _renderMultiviewToSingleView(camera: Camera): void;
  13246. }
  13247. }
  13248. declare module BABYLON {
  13249. /**
  13250. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13251. * This will not be used for webXR as it supports displaying texture arrays directly
  13252. */
  13253. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13254. /**
  13255. * Initializes a VRMultiviewToSingleview
  13256. * @param name name of the post process
  13257. * @param camera camera to be applied to
  13258. * @param scaleFactor scaling factor to the size of the output texture
  13259. */
  13260. constructor(name: string, camera: Camera, scaleFactor: number);
  13261. }
  13262. }
  13263. declare module BABYLON {
  13264. /**
  13265. * Defines the interface used by display changed events
  13266. */
  13267. interface IDisplayChangedEventArgs {
  13268. /** Gets the vrDisplay object (if any) */
  13269. vrDisplay: Nullable<any>;
  13270. /** Gets a boolean indicating if webVR is supported */
  13271. vrSupported: boolean;
  13272. }
  13273. interface Engine {
  13274. /** @hidden */
  13275. _vrDisplay: any;
  13276. /** @hidden */
  13277. _vrSupported: boolean;
  13278. /** @hidden */
  13279. _oldSize: Size;
  13280. /** @hidden */
  13281. _oldHardwareScaleFactor: number;
  13282. /** @hidden */
  13283. _vrExclusivePointerMode: boolean;
  13284. /** @hidden */
  13285. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13286. /** @hidden */
  13287. _onVRDisplayPointerRestricted: () => void;
  13288. /** @hidden */
  13289. _onVRDisplayPointerUnrestricted: () => void;
  13290. /** @hidden */
  13291. _onVrDisplayConnect: Nullable<(display: any) => void>;
  13292. /** @hidden */
  13293. _onVrDisplayDisconnect: Nullable<() => void>;
  13294. /** @hidden */
  13295. _onVrDisplayPresentChange: Nullable<() => void>;
  13296. /**
  13297. * Observable signaled when VR display mode changes
  13298. */
  13299. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13300. /**
  13301. * Observable signaled when VR request present is complete
  13302. */
  13303. onVRRequestPresentComplete: Observable<boolean>;
  13304. /**
  13305. * Observable signaled when VR request present starts
  13306. */
  13307. onVRRequestPresentStart: Observable<Engine>;
  13308. /**
  13309. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13310. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13311. */
  13312. isInVRExclusivePointerMode: boolean;
  13313. /**
  13314. * Gets a boolean indicating if a webVR device was detected
  13315. * @returns true if a webVR device was detected
  13316. */
  13317. isVRDevicePresent(): boolean;
  13318. /**
  13319. * Gets the current webVR device
  13320. * @returns the current webVR device (or null)
  13321. */
  13322. getVRDevice(): any;
  13323. /**
  13324. * Initializes a webVR display and starts listening to display change events
  13325. * The onVRDisplayChangedObservable will be notified upon these changes
  13326. * @returns A promise containing a VRDisplay and if vr is supported
  13327. */
  13328. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13329. /** @hidden */
  13330. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13331. /**
  13332. * Call this function to switch to webVR mode
  13333. * Will do nothing if webVR is not supported or if there is no webVR device
  13334. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13335. */
  13336. enableVR(): void;
  13337. /** @hidden */
  13338. _onVRFullScreenTriggered(): void;
  13339. }
  13340. }
  13341. declare module BABYLON {
  13342. /**
  13343. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13344. * IMPORTANT!! The data is right-hand data.
  13345. * @export
  13346. * @interface DevicePose
  13347. */
  13348. export interface DevicePose {
  13349. /**
  13350. * The position of the device, values in array are [x,y,z].
  13351. */
  13352. readonly position: Nullable<Float32Array>;
  13353. /**
  13354. * The linearVelocity of the device, values in array are [x,y,z].
  13355. */
  13356. readonly linearVelocity: Nullable<Float32Array>;
  13357. /**
  13358. * The linearAcceleration of the device, values in array are [x,y,z].
  13359. */
  13360. readonly linearAcceleration: Nullable<Float32Array>;
  13361. /**
  13362. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13363. */
  13364. readonly orientation: Nullable<Float32Array>;
  13365. /**
  13366. * The angularVelocity of the device, values in array are [x,y,z].
  13367. */
  13368. readonly angularVelocity: Nullable<Float32Array>;
  13369. /**
  13370. * The angularAcceleration of the device, values in array are [x,y,z].
  13371. */
  13372. readonly angularAcceleration: Nullable<Float32Array>;
  13373. }
  13374. /**
  13375. * Interface representing a pose controlled object in Babylon.
  13376. * A pose controlled object has both regular pose values as well as pose values
  13377. * from an external device such as a VR head mounted display
  13378. */
  13379. export interface PoseControlled {
  13380. /**
  13381. * The position of the object in babylon space.
  13382. */
  13383. position: Vector3;
  13384. /**
  13385. * The rotation quaternion of the object in babylon space.
  13386. */
  13387. rotationQuaternion: Quaternion;
  13388. /**
  13389. * The position of the device in babylon space.
  13390. */
  13391. devicePosition?: Vector3;
  13392. /**
  13393. * The rotation quaternion of the device in babylon space.
  13394. */
  13395. deviceRotationQuaternion: Quaternion;
  13396. /**
  13397. * The raw pose coming from the device.
  13398. */
  13399. rawPose: Nullable<DevicePose>;
  13400. /**
  13401. * The scale of the device to be used when translating from device space to babylon space.
  13402. */
  13403. deviceScaleFactor: number;
  13404. /**
  13405. * Updates the poseControlled values based on the input device pose.
  13406. * @param poseData the pose data to update the object with
  13407. */
  13408. updateFromDevice(poseData: DevicePose): void;
  13409. }
  13410. /**
  13411. * Set of options to customize the webVRCamera
  13412. */
  13413. export interface WebVROptions {
  13414. /**
  13415. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13416. */
  13417. trackPosition?: boolean;
  13418. /**
  13419. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13420. */
  13421. positionScale?: number;
  13422. /**
  13423. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13424. */
  13425. displayName?: string;
  13426. /**
  13427. * Should the native controller meshes be initialized. (default: true)
  13428. */
  13429. controllerMeshes?: boolean;
  13430. /**
  13431. * Creating a default HemiLight only on controllers. (default: true)
  13432. */
  13433. defaultLightingOnControllers?: boolean;
  13434. /**
  13435. * If you don't want to use the default VR button of the helper. (default: false)
  13436. */
  13437. useCustomVRButton?: boolean;
  13438. /**
  13439. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13440. */
  13441. customVRButton?: HTMLButtonElement;
  13442. /**
  13443. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13444. */
  13445. rayLength?: number;
  13446. /**
  13447. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13448. */
  13449. defaultHeight?: number;
  13450. /**
  13451. * If multiview should be used if availible (default: false)
  13452. */
  13453. useMultiview?: boolean;
  13454. }
  13455. /**
  13456. * This represents a WebVR camera.
  13457. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13458. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13459. */
  13460. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13461. private webVROptions;
  13462. /**
  13463. * @hidden
  13464. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13465. */
  13466. _vrDevice: any;
  13467. /**
  13468. * The rawPose of the vrDevice.
  13469. */
  13470. rawPose: Nullable<DevicePose>;
  13471. private _onVREnabled;
  13472. private _specsVersion;
  13473. private _attached;
  13474. private _frameData;
  13475. protected _descendants: Array<Node>;
  13476. private _deviceRoomPosition;
  13477. /** @hidden */
  13478. _deviceRoomRotationQuaternion: Quaternion;
  13479. private _standingMatrix;
  13480. /**
  13481. * Represents device position in babylon space.
  13482. */
  13483. devicePosition: Vector3;
  13484. /**
  13485. * Represents device rotation in babylon space.
  13486. */
  13487. deviceRotationQuaternion: Quaternion;
  13488. /**
  13489. * The scale of the device to be used when translating from device space to babylon space.
  13490. */
  13491. deviceScaleFactor: number;
  13492. private _deviceToWorld;
  13493. private _worldToDevice;
  13494. /**
  13495. * References to the webVR controllers for the vrDevice.
  13496. */
  13497. controllers: Array<WebVRController>;
  13498. /**
  13499. * Emits an event when a controller is attached.
  13500. */
  13501. onControllersAttachedObservable: Observable<WebVRController[]>;
  13502. /**
  13503. * Emits an event when a controller's mesh has been loaded;
  13504. */
  13505. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13506. /**
  13507. * Emits an event when the HMD's pose has been updated.
  13508. */
  13509. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13510. private _poseSet;
  13511. /**
  13512. * If the rig cameras be used as parent instead of this camera.
  13513. */
  13514. rigParenting: boolean;
  13515. private _lightOnControllers;
  13516. private _defaultHeight?;
  13517. /**
  13518. * Instantiates a WebVRFreeCamera.
  13519. * @param name The name of the WebVRFreeCamera
  13520. * @param position The starting anchor position for the camera
  13521. * @param scene The scene the camera belongs to
  13522. * @param webVROptions a set of customizable options for the webVRCamera
  13523. */
  13524. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13525. /**
  13526. * Gets the device distance from the ground in meters.
  13527. * @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.
  13528. */
  13529. deviceDistanceToRoomGround(): number;
  13530. /**
  13531. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13532. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13533. */
  13534. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13535. /**
  13536. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13537. * @returns A promise with a boolean set to if the standing matrix is supported.
  13538. */
  13539. useStandingMatrixAsync(): Promise<boolean>;
  13540. /**
  13541. * Disposes the camera
  13542. */
  13543. dispose(): void;
  13544. /**
  13545. * Gets a vrController by name.
  13546. * @param name The name of the controller to retreive
  13547. * @returns the controller matching the name specified or null if not found
  13548. */
  13549. getControllerByName(name: string): Nullable<WebVRController>;
  13550. private _leftController;
  13551. /**
  13552. * The controller corrisponding to the users left hand.
  13553. */
  13554. readonly leftController: Nullable<WebVRController>;
  13555. private _rightController;
  13556. /**
  13557. * The controller corrisponding to the users right hand.
  13558. */
  13559. readonly rightController: Nullable<WebVRController>;
  13560. /**
  13561. * Casts a ray forward from the vrCamera's gaze.
  13562. * @param length Length of the ray (default: 100)
  13563. * @returns the ray corrisponding to the gaze
  13564. */
  13565. getForwardRay(length?: number): Ray;
  13566. /**
  13567. * @hidden
  13568. * Updates the camera based on device's frame data
  13569. */
  13570. _checkInputs(): void;
  13571. /**
  13572. * Updates the poseControlled values based on the input device pose.
  13573. * @param poseData Pose coming from the device
  13574. */
  13575. updateFromDevice(poseData: DevicePose): void;
  13576. private _htmlElementAttached;
  13577. private _detachIfAttached;
  13578. /**
  13579. * WebVR's attach control will start broadcasting frames to the device.
  13580. * Note that in certain browsers (chrome for example) this function must be called
  13581. * within a user-interaction callback. Example:
  13582. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13583. *
  13584. * @param element html element to attach the vrDevice to
  13585. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13586. */
  13587. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13588. /**
  13589. * Detaches the camera from the html element and disables VR
  13590. *
  13591. * @param element html element to detach from
  13592. */
  13593. detachControl(element: HTMLElement): void;
  13594. /**
  13595. * @returns the name of this class
  13596. */
  13597. getClassName(): string;
  13598. /**
  13599. * Calls resetPose on the vrDisplay
  13600. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13601. */
  13602. resetToCurrentRotation(): void;
  13603. /**
  13604. * @hidden
  13605. * Updates the rig cameras (left and right eye)
  13606. */
  13607. _updateRigCameras(): void;
  13608. private _workingVector;
  13609. private _oneVector;
  13610. private _workingMatrix;
  13611. private updateCacheCalled;
  13612. private _correctPositionIfNotTrackPosition;
  13613. /**
  13614. * @hidden
  13615. * Updates the cached values of the camera
  13616. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13617. */
  13618. _updateCache(ignoreParentClass?: boolean): void;
  13619. /**
  13620. * @hidden
  13621. * Get current device position in babylon world
  13622. */
  13623. _computeDevicePosition(): void;
  13624. /**
  13625. * Updates the current device position and rotation in the babylon world
  13626. */
  13627. update(): void;
  13628. /**
  13629. * @hidden
  13630. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13631. * @returns an identity matrix
  13632. */
  13633. _getViewMatrix(): Matrix;
  13634. private _tmpMatrix;
  13635. /**
  13636. * This function is called by the two RIG cameras.
  13637. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13638. * @hidden
  13639. */
  13640. _getWebVRViewMatrix(): Matrix;
  13641. /** @hidden */
  13642. _getWebVRProjectionMatrix(): Matrix;
  13643. private _onGamepadConnectedObserver;
  13644. private _onGamepadDisconnectedObserver;
  13645. private _updateCacheWhenTrackingDisabledObserver;
  13646. /**
  13647. * Initializes the controllers and their meshes
  13648. */
  13649. initControllers(): void;
  13650. }
  13651. }
  13652. declare module BABYLON {
  13653. /**
  13654. * Size options for a post process
  13655. */
  13656. export type PostProcessOptions = {
  13657. width: number;
  13658. height: number;
  13659. };
  13660. /**
  13661. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13662. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13663. */
  13664. export class PostProcess {
  13665. /** Name of the PostProcess. */
  13666. name: string;
  13667. /**
  13668. * Gets or sets the unique id of the post process
  13669. */
  13670. uniqueId: number;
  13671. /**
  13672. * Width of the texture to apply the post process on
  13673. */
  13674. width: number;
  13675. /**
  13676. * Height of the texture to apply the post process on
  13677. */
  13678. height: number;
  13679. /**
  13680. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13681. * @hidden
  13682. */
  13683. _outputTexture: Nullable<InternalTexture>;
  13684. /**
  13685. * Sampling mode used by the shader
  13686. * See https://doc.babylonjs.com/classes/3.1/texture
  13687. */
  13688. renderTargetSamplingMode: number;
  13689. /**
  13690. * Clear color to use when screen clearing
  13691. */
  13692. clearColor: Color4;
  13693. /**
  13694. * If the buffer needs to be cleared before applying the post process. (default: true)
  13695. * Should be set to false if shader will overwrite all previous pixels.
  13696. */
  13697. autoClear: boolean;
  13698. /**
  13699. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13700. */
  13701. alphaMode: number;
  13702. /**
  13703. * Sets the setAlphaBlendConstants of the babylon engine
  13704. */
  13705. alphaConstants: Color4;
  13706. /**
  13707. * Animations to be used for the post processing
  13708. */
  13709. animations: Animation[];
  13710. /**
  13711. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13712. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13713. */
  13714. enablePixelPerfectMode: boolean;
  13715. /**
  13716. * Force the postprocess to be applied without taking in account viewport
  13717. */
  13718. forceFullscreenViewport: boolean;
  13719. /**
  13720. * List of inspectable custom properties (used by the Inspector)
  13721. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13722. */
  13723. inspectableCustomProperties: IInspectable[];
  13724. /**
  13725. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13726. *
  13727. * | Value | Type | Description |
  13728. * | ----- | ----------------------------------- | ----------- |
  13729. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13730. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13731. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13732. *
  13733. */
  13734. scaleMode: number;
  13735. /**
  13736. * Force textures to be a power of two (default: false)
  13737. */
  13738. alwaysForcePOT: boolean;
  13739. private _samples;
  13740. /**
  13741. * Number of sample textures (default: 1)
  13742. */
  13743. samples: number;
  13744. /**
  13745. * Modify the scale of the post process to be the same as the viewport (default: false)
  13746. */
  13747. adaptScaleToCurrentViewport: boolean;
  13748. private _camera;
  13749. private _scene;
  13750. private _engine;
  13751. private _options;
  13752. private _reusable;
  13753. private _textureType;
  13754. /**
  13755. * Smart array of input and output textures for the post process.
  13756. * @hidden
  13757. */
  13758. _textures: SmartArray<InternalTexture>;
  13759. /**
  13760. * The index in _textures that corresponds to the output texture.
  13761. * @hidden
  13762. */
  13763. _currentRenderTextureInd: number;
  13764. private _effect;
  13765. private _samplers;
  13766. private _fragmentUrl;
  13767. private _vertexUrl;
  13768. private _parameters;
  13769. private _scaleRatio;
  13770. protected _indexParameters: any;
  13771. private _shareOutputWithPostProcess;
  13772. private _texelSize;
  13773. private _forcedOutputTexture;
  13774. /**
  13775. * Returns the fragment url or shader name used in the post process.
  13776. * @returns the fragment url or name in the shader store.
  13777. */
  13778. getEffectName(): string;
  13779. /**
  13780. * An event triggered when the postprocess is activated.
  13781. */
  13782. onActivateObservable: Observable<Camera>;
  13783. private _onActivateObserver;
  13784. /**
  13785. * A function that is added to the onActivateObservable
  13786. */
  13787. onActivate: Nullable<(camera: Camera) => void>;
  13788. /**
  13789. * An event triggered when the postprocess changes its size.
  13790. */
  13791. onSizeChangedObservable: Observable<PostProcess>;
  13792. private _onSizeChangedObserver;
  13793. /**
  13794. * A function that is added to the onSizeChangedObservable
  13795. */
  13796. onSizeChanged: (postProcess: PostProcess) => void;
  13797. /**
  13798. * An event triggered when the postprocess applies its effect.
  13799. */
  13800. onApplyObservable: Observable<Effect>;
  13801. private _onApplyObserver;
  13802. /**
  13803. * A function that is added to the onApplyObservable
  13804. */
  13805. onApply: (effect: Effect) => void;
  13806. /**
  13807. * An event triggered before rendering the postprocess
  13808. */
  13809. onBeforeRenderObservable: Observable<Effect>;
  13810. private _onBeforeRenderObserver;
  13811. /**
  13812. * A function that is added to the onBeforeRenderObservable
  13813. */
  13814. onBeforeRender: (effect: Effect) => void;
  13815. /**
  13816. * An event triggered after rendering the postprocess
  13817. */
  13818. onAfterRenderObservable: Observable<Effect>;
  13819. private _onAfterRenderObserver;
  13820. /**
  13821. * A function that is added to the onAfterRenderObservable
  13822. */
  13823. onAfterRender: (efect: Effect) => void;
  13824. /**
  13825. * 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
  13826. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13827. */
  13828. inputTexture: InternalTexture;
  13829. /**
  13830. * Gets the camera which post process is applied to.
  13831. * @returns The camera the post process is applied to.
  13832. */
  13833. getCamera(): Camera;
  13834. /**
  13835. * Gets the texel size of the postprocess.
  13836. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13837. */
  13838. readonly texelSize: Vector2;
  13839. /**
  13840. * Creates a new instance PostProcess
  13841. * @param name The name of the PostProcess.
  13842. * @param fragmentUrl The url of the fragment shader to be used.
  13843. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13844. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13845. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13846. * @param camera The camera to apply the render pass to.
  13847. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13848. * @param engine The engine which the post process will be applied. (default: current engine)
  13849. * @param reusable If the post process can be reused on the same frame. (default: false)
  13850. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13851. * @param textureType Type of textures used when performing the post process. (default: 0)
  13852. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13853. * @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
  13854. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13855. */
  13856. constructor(
  13857. /** Name of the PostProcess. */
  13858. 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);
  13859. /**
  13860. * Gets a string idenfifying the name of the class
  13861. * @returns "PostProcess" string
  13862. */
  13863. getClassName(): string;
  13864. /**
  13865. * Gets the engine which this post process belongs to.
  13866. * @returns The engine the post process was enabled with.
  13867. */
  13868. getEngine(): Engine;
  13869. /**
  13870. * The effect that is created when initializing the post process.
  13871. * @returns The created effect corrisponding the the postprocess.
  13872. */
  13873. getEffect(): Effect;
  13874. /**
  13875. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13876. * @param postProcess The post process to share the output with.
  13877. * @returns This post process.
  13878. */
  13879. shareOutputWith(postProcess: PostProcess): PostProcess;
  13880. /**
  13881. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13882. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13883. */
  13884. useOwnOutput(): void;
  13885. /**
  13886. * Updates the effect with the current post process compile time values and recompiles the shader.
  13887. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13888. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13889. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13890. * @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
  13891. * @param onCompiled Called when the shader has been compiled.
  13892. * @param onError Called if there is an error when compiling a shader.
  13893. */
  13894. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13895. /**
  13896. * The post process is reusable if it can be used multiple times within one frame.
  13897. * @returns If the post process is reusable
  13898. */
  13899. isReusable(): boolean;
  13900. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13901. markTextureDirty(): void;
  13902. /**
  13903. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13904. * 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.
  13905. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13906. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13907. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13908. * @returns The target texture that was bound to be written to.
  13909. */
  13910. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13911. /**
  13912. * If the post process is supported.
  13913. */
  13914. readonly isSupported: boolean;
  13915. /**
  13916. * The aspect ratio of the output texture.
  13917. */
  13918. readonly aspectRatio: number;
  13919. /**
  13920. * Get a value indicating if the post-process is ready to be used
  13921. * @returns true if the post-process is ready (shader is compiled)
  13922. */
  13923. isReady(): boolean;
  13924. /**
  13925. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13926. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13927. */
  13928. apply(): Nullable<Effect>;
  13929. private _disposeTextures;
  13930. /**
  13931. * Disposes the post process.
  13932. * @param camera The camera to dispose the post process on.
  13933. */
  13934. dispose(camera?: Camera): void;
  13935. }
  13936. }
  13937. declare module BABYLON {
  13938. /**
  13939. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13940. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13941. */
  13942. export class PostProcessManager {
  13943. private _scene;
  13944. private _indexBuffer;
  13945. private _vertexBuffers;
  13946. /**
  13947. * Creates a new instance PostProcess
  13948. * @param scene The scene that the post process is associated with.
  13949. */
  13950. constructor(scene: Scene);
  13951. private _prepareBuffers;
  13952. private _buildIndexBuffer;
  13953. /**
  13954. * Rebuilds the vertex buffers of the manager.
  13955. * @hidden
  13956. */
  13957. _rebuild(): void;
  13958. /**
  13959. * Prepares a frame to be run through a post process.
  13960. * @param sourceTexture The input texture to the post procesess. (default: null)
  13961. * @param postProcesses An array of post processes to be run. (default: null)
  13962. * @returns True if the post processes were able to be run.
  13963. * @hidden
  13964. */
  13965. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13966. /**
  13967. * Manually render a set of post processes to a texture.
  13968. * @param postProcesses An array of post processes to be run.
  13969. * @param targetTexture The target texture to render to.
  13970. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13971. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13972. * @param lodLevel defines which lod of the texture to render to
  13973. */
  13974. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13975. /**
  13976. * Finalize the result of the output of the postprocesses.
  13977. * @param doNotPresent If true the result will not be displayed to the screen.
  13978. * @param targetTexture The target texture to render to.
  13979. * @param faceIndex The index of the face to bind the target texture to.
  13980. * @param postProcesses The array of post processes to render.
  13981. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13982. * @hidden
  13983. */
  13984. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13985. /**
  13986. * Disposes of the post process manager.
  13987. */
  13988. dispose(): void;
  13989. }
  13990. }
  13991. declare module BABYLON {
  13992. interface AbstractScene {
  13993. /**
  13994. * The list of procedural textures added to the scene
  13995. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13996. */
  13997. proceduralTextures: Array<ProceduralTexture>;
  13998. }
  13999. /**
  14000. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14001. * in a given scene.
  14002. */
  14003. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14004. /**
  14005. * The component name helpfull to identify the component in the list of scene components.
  14006. */
  14007. readonly name: string;
  14008. /**
  14009. * The scene the component belongs to.
  14010. */
  14011. scene: Scene;
  14012. /**
  14013. * Creates a new instance of the component for the given scene
  14014. * @param scene Defines the scene to register the component in
  14015. */
  14016. constructor(scene: Scene);
  14017. /**
  14018. * Registers the component in a given scene
  14019. */
  14020. register(): void;
  14021. /**
  14022. * Rebuilds the elements related to this component in case of
  14023. * context lost for instance.
  14024. */
  14025. rebuild(): void;
  14026. /**
  14027. * Disposes the component and the associated ressources.
  14028. */
  14029. dispose(): void;
  14030. private _beforeClear;
  14031. }
  14032. }
  14033. declare module BABYLON {
  14034. interface Engine {
  14035. /**
  14036. * Creates a new render target cube texture
  14037. * @param size defines the size of the texture
  14038. * @param options defines the options used to create the texture
  14039. * @returns a new render target cube texture stored in an InternalTexture
  14040. */
  14041. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14042. }
  14043. }
  14044. declare module BABYLON {
  14045. /** @hidden */
  14046. export var proceduralVertexShader: {
  14047. name: string;
  14048. shader: string;
  14049. };
  14050. }
  14051. declare module BABYLON {
  14052. /**
  14053. * 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.
  14054. * This is the base class of any Procedural texture and contains most of the shareable code.
  14055. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14056. */
  14057. export class ProceduralTexture extends Texture {
  14058. isCube: boolean;
  14059. /**
  14060. * Define if the texture is enabled or not (disabled texture will not render)
  14061. */
  14062. isEnabled: boolean;
  14063. /**
  14064. * Define if the texture must be cleared before rendering (default is true)
  14065. */
  14066. autoClear: boolean;
  14067. /**
  14068. * Callback called when the texture is generated
  14069. */
  14070. onGenerated: () => void;
  14071. /**
  14072. * Event raised when the texture is generated
  14073. */
  14074. onGeneratedObservable: Observable<ProceduralTexture>;
  14075. /** @hidden */
  14076. _generateMipMaps: boolean;
  14077. /** @hidden **/
  14078. _effect: Effect;
  14079. /** @hidden */
  14080. _textures: {
  14081. [key: string]: Texture;
  14082. };
  14083. private _size;
  14084. private _currentRefreshId;
  14085. private _refreshRate;
  14086. private _vertexBuffers;
  14087. private _indexBuffer;
  14088. private _uniforms;
  14089. private _samplers;
  14090. private _fragment;
  14091. private _floats;
  14092. private _ints;
  14093. private _floatsArrays;
  14094. private _colors3;
  14095. private _colors4;
  14096. private _vectors2;
  14097. private _vectors3;
  14098. private _matrices;
  14099. private _fallbackTexture;
  14100. private _fallbackTextureUsed;
  14101. private _engine;
  14102. private _cachedDefines;
  14103. private _contentUpdateId;
  14104. private _contentData;
  14105. /**
  14106. * Instantiates a new procedural texture.
  14107. * 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.
  14108. * This is the base class of any Procedural texture and contains most of the shareable code.
  14109. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14110. * @param name Define the name of the texture
  14111. * @param size Define the size of the texture to create
  14112. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14113. * @param scene Define the scene the texture belongs to
  14114. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14115. * @param generateMipMaps Define if the texture should creates mip maps or not
  14116. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14117. */
  14118. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14119. /**
  14120. * The effect that is created when initializing the post process.
  14121. * @returns The created effect corrisponding the the postprocess.
  14122. */
  14123. getEffect(): Effect;
  14124. /**
  14125. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14126. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14127. */
  14128. getContent(): Nullable<ArrayBufferView>;
  14129. private _createIndexBuffer;
  14130. /** @hidden */
  14131. _rebuild(): void;
  14132. /**
  14133. * Resets the texture in order to recreate its associated resources.
  14134. * This can be called in case of context loss
  14135. */
  14136. reset(): void;
  14137. protected _getDefines(): string;
  14138. /**
  14139. * Is the texture ready to be used ? (rendered at least once)
  14140. * @returns true if ready, otherwise, false.
  14141. */
  14142. isReady(): boolean;
  14143. /**
  14144. * Resets the refresh counter of the texture and start bak from scratch.
  14145. * Could be useful to regenerate the texture if it is setup to render only once.
  14146. */
  14147. resetRefreshCounter(): void;
  14148. /**
  14149. * Set the fragment shader to use in order to render the texture.
  14150. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14151. */
  14152. setFragment(fragment: any): void;
  14153. /**
  14154. * Define the refresh rate of the texture or the rendering frequency.
  14155. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14156. */
  14157. refreshRate: number;
  14158. /** @hidden */
  14159. _shouldRender(): boolean;
  14160. /**
  14161. * Get the size the texture is rendering at.
  14162. * @returns the size (texture is always squared)
  14163. */
  14164. getRenderSize(): number;
  14165. /**
  14166. * Resize the texture to new value.
  14167. * @param size Define the new size the texture should have
  14168. * @param generateMipMaps Define whether the new texture should create mip maps
  14169. */
  14170. resize(size: number, generateMipMaps: boolean): void;
  14171. private _checkUniform;
  14172. /**
  14173. * Set a texture in the shader program used to render.
  14174. * @param name Define the name of the uniform samplers as defined in the shader
  14175. * @param texture Define the texture to bind to this sampler
  14176. * @return the texture itself allowing "fluent" like uniform updates
  14177. */
  14178. setTexture(name: string, texture: Texture): ProceduralTexture;
  14179. /**
  14180. * Set a float in the shader.
  14181. * @param name Define the name of the uniform as defined in the shader
  14182. * @param value Define the value to give to the uniform
  14183. * @return the texture itself allowing "fluent" like uniform updates
  14184. */
  14185. setFloat(name: string, value: number): ProceduralTexture;
  14186. /**
  14187. * Set a int in the shader.
  14188. * @param name Define the name of the uniform as defined in the shader
  14189. * @param value Define the value to give to the uniform
  14190. * @return the texture itself allowing "fluent" like uniform updates
  14191. */
  14192. setInt(name: string, value: number): ProceduralTexture;
  14193. /**
  14194. * Set an array of floats in the shader.
  14195. * @param name Define the name of the uniform as defined in the shader
  14196. * @param value Define the value to give to the uniform
  14197. * @return the texture itself allowing "fluent" like uniform updates
  14198. */
  14199. setFloats(name: string, value: number[]): ProceduralTexture;
  14200. /**
  14201. * Set a vec3 in the shader from a Color3.
  14202. * @param name Define the name of the uniform as defined in the shader
  14203. * @param value Define the value to give to the uniform
  14204. * @return the texture itself allowing "fluent" like uniform updates
  14205. */
  14206. setColor3(name: string, value: Color3): ProceduralTexture;
  14207. /**
  14208. * Set a vec4 in the shader from a Color4.
  14209. * @param name Define the name of the uniform as defined in the shader
  14210. * @param value Define the value to give to the uniform
  14211. * @return the texture itself allowing "fluent" like uniform updates
  14212. */
  14213. setColor4(name: string, value: Color4): ProceduralTexture;
  14214. /**
  14215. * Set a vec2 in the shader from a Vector2.
  14216. * @param name Define the name of the uniform as defined in the shader
  14217. * @param value Define the value to give to the uniform
  14218. * @return the texture itself allowing "fluent" like uniform updates
  14219. */
  14220. setVector2(name: string, value: Vector2): ProceduralTexture;
  14221. /**
  14222. * Set a vec3 in the shader from a Vector3.
  14223. * @param name Define the name of the uniform as defined in the shader
  14224. * @param value Define the value to give to the uniform
  14225. * @return the texture itself allowing "fluent" like uniform updates
  14226. */
  14227. setVector3(name: string, value: Vector3): ProceduralTexture;
  14228. /**
  14229. * Set a mat4 in the shader from a MAtrix.
  14230. * @param name Define the name of the uniform as defined in the shader
  14231. * @param value Define the value to give to the uniform
  14232. * @return the texture itself allowing "fluent" like uniform updates
  14233. */
  14234. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14235. /**
  14236. * Render the texture to its associated render target.
  14237. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14238. */
  14239. render(useCameraPostProcess?: boolean): void;
  14240. /**
  14241. * Clone the texture.
  14242. * @returns the cloned texture
  14243. */
  14244. clone(): ProceduralTexture;
  14245. /**
  14246. * Dispose the texture and release its asoociated resources.
  14247. */
  14248. dispose(): void;
  14249. }
  14250. }
  14251. declare module BABYLON {
  14252. /**
  14253. * This represents the base class for particle system in Babylon.
  14254. * 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.
  14255. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14256. * @example https://doc.babylonjs.com/babylon101/particles
  14257. */
  14258. export class BaseParticleSystem {
  14259. /**
  14260. * Source color is added to the destination color without alpha affecting the result
  14261. */
  14262. static BLENDMODE_ONEONE: number;
  14263. /**
  14264. * Blend current color and particle color using particle’s alpha
  14265. */
  14266. static BLENDMODE_STANDARD: number;
  14267. /**
  14268. * Add current color and particle color multiplied by particle’s alpha
  14269. */
  14270. static BLENDMODE_ADD: number;
  14271. /**
  14272. * Multiply current color with particle color
  14273. */
  14274. static BLENDMODE_MULTIPLY: number;
  14275. /**
  14276. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14277. */
  14278. static BLENDMODE_MULTIPLYADD: number;
  14279. /**
  14280. * List of animations used by the particle system.
  14281. */
  14282. animations: Animation[];
  14283. /**
  14284. * The id of the Particle system.
  14285. */
  14286. id: string;
  14287. /**
  14288. * The friendly name of the Particle system.
  14289. */
  14290. name: string;
  14291. /**
  14292. * The rendering group used by the Particle system to chose when to render.
  14293. */
  14294. renderingGroupId: number;
  14295. /**
  14296. * The emitter represents the Mesh or position we are attaching the particle system to.
  14297. */
  14298. emitter: Nullable<AbstractMesh | Vector3>;
  14299. /**
  14300. * The maximum number of particles to emit per frame
  14301. */
  14302. emitRate: number;
  14303. /**
  14304. * If you want to launch only a few particles at once, that can be done, as well.
  14305. */
  14306. manualEmitCount: number;
  14307. /**
  14308. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14309. */
  14310. updateSpeed: number;
  14311. /**
  14312. * The amount of time the particle system is running (depends of the overall update speed).
  14313. */
  14314. targetStopDuration: number;
  14315. /**
  14316. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14317. */
  14318. disposeOnStop: boolean;
  14319. /**
  14320. * Minimum power of emitting particles.
  14321. */
  14322. minEmitPower: number;
  14323. /**
  14324. * Maximum power of emitting particles.
  14325. */
  14326. maxEmitPower: number;
  14327. /**
  14328. * Minimum life time of emitting particles.
  14329. */
  14330. minLifeTime: number;
  14331. /**
  14332. * Maximum life time of emitting particles.
  14333. */
  14334. maxLifeTime: number;
  14335. /**
  14336. * Minimum Size of emitting particles.
  14337. */
  14338. minSize: number;
  14339. /**
  14340. * Maximum Size of emitting particles.
  14341. */
  14342. maxSize: number;
  14343. /**
  14344. * Minimum scale of emitting particles on X axis.
  14345. */
  14346. minScaleX: number;
  14347. /**
  14348. * Maximum scale of emitting particles on X axis.
  14349. */
  14350. maxScaleX: number;
  14351. /**
  14352. * Minimum scale of emitting particles on Y axis.
  14353. */
  14354. minScaleY: number;
  14355. /**
  14356. * Maximum scale of emitting particles on Y axis.
  14357. */
  14358. maxScaleY: number;
  14359. /**
  14360. * Gets or sets the minimal initial rotation in radians.
  14361. */
  14362. minInitialRotation: number;
  14363. /**
  14364. * Gets or sets the maximal initial rotation in radians.
  14365. */
  14366. maxInitialRotation: number;
  14367. /**
  14368. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14369. */
  14370. minAngularSpeed: number;
  14371. /**
  14372. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14373. */
  14374. maxAngularSpeed: number;
  14375. /**
  14376. * The texture used to render each particle. (this can be a spritesheet)
  14377. */
  14378. particleTexture: Nullable<Texture>;
  14379. /**
  14380. * The layer mask we are rendering the particles through.
  14381. */
  14382. layerMask: number;
  14383. /**
  14384. * This can help using your own shader to render the particle system.
  14385. * The according effect will be created
  14386. */
  14387. customShader: any;
  14388. /**
  14389. * By default particle system starts as soon as they are created. This prevents the
  14390. * automatic start to happen and let you decide when to start emitting particles.
  14391. */
  14392. preventAutoStart: boolean;
  14393. private _noiseTexture;
  14394. /**
  14395. * Gets or sets a texture used to add random noise to particle positions
  14396. */
  14397. noiseTexture: Nullable<ProceduralTexture>;
  14398. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14399. noiseStrength: Vector3;
  14400. /**
  14401. * Callback triggered when the particle animation is ending.
  14402. */
  14403. onAnimationEnd: Nullable<() => void>;
  14404. /**
  14405. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14406. */
  14407. blendMode: number;
  14408. /**
  14409. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14410. * to override the particles.
  14411. */
  14412. forceDepthWrite: boolean;
  14413. /** 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 */
  14414. preWarmCycles: number;
  14415. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14416. preWarmStepOffset: number;
  14417. /**
  14418. * 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)
  14419. */
  14420. spriteCellChangeSpeed: number;
  14421. /**
  14422. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14423. */
  14424. startSpriteCellID: number;
  14425. /**
  14426. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14427. */
  14428. endSpriteCellID: number;
  14429. /**
  14430. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14431. */
  14432. spriteCellWidth: number;
  14433. /**
  14434. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14435. */
  14436. spriteCellHeight: number;
  14437. /**
  14438. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14439. */
  14440. spriteRandomStartCell: boolean;
  14441. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14442. translationPivot: Vector2;
  14443. /** @hidden */
  14444. protected _isAnimationSheetEnabled: boolean;
  14445. /**
  14446. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14447. */
  14448. beginAnimationOnStart: boolean;
  14449. /**
  14450. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14451. */
  14452. beginAnimationFrom: number;
  14453. /**
  14454. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14455. */
  14456. beginAnimationTo: number;
  14457. /**
  14458. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14459. */
  14460. beginAnimationLoop: boolean;
  14461. /**
  14462. * Gets or sets a world offset applied to all particles
  14463. */
  14464. worldOffset: Vector3;
  14465. /**
  14466. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14467. */
  14468. isAnimationSheetEnabled: boolean;
  14469. /**
  14470. * Get hosting scene
  14471. * @returns the scene
  14472. */
  14473. getScene(): Scene;
  14474. /**
  14475. * You can use gravity if you want to give an orientation to your particles.
  14476. */
  14477. gravity: Vector3;
  14478. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14479. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14480. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14481. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14482. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14483. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14484. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14485. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14486. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14487. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14488. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14489. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14490. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14491. /**
  14492. * Defines the delay in milliseconds before starting the system (0 by default)
  14493. */
  14494. startDelay: number;
  14495. /**
  14496. * Gets the current list of drag gradients.
  14497. * You must use addDragGradient and removeDragGradient to udpate this list
  14498. * @returns the list of drag gradients
  14499. */
  14500. getDragGradients(): Nullable<Array<FactorGradient>>;
  14501. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14502. limitVelocityDamping: number;
  14503. /**
  14504. * Gets the current list of limit velocity gradients.
  14505. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14506. * @returns the list of limit velocity gradients
  14507. */
  14508. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14509. /**
  14510. * Gets the current list of color gradients.
  14511. * You must use addColorGradient and removeColorGradient to udpate this list
  14512. * @returns the list of color gradients
  14513. */
  14514. getColorGradients(): Nullable<Array<ColorGradient>>;
  14515. /**
  14516. * Gets the current list of size gradients.
  14517. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14518. * @returns the list of size gradients
  14519. */
  14520. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14521. /**
  14522. * Gets the current list of color remap gradients.
  14523. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14524. * @returns the list of color remap gradients
  14525. */
  14526. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14527. /**
  14528. * Gets the current list of alpha remap gradients.
  14529. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14530. * @returns the list of alpha remap gradients
  14531. */
  14532. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14533. /**
  14534. * Gets the current list of life time gradients.
  14535. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14536. * @returns the list of life time gradients
  14537. */
  14538. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14539. /**
  14540. * Gets the current list of angular speed gradients.
  14541. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14542. * @returns the list of angular speed gradients
  14543. */
  14544. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14545. /**
  14546. * Gets the current list of velocity gradients.
  14547. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14548. * @returns the list of velocity gradients
  14549. */
  14550. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14551. /**
  14552. * Gets the current list of start size gradients.
  14553. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14554. * @returns the list of start size gradients
  14555. */
  14556. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14557. /**
  14558. * Gets the current list of emit rate gradients.
  14559. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14560. * @returns the list of emit rate gradients
  14561. */
  14562. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14563. /**
  14564. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14565. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14566. */
  14567. direction1: Vector3;
  14568. /**
  14569. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14570. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14571. */
  14572. direction2: Vector3;
  14573. /**
  14574. * 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.
  14575. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14576. */
  14577. minEmitBox: Vector3;
  14578. /**
  14579. * 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.
  14580. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14581. */
  14582. maxEmitBox: Vector3;
  14583. /**
  14584. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14585. */
  14586. color1: Color4;
  14587. /**
  14588. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14589. */
  14590. color2: Color4;
  14591. /**
  14592. * Color the particle will have at the end of its lifetime
  14593. */
  14594. colorDead: Color4;
  14595. /**
  14596. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14597. */
  14598. textureMask: Color4;
  14599. /**
  14600. * The particle emitter type defines the emitter used by the particle system.
  14601. * It can be for example box, sphere, or cone...
  14602. */
  14603. particleEmitterType: IParticleEmitterType;
  14604. /** @hidden */
  14605. _isSubEmitter: boolean;
  14606. /**
  14607. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14608. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14609. */
  14610. billboardMode: number;
  14611. protected _isBillboardBased: boolean;
  14612. /**
  14613. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14614. */
  14615. isBillboardBased: boolean;
  14616. /**
  14617. * The scene the particle system belongs to.
  14618. */
  14619. protected _scene: Scene;
  14620. /**
  14621. * Local cache of defines for image processing.
  14622. */
  14623. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14624. /**
  14625. * Default configuration related to image processing available in the standard Material.
  14626. */
  14627. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14628. /**
  14629. * Gets the image processing configuration used either in this material.
  14630. */
  14631. /**
  14632. * Sets the Default image processing configuration used either in the this material.
  14633. *
  14634. * If sets to null, the scene one is in use.
  14635. */
  14636. imageProcessingConfiguration: ImageProcessingConfiguration;
  14637. /**
  14638. * Attaches a new image processing configuration to the Standard Material.
  14639. * @param configuration
  14640. */
  14641. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14642. /** @hidden */
  14643. protected _reset(): void;
  14644. /** @hidden */
  14645. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14646. /**
  14647. * Instantiates a particle system.
  14648. * 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.
  14649. * @param name The name of the particle system
  14650. */
  14651. constructor(name: string);
  14652. /**
  14653. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14654. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14655. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14656. * @returns the emitter
  14657. */
  14658. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14659. /**
  14660. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14661. * @param radius The radius of the hemisphere to emit from
  14662. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14663. * @returns the emitter
  14664. */
  14665. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14666. /**
  14667. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14668. * @param radius The radius of the sphere to emit from
  14669. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14670. * @returns the emitter
  14671. */
  14672. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14673. /**
  14674. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14675. * @param radius The radius of the sphere to emit from
  14676. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14677. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14678. * @returns the emitter
  14679. */
  14680. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14681. /**
  14682. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14683. * @param radius The radius of the emission cylinder
  14684. * @param height The height of the emission cylinder
  14685. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14686. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14687. * @returns the emitter
  14688. */
  14689. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14690. /**
  14691. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14692. * @param radius The radius of the cylinder to emit from
  14693. * @param height The height of the emission cylinder
  14694. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14695. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14696. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14697. * @returns the emitter
  14698. */
  14699. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14700. /**
  14701. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14702. * @param radius The radius of the cone to emit from
  14703. * @param angle The base angle of the cone
  14704. * @returns the emitter
  14705. */
  14706. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14707. /**
  14708. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14709. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14710. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14711. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14712. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14713. * @returns the emitter
  14714. */
  14715. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14716. }
  14717. }
  14718. declare module BABYLON {
  14719. /**
  14720. * Type of sub emitter
  14721. */
  14722. export enum SubEmitterType {
  14723. /**
  14724. * Attached to the particle over it's lifetime
  14725. */
  14726. ATTACHED = 0,
  14727. /**
  14728. * Created when the particle dies
  14729. */
  14730. END = 1
  14731. }
  14732. /**
  14733. * Sub emitter class used to emit particles from an existing particle
  14734. */
  14735. export class SubEmitter {
  14736. /**
  14737. * the particle system to be used by the sub emitter
  14738. */
  14739. particleSystem: ParticleSystem;
  14740. /**
  14741. * Type of the submitter (Default: END)
  14742. */
  14743. type: SubEmitterType;
  14744. /**
  14745. * 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)
  14746. * Note: This only is supported when using an emitter of type Mesh
  14747. */
  14748. inheritDirection: boolean;
  14749. /**
  14750. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14751. */
  14752. inheritedVelocityAmount: number;
  14753. /**
  14754. * Creates a sub emitter
  14755. * @param particleSystem the particle system to be used by the sub emitter
  14756. */
  14757. constructor(
  14758. /**
  14759. * the particle system to be used by the sub emitter
  14760. */
  14761. particleSystem: ParticleSystem);
  14762. /**
  14763. * Clones the sub emitter
  14764. * @returns the cloned sub emitter
  14765. */
  14766. clone(): SubEmitter;
  14767. /**
  14768. * Serialize current object to a JSON object
  14769. * @returns the serialized object
  14770. */
  14771. serialize(): any;
  14772. /** @hidden */
  14773. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14774. /**
  14775. * Creates a new SubEmitter from a serialized JSON version
  14776. * @param serializationObject defines the JSON object to read from
  14777. * @param scene defines the hosting scene
  14778. * @param rootUrl defines the rootUrl for data loading
  14779. * @returns a new SubEmitter
  14780. */
  14781. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14782. /** Release associated resources */
  14783. dispose(): void;
  14784. }
  14785. }
  14786. declare module BABYLON {
  14787. /** @hidden */
  14788. export var clipPlaneFragmentDeclaration: {
  14789. name: string;
  14790. shader: string;
  14791. };
  14792. }
  14793. declare module BABYLON {
  14794. /** @hidden */
  14795. export var imageProcessingDeclaration: {
  14796. name: string;
  14797. shader: string;
  14798. };
  14799. }
  14800. declare module BABYLON {
  14801. /** @hidden */
  14802. export var imageProcessingFunctions: {
  14803. name: string;
  14804. shader: string;
  14805. };
  14806. }
  14807. declare module BABYLON {
  14808. /** @hidden */
  14809. export var clipPlaneFragment: {
  14810. name: string;
  14811. shader: string;
  14812. };
  14813. }
  14814. declare module BABYLON {
  14815. /** @hidden */
  14816. export var particlesPixelShader: {
  14817. name: string;
  14818. shader: string;
  14819. };
  14820. }
  14821. declare module BABYLON {
  14822. /** @hidden */
  14823. export var clipPlaneVertexDeclaration: {
  14824. name: string;
  14825. shader: string;
  14826. };
  14827. }
  14828. declare module BABYLON {
  14829. /** @hidden */
  14830. export var clipPlaneVertex: {
  14831. name: string;
  14832. shader: string;
  14833. };
  14834. }
  14835. declare module BABYLON {
  14836. /** @hidden */
  14837. export var particlesVertexShader: {
  14838. name: string;
  14839. shader: string;
  14840. };
  14841. }
  14842. declare module BABYLON {
  14843. /**
  14844. * This represents a particle system in Babylon.
  14845. * 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.
  14846. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14847. * @example https://doc.babylonjs.com/babylon101/particles
  14848. */
  14849. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14850. /**
  14851. * Billboard mode will only apply to Y axis
  14852. */
  14853. static readonly BILLBOARDMODE_Y: number;
  14854. /**
  14855. * Billboard mode will apply to all axes
  14856. */
  14857. static readonly BILLBOARDMODE_ALL: number;
  14858. /**
  14859. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14860. */
  14861. static readonly BILLBOARDMODE_STRETCHED: number;
  14862. /**
  14863. * This function can be defined to provide custom update for active particles.
  14864. * This function will be called instead of regular update (age, position, color, etc.).
  14865. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14866. */
  14867. updateFunction: (particles: Particle[]) => void;
  14868. private _emitterWorldMatrix;
  14869. /**
  14870. * This function can be defined to specify initial direction for every new particle.
  14871. * It by default use the emitterType defined function
  14872. */
  14873. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14874. /**
  14875. * This function can be defined to specify initial position for every new particle.
  14876. * It by default use the emitterType defined function
  14877. */
  14878. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14879. /**
  14880. * @hidden
  14881. */
  14882. _inheritedVelocityOffset: Vector3;
  14883. /**
  14884. * An event triggered when the system is disposed
  14885. */
  14886. onDisposeObservable: Observable<ParticleSystem>;
  14887. private _onDisposeObserver;
  14888. /**
  14889. * Sets a callback that will be triggered when the system is disposed
  14890. */
  14891. onDispose: () => void;
  14892. private _particles;
  14893. private _epsilon;
  14894. private _capacity;
  14895. private _stockParticles;
  14896. private _newPartsExcess;
  14897. private _vertexData;
  14898. private _vertexBuffer;
  14899. private _vertexBuffers;
  14900. private _spriteBuffer;
  14901. private _indexBuffer;
  14902. private _effect;
  14903. private _customEffect;
  14904. private _cachedDefines;
  14905. private _scaledColorStep;
  14906. private _colorDiff;
  14907. private _scaledDirection;
  14908. private _scaledGravity;
  14909. private _currentRenderId;
  14910. private _alive;
  14911. private _useInstancing;
  14912. private _started;
  14913. private _stopped;
  14914. private _actualFrame;
  14915. private _scaledUpdateSpeed;
  14916. private _vertexBufferSize;
  14917. /** @hidden */
  14918. _currentEmitRateGradient: Nullable<FactorGradient>;
  14919. /** @hidden */
  14920. _currentEmitRate1: number;
  14921. /** @hidden */
  14922. _currentEmitRate2: number;
  14923. /** @hidden */
  14924. _currentStartSizeGradient: Nullable<FactorGradient>;
  14925. /** @hidden */
  14926. _currentStartSize1: number;
  14927. /** @hidden */
  14928. _currentStartSize2: number;
  14929. private readonly _rawTextureWidth;
  14930. private _rampGradientsTexture;
  14931. private _useRampGradients;
  14932. /** Gets or sets a boolean indicating that ramp gradients must be used
  14933. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14934. */
  14935. useRampGradients: boolean;
  14936. /**
  14937. * 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.
  14938. * 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: [])
  14939. */
  14940. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14941. private _subEmitters;
  14942. /**
  14943. * @hidden
  14944. * If the particle systems emitter should be disposed when the particle system is disposed
  14945. */
  14946. _disposeEmitterOnDispose: boolean;
  14947. /**
  14948. * The current active Sub-systems, this property is used by the root particle system only.
  14949. */
  14950. activeSubSystems: Array<ParticleSystem>;
  14951. private _rootParticleSystem;
  14952. /**
  14953. * Gets the current list of active particles
  14954. */
  14955. readonly particles: Particle[];
  14956. /**
  14957. * Returns the string "ParticleSystem"
  14958. * @returns a string containing the class name
  14959. */
  14960. getClassName(): string;
  14961. /**
  14962. * Instantiates a particle system.
  14963. * 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.
  14964. * @param name The name of the particle system
  14965. * @param capacity The max number of particles alive at the same time
  14966. * @param scene The scene the particle system belongs to
  14967. * @param customEffect a custom effect used to change the way particles are rendered by default
  14968. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14969. * @param epsilon Offset used to render the particles
  14970. */
  14971. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14972. private _addFactorGradient;
  14973. private _removeFactorGradient;
  14974. /**
  14975. * Adds a new life time gradient
  14976. * @param gradient defines the gradient to use (between 0 and 1)
  14977. * @param factor defines the life time factor to affect to the specified gradient
  14978. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14979. * @returns the current particle system
  14980. */
  14981. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14982. /**
  14983. * Remove a specific life time gradient
  14984. * @param gradient defines the gradient to remove
  14985. * @returns the current particle system
  14986. */
  14987. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14988. /**
  14989. * Adds a new size gradient
  14990. * @param gradient defines the gradient to use (between 0 and 1)
  14991. * @param factor defines the size factor to affect to the specified gradient
  14992. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14993. * @returns the current particle system
  14994. */
  14995. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14996. /**
  14997. * Remove a specific size gradient
  14998. * @param gradient defines the gradient to remove
  14999. * @returns the current particle system
  15000. */
  15001. removeSizeGradient(gradient: number): IParticleSystem;
  15002. /**
  15003. * Adds a new color remap gradient
  15004. * @param gradient defines the gradient to use (between 0 and 1)
  15005. * @param min defines the color remap minimal range
  15006. * @param max defines the color remap maximal range
  15007. * @returns the current particle system
  15008. */
  15009. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15010. /**
  15011. * Remove a specific color remap gradient
  15012. * @param gradient defines the gradient to remove
  15013. * @returns the current particle system
  15014. */
  15015. removeColorRemapGradient(gradient: number): IParticleSystem;
  15016. /**
  15017. * Adds a new alpha remap gradient
  15018. * @param gradient defines the gradient to use (between 0 and 1)
  15019. * @param min defines the alpha remap minimal range
  15020. * @param max defines the alpha remap maximal range
  15021. * @returns the current particle system
  15022. */
  15023. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15024. /**
  15025. * Remove a specific alpha remap gradient
  15026. * @param gradient defines the gradient to remove
  15027. * @returns the current particle system
  15028. */
  15029. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15030. /**
  15031. * Adds a new angular speed gradient
  15032. * @param gradient defines the gradient to use (between 0 and 1)
  15033. * @param factor defines the angular speed to affect to the specified gradient
  15034. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15035. * @returns the current particle system
  15036. */
  15037. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15038. /**
  15039. * Remove a specific angular speed gradient
  15040. * @param gradient defines the gradient to remove
  15041. * @returns the current particle system
  15042. */
  15043. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15044. /**
  15045. * Adds a new velocity gradient
  15046. * @param gradient defines the gradient to use (between 0 and 1)
  15047. * @param factor defines the velocity to affect to the specified gradient
  15048. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15049. * @returns the current particle system
  15050. */
  15051. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15052. /**
  15053. * Remove a specific velocity gradient
  15054. * @param gradient defines the gradient to remove
  15055. * @returns the current particle system
  15056. */
  15057. removeVelocityGradient(gradient: number): IParticleSystem;
  15058. /**
  15059. * Adds a new limit velocity gradient
  15060. * @param gradient defines the gradient to use (between 0 and 1)
  15061. * @param factor defines the limit velocity value to affect to the specified gradient
  15062. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15063. * @returns the current particle system
  15064. */
  15065. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15066. /**
  15067. * Remove a specific limit velocity gradient
  15068. * @param gradient defines the gradient to remove
  15069. * @returns the current particle system
  15070. */
  15071. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15072. /**
  15073. * Adds a new drag gradient
  15074. * @param gradient defines the gradient to use (between 0 and 1)
  15075. * @param factor defines the drag value to affect to the specified gradient
  15076. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15077. * @returns the current particle system
  15078. */
  15079. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15080. /**
  15081. * Remove a specific drag gradient
  15082. * @param gradient defines the gradient to remove
  15083. * @returns the current particle system
  15084. */
  15085. removeDragGradient(gradient: number): IParticleSystem;
  15086. /**
  15087. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15088. * @param gradient defines the gradient to use (between 0 and 1)
  15089. * @param factor defines the emit rate value to affect to the specified gradient
  15090. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15091. * @returns the current particle system
  15092. */
  15093. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15094. /**
  15095. * Remove a specific emit rate gradient
  15096. * @param gradient defines the gradient to remove
  15097. * @returns the current particle system
  15098. */
  15099. removeEmitRateGradient(gradient: number): IParticleSystem;
  15100. /**
  15101. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15102. * @param gradient defines the gradient to use (between 0 and 1)
  15103. * @param factor defines the start size value to affect to the specified gradient
  15104. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15105. * @returns the current particle system
  15106. */
  15107. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15108. /**
  15109. * Remove a specific start size gradient
  15110. * @param gradient defines the gradient to remove
  15111. * @returns the current particle system
  15112. */
  15113. removeStartSizeGradient(gradient: number): IParticleSystem;
  15114. private _createRampGradientTexture;
  15115. /**
  15116. * Gets the current list of ramp gradients.
  15117. * You must use addRampGradient and removeRampGradient to udpate this list
  15118. * @returns the list of ramp gradients
  15119. */
  15120. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15121. /**
  15122. * Adds a new ramp gradient used to remap particle colors
  15123. * @param gradient defines the gradient to use (between 0 and 1)
  15124. * @param color defines the color to affect to the specified gradient
  15125. * @returns the current particle system
  15126. */
  15127. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15128. /**
  15129. * Remove a specific ramp gradient
  15130. * @param gradient defines the gradient to remove
  15131. * @returns the current particle system
  15132. */
  15133. removeRampGradient(gradient: number): ParticleSystem;
  15134. /**
  15135. * Adds a new color gradient
  15136. * @param gradient defines the gradient to use (between 0 and 1)
  15137. * @param color1 defines the color to affect to the specified gradient
  15138. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15139. * @returns this particle system
  15140. */
  15141. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15142. /**
  15143. * Remove a specific color gradient
  15144. * @param gradient defines the gradient to remove
  15145. * @returns this particle system
  15146. */
  15147. removeColorGradient(gradient: number): IParticleSystem;
  15148. private _fetchR;
  15149. protected _reset(): void;
  15150. private _resetEffect;
  15151. private _createVertexBuffers;
  15152. private _createIndexBuffer;
  15153. /**
  15154. * Gets the maximum number of particles active at the same time.
  15155. * @returns The max number of active particles.
  15156. */
  15157. getCapacity(): number;
  15158. /**
  15159. * Gets whether there are still active particles in the system.
  15160. * @returns True if it is alive, otherwise false.
  15161. */
  15162. isAlive(): boolean;
  15163. /**
  15164. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15165. * @returns True if it has been started, otherwise false.
  15166. */
  15167. isStarted(): boolean;
  15168. private _prepareSubEmitterInternalArray;
  15169. /**
  15170. * Starts the particle system and begins to emit
  15171. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15172. */
  15173. start(delay?: number): void;
  15174. /**
  15175. * Stops the particle system.
  15176. * @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.
  15177. */
  15178. stop(stopSubEmitters?: boolean): void;
  15179. /**
  15180. * Remove all active particles
  15181. */
  15182. reset(): void;
  15183. /**
  15184. * @hidden (for internal use only)
  15185. */
  15186. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15187. /**
  15188. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15189. * Its lifetime will start back at 0.
  15190. */
  15191. recycleParticle: (particle: Particle) => void;
  15192. private _stopSubEmitters;
  15193. private _createParticle;
  15194. private _removeFromRoot;
  15195. private _emitFromParticle;
  15196. private _update;
  15197. /** @hidden */
  15198. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15199. /** @hidden */
  15200. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15201. /** @hidden */
  15202. private _getEffect;
  15203. /**
  15204. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15205. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15206. */
  15207. animate(preWarmOnly?: boolean): void;
  15208. private _appendParticleVertices;
  15209. /**
  15210. * Rebuilds the particle system.
  15211. */
  15212. rebuild(): void;
  15213. /**
  15214. * Is this system ready to be used/rendered
  15215. * @return true if the system is ready
  15216. */
  15217. isReady(): boolean;
  15218. private _render;
  15219. /**
  15220. * Renders the particle system in its current state.
  15221. * @returns the current number of particles
  15222. */
  15223. render(): number;
  15224. /**
  15225. * Disposes the particle system and free the associated resources
  15226. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15227. */
  15228. dispose(disposeTexture?: boolean): void;
  15229. /**
  15230. * Clones the particle system.
  15231. * @param name The name of the cloned object
  15232. * @param newEmitter The new emitter to use
  15233. * @returns the cloned particle system
  15234. */
  15235. clone(name: string, newEmitter: any): ParticleSystem;
  15236. /**
  15237. * Serializes the particle system to a JSON object.
  15238. * @returns the JSON object
  15239. */
  15240. serialize(): any;
  15241. /** @hidden */
  15242. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15243. /** @hidden */
  15244. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15245. /**
  15246. * Parses a JSON object to create a particle system.
  15247. * @param parsedParticleSystem The JSON object to parse
  15248. * @param scene The scene to create the particle system in
  15249. * @param rootUrl The root url to use to load external dependencies like texture
  15250. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15251. * @returns the Parsed particle system
  15252. */
  15253. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15254. }
  15255. }
  15256. declare module BABYLON {
  15257. /**
  15258. * A particle represents one of the element emitted by a particle system.
  15259. * This is mainly define by its coordinates, direction, velocity and age.
  15260. */
  15261. export class Particle {
  15262. /**
  15263. * The particle system the particle belongs to.
  15264. */
  15265. particleSystem: ParticleSystem;
  15266. private static _Count;
  15267. /**
  15268. * Unique ID of the particle
  15269. */
  15270. id: number;
  15271. /**
  15272. * The world position of the particle in the scene.
  15273. */
  15274. position: Vector3;
  15275. /**
  15276. * The world direction of the particle in the scene.
  15277. */
  15278. direction: Vector3;
  15279. /**
  15280. * The color of the particle.
  15281. */
  15282. color: Color4;
  15283. /**
  15284. * The color change of the particle per step.
  15285. */
  15286. colorStep: Color4;
  15287. /**
  15288. * Defines how long will the life of the particle be.
  15289. */
  15290. lifeTime: number;
  15291. /**
  15292. * The current age of the particle.
  15293. */
  15294. age: number;
  15295. /**
  15296. * The current size of the particle.
  15297. */
  15298. size: number;
  15299. /**
  15300. * The current scale of the particle.
  15301. */
  15302. scale: Vector2;
  15303. /**
  15304. * The current angle of the particle.
  15305. */
  15306. angle: number;
  15307. /**
  15308. * Defines how fast is the angle changing.
  15309. */
  15310. angularSpeed: number;
  15311. /**
  15312. * Defines the cell index used by the particle to be rendered from a sprite.
  15313. */
  15314. cellIndex: number;
  15315. /**
  15316. * The information required to support color remapping
  15317. */
  15318. remapData: Vector4;
  15319. /** @hidden */
  15320. _randomCellOffset?: number;
  15321. /** @hidden */
  15322. _initialDirection: Nullable<Vector3>;
  15323. /** @hidden */
  15324. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15325. /** @hidden */
  15326. _initialStartSpriteCellID: number;
  15327. /** @hidden */
  15328. _initialEndSpriteCellID: number;
  15329. /** @hidden */
  15330. _currentColorGradient: Nullable<ColorGradient>;
  15331. /** @hidden */
  15332. _currentColor1: Color4;
  15333. /** @hidden */
  15334. _currentColor2: Color4;
  15335. /** @hidden */
  15336. _currentSizeGradient: Nullable<FactorGradient>;
  15337. /** @hidden */
  15338. _currentSize1: number;
  15339. /** @hidden */
  15340. _currentSize2: number;
  15341. /** @hidden */
  15342. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15343. /** @hidden */
  15344. _currentAngularSpeed1: number;
  15345. /** @hidden */
  15346. _currentAngularSpeed2: number;
  15347. /** @hidden */
  15348. _currentVelocityGradient: Nullable<FactorGradient>;
  15349. /** @hidden */
  15350. _currentVelocity1: number;
  15351. /** @hidden */
  15352. _currentVelocity2: number;
  15353. /** @hidden */
  15354. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15355. /** @hidden */
  15356. _currentLimitVelocity1: number;
  15357. /** @hidden */
  15358. _currentLimitVelocity2: number;
  15359. /** @hidden */
  15360. _currentDragGradient: Nullable<FactorGradient>;
  15361. /** @hidden */
  15362. _currentDrag1: number;
  15363. /** @hidden */
  15364. _currentDrag2: number;
  15365. /** @hidden */
  15366. _randomNoiseCoordinates1: Vector3;
  15367. /** @hidden */
  15368. _randomNoiseCoordinates2: Vector3;
  15369. /**
  15370. * Creates a new instance Particle
  15371. * @param particleSystem the particle system the particle belongs to
  15372. */
  15373. constructor(
  15374. /**
  15375. * The particle system the particle belongs to.
  15376. */
  15377. particleSystem: ParticleSystem);
  15378. private updateCellInfoFromSystem;
  15379. /**
  15380. * Defines how the sprite cell index is updated for the particle
  15381. */
  15382. updateCellIndex(): void;
  15383. /** @hidden */
  15384. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15385. /** @hidden */
  15386. _inheritParticleInfoToSubEmitters(): void;
  15387. /** @hidden */
  15388. _reset(): void;
  15389. /**
  15390. * Copy the properties of particle to another one.
  15391. * @param other the particle to copy the information to.
  15392. */
  15393. copyTo(other: Particle): void;
  15394. }
  15395. }
  15396. declare module BABYLON {
  15397. /**
  15398. * Particle emitter represents a volume emitting particles.
  15399. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15400. */
  15401. export interface IParticleEmitterType {
  15402. /**
  15403. * Called by the particle System when the direction is computed for the created particle.
  15404. * @param worldMatrix is the world matrix of the particle system
  15405. * @param directionToUpdate is the direction vector to update with the result
  15406. * @param particle is the particle we are computed the direction for
  15407. */
  15408. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15409. /**
  15410. * Called by the particle System when the position is computed for the created particle.
  15411. * @param worldMatrix is the world matrix of the particle system
  15412. * @param positionToUpdate is the position vector to update with the result
  15413. * @param particle is the particle we are computed the position for
  15414. */
  15415. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15416. /**
  15417. * Clones the current emitter and returns a copy of it
  15418. * @returns the new emitter
  15419. */
  15420. clone(): IParticleEmitterType;
  15421. /**
  15422. * Called by the GPUParticleSystem to setup the update shader
  15423. * @param effect defines the update shader
  15424. */
  15425. applyToShader(effect: Effect): void;
  15426. /**
  15427. * Returns a string to use to update the GPU particles update shader
  15428. * @returns the effect defines string
  15429. */
  15430. getEffectDefines(): string;
  15431. /**
  15432. * Returns a string representing the class name
  15433. * @returns a string containing the class name
  15434. */
  15435. getClassName(): string;
  15436. /**
  15437. * Serializes the particle system to a JSON object.
  15438. * @returns the JSON object
  15439. */
  15440. serialize(): any;
  15441. /**
  15442. * Parse properties from a JSON object
  15443. * @param serializationObject defines the JSON object
  15444. */
  15445. parse(serializationObject: any): void;
  15446. }
  15447. }
  15448. declare module BABYLON {
  15449. /**
  15450. * Particle emitter emitting particles from the inside of a box.
  15451. * It emits the particles randomly between 2 given directions.
  15452. */
  15453. export class BoxParticleEmitter implements IParticleEmitterType {
  15454. /**
  15455. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15456. */
  15457. direction1: Vector3;
  15458. /**
  15459. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15460. */
  15461. direction2: Vector3;
  15462. /**
  15463. * 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.
  15464. */
  15465. minEmitBox: Vector3;
  15466. /**
  15467. * 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.
  15468. */
  15469. maxEmitBox: Vector3;
  15470. /**
  15471. * Creates a new instance BoxParticleEmitter
  15472. */
  15473. constructor();
  15474. /**
  15475. * Called by the particle System when the direction is computed for the created particle.
  15476. * @param worldMatrix is the world matrix of the particle system
  15477. * @param directionToUpdate is the direction vector to update with the result
  15478. * @param particle is the particle we are computed the direction for
  15479. */
  15480. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15481. /**
  15482. * Called by the particle System when the position is computed for the created particle.
  15483. * @param worldMatrix is the world matrix of the particle system
  15484. * @param positionToUpdate is the position vector to update with the result
  15485. * @param particle is the particle we are computed the position for
  15486. */
  15487. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15488. /**
  15489. * Clones the current emitter and returns a copy of it
  15490. * @returns the new emitter
  15491. */
  15492. clone(): BoxParticleEmitter;
  15493. /**
  15494. * Called by the GPUParticleSystem to setup the update shader
  15495. * @param effect defines the update shader
  15496. */
  15497. applyToShader(effect: Effect): void;
  15498. /**
  15499. * Returns a string to use to update the GPU particles update shader
  15500. * @returns a string containng the defines string
  15501. */
  15502. getEffectDefines(): string;
  15503. /**
  15504. * Returns the string "BoxParticleEmitter"
  15505. * @returns a string containing the class name
  15506. */
  15507. getClassName(): string;
  15508. /**
  15509. * Serializes the particle system to a JSON object.
  15510. * @returns the JSON object
  15511. */
  15512. serialize(): any;
  15513. /**
  15514. * Parse properties from a JSON object
  15515. * @param serializationObject defines the JSON object
  15516. */
  15517. parse(serializationObject: any): void;
  15518. }
  15519. }
  15520. declare module BABYLON {
  15521. /**
  15522. * Particle emitter emitting particles from the inside of a cone.
  15523. * It emits the particles alongside the cone volume from the base to the particle.
  15524. * The emission direction might be randomized.
  15525. */
  15526. export class ConeParticleEmitter implements IParticleEmitterType {
  15527. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15528. directionRandomizer: number;
  15529. private _radius;
  15530. private _angle;
  15531. private _height;
  15532. /**
  15533. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15534. */
  15535. radiusRange: number;
  15536. /**
  15537. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15538. */
  15539. heightRange: number;
  15540. /**
  15541. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15542. */
  15543. emitFromSpawnPointOnly: boolean;
  15544. /**
  15545. * Gets or sets the radius of the emission cone
  15546. */
  15547. radius: number;
  15548. /**
  15549. * Gets or sets the angle of the emission cone
  15550. */
  15551. angle: number;
  15552. private _buildHeight;
  15553. /**
  15554. * Creates a new instance ConeParticleEmitter
  15555. * @param radius the radius of the emission cone (1 by default)
  15556. * @param angle the cone base angle (PI by default)
  15557. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15558. */
  15559. constructor(radius?: number, angle?: number,
  15560. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15561. directionRandomizer?: number);
  15562. /**
  15563. * Called by the particle System when the direction is computed for the created particle.
  15564. * @param worldMatrix is the world matrix of the particle system
  15565. * @param directionToUpdate is the direction vector to update with the result
  15566. * @param particle is the particle we are computed the direction for
  15567. */
  15568. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15569. /**
  15570. * Called by the particle System when the position is computed for the created particle.
  15571. * @param worldMatrix is the world matrix of the particle system
  15572. * @param positionToUpdate is the position vector to update with the result
  15573. * @param particle is the particle we are computed the position for
  15574. */
  15575. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15576. /**
  15577. * Clones the current emitter and returns a copy of it
  15578. * @returns the new emitter
  15579. */
  15580. clone(): ConeParticleEmitter;
  15581. /**
  15582. * Called by the GPUParticleSystem to setup the update shader
  15583. * @param effect defines the update shader
  15584. */
  15585. applyToShader(effect: Effect): void;
  15586. /**
  15587. * Returns a string to use to update the GPU particles update shader
  15588. * @returns a string containng the defines string
  15589. */
  15590. getEffectDefines(): string;
  15591. /**
  15592. * Returns the string "ConeParticleEmitter"
  15593. * @returns a string containing the class name
  15594. */
  15595. getClassName(): string;
  15596. /**
  15597. * Serializes the particle system to a JSON object.
  15598. * @returns the JSON object
  15599. */
  15600. serialize(): any;
  15601. /**
  15602. * Parse properties from a JSON object
  15603. * @param serializationObject defines the JSON object
  15604. */
  15605. parse(serializationObject: any): void;
  15606. }
  15607. }
  15608. declare module BABYLON {
  15609. /**
  15610. * Particle emitter emitting particles from the inside of a cylinder.
  15611. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15612. */
  15613. export class CylinderParticleEmitter implements IParticleEmitterType {
  15614. /**
  15615. * The radius of the emission cylinder.
  15616. */
  15617. radius: number;
  15618. /**
  15619. * The height of the emission cylinder.
  15620. */
  15621. height: number;
  15622. /**
  15623. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15624. */
  15625. radiusRange: number;
  15626. /**
  15627. * How much to randomize the particle direction [0-1].
  15628. */
  15629. directionRandomizer: number;
  15630. /**
  15631. * Creates a new instance CylinderParticleEmitter
  15632. * @param radius the radius of the emission cylinder (1 by default)
  15633. * @param height the height of the emission cylinder (1 by default)
  15634. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15635. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15636. */
  15637. constructor(
  15638. /**
  15639. * The radius of the emission cylinder.
  15640. */
  15641. radius?: number,
  15642. /**
  15643. * The height of the emission cylinder.
  15644. */
  15645. height?: number,
  15646. /**
  15647. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15648. */
  15649. radiusRange?: number,
  15650. /**
  15651. * How much to randomize the particle direction [0-1].
  15652. */
  15653. directionRandomizer?: number);
  15654. /**
  15655. * Called by the particle System when the direction is computed for the created particle.
  15656. * @param worldMatrix is the world matrix of the particle system
  15657. * @param directionToUpdate is the direction vector to update with the result
  15658. * @param particle is the particle we are computed the direction for
  15659. */
  15660. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15661. /**
  15662. * Called by the particle System when the position is computed for the created particle.
  15663. * @param worldMatrix is the world matrix of the particle system
  15664. * @param positionToUpdate is the position vector to update with the result
  15665. * @param particle is the particle we are computed the position for
  15666. */
  15667. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15668. /**
  15669. * Clones the current emitter and returns a copy of it
  15670. * @returns the new emitter
  15671. */
  15672. clone(): CylinderParticleEmitter;
  15673. /**
  15674. * Called by the GPUParticleSystem to setup the update shader
  15675. * @param effect defines the update shader
  15676. */
  15677. applyToShader(effect: Effect): void;
  15678. /**
  15679. * Returns a string to use to update the GPU particles update shader
  15680. * @returns a string containng the defines string
  15681. */
  15682. getEffectDefines(): string;
  15683. /**
  15684. * Returns the string "CylinderParticleEmitter"
  15685. * @returns a string containing the class name
  15686. */
  15687. getClassName(): string;
  15688. /**
  15689. * Serializes the particle system to a JSON object.
  15690. * @returns the JSON object
  15691. */
  15692. serialize(): any;
  15693. /**
  15694. * Parse properties from a JSON object
  15695. * @param serializationObject defines the JSON object
  15696. */
  15697. parse(serializationObject: any): void;
  15698. }
  15699. /**
  15700. * Particle emitter emitting particles from the inside of a cylinder.
  15701. * It emits the particles randomly between two vectors.
  15702. */
  15703. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15704. /**
  15705. * The min limit of the emission direction.
  15706. */
  15707. direction1: Vector3;
  15708. /**
  15709. * The max limit of the emission direction.
  15710. */
  15711. direction2: Vector3;
  15712. /**
  15713. * Creates a new instance CylinderDirectedParticleEmitter
  15714. * @param radius the radius of the emission cylinder (1 by default)
  15715. * @param height the height of the emission cylinder (1 by default)
  15716. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15717. * @param direction1 the min limit of the emission direction (up vector by default)
  15718. * @param direction2 the max limit of the emission direction (up vector by default)
  15719. */
  15720. constructor(radius?: number, height?: number, radiusRange?: number,
  15721. /**
  15722. * The min limit of the emission direction.
  15723. */
  15724. direction1?: Vector3,
  15725. /**
  15726. * The max limit of the emission direction.
  15727. */
  15728. direction2?: Vector3);
  15729. /**
  15730. * Called by the particle System when the direction is computed for the created particle.
  15731. * @param worldMatrix is the world matrix of the particle system
  15732. * @param directionToUpdate is the direction vector to update with the result
  15733. * @param particle is the particle we are computed the direction for
  15734. */
  15735. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15736. /**
  15737. * Clones the current emitter and returns a copy of it
  15738. * @returns the new emitter
  15739. */
  15740. clone(): CylinderDirectedParticleEmitter;
  15741. /**
  15742. * Called by the GPUParticleSystem to setup the update shader
  15743. * @param effect defines the update shader
  15744. */
  15745. applyToShader(effect: Effect): void;
  15746. /**
  15747. * Returns a string to use to update the GPU particles update shader
  15748. * @returns a string containng the defines string
  15749. */
  15750. getEffectDefines(): string;
  15751. /**
  15752. * Returns the string "CylinderDirectedParticleEmitter"
  15753. * @returns a string containing the class name
  15754. */
  15755. getClassName(): string;
  15756. /**
  15757. * Serializes the particle system to a JSON object.
  15758. * @returns the JSON object
  15759. */
  15760. serialize(): any;
  15761. /**
  15762. * Parse properties from a JSON object
  15763. * @param serializationObject defines the JSON object
  15764. */
  15765. parse(serializationObject: any): void;
  15766. }
  15767. }
  15768. declare module BABYLON {
  15769. /**
  15770. * Particle emitter emitting particles from the inside of a hemisphere.
  15771. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15772. */
  15773. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15774. /**
  15775. * The radius of the emission hemisphere.
  15776. */
  15777. radius: number;
  15778. /**
  15779. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15780. */
  15781. radiusRange: number;
  15782. /**
  15783. * How much to randomize the particle direction [0-1].
  15784. */
  15785. directionRandomizer: number;
  15786. /**
  15787. * Creates a new instance HemisphericParticleEmitter
  15788. * @param radius the radius of the emission hemisphere (1 by default)
  15789. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15790. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15791. */
  15792. constructor(
  15793. /**
  15794. * The radius of the emission hemisphere.
  15795. */
  15796. radius?: number,
  15797. /**
  15798. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15799. */
  15800. radiusRange?: number,
  15801. /**
  15802. * How much to randomize the particle direction [0-1].
  15803. */
  15804. directionRandomizer?: number);
  15805. /**
  15806. * Called by the particle System when the direction is computed for the created particle.
  15807. * @param worldMatrix is the world matrix of the particle system
  15808. * @param directionToUpdate is the direction vector to update with the result
  15809. * @param particle is the particle we are computed the direction for
  15810. */
  15811. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15812. /**
  15813. * Called by the particle System when the position is computed for the created particle.
  15814. * @param worldMatrix is the world matrix of the particle system
  15815. * @param positionToUpdate is the position vector to update with the result
  15816. * @param particle is the particle we are computed the position for
  15817. */
  15818. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15819. /**
  15820. * Clones the current emitter and returns a copy of it
  15821. * @returns the new emitter
  15822. */
  15823. clone(): HemisphericParticleEmitter;
  15824. /**
  15825. * Called by the GPUParticleSystem to setup the update shader
  15826. * @param effect defines the update shader
  15827. */
  15828. applyToShader(effect: Effect): void;
  15829. /**
  15830. * Returns a string to use to update the GPU particles update shader
  15831. * @returns a string containng the defines string
  15832. */
  15833. getEffectDefines(): string;
  15834. /**
  15835. * Returns the string "HemisphericParticleEmitter"
  15836. * @returns a string containing the class name
  15837. */
  15838. getClassName(): string;
  15839. /**
  15840. * Serializes the particle system to a JSON object.
  15841. * @returns the JSON object
  15842. */
  15843. serialize(): any;
  15844. /**
  15845. * Parse properties from a JSON object
  15846. * @param serializationObject defines the JSON object
  15847. */
  15848. parse(serializationObject: any): void;
  15849. }
  15850. }
  15851. declare module BABYLON {
  15852. /**
  15853. * Particle emitter emitting particles from a point.
  15854. * It emits the particles randomly between 2 given directions.
  15855. */
  15856. export class PointParticleEmitter implements IParticleEmitterType {
  15857. /**
  15858. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15859. */
  15860. direction1: Vector3;
  15861. /**
  15862. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15863. */
  15864. direction2: Vector3;
  15865. /**
  15866. * Creates a new instance PointParticleEmitter
  15867. */
  15868. constructor();
  15869. /**
  15870. * Called by the particle System when the direction is computed for the created particle.
  15871. * @param worldMatrix is the world matrix of the particle system
  15872. * @param directionToUpdate is the direction vector to update with the result
  15873. * @param particle is the particle we are computed the direction for
  15874. */
  15875. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15876. /**
  15877. * Called by the particle System when the position is computed for the created particle.
  15878. * @param worldMatrix is the world matrix of the particle system
  15879. * @param positionToUpdate is the position vector to update with the result
  15880. * @param particle is the particle we are computed the position for
  15881. */
  15882. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15883. /**
  15884. * Clones the current emitter and returns a copy of it
  15885. * @returns the new emitter
  15886. */
  15887. clone(): PointParticleEmitter;
  15888. /**
  15889. * Called by the GPUParticleSystem to setup the update shader
  15890. * @param effect defines the update shader
  15891. */
  15892. applyToShader(effect: Effect): void;
  15893. /**
  15894. * Returns a string to use to update the GPU particles update shader
  15895. * @returns a string containng the defines string
  15896. */
  15897. getEffectDefines(): string;
  15898. /**
  15899. * Returns the string "PointParticleEmitter"
  15900. * @returns a string containing the class name
  15901. */
  15902. getClassName(): string;
  15903. /**
  15904. * Serializes the particle system to a JSON object.
  15905. * @returns the JSON object
  15906. */
  15907. serialize(): any;
  15908. /**
  15909. * Parse properties from a JSON object
  15910. * @param serializationObject defines the JSON object
  15911. */
  15912. parse(serializationObject: any): void;
  15913. }
  15914. }
  15915. declare module BABYLON {
  15916. /**
  15917. * Particle emitter emitting particles from the inside of a sphere.
  15918. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15919. */
  15920. export class SphereParticleEmitter implements IParticleEmitterType {
  15921. /**
  15922. * The radius of the emission sphere.
  15923. */
  15924. radius: number;
  15925. /**
  15926. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15927. */
  15928. radiusRange: number;
  15929. /**
  15930. * How much to randomize the particle direction [0-1].
  15931. */
  15932. directionRandomizer: number;
  15933. /**
  15934. * Creates a new instance SphereParticleEmitter
  15935. * @param radius the radius of the emission sphere (1 by default)
  15936. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15937. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15938. */
  15939. constructor(
  15940. /**
  15941. * The radius of the emission sphere.
  15942. */
  15943. radius?: number,
  15944. /**
  15945. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15946. */
  15947. radiusRange?: number,
  15948. /**
  15949. * How much to randomize the particle direction [0-1].
  15950. */
  15951. directionRandomizer?: number);
  15952. /**
  15953. * Called by the particle System when the direction is computed for the created particle.
  15954. * @param worldMatrix is the world matrix of the particle system
  15955. * @param directionToUpdate is the direction vector to update with the result
  15956. * @param particle is the particle we are computed the direction for
  15957. */
  15958. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15959. /**
  15960. * Called by the particle System when the position is computed for the created particle.
  15961. * @param worldMatrix is the world matrix of the particle system
  15962. * @param positionToUpdate is the position vector to update with the result
  15963. * @param particle is the particle we are computed the position for
  15964. */
  15965. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15966. /**
  15967. * Clones the current emitter and returns a copy of it
  15968. * @returns the new emitter
  15969. */
  15970. clone(): SphereParticleEmitter;
  15971. /**
  15972. * Called by the GPUParticleSystem to setup the update shader
  15973. * @param effect defines the update shader
  15974. */
  15975. applyToShader(effect: Effect): void;
  15976. /**
  15977. * Returns a string to use to update the GPU particles update shader
  15978. * @returns a string containng the defines string
  15979. */
  15980. getEffectDefines(): string;
  15981. /**
  15982. * Returns the string "SphereParticleEmitter"
  15983. * @returns a string containing the class name
  15984. */
  15985. getClassName(): string;
  15986. /**
  15987. * Serializes the particle system to a JSON object.
  15988. * @returns the JSON object
  15989. */
  15990. serialize(): any;
  15991. /**
  15992. * Parse properties from a JSON object
  15993. * @param serializationObject defines the JSON object
  15994. */
  15995. parse(serializationObject: any): void;
  15996. }
  15997. /**
  15998. * Particle emitter emitting particles from the inside of a sphere.
  15999. * It emits the particles randomly between two vectors.
  16000. */
  16001. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16002. /**
  16003. * The min limit of the emission direction.
  16004. */
  16005. direction1: Vector3;
  16006. /**
  16007. * The max limit of the emission direction.
  16008. */
  16009. direction2: Vector3;
  16010. /**
  16011. * Creates a new instance SphereDirectedParticleEmitter
  16012. * @param radius the radius of the emission sphere (1 by default)
  16013. * @param direction1 the min limit of the emission direction (up vector by default)
  16014. * @param direction2 the max limit of the emission direction (up vector by default)
  16015. */
  16016. constructor(radius?: number,
  16017. /**
  16018. * The min limit of the emission direction.
  16019. */
  16020. direction1?: Vector3,
  16021. /**
  16022. * The max limit of the emission direction.
  16023. */
  16024. direction2?: Vector3);
  16025. /**
  16026. * Called by the particle System when the direction is computed for the created particle.
  16027. * @param worldMatrix is the world matrix of the particle system
  16028. * @param directionToUpdate is the direction vector to update with the result
  16029. * @param particle is the particle we are computed the direction for
  16030. */
  16031. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16032. /**
  16033. * Clones the current emitter and returns a copy of it
  16034. * @returns the new emitter
  16035. */
  16036. clone(): SphereDirectedParticleEmitter;
  16037. /**
  16038. * Called by the GPUParticleSystem to setup the update shader
  16039. * @param effect defines the update shader
  16040. */
  16041. applyToShader(effect: Effect): void;
  16042. /**
  16043. * Returns a string to use to update the GPU particles update shader
  16044. * @returns a string containng the defines string
  16045. */
  16046. getEffectDefines(): string;
  16047. /**
  16048. * Returns the string "SphereDirectedParticleEmitter"
  16049. * @returns a string containing the class name
  16050. */
  16051. getClassName(): string;
  16052. /**
  16053. * Serializes the particle system to a JSON object.
  16054. * @returns the JSON object
  16055. */
  16056. serialize(): any;
  16057. /**
  16058. * Parse properties from a JSON object
  16059. * @param serializationObject defines the JSON object
  16060. */
  16061. parse(serializationObject: any): void;
  16062. }
  16063. }
  16064. declare module BABYLON {
  16065. /**
  16066. * Interface representing a particle system in Babylon.js.
  16067. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16068. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16069. */
  16070. export interface IParticleSystem {
  16071. /**
  16072. * List of animations used by the particle system.
  16073. */
  16074. animations: Animation[];
  16075. /**
  16076. * The id of the Particle system.
  16077. */
  16078. id: string;
  16079. /**
  16080. * The name of the Particle system.
  16081. */
  16082. name: string;
  16083. /**
  16084. * The emitter represents the Mesh or position we are attaching the particle system to.
  16085. */
  16086. emitter: Nullable<AbstractMesh | Vector3>;
  16087. /**
  16088. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16089. */
  16090. isBillboardBased: boolean;
  16091. /**
  16092. * The rendering group used by the Particle system to chose when to render.
  16093. */
  16094. renderingGroupId: number;
  16095. /**
  16096. * The layer mask we are rendering the particles through.
  16097. */
  16098. layerMask: number;
  16099. /**
  16100. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16101. */
  16102. updateSpeed: number;
  16103. /**
  16104. * The amount of time the particle system is running (depends of the overall update speed).
  16105. */
  16106. targetStopDuration: number;
  16107. /**
  16108. * The texture used to render each particle. (this can be a spritesheet)
  16109. */
  16110. particleTexture: Nullable<Texture>;
  16111. /**
  16112. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16113. */
  16114. blendMode: number;
  16115. /**
  16116. * Minimum life time of emitting particles.
  16117. */
  16118. minLifeTime: number;
  16119. /**
  16120. * Maximum life time of emitting particles.
  16121. */
  16122. maxLifeTime: number;
  16123. /**
  16124. * Minimum Size of emitting particles.
  16125. */
  16126. minSize: number;
  16127. /**
  16128. * Maximum Size of emitting particles.
  16129. */
  16130. maxSize: number;
  16131. /**
  16132. * Minimum scale of emitting particles on X axis.
  16133. */
  16134. minScaleX: number;
  16135. /**
  16136. * Maximum scale of emitting particles on X axis.
  16137. */
  16138. maxScaleX: number;
  16139. /**
  16140. * Minimum scale of emitting particles on Y axis.
  16141. */
  16142. minScaleY: number;
  16143. /**
  16144. * Maximum scale of emitting particles on Y axis.
  16145. */
  16146. maxScaleY: number;
  16147. /**
  16148. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16149. */
  16150. color1: Color4;
  16151. /**
  16152. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16153. */
  16154. color2: Color4;
  16155. /**
  16156. * Color the particle will have at the end of its lifetime.
  16157. */
  16158. colorDead: Color4;
  16159. /**
  16160. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16161. */
  16162. emitRate: number;
  16163. /**
  16164. * You can use gravity if you want to give an orientation to your particles.
  16165. */
  16166. gravity: Vector3;
  16167. /**
  16168. * Minimum power of emitting particles.
  16169. */
  16170. minEmitPower: number;
  16171. /**
  16172. * Maximum power of emitting particles.
  16173. */
  16174. maxEmitPower: number;
  16175. /**
  16176. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16177. */
  16178. minAngularSpeed: number;
  16179. /**
  16180. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16181. */
  16182. maxAngularSpeed: number;
  16183. /**
  16184. * Gets or sets the minimal initial rotation in radians.
  16185. */
  16186. minInitialRotation: number;
  16187. /**
  16188. * Gets or sets the maximal initial rotation in radians.
  16189. */
  16190. maxInitialRotation: number;
  16191. /**
  16192. * The particle emitter type defines the emitter used by the particle system.
  16193. * It can be for example box, sphere, or cone...
  16194. */
  16195. particleEmitterType: Nullable<IParticleEmitterType>;
  16196. /**
  16197. * Defines the delay in milliseconds before starting the system (0 by default)
  16198. */
  16199. startDelay: number;
  16200. /**
  16201. * 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
  16202. */
  16203. preWarmCycles: number;
  16204. /**
  16205. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16206. */
  16207. preWarmStepOffset: number;
  16208. /**
  16209. * 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)
  16210. */
  16211. spriteCellChangeSpeed: number;
  16212. /**
  16213. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16214. */
  16215. startSpriteCellID: number;
  16216. /**
  16217. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16218. */
  16219. endSpriteCellID: number;
  16220. /**
  16221. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16222. */
  16223. spriteCellWidth: number;
  16224. /**
  16225. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16226. */
  16227. spriteCellHeight: number;
  16228. /**
  16229. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16230. */
  16231. spriteRandomStartCell: boolean;
  16232. /**
  16233. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16234. */
  16235. isAnimationSheetEnabled: boolean;
  16236. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16237. translationPivot: Vector2;
  16238. /**
  16239. * Gets or sets a texture used to add random noise to particle positions
  16240. */
  16241. noiseTexture: Nullable<BaseTexture>;
  16242. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16243. noiseStrength: Vector3;
  16244. /**
  16245. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16246. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16247. */
  16248. billboardMode: number;
  16249. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16250. limitVelocityDamping: number;
  16251. /**
  16252. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16253. */
  16254. beginAnimationOnStart: boolean;
  16255. /**
  16256. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16257. */
  16258. beginAnimationFrom: number;
  16259. /**
  16260. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16261. */
  16262. beginAnimationTo: number;
  16263. /**
  16264. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16265. */
  16266. beginAnimationLoop: boolean;
  16267. /**
  16268. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16269. */
  16270. disposeOnStop: boolean;
  16271. /**
  16272. * Gets the maximum number of particles active at the same time.
  16273. * @returns The max number of active particles.
  16274. */
  16275. getCapacity(): number;
  16276. /**
  16277. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16278. * @returns True if it has been started, otherwise false.
  16279. */
  16280. isStarted(): boolean;
  16281. /**
  16282. * Animates the particle system for this frame.
  16283. */
  16284. animate(): void;
  16285. /**
  16286. * Renders the particle system in its current state.
  16287. * @returns the current number of particles
  16288. */
  16289. render(): number;
  16290. /**
  16291. * Dispose the particle system and frees its associated resources.
  16292. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16293. */
  16294. dispose(disposeTexture?: boolean): void;
  16295. /**
  16296. * Clones the particle system.
  16297. * @param name The name of the cloned object
  16298. * @param newEmitter The new emitter to use
  16299. * @returns the cloned particle system
  16300. */
  16301. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16302. /**
  16303. * Serializes the particle system to a JSON object.
  16304. * @returns the JSON object
  16305. */
  16306. serialize(): any;
  16307. /**
  16308. * Rebuild the particle system
  16309. */
  16310. rebuild(): void;
  16311. /**
  16312. * Starts the particle system and begins to emit
  16313. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16314. */
  16315. start(delay?: number): void;
  16316. /**
  16317. * Stops the particle system.
  16318. */
  16319. stop(): void;
  16320. /**
  16321. * Remove all active particles
  16322. */
  16323. reset(): void;
  16324. /**
  16325. * Is this system ready to be used/rendered
  16326. * @return true if the system is ready
  16327. */
  16328. isReady(): boolean;
  16329. /**
  16330. * Adds a new color gradient
  16331. * @param gradient defines the gradient to use (between 0 and 1)
  16332. * @param color1 defines the color to affect to the specified gradient
  16333. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16334. * @returns the current particle system
  16335. */
  16336. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16337. /**
  16338. * Remove a specific color gradient
  16339. * @param gradient defines the gradient to remove
  16340. * @returns the current particle system
  16341. */
  16342. removeColorGradient(gradient: number): IParticleSystem;
  16343. /**
  16344. * Adds a new size gradient
  16345. * @param gradient defines the gradient to use (between 0 and 1)
  16346. * @param factor defines the size factor to affect to the specified gradient
  16347. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16348. * @returns the current particle system
  16349. */
  16350. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16351. /**
  16352. * Remove a specific size gradient
  16353. * @param gradient defines the gradient to remove
  16354. * @returns the current particle system
  16355. */
  16356. removeSizeGradient(gradient: number): IParticleSystem;
  16357. /**
  16358. * Gets the current list of color gradients.
  16359. * You must use addColorGradient and removeColorGradient to udpate this list
  16360. * @returns the list of color gradients
  16361. */
  16362. getColorGradients(): Nullable<Array<ColorGradient>>;
  16363. /**
  16364. * Gets the current list of size gradients.
  16365. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16366. * @returns the list of size gradients
  16367. */
  16368. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16369. /**
  16370. * Gets the current list of angular speed gradients.
  16371. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16372. * @returns the list of angular speed gradients
  16373. */
  16374. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16375. /**
  16376. * Adds a new angular speed gradient
  16377. * @param gradient defines the gradient to use (between 0 and 1)
  16378. * @param factor defines the angular speed to affect to the specified gradient
  16379. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16380. * @returns the current particle system
  16381. */
  16382. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16383. /**
  16384. * Remove a specific angular speed gradient
  16385. * @param gradient defines the gradient to remove
  16386. * @returns the current particle system
  16387. */
  16388. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16389. /**
  16390. * Gets the current list of velocity gradients.
  16391. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16392. * @returns the list of velocity gradients
  16393. */
  16394. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16395. /**
  16396. * Adds a new velocity gradient
  16397. * @param gradient defines the gradient to use (between 0 and 1)
  16398. * @param factor defines the velocity to affect to the specified gradient
  16399. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16400. * @returns the current particle system
  16401. */
  16402. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16403. /**
  16404. * Remove a specific velocity gradient
  16405. * @param gradient defines the gradient to remove
  16406. * @returns the current particle system
  16407. */
  16408. removeVelocityGradient(gradient: number): IParticleSystem;
  16409. /**
  16410. * Gets the current list of limit velocity gradients.
  16411. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16412. * @returns the list of limit velocity gradients
  16413. */
  16414. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16415. /**
  16416. * Adds a new limit velocity gradient
  16417. * @param gradient defines the gradient to use (between 0 and 1)
  16418. * @param factor defines the limit velocity to affect to the specified gradient
  16419. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16420. * @returns the current particle system
  16421. */
  16422. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16423. /**
  16424. * Remove a specific limit velocity gradient
  16425. * @param gradient defines the gradient to remove
  16426. * @returns the current particle system
  16427. */
  16428. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16429. /**
  16430. * Adds a new drag gradient
  16431. * @param gradient defines the gradient to use (between 0 and 1)
  16432. * @param factor defines the drag to affect to the specified gradient
  16433. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16434. * @returns the current particle system
  16435. */
  16436. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16437. /**
  16438. * Remove a specific drag gradient
  16439. * @param gradient defines the gradient to remove
  16440. * @returns the current particle system
  16441. */
  16442. removeDragGradient(gradient: number): IParticleSystem;
  16443. /**
  16444. * Gets the current list of drag gradients.
  16445. * You must use addDragGradient and removeDragGradient to udpate this list
  16446. * @returns the list of drag gradients
  16447. */
  16448. getDragGradients(): Nullable<Array<FactorGradient>>;
  16449. /**
  16450. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16451. * @param gradient defines the gradient to use (between 0 and 1)
  16452. * @param factor defines the emit rate to affect to the specified gradient
  16453. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16454. * @returns the current particle system
  16455. */
  16456. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16457. /**
  16458. * Remove a specific emit rate gradient
  16459. * @param gradient defines the gradient to remove
  16460. * @returns the current particle system
  16461. */
  16462. removeEmitRateGradient(gradient: number): IParticleSystem;
  16463. /**
  16464. * Gets the current list of emit rate gradients.
  16465. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16466. * @returns the list of emit rate gradients
  16467. */
  16468. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16469. /**
  16470. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16471. * @param gradient defines the gradient to use (between 0 and 1)
  16472. * @param factor defines the start size to affect to the specified gradient
  16473. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16474. * @returns the current particle system
  16475. */
  16476. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16477. /**
  16478. * Remove a specific start size gradient
  16479. * @param gradient defines the gradient to remove
  16480. * @returns the current particle system
  16481. */
  16482. removeStartSizeGradient(gradient: number): IParticleSystem;
  16483. /**
  16484. * Gets the current list of start size gradients.
  16485. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16486. * @returns the list of start size gradients
  16487. */
  16488. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16489. /**
  16490. * Adds a new life time gradient
  16491. * @param gradient defines the gradient to use (between 0 and 1)
  16492. * @param factor defines the life time factor to affect to the specified gradient
  16493. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16494. * @returns the current particle system
  16495. */
  16496. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16497. /**
  16498. * Remove a specific life time gradient
  16499. * @param gradient defines the gradient to remove
  16500. * @returns the current particle system
  16501. */
  16502. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16503. /**
  16504. * Gets the current list of life time gradients.
  16505. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16506. * @returns the list of life time gradients
  16507. */
  16508. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16509. /**
  16510. * Gets the current list of color gradients.
  16511. * You must use addColorGradient and removeColorGradient to udpate this list
  16512. * @returns the list of color gradients
  16513. */
  16514. getColorGradients(): Nullable<Array<ColorGradient>>;
  16515. /**
  16516. * Adds a new ramp gradient used to remap particle colors
  16517. * @param gradient defines the gradient to use (between 0 and 1)
  16518. * @param color defines the color to affect to the specified gradient
  16519. * @returns the current particle system
  16520. */
  16521. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16522. /**
  16523. * Gets the current list of ramp gradients.
  16524. * You must use addRampGradient and removeRampGradient to udpate this list
  16525. * @returns the list of ramp gradients
  16526. */
  16527. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16528. /** Gets or sets a boolean indicating that ramp gradients must be used
  16529. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16530. */
  16531. useRampGradients: boolean;
  16532. /**
  16533. * Adds a new color remap gradient
  16534. * @param gradient defines the gradient to use (between 0 and 1)
  16535. * @param min defines the color remap minimal range
  16536. * @param max defines the color remap maximal range
  16537. * @returns the current particle system
  16538. */
  16539. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16540. /**
  16541. * Gets the current list of color remap gradients.
  16542. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16543. * @returns the list of color remap gradients
  16544. */
  16545. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16546. /**
  16547. * Adds a new alpha remap gradient
  16548. * @param gradient defines the gradient to use (between 0 and 1)
  16549. * @param min defines the alpha remap minimal range
  16550. * @param max defines the alpha remap maximal range
  16551. * @returns the current particle system
  16552. */
  16553. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16554. /**
  16555. * Gets the current list of alpha remap gradients.
  16556. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16557. * @returns the list of alpha remap gradients
  16558. */
  16559. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16560. /**
  16561. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16562. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16563. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16564. * @returns the emitter
  16565. */
  16566. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16567. /**
  16568. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16569. * @param radius The radius of the hemisphere to emit from
  16570. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16571. * @returns the emitter
  16572. */
  16573. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16574. /**
  16575. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16576. * @param radius The radius of the sphere to emit from
  16577. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16578. * @returns the emitter
  16579. */
  16580. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16581. /**
  16582. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16583. * @param radius The radius of the sphere to emit from
  16584. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16585. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16586. * @returns the emitter
  16587. */
  16588. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16589. /**
  16590. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16591. * @param radius The radius of the emission cylinder
  16592. * @param height The height of the emission cylinder
  16593. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16594. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16595. * @returns the emitter
  16596. */
  16597. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16598. /**
  16599. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16600. * @param radius The radius of the cylinder to emit from
  16601. * @param height The height of the emission cylinder
  16602. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16603. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16604. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16605. * @returns the emitter
  16606. */
  16607. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16608. /**
  16609. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16610. * @param radius The radius of the cone to emit from
  16611. * @param angle The base angle of the cone
  16612. * @returns the emitter
  16613. */
  16614. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16615. /**
  16616. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16617. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16618. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16619. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16620. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16621. * @returns the emitter
  16622. */
  16623. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16624. /**
  16625. * Get hosting scene
  16626. * @returns the scene
  16627. */
  16628. getScene(): Scene;
  16629. }
  16630. }
  16631. declare module BABYLON {
  16632. /**
  16633. * Creates an instance based on a source mesh.
  16634. */
  16635. export class InstancedMesh extends AbstractMesh {
  16636. private _sourceMesh;
  16637. private _currentLOD;
  16638. /** @hidden */
  16639. _indexInSourceMeshInstanceArray: number;
  16640. constructor(name: string, source: Mesh);
  16641. /**
  16642. * Returns the string "InstancedMesh".
  16643. */
  16644. getClassName(): string;
  16645. /** Gets the list of lights affecting that mesh */
  16646. readonly lightSources: Light[];
  16647. _resyncLightSources(): void;
  16648. _resyncLighSource(light: Light): void;
  16649. _removeLightSource(light: Light): void;
  16650. /**
  16651. * If the source mesh receives shadows
  16652. */
  16653. readonly receiveShadows: boolean;
  16654. /**
  16655. * The material of the source mesh
  16656. */
  16657. readonly material: Nullable<Material>;
  16658. /**
  16659. * Visibility of the source mesh
  16660. */
  16661. readonly visibility: number;
  16662. /**
  16663. * Skeleton of the source mesh
  16664. */
  16665. readonly skeleton: Nullable<Skeleton>;
  16666. /**
  16667. * Rendering ground id of the source mesh
  16668. */
  16669. renderingGroupId: number;
  16670. /**
  16671. * Returns the total number of vertices (integer).
  16672. */
  16673. getTotalVertices(): number;
  16674. /**
  16675. * Returns a positive integer : the total number of indices in this mesh geometry.
  16676. * @returns the numner of indices or zero if the mesh has no geometry.
  16677. */
  16678. getTotalIndices(): number;
  16679. /**
  16680. * The source mesh of the instance
  16681. */
  16682. readonly sourceMesh: Mesh;
  16683. /**
  16684. * Is this node ready to be used/rendered
  16685. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16686. * @return {boolean} is it ready
  16687. */
  16688. isReady(completeCheck?: boolean): boolean;
  16689. /**
  16690. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16691. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16692. * @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.
  16693. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16694. */
  16695. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16696. /**
  16697. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16698. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16699. * The `data` are either a numeric array either a Float32Array.
  16700. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16701. * 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).
  16702. * Note that a new underlying VertexBuffer object is created each call.
  16703. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16704. *
  16705. * Possible `kind` values :
  16706. * - VertexBuffer.PositionKind
  16707. * - VertexBuffer.UVKind
  16708. * - VertexBuffer.UV2Kind
  16709. * - VertexBuffer.UV3Kind
  16710. * - VertexBuffer.UV4Kind
  16711. * - VertexBuffer.UV5Kind
  16712. * - VertexBuffer.UV6Kind
  16713. * - VertexBuffer.ColorKind
  16714. * - VertexBuffer.MatricesIndicesKind
  16715. * - VertexBuffer.MatricesIndicesExtraKind
  16716. * - VertexBuffer.MatricesWeightsKind
  16717. * - VertexBuffer.MatricesWeightsExtraKind
  16718. *
  16719. * Returns the Mesh.
  16720. */
  16721. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16722. /**
  16723. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16724. * If the mesh has no geometry, it is simply returned as it is.
  16725. * The `data` are either a numeric array either a Float32Array.
  16726. * No new underlying VertexBuffer object is created.
  16727. * 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.
  16728. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16729. *
  16730. * Possible `kind` values :
  16731. * - VertexBuffer.PositionKind
  16732. * - VertexBuffer.UVKind
  16733. * - VertexBuffer.UV2Kind
  16734. * - VertexBuffer.UV3Kind
  16735. * - VertexBuffer.UV4Kind
  16736. * - VertexBuffer.UV5Kind
  16737. * - VertexBuffer.UV6Kind
  16738. * - VertexBuffer.ColorKind
  16739. * - VertexBuffer.MatricesIndicesKind
  16740. * - VertexBuffer.MatricesIndicesExtraKind
  16741. * - VertexBuffer.MatricesWeightsKind
  16742. * - VertexBuffer.MatricesWeightsExtraKind
  16743. *
  16744. * Returns the Mesh.
  16745. */
  16746. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16747. /**
  16748. * Sets the mesh indices.
  16749. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16750. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16751. * This method creates a new index buffer each call.
  16752. * Returns the Mesh.
  16753. */
  16754. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16755. /**
  16756. * Boolean : True if the mesh owns the requested kind of data.
  16757. */
  16758. isVerticesDataPresent(kind: string): boolean;
  16759. /**
  16760. * Returns an array of indices (IndicesArray).
  16761. */
  16762. getIndices(): Nullable<IndicesArray>;
  16763. readonly _positions: Nullable<Vector3[]>;
  16764. /**
  16765. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16766. * This means the mesh underlying bounding box and sphere are recomputed.
  16767. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16768. * @returns the current mesh
  16769. */
  16770. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16771. /** @hidden */
  16772. _preActivate(): InstancedMesh;
  16773. /** @hidden */
  16774. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16775. /** @hidden */
  16776. _postActivate(): void;
  16777. getWorldMatrix(): Matrix;
  16778. readonly isAnInstance: boolean;
  16779. /**
  16780. * Returns the current associated LOD AbstractMesh.
  16781. */
  16782. getLOD(camera: Camera): AbstractMesh;
  16783. /** @hidden */
  16784. _syncSubMeshes(): InstancedMesh;
  16785. /** @hidden */
  16786. _generatePointsArray(): boolean;
  16787. /**
  16788. * Creates a new InstancedMesh from the current mesh.
  16789. * - name (string) : the cloned mesh name
  16790. * - newParent (optional Node) : the optional Node to parent the clone to.
  16791. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16792. *
  16793. * Returns the clone.
  16794. */
  16795. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16796. /**
  16797. * Disposes the InstancedMesh.
  16798. * Returns nothing.
  16799. */
  16800. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16801. }
  16802. }
  16803. declare module BABYLON {
  16804. /**
  16805. * Defines the options associated with the creation of a shader material.
  16806. */
  16807. export interface IShaderMaterialOptions {
  16808. /**
  16809. * Does the material work in alpha blend mode
  16810. */
  16811. needAlphaBlending: boolean;
  16812. /**
  16813. * Does the material work in alpha test mode
  16814. */
  16815. needAlphaTesting: boolean;
  16816. /**
  16817. * The list of attribute names used in the shader
  16818. */
  16819. attributes: string[];
  16820. /**
  16821. * The list of unifrom names used in the shader
  16822. */
  16823. uniforms: string[];
  16824. /**
  16825. * The list of UBO names used in the shader
  16826. */
  16827. uniformBuffers: string[];
  16828. /**
  16829. * The list of sampler names used in the shader
  16830. */
  16831. samplers: string[];
  16832. /**
  16833. * The list of defines used in the shader
  16834. */
  16835. defines: string[];
  16836. }
  16837. /**
  16838. * 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.
  16839. *
  16840. * This returned material effects how the mesh will look based on the code in the shaders.
  16841. *
  16842. * @see http://doc.babylonjs.com/how_to/shader_material
  16843. */
  16844. export class ShaderMaterial extends Material {
  16845. private _shaderPath;
  16846. private _options;
  16847. private _textures;
  16848. private _textureArrays;
  16849. private _floats;
  16850. private _ints;
  16851. private _floatsArrays;
  16852. private _colors3;
  16853. private _colors3Arrays;
  16854. private _colors4;
  16855. private _vectors2;
  16856. private _vectors3;
  16857. private _vectors4;
  16858. private _matrices;
  16859. private _matrices3x3;
  16860. private _matrices2x2;
  16861. private _vectors2Arrays;
  16862. private _vectors3Arrays;
  16863. private _cachedWorldViewMatrix;
  16864. private _cachedWorldViewProjectionMatrix;
  16865. private _renderId;
  16866. /**
  16867. * Instantiate a new shader material.
  16868. * 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.
  16869. * This returned material effects how the mesh will look based on the code in the shaders.
  16870. * @see http://doc.babylonjs.com/how_to/shader_material
  16871. * @param name Define the name of the material in the scene
  16872. * @param scene Define the scene the material belongs to
  16873. * @param shaderPath Defines the route to the shader code in one of three ways:
  16874. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16875. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16876. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16877. * @param options Define the options used to create the shader
  16878. */
  16879. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16880. /**
  16881. * Gets the options used to compile the shader.
  16882. * They can be modified to trigger a new compilation
  16883. */
  16884. readonly options: IShaderMaterialOptions;
  16885. /**
  16886. * Gets the current class name of the material e.g. "ShaderMaterial"
  16887. * Mainly use in serialization.
  16888. * @returns the class name
  16889. */
  16890. getClassName(): string;
  16891. /**
  16892. * Specifies if the material will require alpha blending
  16893. * @returns a boolean specifying if alpha blending is needed
  16894. */
  16895. needAlphaBlending(): boolean;
  16896. /**
  16897. * Specifies if this material should be rendered in alpha test mode
  16898. * @returns a boolean specifying if an alpha test is needed.
  16899. */
  16900. needAlphaTesting(): boolean;
  16901. private _checkUniform;
  16902. /**
  16903. * Set a texture in the shader.
  16904. * @param name Define the name of the uniform samplers as defined in the shader
  16905. * @param texture Define the texture to bind to this sampler
  16906. * @return the material itself allowing "fluent" like uniform updates
  16907. */
  16908. setTexture(name: string, texture: Texture): ShaderMaterial;
  16909. /**
  16910. * Set a texture array in the shader.
  16911. * @param name Define the name of the uniform sampler array as defined in the shader
  16912. * @param textures Define the list of textures to bind to this sampler
  16913. * @return the material itself allowing "fluent" like uniform updates
  16914. */
  16915. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16916. /**
  16917. * Set a float in the shader.
  16918. * @param name Define the name of the uniform as defined in the shader
  16919. * @param value Define the value to give to the uniform
  16920. * @return the material itself allowing "fluent" like uniform updates
  16921. */
  16922. setFloat(name: string, value: number): ShaderMaterial;
  16923. /**
  16924. * Set a int in the shader.
  16925. * @param name Define the name of the uniform as defined in the shader
  16926. * @param value Define the value to give to the uniform
  16927. * @return the material itself allowing "fluent" like uniform updates
  16928. */
  16929. setInt(name: string, value: number): ShaderMaterial;
  16930. /**
  16931. * Set an array of floats in the shader.
  16932. * @param name Define the name of the uniform as defined in the shader
  16933. * @param value Define the value to give to the uniform
  16934. * @return the material itself allowing "fluent" like uniform updates
  16935. */
  16936. setFloats(name: string, value: number[]): ShaderMaterial;
  16937. /**
  16938. * Set a vec3 in the shader from a Color3.
  16939. * @param name Define the name of the uniform as defined in the shader
  16940. * @param value Define the value to give to the uniform
  16941. * @return the material itself allowing "fluent" like uniform updates
  16942. */
  16943. setColor3(name: string, value: Color3): ShaderMaterial;
  16944. /**
  16945. * Set a vec3 array in the shader from a Color3 array.
  16946. * @param name Define the name of the uniform as defined in the shader
  16947. * @param value Define the value to give to the uniform
  16948. * @return the material itself allowing "fluent" like uniform updates
  16949. */
  16950. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16951. /**
  16952. * Set a vec4 in the shader from a Color4.
  16953. * @param name Define the name of the uniform as defined in the shader
  16954. * @param value Define the value to give to the uniform
  16955. * @return the material itself allowing "fluent" like uniform updates
  16956. */
  16957. setColor4(name: string, value: Color4): ShaderMaterial;
  16958. /**
  16959. * Set a vec2 in the shader from a Vector2.
  16960. * @param name Define the name of the uniform as defined in the shader
  16961. * @param value Define the value to give to the uniform
  16962. * @return the material itself allowing "fluent" like uniform updates
  16963. */
  16964. setVector2(name: string, value: Vector2): ShaderMaterial;
  16965. /**
  16966. * Set a vec3 in the shader from a Vector3.
  16967. * @param name Define the name of the uniform as defined in the shader
  16968. * @param value Define the value to give to the uniform
  16969. * @return the material itself allowing "fluent" like uniform updates
  16970. */
  16971. setVector3(name: string, value: Vector3): ShaderMaterial;
  16972. /**
  16973. * Set a vec4 in the shader from a Vector4.
  16974. * @param name Define the name of the uniform as defined in the shader
  16975. * @param value Define the value to give to the uniform
  16976. * @return the material itself allowing "fluent" like uniform updates
  16977. */
  16978. setVector4(name: string, value: Vector4): ShaderMaterial;
  16979. /**
  16980. * Set a mat4 in the shader from a Matrix.
  16981. * @param name Define the name of the uniform as defined in the shader
  16982. * @param value Define the value to give to the uniform
  16983. * @return the material itself allowing "fluent" like uniform updates
  16984. */
  16985. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16986. /**
  16987. * Set a mat3 in the shader from a Float32Array.
  16988. * @param name Define the name of the uniform as defined in the shader
  16989. * @param value Define the value to give to the uniform
  16990. * @return the material itself allowing "fluent" like uniform updates
  16991. */
  16992. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16993. /**
  16994. * Set a mat2 in the shader from a Float32Array.
  16995. * @param name Define the name of the uniform as defined in the shader
  16996. * @param value Define the value to give to the uniform
  16997. * @return the material itself allowing "fluent" like uniform updates
  16998. */
  16999. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17000. /**
  17001. * Set a vec2 array in the shader from a number array.
  17002. * @param name Define the name of the uniform as defined in the shader
  17003. * @param value Define the value to give to the uniform
  17004. * @return the material itself allowing "fluent" like uniform updates
  17005. */
  17006. setArray2(name: string, value: number[]): ShaderMaterial;
  17007. /**
  17008. * Set a vec3 array in the shader from a number array.
  17009. * @param name Define the name of the uniform as defined in the shader
  17010. * @param value Define the value to give to the uniform
  17011. * @return the material itself allowing "fluent" like uniform updates
  17012. */
  17013. setArray3(name: string, value: number[]): ShaderMaterial;
  17014. private _checkCache;
  17015. /**
  17016. * Specifies that the submesh is ready to be used
  17017. * @param mesh defines the mesh to check
  17018. * @param subMesh defines which submesh to check
  17019. * @param useInstances specifies that instances should be used
  17020. * @returns a boolean indicating that the submesh is ready or not
  17021. */
  17022. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17023. /**
  17024. * Checks if the material is ready to render the requested mesh
  17025. * @param mesh Define the mesh to render
  17026. * @param useInstances Define whether or not the material is used with instances
  17027. * @returns true if ready, otherwise false
  17028. */
  17029. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17030. /**
  17031. * Binds the world matrix to the material
  17032. * @param world defines the world transformation matrix
  17033. */
  17034. bindOnlyWorldMatrix(world: Matrix): void;
  17035. /**
  17036. * Binds the material to the mesh
  17037. * @param world defines the world transformation matrix
  17038. * @param mesh defines the mesh to bind the material to
  17039. */
  17040. bind(world: Matrix, mesh?: Mesh): void;
  17041. /**
  17042. * Gets the active textures from the material
  17043. * @returns an array of textures
  17044. */
  17045. getActiveTextures(): BaseTexture[];
  17046. /**
  17047. * Specifies if the material uses a texture
  17048. * @param texture defines the texture to check against the material
  17049. * @returns a boolean specifying if the material uses the texture
  17050. */
  17051. hasTexture(texture: BaseTexture): boolean;
  17052. /**
  17053. * Makes a duplicate of the material, and gives it a new name
  17054. * @param name defines the new name for the duplicated material
  17055. * @returns the cloned material
  17056. */
  17057. clone(name: string): ShaderMaterial;
  17058. /**
  17059. * Disposes the material
  17060. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17061. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17062. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17063. */
  17064. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17065. /**
  17066. * Serializes this material in a JSON representation
  17067. * @returns the serialized material object
  17068. */
  17069. serialize(): any;
  17070. /**
  17071. * Creates a shader material from parsed shader material data
  17072. * @param source defines the JSON represnetation of the material
  17073. * @param scene defines the hosting scene
  17074. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17075. * @returns a new material
  17076. */
  17077. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17078. }
  17079. }
  17080. declare module BABYLON {
  17081. /** @hidden */
  17082. export var colorPixelShader: {
  17083. name: string;
  17084. shader: string;
  17085. };
  17086. }
  17087. declare module BABYLON {
  17088. /** @hidden */
  17089. export var colorVertexShader: {
  17090. name: string;
  17091. shader: string;
  17092. };
  17093. }
  17094. declare module BABYLON {
  17095. /**
  17096. * Line mesh
  17097. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17098. */
  17099. export class LinesMesh extends Mesh {
  17100. /**
  17101. * If vertex color should be applied to the mesh
  17102. */
  17103. readonly useVertexColor?: boolean | undefined;
  17104. /**
  17105. * If vertex alpha should be applied to the mesh
  17106. */
  17107. readonly useVertexAlpha?: boolean | undefined;
  17108. /**
  17109. * Color of the line (Default: White)
  17110. */
  17111. color: Color3;
  17112. /**
  17113. * Alpha of the line (Default: 1)
  17114. */
  17115. alpha: number;
  17116. /**
  17117. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17118. * This margin is expressed in world space coordinates, so its value may vary.
  17119. * Default value is 0.1
  17120. */
  17121. intersectionThreshold: number;
  17122. private _colorShader;
  17123. private color4;
  17124. /**
  17125. * Creates a new LinesMesh
  17126. * @param name defines the name
  17127. * @param scene defines the hosting scene
  17128. * @param parent defines the parent mesh if any
  17129. * @param source defines the optional source LinesMesh used to clone data from
  17130. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17131. * When false, achieved by calling a clone(), also passing False.
  17132. * This will make creation of children, recursive.
  17133. * @param useVertexColor defines if this LinesMesh supports vertex color
  17134. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17135. */
  17136. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17137. /**
  17138. * If vertex color should be applied to the mesh
  17139. */
  17140. useVertexColor?: boolean | undefined,
  17141. /**
  17142. * If vertex alpha should be applied to the mesh
  17143. */
  17144. useVertexAlpha?: boolean | undefined);
  17145. private _addClipPlaneDefine;
  17146. private _removeClipPlaneDefine;
  17147. isReady(): boolean;
  17148. /**
  17149. * Returns the string "LineMesh"
  17150. */
  17151. getClassName(): string;
  17152. /**
  17153. * @hidden
  17154. */
  17155. /**
  17156. * @hidden
  17157. */
  17158. material: Material;
  17159. /**
  17160. * @hidden
  17161. */
  17162. readonly checkCollisions: boolean;
  17163. /** @hidden */
  17164. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17165. /** @hidden */
  17166. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17167. /**
  17168. * Disposes of the line mesh
  17169. * @param doNotRecurse If children should be disposed
  17170. */
  17171. dispose(doNotRecurse?: boolean): void;
  17172. /**
  17173. * Returns a new LineMesh object cloned from the current one.
  17174. */
  17175. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17176. /**
  17177. * Creates a new InstancedLinesMesh object from the mesh model.
  17178. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17179. * @param name defines the name of the new instance
  17180. * @returns a new InstancedLinesMesh
  17181. */
  17182. createInstance(name: string): InstancedLinesMesh;
  17183. }
  17184. /**
  17185. * Creates an instance based on a source LinesMesh
  17186. */
  17187. export class InstancedLinesMesh extends InstancedMesh {
  17188. /**
  17189. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17190. * This margin is expressed in world space coordinates, so its value may vary.
  17191. * Initilized with the intersectionThreshold value of the source LinesMesh
  17192. */
  17193. intersectionThreshold: number;
  17194. constructor(name: string, source: LinesMesh);
  17195. /**
  17196. * Returns the string "InstancedLinesMesh".
  17197. */
  17198. getClassName(): string;
  17199. }
  17200. }
  17201. declare module BABYLON {
  17202. /** @hidden */
  17203. export var linePixelShader: {
  17204. name: string;
  17205. shader: string;
  17206. };
  17207. }
  17208. declare module BABYLON {
  17209. /** @hidden */
  17210. export var lineVertexShader: {
  17211. name: string;
  17212. shader: string;
  17213. };
  17214. }
  17215. declare module BABYLON {
  17216. interface AbstractMesh {
  17217. /**
  17218. * Gets the edgesRenderer associated with the mesh
  17219. */
  17220. edgesRenderer: Nullable<EdgesRenderer>;
  17221. }
  17222. interface LinesMesh {
  17223. /**
  17224. * Enables the edge rendering mode on the mesh.
  17225. * This mode makes the mesh edges visible
  17226. * @param epsilon defines the maximal distance between two angles to detect a face
  17227. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17228. * @returns the currentAbstractMesh
  17229. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17230. */
  17231. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17232. }
  17233. interface InstancedLinesMesh {
  17234. /**
  17235. * Enables the edge rendering mode on the mesh.
  17236. * This mode makes the mesh edges visible
  17237. * @param epsilon defines the maximal distance between two angles to detect a face
  17238. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17239. * @returns the current InstancedLinesMesh
  17240. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17241. */
  17242. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17243. }
  17244. /**
  17245. * Defines the minimum contract an Edges renderer should follow.
  17246. */
  17247. export interface IEdgesRenderer extends IDisposable {
  17248. /**
  17249. * Gets or sets a boolean indicating if the edgesRenderer is active
  17250. */
  17251. isEnabled: boolean;
  17252. /**
  17253. * Renders the edges of the attached mesh,
  17254. */
  17255. render(): void;
  17256. /**
  17257. * Checks wether or not the edges renderer is ready to render.
  17258. * @return true if ready, otherwise false.
  17259. */
  17260. isReady(): boolean;
  17261. }
  17262. /**
  17263. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17264. */
  17265. export class EdgesRenderer implements IEdgesRenderer {
  17266. /**
  17267. * Define the size of the edges with an orthographic camera
  17268. */
  17269. edgesWidthScalerForOrthographic: number;
  17270. /**
  17271. * Define the size of the edges with a perspective camera
  17272. */
  17273. edgesWidthScalerForPerspective: number;
  17274. protected _source: AbstractMesh;
  17275. protected _linesPositions: number[];
  17276. protected _linesNormals: number[];
  17277. protected _linesIndices: number[];
  17278. protected _epsilon: number;
  17279. protected _indicesCount: number;
  17280. protected _lineShader: ShaderMaterial;
  17281. protected _ib: DataBuffer;
  17282. protected _buffers: {
  17283. [key: string]: Nullable<VertexBuffer>;
  17284. };
  17285. protected _checkVerticesInsteadOfIndices: boolean;
  17286. private _meshRebuildObserver;
  17287. private _meshDisposeObserver;
  17288. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17289. isEnabled: boolean;
  17290. /**
  17291. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17292. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17293. * @param source Mesh used to create edges
  17294. * @param epsilon sum of angles in adjacency to check for edge
  17295. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17296. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17297. */
  17298. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17299. protected _prepareRessources(): void;
  17300. /** @hidden */
  17301. _rebuild(): void;
  17302. /**
  17303. * Releases the required resources for the edges renderer
  17304. */
  17305. dispose(): void;
  17306. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17307. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17308. /**
  17309. * Checks if the pair of p0 and p1 is en edge
  17310. * @param faceIndex
  17311. * @param edge
  17312. * @param faceNormals
  17313. * @param p0
  17314. * @param p1
  17315. * @private
  17316. */
  17317. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17318. /**
  17319. * push line into the position, normal and index buffer
  17320. * @protected
  17321. */
  17322. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17323. /**
  17324. * Generates lines edges from adjacencjes
  17325. * @private
  17326. */
  17327. _generateEdgesLines(): void;
  17328. /**
  17329. * Checks wether or not the edges renderer is ready to render.
  17330. * @return true if ready, otherwise false.
  17331. */
  17332. isReady(): boolean;
  17333. /**
  17334. * Renders the edges of the attached mesh,
  17335. */
  17336. render(): void;
  17337. }
  17338. /**
  17339. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17340. */
  17341. export class LineEdgesRenderer extends EdgesRenderer {
  17342. /**
  17343. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17344. * @param source LineMesh used to generate edges
  17345. * @param epsilon not important (specified angle for edge detection)
  17346. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17347. */
  17348. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17349. /**
  17350. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17351. */
  17352. _generateEdgesLines(): void;
  17353. }
  17354. }
  17355. declare module BABYLON {
  17356. /**
  17357. * This represents the object necessary to create a rendering group.
  17358. * This is exclusively used and created by the rendering manager.
  17359. * To modify the behavior, you use the available helpers in your scene or meshes.
  17360. * @hidden
  17361. */
  17362. export class RenderingGroup {
  17363. index: number;
  17364. private static _zeroVector;
  17365. private _scene;
  17366. private _opaqueSubMeshes;
  17367. private _transparentSubMeshes;
  17368. private _alphaTestSubMeshes;
  17369. private _depthOnlySubMeshes;
  17370. private _particleSystems;
  17371. private _spriteManagers;
  17372. private _opaqueSortCompareFn;
  17373. private _alphaTestSortCompareFn;
  17374. private _transparentSortCompareFn;
  17375. private _renderOpaque;
  17376. private _renderAlphaTest;
  17377. private _renderTransparent;
  17378. /** @hidden */
  17379. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17380. onBeforeTransparentRendering: () => void;
  17381. /**
  17382. * Set the opaque sort comparison function.
  17383. * If null the sub meshes will be render in the order they were created
  17384. */
  17385. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17386. /**
  17387. * Set the alpha test sort comparison function.
  17388. * If null the sub meshes will be render in the order they were created
  17389. */
  17390. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17391. /**
  17392. * Set the transparent sort comparison function.
  17393. * If null the sub meshes will be render in the order they were created
  17394. */
  17395. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17396. /**
  17397. * Creates a new rendering group.
  17398. * @param index The rendering group index
  17399. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17400. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17401. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17402. */
  17403. 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>);
  17404. /**
  17405. * Render all the sub meshes contained in the group.
  17406. * @param customRenderFunction Used to override the default render behaviour of the group.
  17407. * @returns true if rendered some submeshes.
  17408. */
  17409. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17410. /**
  17411. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17412. * @param subMeshes The submeshes to render
  17413. */
  17414. private renderOpaqueSorted;
  17415. /**
  17416. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17417. * @param subMeshes The submeshes to render
  17418. */
  17419. private renderAlphaTestSorted;
  17420. /**
  17421. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17422. * @param subMeshes The submeshes to render
  17423. */
  17424. private renderTransparentSorted;
  17425. /**
  17426. * Renders the submeshes in a specified order.
  17427. * @param subMeshes The submeshes to sort before render
  17428. * @param sortCompareFn The comparison function use to sort
  17429. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17430. * @param transparent Specifies to activate blending if true
  17431. */
  17432. private static renderSorted;
  17433. /**
  17434. * Renders the submeshes in the order they were dispatched (no sort applied).
  17435. * @param subMeshes The submeshes to render
  17436. */
  17437. private static renderUnsorted;
  17438. /**
  17439. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17440. * are rendered back to front if in the same alpha index.
  17441. *
  17442. * @param a The first submesh
  17443. * @param b The second submesh
  17444. * @returns The result of the comparison
  17445. */
  17446. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17447. /**
  17448. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17449. * are rendered back to front.
  17450. *
  17451. * @param a The first submesh
  17452. * @param b The second submesh
  17453. * @returns The result of the comparison
  17454. */
  17455. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17456. /**
  17457. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17458. * are rendered front to back (prevent overdraw).
  17459. *
  17460. * @param a The first submesh
  17461. * @param b The second submesh
  17462. * @returns The result of the comparison
  17463. */
  17464. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17465. /**
  17466. * Resets the different lists of submeshes to prepare a new frame.
  17467. */
  17468. prepare(): void;
  17469. dispose(): void;
  17470. /**
  17471. * Inserts the submesh in its correct queue depending on its material.
  17472. * @param subMesh The submesh to dispatch
  17473. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17474. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17475. */
  17476. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17477. dispatchSprites(spriteManager: ISpriteManager): void;
  17478. dispatchParticles(particleSystem: IParticleSystem): void;
  17479. private _renderParticles;
  17480. private _renderSprites;
  17481. }
  17482. }
  17483. declare module BABYLON {
  17484. /**
  17485. * Interface describing the different options available in the rendering manager
  17486. * regarding Auto Clear between groups.
  17487. */
  17488. export interface IRenderingManagerAutoClearSetup {
  17489. /**
  17490. * Defines whether or not autoclear is enable.
  17491. */
  17492. autoClear: boolean;
  17493. /**
  17494. * Defines whether or not to autoclear the depth buffer.
  17495. */
  17496. depth: boolean;
  17497. /**
  17498. * Defines whether or not to autoclear the stencil buffer.
  17499. */
  17500. stencil: boolean;
  17501. }
  17502. /**
  17503. * This class is used by the onRenderingGroupObservable
  17504. */
  17505. export class RenderingGroupInfo {
  17506. /**
  17507. * The Scene that being rendered
  17508. */
  17509. scene: Scene;
  17510. /**
  17511. * The camera currently used for the rendering pass
  17512. */
  17513. camera: Nullable<Camera>;
  17514. /**
  17515. * The ID of the renderingGroup being processed
  17516. */
  17517. renderingGroupId: number;
  17518. }
  17519. /**
  17520. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17521. * It is enable to manage the different groups as well as the different necessary sort functions.
  17522. * This should not be used directly aside of the few static configurations
  17523. */
  17524. export class RenderingManager {
  17525. /**
  17526. * The max id used for rendering groups (not included)
  17527. */
  17528. static MAX_RENDERINGGROUPS: number;
  17529. /**
  17530. * The min id used for rendering groups (included)
  17531. */
  17532. static MIN_RENDERINGGROUPS: number;
  17533. /**
  17534. * Used to globally prevent autoclearing scenes.
  17535. */
  17536. static AUTOCLEAR: boolean;
  17537. /**
  17538. * @hidden
  17539. */
  17540. _useSceneAutoClearSetup: boolean;
  17541. private _scene;
  17542. private _renderingGroups;
  17543. private _depthStencilBufferAlreadyCleaned;
  17544. private _autoClearDepthStencil;
  17545. private _customOpaqueSortCompareFn;
  17546. private _customAlphaTestSortCompareFn;
  17547. private _customTransparentSortCompareFn;
  17548. private _renderingGroupInfo;
  17549. /**
  17550. * Instantiates a new rendering group for a particular scene
  17551. * @param scene Defines the scene the groups belongs to
  17552. */
  17553. constructor(scene: Scene);
  17554. private _clearDepthStencilBuffer;
  17555. /**
  17556. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17557. * @hidden
  17558. */
  17559. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17560. /**
  17561. * Resets the different information of the group to prepare a new frame
  17562. * @hidden
  17563. */
  17564. reset(): void;
  17565. /**
  17566. * Dispose and release the group and its associated resources.
  17567. * @hidden
  17568. */
  17569. dispose(): void;
  17570. /**
  17571. * Clear the info related to rendering groups preventing retention points during dispose.
  17572. */
  17573. freeRenderingGroups(): void;
  17574. private _prepareRenderingGroup;
  17575. /**
  17576. * Add a sprite manager to the rendering manager in order to render it this frame.
  17577. * @param spriteManager Define the sprite manager to render
  17578. */
  17579. dispatchSprites(spriteManager: ISpriteManager): void;
  17580. /**
  17581. * Add a particle system to the rendering manager in order to render it this frame.
  17582. * @param particleSystem Define the particle system to render
  17583. */
  17584. dispatchParticles(particleSystem: IParticleSystem): void;
  17585. /**
  17586. * Add a submesh to the manager in order to render it this frame
  17587. * @param subMesh The submesh to dispatch
  17588. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17589. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17590. */
  17591. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17592. /**
  17593. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17594. * This allowed control for front to back rendering or reversly depending of the special needs.
  17595. *
  17596. * @param renderingGroupId The rendering group id corresponding to its index
  17597. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17598. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17599. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17600. */
  17601. 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;
  17602. /**
  17603. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17604. *
  17605. * @param renderingGroupId The rendering group id corresponding to its index
  17606. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17607. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17608. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17609. */
  17610. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17611. /**
  17612. * Gets the current auto clear configuration for one rendering group of the rendering
  17613. * manager.
  17614. * @param index the rendering group index to get the information for
  17615. * @returns The auto clear setup for the requested rendering group
  17616. */
  17617. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17618. }
  17619. }
  17620. declare module BABYLON {
  17621. /**
  17622. * This Helps creating a texture that will be created from a camera in your scene.
  17623. * It is basically a dynamic texture that could be used to create special effects for instance.
  17624. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17625. */
  17626. export class RenderTargetTexture extends Texture {
  17627. isCube: boolean;
  17628. /**
  17629. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17630. */
  17631. static readonly REFRESHRATE_RENDER_ONCE: number;
  17632. /**
  17633. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17634. */
  17635. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17636. /**
  17637. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17638. * the central point of your effect and can save a lot of performances.
  17639. */
  17640. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17641. /**
  17642. * Use this predicate to dynamically define the list of mesh you want to render.
  17643. * If set, the renderList property will be overwritten.
  17644. */
  17645. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17646. private _renderList;
  17647. /**
  17648. * Use this list to define the list of mesh you want to render.
  17649. */
  17650. renderList: Nullable<Array<AbstractMesh>>;
  17651. private _hookArray;
  17652. /**
  17653. * Define if particles should be rendered in your texture.
  17654. */
  17655. renderParticles: boolean;
  17656. /**
  17657. * Define if sprites should be rendered in your texture.
  17658. */
  17659. renderSprites: boolean;
  17660. /**
  17661. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17662. */
  17663. coordinatesMode: number;
  17664. /**
  17665. * Define the camera used to render the texture.
  17666. */
  17667. activeCamera: Nullable<Camera>;
  17668. /**
  17669. * Override the render function of the texture with your own one.
  17670. */
  17671. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17672. /**
  17673. * Define if camera post processes should be use while rendering the texture.
  17674. */
  17675. useCameraPostProcesses: boolean;
  17676. /**
  17677. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17678. */
  17679. ignoreCameraViewport: boolean;
  17680. private _postProcessManager;
  17681. private _postProcesses;
  17682. private _resizeObserver;
  17683. /**
  17684. * An event triggered when the texture is unbind.
  17685. */
  17686. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17687. /**
  17688. * An event triggered when the texture is unbind.
  17689. */
  17690. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17691. private _onAfterUnbindObserver;
  17692. /**
  17693. * Set a after unbind callback in the texture.
  17694. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17695. */
  17696. onAfterUnbind: () => void;
  17697. /**
  17698. * An event triggered before rendering the texture
  17699. */
  17700. onBeforeRenderObservable: Observable<number>;
  17701. private _onBeforeRenderObserver;
  17702. /**
  17703. * Set a before render callback in the texture.
  17704. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17705. */
  17706. onBeforeRender: (faceIndex: number) => void;
  17707. /**
  17708. * An event triggered after rendering the texture
  17709. */
  17710. onAfterRenderObservable: Observable<number>;
  17711. private _onAfterRenderObserver;
  17712. /**
  17713. * Set a after render callback in the texture.
  17714. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17715. */
  17716. onAfterRender: (faceIndex: number) => void;
  17717. /**
  17718. * An event triggered after the texture clear
  17719. */
  17720. onClearObservable: Observable<Engine>;
  17721. private _onClearObserver;
  17722. /**
  17723. * Set a clear callback in the texture.
  17724. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17725. */
  17726. onClear: (Engine: Engine) => void;
  17727. /**
  17728. * Define the clear color of the Render Target if it should be different from the scene.
  17729. */
  17730. clearColor: Color4;
  17731. protected _size: number | {
  17732. width: number;
  17733. height: number;
  17734. };
  17735. protected _initialSizeParameter: number | {
  17736. width: number;
  17737. height: number;
  17738. } | {
  17739. ratio: number;
  17740. };
  17741. protected _sizeRatio: Nullable<number>;
  17742. /** @hidden */
  17743. _generateMipMaps: boolean;
  17744. protected _renderingManager: RenderingManager;
  17745. /** @hidden */
  17746. _waitingRenderList: string[];
  17747. protected _doNotChangeAspectRatio: boolean;
  17748. protected _currentRefreshId: number;
  17749. protected _refreshRate: number;
  17750. protected _textureMatrix: Matrix;
  17751. protected _samples: number;
  17752. protected _renderTargetOptions: RenderTargetCreationOptions;
  17753. /**
  17754. * Gets render target creation options that were used.
  17755. */
  17756. readonly renderTargetOptions: RenderTargetCreationOptions;
  17757. protected _engine: Engine;
  17758. protected _onRatioRescale(): void;
  17759. /**
  17760. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17761. * It must define where the camera used to render the texture is set
  17762. */
  17763. boundingBoxPosition: Vector3;
  17764. private _boundingBoxSize;
  17765. /**
  17766. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17767. * When defined, the cubemap will switch to local mode
  17768. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17769. * @example https://www.babylonjs-playground.com/#RNASML
  17770. */
  17771. boundingBoxSize: Vector3;
  17772. /**
  17773. * In case the RTT has been created with a depth texture, get the associated
  17774. * depth texture.
  17775. * Otherwise, return null.
  17776. */
  17777. depthStencilTexture: Nullable<InternalTexture>;
  17778. /**
  17779. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17780. * or used a shadow, depth texture...
  17781. * @param name The friendly name of the texture
  17782. * @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)
  17783. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17784. * @param generateMipMaps True if mip maps need to be generated after render.
  17785. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17786. * @param type The type of the buffer in the RTT (int, half float, float...)
  17787. * @param isCube True if a cube texture needs to be created
  17788. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17789. * @param generateDepthBuffer True to generate a depth buffer
  17790. * @param generateStencilBuffer True to generate a stencil buffer
  17791. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17792. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17793. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17794. */
  17795. constructor(name: string, size: number | {
  17796. width: number;
  17797. height: number;
  17798. } | {
  17799. ratio: number;
  17800. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17801. /**
  17802. * Creates a depth stencil texture.
  17803. * This is only available in WebGL 2 or with the depth texture extension available.
  17804. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17805. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17806. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17807. */
  17808. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17809. private _processSizeParameter;
  17810. /**
  17811. * Define the number of samples to use in case of MSAA.
  17812. * It defaults to one meaning no MSAA has been enabled.
  17813. */
  17814. samples: number;
  17815. /**
  17816. * Resets the refresh counter of the texture and start bak from scratch.
  17817. * Could be useful to regenerate the texture if it is setup to render only once.
  17818. */
  17819. resetRefreshCounter(): void;
  17820. /**
  17821. * Define the refresh rate of the texture or the rendering frequency.
  17822. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17823. */
  17824. refreshRate: number;
  17825. /**
  17826. * Adds a post process to the render target rendering passes.
  17827. * @param postProcess define the post process to add
  17828. */
  17829. addPostProcess(postProcess: PostProcess): void;
  17830. /**
  17831. * Clear all the post processes attached to the render target
  17832. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17833. */
  17834. clearPostProcesses(dispose?: boolean): void;
  17835. /**
  17836. * Remove one of the post process from the list of attached post processes to the texture
  17837. * @param postProcess define the post process to remove from the list
  17838. */
  17839. removePostProcess(postProcess: PostProcess): void;
  17840. /** @hidden */
  17841. _shouldRender(): boolean;
  17842. /**
  17843. * Gets the actual render size of the texture.
  17844. * @returns the width of the render size
  17845. */
  17846. getRenderSize(): number;
  17847. /**
  17848. * Gets the actual render width of the texture.
  17849. * @returns the width of the render size
  17850. */
  17851. getRenderWidth(): number;
  17852. /**
  17853. * Gets the actual render height of the texture.
  17854. * @returns the height of the render size
  17855. */
  17856. getRenderHeight(): number;
  17857. /**
  17858. * Get if the texture can be rescaled or not.
  17859. */
  17860. readonly canRescale: boolean;
  17861. /**
  17862. * Resize the texture using a ratio.
  17863. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17864. */
  17865. scale(ratio: number): void;
  17866. /**
  17867. * Get the texture reflection matrix used to rotate/transform the reflection.
  17868. * @returns the reflection matrix
  17869. */
  17870. getReflectionTextureMatrix(): Matrix;
  17871. /**
  17872. * Resize the texture to a new desired size.
  17873. * Be carrefull as it will recreate all the data in the new texture.
  17874. * @param size Define the new size. It can be:
  17875. * - a number for squared texture,
  17876. * - an object containing { width: number, height: number }
  17877. * - or an object containing a ratio { ratio: number }
  17878. */
  17879. resize(size: number | {
  17880. width: number;
  17881. height: number;
  17882. } | {
  17883. ratio: number;
  17884. }): void;
  17885. /**
  17886. * Renders all the objects from the render list into the texture.
  17887. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17888. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17889. */
  17890. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17891. private _bestReflectionRenderTargetDimension;
  17892. /**
  17893. * @hidden
  17894. * @param faceIndex face index to bind to if this is a cubetexture
  17895. */
  17896. _bindFrameBuffer(faceIndex?: number): void;
  17897. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17898. private renderToTarget;
  17899. /**
  17900. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17901. * This allowed control for front to back rendering or reversly depending of the special needs.
  17902. *
  17903. * @param renderingGroupId The rendering group id corresponding to its index
  17904. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17905. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17906. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17907. */
  17908. 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;
  17909. /**
  17910. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17911. *
  17912. * @param renderingGroupId The rendering group id corresponding to its index
  17913. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17914. */
  17915. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17916. /**
  17917. * Clones the texture.
  17918. * @returns the cloned texture
  17919. */
  17920. clone(): RenderTargetTexture;
  17921. /**
  17922. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17923. * @returns The JSON representation of the texture
  17924. */
  17925. serialize(): any;
  17926. /**
  17927. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17928. */
  17929. disposeFramebufferObjects(): void;
  17930. /**
  17931. * Dispose the texture and release its associated resources.
  17932. */
  17933. dispose(): void;
  17934. /** @hidden */
  17935. _rebuild(): void;
  17936. /**
  17937. * Clear the info related to rendering groups preventing retention point in material dispose.
  17938. */
  17939. freeRenderingGroups(): void;
  17940. /**
  17941. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17942. * @returns the view count
  17943. */
  17944. getViewCount(): number;
  17945. }
  17946. }
  17947. declare module BABYLON {
  17948. /**
  17949. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17950. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17951. * You can then easily use it as a reflectionTexture on a flat surface.
  17952. * In case the surface is not a plane, please consider relying on reflection probes.
  17953. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17954. */
  17955. export class MirrorTexture extends RenderTargetTexture {
  17956. private scene;
  17957. /**
  17958. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17959. * 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.
  17960. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17961. */
  17962. mirrorPlane: Plane;
  17963. /**
  17964. * Define the blur ratio used to blur the reflection if needed.
  17965. */
  17966. blurRatio: number;
  17967. /**
  17968. * Define the adaptive blur kernel used to blur the reflection if needed.
  17969. * This will autocompute the closest best match for the `blurKernel`
  17970. */
  17971. adaptiveBlurKernel: number;
  17972. /**
  17973. * Define the blur kernel used to blur the reflection if needed.
  17974. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17975. */
  17976. blurKernel: number;
  17977. /**
  17978. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17979. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17980. */
  17981. blurKernelX: number;
  17982. /**
  17983. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17984. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17985. */
  17986. blurKernelY: number;
  17987. private _autoComputeBlurKernel;
  17988. protected _onRatioRescale(): void;
  17989. private _updateGammaSpace;
  17990. private _imageProcessingConfigChangeObserver;
  17991. private _transformMatrix;
  17992. private _mirrorMatrix;
  17993. private _savedViewMatrix;
  17994. private _blurX;
  17995. private _blurY;
  17996. private _adaptiveBlurKernel;
  17997. private _blurKernelX;
  17998. private _blurKernelY;
  17999. private _blurRatio;
  18000. /**
  18001. * Instantiates a Mirror Texture.
  18002. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18003. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18004. * You can then easily use it as a reflectionTexture on a flat surface.
  18005. * In case the surface is not a plane, please consider relying on reflection probes.
  18006. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18007. * @param name
  18008. * @param size
  18009. * @param scene
  18010. * @param generateMipMaps
  18011. * @param type
  18012. * @param samplingMode
  18013. * @param generateDepthBuffer
  18014. */
  18015. constructor(name: string, size: number | {
  18016. width: number;
  18017. height: number;
  18018. } | {
  18019. ratio: number;
  18020. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18021. private _preparePostProcesses;
  18022. /**
  18023. * Clone the mirror texture.
  18024. * @returns the cloned texture
  18025. */
  18026. clone(): MirrorTexture;
  18027. /**
  18028. * Serialize the texture to a JSON representation you could use in Parse later on
  18029. * @returns the serialized JSON representation
  18030. */
  18031. serialize(): any;
  18032. /**
  18033. * Dispose the texture and release its associated resources.
  18034. */
  18035. dispose(): void;
  18036. }
  18037. }
  18038. declare module BABYLON {
  18039. /**
  18040. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18041. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18042. */
  18043. export class Texture extends BaseTexture {
  18044. /** @hidden */
  18045. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  18046. /** @hidden */
  18047. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  18048. /** @hidden */
  18049. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  18050. /** nearest is mag = nearest and min = nearest and mip = linear */
  18051. static readonly NEAREST_SAMPLINGMODE: number;
  18052. /** nearest is mag = nearest and min = nearest and mip = linear */
  18053. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18054. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18055. static readonly BILINEAR_SAMPLINGMODE: number;
  18056. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18057. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18058. /** Trilinear is mag = linear and min = linear and mip = linear */
  18059. static readonly TRILINEAR_SAMPLINGMODE: number;
  18060. /** Trilinear is mag = linear and min = linear and mip = linear */
  18061. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18062. /** mag = nearest and min = nearest and mip = nearest */
  18063. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18064. /** mag = nearest and min = linear and mip = nearest */
  18065. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18066. /** mag = nearest and min = linear and mip = linear */
  18067. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18068. /** mag = nearest and min = linear and mip = none */
  18069. static readonly NEAREST_LINEAR: number;
  18070. /** mag = nearest and min = nearest and mip = none */
  18071. static readonly NEAREST_NEAREST: number;
  18072. /** mag = linear and min = nearest and mip = nearest */
  18073. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18074. /** mag = linear and min = nearest and mip = linear */
  18075. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18076. /** mag = linear and min = linear and mip = none */
  18077. static readonly LINEAR_LINEAR: number;
  18078. /** mag = linear and min = nearest and mip = none */
  18079. static readonly LINEAR_NEAREST: number;
  18080. /** Explicit coordinates mode */
  18081. static readonly EXPLICIT_MODE: number;
  18082. /** Spherical coordinates mode */
  18083. static readonly SPHERICAL_MODE: number;
  18084. /** Planar coordinates mode */
  18085. static readonly PLANAR_MODE: number;
  18086. /** Cubic coordinates mode */
  18087. static readonly CUBIC_MODE: number;
  18088. /** Projection coordinates mode */
  18089. static readonly PROJECTION_MODE: number;
  18090. /** Inverse Cubic coordinates mode */
  18091. static readonly SKYBOX_MODE: number;
  18092. /** Inverse Cubic coordinates mode */
  18093. static readonly INVCUBIC_MODE: number;
  18094. /** Equirectangular coordinates mode */
  18095. static readonly EQUIRECTANGULAR_MODE: number;
  18096. /** Equirectangular Fixed coordinates mode */
  18097. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18098. /** Equirectangular Fixed Mirrored coordinates mode */
  18099. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18100. /** Texture is not repeating outside of 0..1 UVs */
  18101. static readonly CLAMP_ADDRESSMODE: number;
  18102. /** Texture is repeating outside of 0..1 UVs */
  18103. static readonly WRAP_ADDRESSMODE: number;
  18104. /** Texture is repeating and mirrored */
  18105. static readonly MIRROR_ADDRESSMODE: number;
  18106. /**
  18107. * 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
  18108. */
  18109. static UseSerializedUrlIfAny: boolean;
  18110. /**
  18111. * Define the url of the texture.
  18112. */
  18113. url: Nullable<string>;
  18114. /**
  18115. * Define an offset on the texture to offset the u coordinates of the UVs
  18116. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18117. */
  18118. uOffset: number;
  18119. /**
  18120. * Define an offset on the texture to offset the v coordinates of the UVs
  18121. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18122. */
  18123. vOffset: number;
  18124. /**
  18125. * Define an offset on the texture to scale the u coordinates of the UVs
  18126. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18127. */
  18128. uScale: number;
  18129. /**
  18130. * Define an offset on the texture to scale the v coordinates of the UVs
  18131. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18132. */
  18133. vScale: number;
  18134. /**
  18135. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18136. * @see http://doc.babylonjs.com/how_to/more_materials
  18137. */
  18138. uAng: number;
  18139. /**
  18140. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18141. * @see http://doc.babylonjs.com/how_to/more_materials
  18142. */
  18143. vAng: number;
  18144. /**
  18145. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18146. * @see http://doc.babylonjs.com/how_to/more_materials
  18147. */
  18148. wAng: number;
  18149. /**
  18150. * Defines the center of rotation (U)
  18151. */
  18152. uRotationCenter: number;
  18153. /**
  18154. * Defines the center of rotation (V)
  18155. */
  18156. vRotationCenter: number;
  18157. /**
  18158. * Defines the center of rotation (W)
  18159. */
  18160. wRotationCenter: number;
  18161. /**
  18162. * Are mip maps generated for this texture or not.
  18163. */
  18164. readonly noMipmap: boolean;
  18165. /**
  18166. * List of inspectable custom properties (used by the Inspector)
  18167. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18168. */
  18169. inspectableCustomProperties: Nullable<IInspectable[]>;
  18170. private _noMipmap;
  18171. /** @hidden */
  18172. _invertY: boolean;
  18173. private _rowGenerationMatrix;
  18174. private _cachedTextureMatrix;
  18175. private _projectionModeMatrix;
  18176. private _t0;
  18177. private _t1;
  18178. private _t2;
  18179. private _cachedUOffset;
  18180. private _cachedVOffset;
  18181. private _cachedUScale;
  18182. private _cachedVScale;
  18183. private _cachedUAng;
  18184. private _cachedVAng;
  18185. private _cachedWAng;
  18186. private _cachedProjectionMatrixId;
  18187. private _cachedCoordinatesMode;
  18188. /** @hidden */
  18189. protected _initialSamplingMode: number;
  18190. /** @hidden */
  18191. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18192. private _deleteBuffer;
  18193. protected _format: Nullable<number>;
  18194. private _delayedOnLoad;
  18195. private _delayedOnError;
  18196. /**
  18197. * Observable triggered once the texture has been loaded.
  18198. */
  18199. onLoadObservable: Observable<Texture>;
  18200. protected _isBlocking: boolean;
  18201. /**
  18202. * Is the texture preventing material to render while loading.
  18203. * If false, a default texture will be used instead of the loading one during the preparation step.
  18204. */
  18205. isBlocking: boolean;
  18206. /**
  18207. * Get the current sampling mode associated with the texture.
  18208. */
  18209. readonly samplingMode: number;
  18210. /**
  18211. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18212. */
  18213. readonly invertY: boolean;
  18214. /**
  18215. * Instantiates a new texture.
  18216. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18217. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18218. * @param url define the url of the picture to load as a texture
  18219. * @param scene define the scene the texture will belong to
  18220. * @param noMipmap define if the texture will require mip maps or not
  18221. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18222. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18223. * @param onLoad define a callback triggered when the texture has been loaded
  18224. * @param onError define a callback triggered when an error occurred during the loading session
  18225. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18226. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18227. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18228. */
  18229. 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);
  18230. /**
  18231. * Update the url (and optional buffer) of this texture if url was null during construction.
  18232. * @param url the url of the texture
  18233. * @param buffer the buffer of the texture (defaults to null)
  18234. * @param onLoad callback called when the texture is loaded (defaults to null)
  18235. */
  18236. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18237. /**
  18238. * Finish the loading sequence of a texture flagged as delayed load.
  18239. * @hidden
  18240. */
  18241. delayLoad(): void;
  18242. private _prepareRowForTextureGeneration;
  18243. /**
  18244. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18245. * @returns the transform matrix of the texture.
  18246. */
  18247. getTextureMatrix(): Matrix;
  18248. /**
  18249. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18250. * @returns The reflection texture transform
  18251. */
  18252. getReflectionTextureMatrix(): Matrix;
  18253. /**
  18254. * Clones the texture.
  18255. * @returns the cloned texture
  18256. */
  18257. clone(): Texture;
  18258. /**
  18259. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18260. * @returns The JSON representation of the texture
  18261. */
  18262. serialize(): any;
  18263. /**
  18264. * Get the current class name of the texture useful for serialization or dynamic coding.
  18265. * @returns "Texture"
  18266. */
  18267. getClassName(): string;
  18268. /**
  18269. * Dispose the texture and release its associated resources.
  18270. */
  18271. dispose(): void;
  18272. /**
  18273. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18274. * @param parsedTexture Define the JSON representation of the texture
  18275. * @param scene Define the scene the parsed texture should be instantiated in
  18276. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18277. * @returns The parsed texture if successful
  18278. */
  18279. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18280. /**
  18281. * Creates a texture from its base 64 representation.
  18282. * @param data Define the base64 payload without the data: prefix
  18283. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18284. * @param scene Define the scene the texture should belong to
  18285. * @param noMipmap Forces the texture to not create mip map information if true
  18286. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18287. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18288. * @param onLoad define a callback triggered when the texture has been loaded
  18289. * @param onError define a callback triggered when an error occurred during the loading session
  18290. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18291. * @returns the created texture
  18292. */
  18293. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18294. /**
  18295. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18296. * @param data Define the base64 payload without the data: prefix
  18297. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18298. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18299. * @param scene Define the scene the texture should belong to
  18300. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18301. * @param noMipmap Forces the texture to not create mip map information if true
  18302. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18303. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18304. * @param onLoad define a callback triggered when the texture has been loaded
  18305. * @param onError define a callback triggered when an error occurred during the loading session
  18306. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18307. * @returns the created texture
  18308. */
  18309. 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;
  18310. }
  18311. }
  18312. declare module BABYLON {
  18313. interface Engine {
  18314. /**
  18315. * Creates a raw texture
  18316. * @param data defines the data to store in the texture
  18317. * @param width defines the width of the texture
  18318. * @param height defines the height of the texture
  18319. * @param format defines the format of the data
  18320. * @param generateMipMaps defines if the engine should generate the mip levels
  18321. * @param invertY defines if data must be stored with Y axis inverted
  18322. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18323. * @param compression defines the compression used (null by default)
  18324. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18325. * @returns the raw texture inside an InternalTexture
  18326. */
  18327. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18328. /**
  18329. * Update a raw texture
  18330. * @param texture defines the texture to update
  18331. * @param data defines the data to store in the texture
  18332. * @param format defines the format of the data
  18333. * @param invertY defines if data must be stored with Y axis inverted
  18334. */
  18335. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18336. /**
  18337. * Update a raw texture
  18338. * @param texture defines the texture to update
  18339. * @param data defines the data to store in the texture
  18340. * @param format defines the format of the data
  18341. * @param invertY defines if data must be stored with Y axis inverted
  18342. * @param compression defines the compression used (null by default)
  18343. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18344. */
  18345. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18346. /**
  18347. * Creates a new raw cube texture
  18348. * @param data defines the array of data to use to create each face
  18349. * @param size defines the size of the textures
  18350. * @param format defines the format of the data
  18351. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18352. * @param generateMipMaps defines if the engine should generate the mip levels
  18353. * @param invertY defines if data must be stored with Y axis inverted
  18354. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18355. * @param compression defines the compression used (null by default)
  18356. * @returns the cube texture as an InternalTexture
  18357. */
  18358. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18359. /**
  18360. * Update a raw cube texture
  18361. * @param texture defines the texture to udpdate
  18362. * @param data defines the data to store
  18363. * @param format defines the data format
  18364. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18365. * @param invertY defines if data must be stored with Y axis inverted
  18366. */
  18367. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18368. /**
  18369. * Update a raw cube texture
  18370. * @param texture defines the texture to udpdate
  18371. * @param data defines the data to store
  18372. * @param format defines the data format
  18373. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18374. * @param invertY defines if data must be stored with Y axis inverted
  18375. * @param compression defines the compression used (null by default)
  18376. */
  18377. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18378. /**
  18379. * Update a raw cube texture
  18380. * @param texture defines the texture to udpdate
  18381. * @param data defines the data to store
  18382. * @param format defines the data format
  18383. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18384. * @param invertY defines if data must be stored with Y axis inverted
  18385. * @param compression defines the compression used (null by default)
  18386. * @param level defines which level of the texture to update
  18387. */
  18388. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18389. /**
  18390. * Creates a new raw cube texture from a specified url
  18391. * @param url defines the url where the data is located
  18392. * @param scene defines the current scene
  18393. * @param size defines the size of the textures
  18394. * @param format defines the format of the data
  18395. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18396. * @param noMipmap defines if the engine should avoid generating the mip levels
  18397. * @param callback defines a callback used to extract texture data from loaded data
  18398. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18399. * @param onLoad defines a callback called when texture is loaded
  18400. * @param onError defines a callback called if there is an error
  18401. * @returns the cube texture as an InternalTexture
  18402. */
  18403. 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;
  18404. /**
  18405. * Creates a new raw cube texture from a specified url
  18406. * @param url defines the url where the data is located
  18407. * @param scene defines the current scene
  18408. * @param size defines the size of the textures
  18409. * @param format defines the format of the data
  18410. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18411. * @param noMipmap defines if the engine should avoid generating the mip levels
  18412. * @param callback defines a callback used to extract texture data from loaded data
  18413. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18414. * @param onLoad defines a callback called when texture is loaded
  18415. * @param onError defines a callback called if there is an error
  18416. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18417. * @param invertY defines if data must be stored with Y axis inverted
  18418. * @returns the cube texture as an InternalTexture
  18419. */
  18420. 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;
  18421. /**
  18422. * Creates a new raw 3D texture
  18423. * @param data defines the data used to create the texture
  18424. * @param width defines the width of the texture
  18425. * @param height defines the height of the texture
  18426. * @param depth defines the depth of the texture
  18427. * @param format defines the format of the texture
  18428. * @param generateMipMaps defines if the engine must generate mip levels
  18429. * @param invertY defines if data must be stored with Y axis inverted
  18430. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18431. * @param compression defines the compressed used (can be null)
  18432. * @param textureType defines the compressed used (can be null)
  18433. * @returns a new raw 3D texture (stored in an InternalTexture)
  18434. */
  18435. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  18436. /**
  18437. * Update a raw 3D texture
  18438. * @param texture defines the texture to update
  18439. * @param data defines the data to store
  18440. * @param format defines the data format
  18441. * @param invertY defines if data must be stored with Y axis inverted
  18442. */
  18443. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18444. /**
  18445. * Update a raw 3D texture
  18446. * @param texture defines the texture to update
  18447. * @param data defines the data to store
  18448. * @param format defines the data format
  18449. * @param invertY defines if data must be stored with Y axis inverted
  18450. * @param compression defines the used compression (can be null)
  18451. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  18452. */
  18453. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  18454. }
  18455. }
  18456. declare module BABYLON {
  18457. /**
  18458. * Raw texture can help creating a texture directly from an array of data.
  18459. * This can be super useful if you either get the data from an uncompressed source or
  18460. * if you wish to create your texture pixel by pixel.
  18461. */
  18462. export class RawTexture extends Texture {
  18463. /**
  18464. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18465. */
  18466. format: number;
  18467. private _engine;
  18468. /**
  18469. * Instantiates a new RawTexture.
  18470. * Raw texture can help creating a texture directly from an array of data.
  18471. * This can be super useful if you either get the data from an uncompressed source or
  18472. * if you wish to create your texture pixel by pixel.
  18473. * @param data define the array of data to use to create the texture
  18474. * @param width define the width of the texture
  18475. * @param height define the height of the texture
  18476. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18477. * @param scene define the scene the texture belongs to
  18478. * @param generateMipMaps define whether mip maps should be generated or not
  18479. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18480. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18481. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18482. */
  18483. constructor(data: ArrayBufferView, width: number, height: number,
  18484. /**
  18485. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18486. */
  18487. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18488. /**
  18489. * Updates the texture underlying data.
  18490. * @param data Define the new data of the texture
  18491. */
  18492. update(data: ArrayBufferView): void;
  18493. /**
  18494. * Creates a luminance texture from some data.
  18495. * @param data Define the texture data
  18496. * @param width Define the width of the texture
  18497. * @param height Define the height of the texture
  18498. * @param scene Define the scene the texture belongs to
  18499. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18500. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18501. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18502. * @returns the luminance texture
  18503. */
  18504. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18505. /**
  18506. * Creates a luminance alpha texture from some data.
  18507. * @param data Define the texture data
  18508. * @param width Define the width of the texture
  18509. * @param height Define the height of the texture
  18510. * @param scene Define the scene the texture belongs to
  18511. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18512. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18513. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18514. * @returns the luminance alpha texture
  18515. */
  18516. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18517. /**
  18518. * Creates an alpha texture from some data.
  18519. * @param data Define the texture data
  18520. * @param width Define the width of the texture
  18521. * @param height Define the height of the texture
  18522. * @param scene Define the scene the texture belongs to
  18523. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18524. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18525. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18526. * @returns the alpha texture
  18527. */
  18528. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18529. /**
  18530. * Creates a RGB texture from some data.
  18531. * @param data Define the texture data
  18532. * @param width Define the width of the texture
  18533. * @param height Define the height of the texture
  18534. * @param scene Define the scene the texture belongs to
  18535. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18536. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18537. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18538. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18539. * @returns the RGB alpha texture
  18540. */
  18541. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18542. /**
  18543. * Creates a RGBA texture from some data.
  18544. * @param data Define the texture data
  18545. * @param width Define the width of the texture
  18546. * @param height Define the height of the texture
  18547. * @param scene Define the scene the texture belongs to
  18548. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18549. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18550. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18551. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18552. * @returns the RGBA texture
  18553. */
  18554. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18555. /**
  18556. * Creates a R texture from some data.
  18557. * @param data Define the texture data
  18558. * @param width Define the width of the texture
  18559. * @param height Define the height of the texture
  18560. * @param scene Define the scene the texture belongs to
  18561. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18562. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18563. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18564. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18565. * @returns the R texture
  18566. */
  18567. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18568. }
  18569. }
  18570. declare module BABYLON {
  18571. /**
  18572. * Defines a runtime animation
  18573. */
  18574. export class RuntimeAnimation {
  18575. private _events;
  18576. /**
  18577. * The current frame of the runtime animation
  18578. */
  18579. private _currentFrame;
  18580. /**
  18581. * The animation used by the runtime animation
  18582. */
  18583. private _animation;
  18584. /**
  18585. * The target of the runtime animation
  18586. */
  18587. private _target;
  18588. /**
  18589. * The initiating animatable
  18590. */
  18591. private _host;
  18592. /**
  18593. * The original value of the runtime animation
  18594. */
  18595. private _originalValue;
  18596. /**
  18597. * The original blend value of the runtime animation
  18598. */
  18599. private _originalBlendValue;
  18600. /**
  18601. * The offsets cache of the runtime animation
  18602. */
  18603. private _offsetsCache;
  18604. /**
  18605. * The high limits cache of the runtime animation
  18606. */
  18607. private _highLimitsCache;
  18608. /**
  18609. * Specifies if the runtime animation has been stopped
  18610. */
  18611. private _stopped;
  18612. /**
  18613. * The blending factor of the runtime animation
  18614. */
  18615. private _blendingFactor;
  18616. /**
  18617. * The BabylonJS scene
  18618. */
  18619. private _scene;
  18620. /**
  18621. * The current value of the runtime animation
  18622. */
  18623. private _currentValue;
  18624. /** @hidden */
  18625. _animationState: _IAnimationState;
  18626. /**
  18627. * The active target of the runtime animation
  18628. */
  18629. private _activeTargets;
  18630. private _currentActiveTarget;
  18631. private _directTarget;
  18632. /**
  18633. * The target path of the runtime animation
  18634. */
  18635. private _targetPath;
  18636. /**
  18637. * The weight of the runtime animation
  18638. */
  18639. private _weight;
  18640. /**
  18641. * The ratio offset of the runtime animation
  18642. */
  18643. private _ratioOffset;
  18644. /**
  18645. * The previous delay of the runtime animation
  18646. */
  18647. private _previousDelay;
  18648. /**
  18649. * The previous ratio of the runtime animation
  18650. */
  18651. private _previousRatio;
  18652. private _enableBlending;
  18653. private _keys;
  18654. private _minFrame;
  18655. private _maxFrame;
  18656. private _minValue;
  18657. private _maxValue;
  18658. private _targetIsArray;
  18659. /**
  18660. * Gets the current frame of the runtime animation
  18661. */
  18662. readonly currentFrame: number;
  18663. /**
  18664. * Gets the weight of the runtime animation
  18665. */
  18666. readonly weight: number;
  18667. /**
  18668. * Gets the current value of the runtime animation
  18669. */
  18670. readonly currentValue: any;
  18671. /**
  18672. * Gets the target path of the runtime animation
  18673. */
  18674. readonly targetPath: string;
  18675. /**
  18676. * Gets the actual target of the runtime animation
  18677. */
  18678. readonly target: any;
  18679. /** @hidden */
  18680. _onLoop: () => void;
  18681. /**
  18682. * Create a new RuntimeAnimation object
  18683. * @param target defines the target of the animation
  18684. * @param animation defines the source animation object
  18685. * @param scene defines the hosting scene
  18686. * @param host defines the initiating Animatable
  18687. */
  18688. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18689. private _preparePath;
  18690. /**
  18691. * Gets the animation from the runtime animation
  18692. */
  18693. readonly animation: Animation;
  18694. /**
  18695. * Resets the runtime animation to the beginning
  18696. * @param restoreOriginal defines whether to restore the target property to the original value
  18697. */
  18698. reset(restoreOriginal?: boolean): void;
  18699. /**
  18700. * Specifies if the runtime animation is stopped
  18701. * @returns Boolean specifying if the runtime animation is stopped
  18702. */
  18703. isStopped(): boolean;
  18704. /**
  18705. * Disposes of the runtime animation
  18706. */
  18707. dispose(): void;
  18708. /**
  18709. * Apply the interpolated value to the target
  18710. * @param currentValue defines the value computed by the animation
  18711. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18712. */
  18713. setValue(currentValue: any, weight: number): void;
  18714. private _getOriginalValues;
  18715. private _setValue;
  18716. /**
  18717. * Gets the loop pmode of the runtime animation
  18718. * @returns Loop Mode
  18719. */
  18720. private _getCorrectLoopMode;
  18721. /**
  18722. * Move the current animation to a given frame
  18723. * @param frame defines the frame to move to
  18724. */
  18725. goToFrame(frame: number): void;
  18726. /**
  18727. * @hidden Internal use only
  18728. */
  18729. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18730. /**
  18731. * Execute the current animation
  18732. * @param delay defines the delay to add to the current frame
  18733. * @param from defines the lower bound of the animation range
  18734. * @param to defines the upper bound of the animation range
  18735. * @param loop defines if the current animation must loop
  18736. * @param speedRatio defines the current speed ratio
  18737. * @param weight defines the weight of the animation (default is -1 so no weight)
  18738. * @param onLoop optional callback called when animation loops
  18739. * @returns a boolean indicating if the animation is running
  18740. */
  18741. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  18742. }
  18743. }
  18744. declare module BABYLON {
  18745. /**
  18746. * Class used to store an actual running animation
  18747. */
  18748. export class Animatable {
  18749. /** defines the target object */
  18750. target: any;
  18751. /** defines the starting frame number (default is 0) */
  18752. fromFrame: number;
  18753. /** defines the ending frame number (default is 100) */
  18754. toFrame: number;
  18755. /** defines if the animation must loop (default is false) */
  18756. loopAnimation: boolean;
  18757. /** defines a callback to call when animation ends if it is not looping */
  18758. onAnimationEnd?: (() => void) | null | undefined;
  18759. /** defines a callback to call when animation loops */
  18760. onAnimationLoop?: (() => void) | null | undefined;
  18761. private _localDelayOffset;
  18762. private _pausedDelay;
  18763. private _runtimeAnimations;
  18764. private _paused;
  18765. private _scene;
  18766. private _speedRatio;
  18767. private _weight;
  18768. private _syncRoot;
  18769. /**
  18770. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18771. * This will only apply for non looping animation (default is true)
  18772. */
  18773. disposeOnEnd: boolean;
  18774. /**
  18775. * Gets a boolean indicating if the animation has started
  18776. */
  18777. animationStarted: boolean;
  18778. /**
  18779. * Observer raised when the animation ends
  18780. */
  18781. onAnimationEndObservable: Observable<Animatable>;
  18782. /**
  18783. * Observer raised when the animation loops
  18784. */
  18785. onAnimationLoopObservable: Observable<Animatable>;
  18786. /**
  18787. * Gets the root Animatable used to synchronize and normalize animations
  18788. */
  18789. readonly syncRoot: Nullable<Animatable>;
  18790. /**
  18791. * Gets the current frame of the first RuntimeAnimation
  18792. * Used to synchronize Animatables
  18793. */
  18794. readonly masterFrame: number;
  18795. /**
  18796. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18797. */
  18798. weight: number;
  18799. /**
  18800. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18801. */
  18802. speedRatio: number;
  18803. /**
  18804. * Creates a new Animatable
  18805. * @param scene defines the hosting scene
  18806. * @param target defines the target object
  18807. * @param fromFrame defines the starting frame number (default is 0)
  18808. * @param toFrame defines the ending frame number (default is 100)
  18809. * @param loopAnimation defines if the animation must loop (default is false)
  18810. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18811. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18812. * @param animations defines a group of animation to add to the new Animatable
  18813. * @param onAnimationLoop defines a callback to call when animation loops
  18814. */
  18815. constructor(scene: Scene,
  18816. /** defines the target object */
  18817. target: any,
  18818. /** defines the starting frame number (default is 0) */
  18819. fromFrame?: number,
  18820. /** defines the ending frame number (default is 100) */
  18821. toFrame?: number,
  18822. /** defines if the animation must loop (default is false) */
  18823. loopAnimation?: boolean, speedRatio?: number,
  18824. /** defines a callback to call when animation ends if it is not looping */
  18825. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18826. /** defines a callback to call when animation loops */
  18827. onAnimationLoop?: (() => void) | null | undefined);
  18828. /**
  18829. * Synchronize and normalize current Animatable with a source Animatable
  18830. * This is useful when using animation weights and when animations are not of the same length
  18831. * @param root defines the root Animatable to synchronize with
  18832. * @returns the current Animatable
  18833. */
  18834. syncWith(root: Animatable): Animatable;
  18835. /**
  18836. * Gets the list of runtime animations
  18837. * @returns an array of RuntimeAnimation
  18838. */
  18839. getAnimations(): RuntimeAnimation[];
  18840. /**
  18841. * Adds more animations to the current animatable
  18842. * @param target defines the target of the animations
  18843. * @param animations defines the new animations to add
  18844. */
  18845. appendAnimations(target: any, animations: Animation[]): void;
  18846. /**
  18847. * Gets the source animation for a specific property
  18848. * @param property defines the propertyu to look for
  18849. * @returns null or the source animation for the given property
  18850. */
  18851. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18852. /**
  18853. * Gets the runtime animation for a specific property
  18854. * @param property defines the propertyu to look for
  18855. * @returns null or the runtime animation for the given property
  18856. */
  18857. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18858. /**
  18859. * Resets the animatable to its original state
  18860. */
  18861. reset(): void;
  18862. /**
  18863. * Allows the animatable to blend with current running animations
  18864. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18865. * @param blendingSpeed defines the blending speed to use
  18866. */
  18867. enableBlending(blendingSpeed: number): void;
  18868. /**
  18869. * Disable animation blending
  18870. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18871. */
  18872. disableBlending(): void;
  18873. /**
  18874. * Jump directly to a given frame
  18875. * @param frame defines the frame to jump to
  18876. */
  18877. goToFrame(frame: number): void;
  18878. /**
  18879. * Pause the animation
  18880. */
  18881. pause(): void;
  18882. /**
  18883. * Restart the animation
  18884. */
  18885. restart(): void;
  18886. private _raiseOnAnimationEnd;
  18887. /**
  18888. * Stop and delete the current animation
  18889. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18890. * @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)
  18891. */
  18892. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18893. /**
  18894. * Wait asynchronously for the animation to end
  18895. * @returns a promise which will be fullfilled when the animation ends
  18896. */
  18897. waitAsync(): Promise<Animatable>;
  18898. /** @hidden */
  18899. _animate(delay: number): boolean;
  18900. }
  18901. interface Scene {
  18902. /** @hidden */
  18903. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18904. /** @hidden */
  18905. _processLateAnimationBindingsForMatrices(holder: {
  18906. totalWeight: number;
  18907. animations: RuntimeAnimation[];
  18908. originalValue: Matrix;
  18909. }): any;
  18910. /** @hidden */
  18911. _processLateAnimationBindingsForQuaternions(holder: {
  18912. totalWeight: number;
  18913. animations: RuntimeAnimation[];
  18914. originalValue: Quaternion;
  18915. }, refQuaternion: Quaternion): Quaternion;
  18916. /** @hidden */
  18917. _processLateAnimationBindings(): void;
  18918. /**
  18919. * Will start the animation sequence of a given target
  18920. * @param target defines the target
  18921. * @param from defines from which frame should animation start
  18922. * @param to defines until which frame should animation run.
  18923. * @param weight defines the weight to apply to the animation (1.0 by default)
  18924. * @param loop defines if the animation loops
  18925. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18926. * @param onAnimationEnd defines the function to be executed when the animation ends
  18927. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18928. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18929. * @param onAnimationLoop defines the callback to call when an animation loops
  18930. * @returns the animatable object created for this animation
  18931. */
  18932. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18933. /**
  18934. * Will start the animation sequence of a given target
  18935. * @param target defines the target
  18936. * @param from defines from which frame should animation start
  18937. * @param to defines until which frame should animation run.
  18938. * @param loop defines if the animation loops
  18939. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18940. * @param onAnimationEnd defines the function to be executed when the animation ends
  18941. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18942. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18943. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18944. * @param onAnimationLoop defines the callback to call when an animation loops
  18945. * @returns the animatable object created for this animation
  18946. */
  18947. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18948. /**
  18949. * Will start the animation sequence of a given target and its hierarchy
  18950. * @param target defines the target
  18951. * @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.
  18952. * @param from defines from which frame should animation start
  18953. * @param to defines until which frame should animation run.
  18954. * @param loop defines if the animation loops
  18955. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18956. * @param onAnimationEnd defines the function to be executed when the animation ends
  18957. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18958. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18959. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18960. * @param onAnimationLoop defines the callback to call when an animation loops
  18961. * @returns the list of created animatables
  18962. */
  18963. 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[];
  18964. /**
  18965. * Begin a new animation on a given node
  18966. * @param target defines the target where the animation will take place
  18967. * @param animations defines the list of animations to start
  18968. * @param from defines the initial value
  18969. * @param to defines the final value
  18970. * @param loop defines if you want animation to loop (off by default)
  18971. * @param speedRatio defines the speed ratio to apply to all animations
  18972. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18973. * @param onAnimationLoop defines the callback to call when an animation loops
  18974. * @returns the list of created animatables
  18975. */
  18976. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18977. /**
  18978. * Begin a new animation on a given node and its hierarchy
  18979. * @param target defines the root node where the animation will take place
  18980. * @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.
  18981. * @param animations defines the list of animations to start
  18982. * @param from defines the initial value
  18983. * @param to defines the final value
  18984. * @param loop defines if you want animation to loop (off by default)
  18985. * @param speedRatio defines the speed ratio to apply to all animations
  18986. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18987. * @param onAnimationLoop defines the callback to call when an animation loops
  18988. * @returns the list of animatables created for all nodes
  18989. */
  18990. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18991. /**
  18992. * Gets the animatable associated with a specific target
  18993. * @param target defines the target of the animatable
  18994. * @returns the required animatable if found
  18995. */
  18996. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18997. /**
  18998. * Gets all animatables associated with a given target
  18999. * @param target defines the target to look animatables for
  19000. * @returns an array of Animatables
  19001. */
  19002. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19003. /**
  19004. * Stops and removes all animations that have been applied to the scene
  19005. */
  19006. stopAllAnimations(): void;
  19007. }
  19008. interface Bone {
  19009. /**
  19010. * Copy an animation range from another bone
  19011. * @param source defines the source bone
  19012. * @param rangeName defines the range name to copy
  19013. * @param frameOffset defines the frame offset
  19014. * @param rescaleAsRequired defines if rescaling must be applied if required
  19015. * @param skelDimensionsRatio defines the scaling ratio
  19016. * @returns true if operation was successful
  19017. */
  19018. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19019. }
  19020. }
  19021. declare module BABYLON {
  19022. /**
  19023. * Class used to handle skinning animations
  19024. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19025. */
  19026. export class Skeleton implements IAnimatable {
  19027. /** defines the skeleton name */
  19028. name: string;
  19029. /** defines the skeleton Id */
  19030. id: string;
  19031. /**
  19032. * Defines the list of child bones
  19033. */
  19034. bones: Bone[];
  19035. /**
  19036. * Defines an estimate of the dimension of the skeleton at rest
  19037. */
  19038. dimensionsAtRest: Vector3;
  19039. /**
  19040. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19041. */
  19042. needInitialSkinMatrix: boolean;
  19043. /**
  19044. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19045. */
  19046. overrideMesh: Nullable<AbstractMesh>;
  19047. /**
  19048. * Gets the list of animations attached to this skeleton
  19049. */
  19050. animations: Array<Animation>;
  19051. private _scene;
  19052. private _isDirty;
  19053. private _transformMatrices;
  19054. private _transformMatrixTexture;
  19055. private _meshesWithPoseMatrix;
  19056. private _animatables;
  19057. private _identity;
  19058. private _synchronizedWithMesh;
  19059. private _ranges;
  19060. private _lastAbsoluteTransformsUpdateId;
  19061. private _canUseTextureForBones;
  19062. private _uniqueId;
  19063. /** @hidden */
  19064. _numBonesWithLinkedTransformNode: number;
  19065. /** @hidden */
  19066. _hasWaitingData: Nullable<boolean>;
  19067. /**
  19068. * Specifies if the skeleton should be serialized
  19069. */
  19070. doNotSerialize: boolean;
  19071. private _useTextureToStoreBoneMatrices;
  19072. /**
  19073. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19074. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19075. */
  19076. useTextureToStoreBoneMatrices: boolean;
  19077. private _animationPropertiesOverride;
  19078. /**
  19079. * Gets or sets the animation properties override
  19080. */
  19081. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19082. /**
  19083. * List of inspectable custom properties (used by the Inspector)
  19084. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19085. */
  19086. inspectableCustomProperties: IInspectable[];
  19087. /**
  19088. * An observable triggered before computing the skeleton's matrices
  19089. */
  19090. onBeforeComputeObservable: Observable<Skeleton>;
  19091. /**
  19092. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19093. */
  19094. readonly isUsingTextureForMatrices: boolean;
  19095. /**
  19096. * Gets the unique ID of this skeleton
  19097. */
  19098. readonly uniqueId: number;
  19099. /**
  19100. * Creates a new skeleton
  19101. * @param name defines the skeleton name
  19102. * @param id defines the skeleton Id
  19103. * @param scene defines the hosting scene
  19104. */
  19105. constructor(
  19106. /** defines the skeleton name */
  19107. name: string,
  19108. /** defines the skeleton Id */
  19109. id: string, scene: Scene);
  19110. /**
  19111. * Gets the current object class name.
  19112. * @return the class name
  19113. */
  19114. getClassName(): string;
  19115. /**
  19116. * Returns an array containing the root bones
  19117. * @returns an array containing the root bones
  19118. */
  19119. getChildren(): Array<Bone>;
  19120. /**
  19121. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19122. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19123. * @returns a Float32Array containing matrices data
  19124. */
  19125. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19126. /**
  19127. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19128. * @returns a raw texture containing the data
  19129. */
  19130. getTransformMatrixTexture(): Nullable<RawTexture>;
  19131. /**
  19132. * Gets the current hosting scene
  19133. * @returns a scene object
  19134. */
  19135. getScene(): Scene;
  19136. /**
  19137. * Gets a string representing the current skeleton data
  19138. * @param fullDetails defines a boolean indicating if we want a verbose version
  19139. * @returns a string representing the current skeleton data
  19140. */
  19141. toString(fullDetails?: boolean): string;
  19142. /**
  19143. * Get bone's index searching by name
  19144. * @param name defines bone's name to search for
  19145. * @return the indice of the bone. Returns -1 if not found
  19146. */
  19147. getBoneIndexByName(name: string): number;
  19148. /**
  19149. * Creater a new animation range
  19150. * @param name defines the name of the range
  19151. * @param from defines the start key
  19152. * @param to defines the end key
  19153. */
  19154. createAnimationRange(name: string, from: number, to: number): void;
  19155. /**
  19156. * Delete a specific animation range
  19157. * @param name defines the name of the range
  19158. * @param deleteFrames defines if frames must be removed as well
  19159. */
  19160. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19161. /**
  19162. * Gets a specific animation range
  19163. * @param name defines the name of the range to look for
  19164. * @returns the requested animation range or null if not found
  19165. */
  19166. getAnimationRange(name: string): Nullable<AnimationRange>;
  19167. /**
  19168. * Gets the list of all animation ranges defined on this skeleton
  19169. * @returns an array
  19170. */
  19171. getAnimationRanges(): Nullable<AnimationRange>[];
  19172. /**
  19173. * Copy animation range from a source skeleton.
  19174. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19175. * @param source defines the source skeleton
  19176. * @param name defines the name of the range to copy
  19177. * @param rescaleAsRequired defines if rescaling must be applied if required
  19178. * @returns true if operation was successful
  19179. */
  19180. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19181. /**
  19182. * Forces the skeleton to go to rest pose
  19183. */
  19184. returnToRest(): void;
  19185. private _getHighestAnimationFrame;
  19186. /**
  19187. * Begin a specific animation range
  19188. * @param name defines the name of the range to start
  19189. * @param loop defines if looping must be turned on (false by default)
  19190. * @param speedRatio defines the speed ratio to apply (1 by default)
  19191. * @param onAnimationEnd defines a callback which will be called when animation will end
  19192. * @returns a new animatable
  19193. */
  19194. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19195. /** @hidden */
  19196. _markAsDirty(): void;
  19197. /** @hidden */
  19198. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19199. /** @hidden */
  19200. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19201. private _computeTransformMatrices;
  19202. /**
  19203. * Build all resources required to render a skeleton
  19204. */
  19205. prepare(): void;
  19206. /**
  19207. * Gets the list of animatables currently running for this skeleton
  19208. * @returns an array of animatables
  19209. */
  19210. getAnimatables(): IAnimatable[];
  19211. /**
  19212. * Clone the current skeleton
  19213. * @param name defines the name of the new skeleton
  19214. * @param id defines the id of the new skeleton
  19215. * @returns the new skeleton
  19216. */
  19217. clone(name: string, id: string): Skeleton;
  19218. /**
  19219. * Enable animation blending for this skeleton
  19220. * @param blendingSpeed defines the blending speed to apply
  19221. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19222. */
  19223. enableBlending(blendingSpeed?: number): void;
  19224. /**
  19225. * Releases all resources associated with the current skeleton
  19226. */
  19227. dispose(): void;
  19228. /**
  19229. * Serialize the skeleton in a JSON object
  19230. * @returns a JSON object
  19231. */
  19232. serialize(): any;
  19233. /**
  19234. * Creates a new skeleton from serialized data
  19235. * @param parsedSkeleton defines the serialized data
  19236. * @param scene defines the hosting scene
  19237. * @returns a new skeleton
  19238. */
  19239. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19240. /**
  19241. * Compute all node absolute transforms
  19242. * @param forceUpdate defines if computation must be done even if cache is up to date
  19243. */
  19244. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19245. /**
  19246. * Gets the root pose matrix
  19247. * @returns a matrix
  19248. */
  19249. getPoseMatrix(): Nullable<Matrix>;
  19250. /**
  19251. * Sorts bones per internal index
  19252. */
  19253. sortBones(): void;
  19254. private _sortBones;
  19255. }
  19256. }
  19257. declare module BABYLON {
  19258. /**
  19259. * Defines a target to use with MorphTargetManager
  19260. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19261. */
  19262. export class MorphTarget implements IAnimatable {
  19263. /** defines the name of the target */
  19264. name: string;
  19265. /**
  19266. * Gets or sets the list of animations
  19267. */
  19268. animations: Animation[];
  19269. private _scene;
  19270. private _positions;
  19271. private _normals;
  19272. private _tangents;
  19273. private _influence;
  19274. /**
  19275. * Observable raised when the influence changes
  19276. */
  19277. onInfluenceChanged: Observable<boolean>;
  19278. /** @hidden */
  19279. _onDataLayoutChanged: Observable<void>;
  19280. /**
  19281. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19282. */
  19283. influence: number;
  19284. /**
  19285. * Gets or sets the id of the morph Target
  19286. */
  19287. id: string;
  19288. private _animationPropertiesOverride;
  19289. /**
  19290. * Gets or sets the animation properties override
  19291. */
  19292. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19293. /**
  19294. * Creates a new MorphTarget
  19295. * @param name defines the name of the target
  19296. * @param influence defines the influence to use
  19297. * @param scene defines the scene the morphtarget belongs to
  19298. */
  19299. constructor(
  19300. /** defines the name of the target */
  19301. name: string, influence?: number, scene?: Nullable<Scene>);
  19302. /**
  19303. * Gets a boolean defining if the target contains position data
  19304. */
  19305. readonly hasPositions: boolean;
  19306. /**
  19307. * Gets a boolean defining if the target contains normal data
  19308. */
  19309. readonly hasNormals: boolean;
  19310. /**
  19311. * Gets a boolean defining if the target contains tangent data
  19312. */
  19313. readonly hasTangents: boolean;
  19314. /**
  19315. * Affects position data to this target
  19316. * @param data defines the position data to use
  19317. */
  19318. setPositions(data: Nullable<FloatArray>): void;
  19319. /**
  19320. * Gets the position data stored in this target
  19321. * @returns a FloatArray containing the position data (or null if not present)
  19322. */
  19323. getPositions(): Nullable<FloatArray>;
  19324. /**
  19325. * Affects normal data to this target
  19326. * @param data defines the normal data to use
  19327. */
  19328. setNormals(data: Nullable<FloatArray>): void;
  19329. /**
  19330. * Gets the normal data stored in this target
  19331. * @returns a FloatArray containing the normal data (or null if not present)
  19332. */
  19333. getNormals(): Nullable<FloatArray>;
  19334. /**
  19335. * Affects tangent data to this target
  19336. * @param data defines the tangent data to use
  19337. */
  19338. setTangents(data: Nullable<FloatArray>): void;
  19339. /**
  19340. * Gets the tangent data stored in this target
  19341. * @returns a FloatArray containing the tangent data (or null if not present)
  19342. */
  19343. getTangents(): Nullable<FloatArray>;
  19344. /**
  19345. * Serializes the current target into a Serialization object
  19346. * @returns the serialized object
  19347. */
  19348. serialize(): any;
  19349. /**
  19350. * Returns the string "MorphTarget"
  19351. * @returns "MorphTarget"
  19352. */
  19353. getClassName(): string;
  19354. /**
  19355. * Creates a new target from serialized data
  19356. * @param serializationObject defines the serialized data to use
  19357. * @returns a new MorphTarget
  19358. */
  19359. static Parse(serializationObject: any): MorphTarget;
  19360. /**
  19361. * Creates a MorphTarget from mesh data
  19362. * @param mesh defines the source mesh
  19363. * @param name defines the name to use for the new target
  19364. * @param influence defines the influence to attach to the target
  19365. * @returns a new MorphTarget
  19366. */
  19367. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19368. }
  19369. }
  19370. declare module BABYLON {
  19371. /**
  19372. * This class is used to deform meshes using morphing between different targets
  19373. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19374. */
  19375. export class MorphTargetManager {
  19376. private _targets;
  19377. private _targetInfluenceChangedObservers;
  19378. private _targetDataLayoutChangedObservers;
  19379. private _activeTargets;
  19380. private _scene;
  19381. private _influences;
  19382. private _supportsNormals;
  19383. private _supportsTangents;
  19384. private _vertexCount;
  19385. private _uniqueId;
  19386. private _tempInfluences;
  19387. /**
  19388. * Creates a new MorphTargetManager
  19389. * @param scene defines the current scene
  19390. */
  19391. constructor(scene?: Nullable<Scene>);
  19392. /**
  19393. * Gets the unique ID of this manager
  19394. */
  19395. readonly uniqueId: number;
  19396. /**
  19397. * Gets the number of vertices handled by this manager
  19398. */
  19399. readonly vertexCount: number;
  19400. /**
  19401. * Gets a boolean indicating if this manager supports morphing of normals
  19402. */
  19403. readonly supportsNormals: boolean;
  19404. /**
  19405. * Gets a boolean indicating if this manager supports morphing of tangents
  19406. */
  19407. readonly supportsTangents: boolean;
  19408. /**
  19409. * Gets the number of targets stored in this manager
  19410. */
  19411. readonly numTargets: number;
  19412. /**
  19413. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19414. */
  19415. readonly numInfluencers: number;
  19416. /**
  19417. * Gets the list of influences (one per target)
  19418. */
  19419. readonly influences: Float32Array;
  19420. /**
  19421. * Gets the active target at specified index. An active target is a target with an influence > 0
  19422. * @param index defines the index to check
  19423. * @returns the requested target
  19424. */
  19425. getActiveTarget(index: number): MorphTarget;
  19426. /**
  19427. * Gets the target at specified index
  19428. * @param index defines the index to check
  19429. * @returns the requested target
  19430. */
  19431. getTarget(index: number): MorphTarget;
  19432. /**
  19433. * Add a new target to this manager
  19434. * @param target defines the target to add
  19435. */
  19436. addTarget(target: MorphTarget): void;
  19437. /**
  19438. * Removes a target from the manager
  19439. * @param target defines the target to remove
  19440. */
  19441. removeTarget(target: MorphTarget): void;
  19442. /**
  19443. * Serializes the current manager into a Serialization object
  19444. * @returns the serialized object
  19445. */
  19446. serialize(): any;
  19447. private _syncActiveTargets;
  19448. /**
  19449. * Syncrhonize the targets with all the meshes using this morph target manager
  19450. */
  19451. synchronize(): void;
  19452. /**
  19453. * Creates a new MorphTargetManager from serialized data
  19454. * @param serializationObject defines the serialized data
  19455. * @param scene defines the hosting scene
  19456. * @returns the new MorphTargetManager
  19457. */
  19458. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19459. }
  19460. }
  19461. declare module BABYLON {
  19462. /**
  19463. * Class used to represent a specific level of detail of a mesh
  19464. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19465. */
  19466. export class MeshLODLevel {
  19467. /** Defines the distance where this level should star being displayed */
  19468. distance: number;
  19469. /** Defines the mesh to use to render this level */
  19470. mesh: Nullable<Mesh>;
  19471. /**
  19472. * Creates a new LOD level
  19473. * @param distance defines the distance where this level should star being displayed
  19474. * @param mesh defines the mesh to use to render this level
  19475. */
  19476. constructor(
  19477. /** Defines the distance where this level should star being displayed */
  19478. distance: number,
  19479. /** Defines the mesh to use to render this level */
  19480. mesh: Nullable<Mesh>);
  19481. }
  19482. }
  19483. declare module BABYLON {
  19484. /**
  19485. * Mesh representing the gorund
  19486. */
  19487. export class GroundMesh extends Mesh {
  19488. /** If octree should be generated */
  19489. generateOctree: boolean;
  19490. private _heightQuads;
  19491. /** @hidden */
  19492. _subdivisionsX: number;
  19493. /** @hidden */
  19494. _subdivisionsY: number;
  19495. /** @hidden */
  19496. _width: number;
  19497. /** @hidden */
  19498. _height: number;
  19499. /** @hidden */
  19500. _minX: number;
  19501. /** @hidden */
  19502. _maxX: number;
  19503. /** @hidden */
  19504. _minZ: number;
  19505. /** @hidden */
  19506. _maxZ: number;
  19507. constructor(name: string, scene: Scene);
  19508. /**
  19509. * "GroundMesh"
  19510. * @returns "GroundMesh"
  19511. */
  19512. getClassName(): string;
  19513. /**
  19514. * The minimum of x and y subdivisions
  19515. */
  19516. readonly subdivisions: number;
  19517. /**
  19518. * X subdivisions
  19519. */
  19520. readonly subdivisionsX: number;
  19521. /**
  19522. * Y subdivisions
  19523. */
  19524. readonly subdivisionsY: number;
  19525. /**
  19526. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19527. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19528. * @param chunksCount the number of subdivisions for x and y
  19529. * @param octreeBlocksSize (Default: 32)
  19530. */
  19531. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19532. /**
  19533. * Returns a height (y) value in the Worl system :
  19534. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19535. * @param x x coordinate
  19536. * @param z z coordinate
  19537. * @returns the ground y position if (x, z) are outside the ground surface.
  19538. */
  19539. getHeightAtCoordinates(x: number, z: number): number;
  19540. /**
  19541. * Returns a normalized vector (Vector3) orthogonal to the ground
  19542. * at the ground coordinates (x, z) expressed in the World system.
  19543. * @param x x coordinate
  19544. * @param z z coordinate
  19545. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19546. */
  19547. getNormalAtCoordinates(x: number, z: number): Vector3;
  19548. /**
  19549. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19550. * at the ground coordinates (x, z) expressed in the World system.
  19551. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19552. * @param x x coordinate
  19553. * @param z z coordinate
  19554. * @param ref vector to store the result
  19555. * @returns the GroundMesh.
  19556. */
  19557. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19558. /**
  19559. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19560. * if the ground has been updated.
  19561. * This can be used in the render loop.
  19562. * @returns the GroundMesh.
  19563. */
  19564. updateCoordinateHeights(): GroundMesh;
  19565. private _getFacetAt;
  19566. private _initHeightQuads;
  19567. private _computeHeightQuads;
  19568. /**
  19569. * Serializes this ground mesh
  19570. * @param serializationObject object to write serialization to
  19571. */
  19572. serialize(serializationObject: any): void;
  19573. /**
  19574. * Parses a serialized ground mesh
  19575. * @param parsedMesh the serialized mesh
  19576. * @param scene the scene to create the ground mesh in
  19577. * @returns the created ground mesh
  19578. */
  19579. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19580. }
  19581. }
  19582. declare module BABYLON {
  19583. /**
  19584. * Interface for Physics-Joint data
  19585. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19586. */
  19587. export interface PhysicsJointData {
  19588. /**
  19589. * The main pivot of the joint
  19590. */
  19591. mainPivot?: Vector3;
  19592. /**
  19593. * The connected pivot of the joint
  19594. */
  19595. connectedPivot?: Vector3;
  19596. /**
  19597. * The main axis of the joint
  19598. */
  19599. mainAxis?: Vector3;
  19600. /**
  19601. * The connected axis of the joint
  19602. */
  19603. connectedAxis?: Vector3;
  19604. /**
  19605. * The collision of the joint
  19606. */
  19607. collision?: boolean;
  19608. /**
  19609. * Native Oimo/Cannon/Energy data
  19610. */
  19611. nativeParams?: any;
  19612. }
  19613. /**
  19614. * This is a holder class for the physics joint created by the physics plugin
  19615. * It holds a set of functions to control the underlying joint
  19616. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19617. */
  19618. export class PhysicsJoint {
  19619. /**
  19620. * The type of the physics joint
  19621. */
  19622. type: number;
  19623. /**
  19624. * The data for the physics joint
  19625. */
  19626. jointData: PhysicsJointData;
  19627. private _physicsJoint;
  19628. protected _physicsPlugin: IPhysicsEnginePlugin;
  19629. /**
  19630. * Initializes the physics joint
  19631. * @param type The type of the physics joint
  19632. * @param jointData The data for the physics joint
  19633. */
  19634. constructor(
  19635. /**
  19636. * The type of the physics joint
  19637. */
  19638. type: number,
  19639. /**
  19640. * The data for the physics joint
  19641. */
  19642. jointData: PhysicsJointData);
  19643. /**
  19644. * Gets the physics joint
  19645. */
  19646. /**
  19647. * Sets the physics joint
  19648. */
  19649. physicsJoint: any;
  19650. /**
  19651. * Sets the physics plugin
  19652. */
  19653. physicsPlugin: IPhysicsEnginePlugin;
  19654. /**
  19655. * Execute a function that is physics-plugin specific.
  19656. * @param {Function} func the function that will be executed.
  19657. * It accepts two parameters: the physics world and the physics joint
  19658. */
  19659. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19660. /**
  19661. * Distance-Joint type
  19662. */
  19663. static DistanceJoint: number;
  19664. /**
  19665. * Hinge-Joint type
  19666. */
  19667. static HingeJoint: number;
  19668. /**
  19669. * Ball-and-Socket joint type
  19670. */
  19671. static BallAndSocketJoint: number;
  19672. /**
  19673. * Wheel-Joint type
  19674. */
  19675. static WheelJoint: number;
  19676. /**
  19677. * Slider-Joint type
  19678. */
  19679. static SliderJoint: number;
  19680. /**
  19681. * Prismatic-Joint type
  19682. */
  19683. static PrismaticJoint: number;
  19684. /**
  19685. * Universal-Joint type
  19686. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19687. */
  19688. static UniversalJoint: number;
  19689. /**
  19690. * Hinge-Joint 2 type
  19691. */
  19692. static Hinge2Joint: number;
  19693. /**
  19694. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19695. */
  19696. static PointToPointJoint: number;
  19697. /**
  19698. * Spring-Joint type
  19699. */
  19700. static SpringJoint: number;
  19701. /**
  19702. * Lock-Joint type
  19703. */
  19704. static LockJoint: number;
  19705. }
  19706. /**
  19707. * A class representing a physics distance joint
  19708. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19709. */
  19710. export class DistanceJoint extends PhysicsJoint {
  19711. /**
  19712. *
  19713. * @param jointData The data for the Distance-Joint
  19714. */
  19715. constructor(jointData: DistanceJointData);
  19716. /**
  19717. * Update the predefined distance.
  19718. * @param maxDistance The maximum preferred distance
  19719. * @param minDistance The minimum preferred distance
  19720. */
  19721. updateDistance(maxDistance: number, minDistance?: number): void;
  19722. }
  19723. /**
  19724. * Represents a Motor-Enabled Joint
  19725. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19726. */
  19727. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19728. /**
  19729. * Initializes the Motor-Enabled Joint
  19730. * @param type The type of the joint
  19731. * @param jointData The physica joint data for the joint
  19732. */
  19733. constructor(type: number, jointData: PhysicsJointData);
  19734. /**
  19735. * Set the motor values.
  19736. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19737. * @param force the force to apply
  19738. * @param maxForce max force for this motor.
  19739. */
  19740. setMotor(force?: number, maxForce?: number): void;
  19741. /**
  19742. * Set the motor's limits.
  19743. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19744. * @param upperLimit The upper limit of the motor
  19745. * @param lowerLimit The lower limit of the motor
  19746. */
  19747. setLimit(upperLimit: number, lowerLimit?: number): void;
  19748. }
  19749. /**
  19750. * This class represents a single physics Hinge-Joint
  19751. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19752. */
  19753. export class HingeJoint extends MotorEnabledJoint {
  19754. /**
  19755. * Initializes the Hinge-Joint
  19756. * @param jointData The joint data for the Hinge-Joint
  19757. */
  19758. constructor(jointData: PhysicsJointData);
  19759. /**
  19760. * Set the motor values.
  19761. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19762. * @param {number} force the force to apply
  19763. * @param {number} maxForce max force for this motor.
  19764. */
  19765. setMotor(force?: number, maxForce?: number): void;
  19766. /**
  19767. * Set the motor's limits.
  19768. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19769. * @param upperLimit The upper limit of the motor
  19770. * @param lowerLimit The lower limit of the motor
  19771. */
  19772. setLimit(upperLimit: number, lowerLimit?: number): void;
  19773. }
  19774. /**
  19775. * This class represents a dual hinge physics joint (same as wheel joint)
  19776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19777. */
  19778. export class Hinge2Joint extends MotorEnabledJoint {
  19779. /**
  19780. * Initializes the Hinge2-Joint
  19781. * @param jointData The joint data for the Hinge2-Joint
  19782. */
  19783. constructor(jointData: PhysicsJointData);
  19784. /**
  19785. * Set the motor values.
  19786. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19787. * @param {number} targetSpeed the speed the motor is to reach
  19788. * @param {number} maxForce max force for this motor.
  19789. * @param {motorIndex} the motor's index, 0 or 1.
  19790. */
  19791. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19792. /**
  19793. * Set the motor limits.
  19794. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19795. * @param {number} upperLimit the upper limit
  19796. * @param {number} lowerLimit lower limit
  19797. * @param {motorIndex} the motor's index, 0 or 1.
  19798. */
  19799. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19800. }
  19801. /**
  19802. * Interface for a motor enabled joint
  19803. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19804. */
  19805. export interface IMotorEnabledJoint {
  19806. /**
  19807. * Physics joint
  19808. */
  19809. physicsJoint: any;
  19810. /**
  19811. * Sets the motor of the motor-enabled joint
  19812. * @param force The force of the motor
  19813. * @param maxForce The maximum force of the motor
  19814. * @param motorIndex The index of the motor
  19815. */
  19816. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19817. /**
  19818. * Sets the limit of the motor
  19819. * @param upperLimit The upper limit of the motor
  19820. * @param lowerLimit The lower limit of the motor
  19821. * @param motorIndex The index of the motor
  19822. */
  19823. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19824. }
  19825. /**
  19826. * Joint data for a Distance-Joint
  19827. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19828. */
  19829. export interface DistanceJointData extends PhysicsJointData {
  19830. /**
  19831. * Max distance the 2 joint objects can be apart
  19832. */
  19833. maxDistance: number;
  19834. }
  19835. /**
  19836. * Joint data from a spring joint
  19837. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19838. */
  19839. export interface SpringJointData extends PhysicsJointData {
  19840. /**
  19841. * Length of the spring
  19842. */
  19843. length: number;
  19844. /**
  19845. * Stiffness of the spring
  19846. */
  19847. stiffness: number;
  19848. /**
  19849. * Damping of the spring
  19850. */
  19851. damping: number;
  19852. /** this callback will be called when applying the force to the impostors. */
  19853. forceApplicationCallback: () => void;
  19854. }
  19855. }
  19856. declare module BABYLON {
  19857. /**
  19858. * Holds the data for the raycast result
  19859. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19860. */
  19861. export class PhysicsRaycastResult {
  19862. private _hasHit;
  19863. private _hitDistance;
  19864. private _hitNormalWorld;
  19865. private _hitPointWorld;
  19866. private _rayFromWorld;
  19867. private _rayToWorld;
  19868. /**
  19869. * Gets if there was a hit
  19870. */
  19871. readonly hasHit: boolean;
  19872. /**
  19873. * Gets the distance from the hit
  19874. */
  19875. readonly hitDistance: number;
  19876. /**
  19877. * Gets the hit normal/direction in the world
  19878. */
  19879. readonly hitNormalWorld: Vector3;
  19880. /**
  19881. * Gets the hit point in the world
  19882. */
  19883. readonly hitPointWorld: Vector3;
  19884. /**
  19885. * Gets the ray "start point" of the ray in the world
  19886. */
  19887. readonly rayFromWorld: Vector3;
  19888. /**
  19889. * Gets the ray "end point" of the ray in the world
  19890. */
  19891. readonly rayToWorld: Vector3;
  19892. /**
  19893. * Sets the hit data (normal & point in world space)
  19894. * @param hitNormalWorld defines the normal in world space
  19895. * @param hitPointWorld defines the point in world space
  19896. */
  19897. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19898. /**
  19899. * Sets the distance from the start point to the hit point
  19900. * @param distance
  19901. */
  19902. setHitDistance(distance: number): void;
  19903. /**
  19904. * Calculates the distance manually
  19905. */
  19906. calculateHitDistance(): void;
  19907. /**
  19908. * Resets all the values to default
  19909. * @param from The from point on world space
  19910. * @param to The to point on world space
  19911. */
  19912. reset(from?: Vector3, to?: Vector3): void;
  19913. }
  19914. /**
  19915. * Interface for the size containing width and height
  19916. */
  19917. interface IXYZ {
  19918. /**
  19919. * X
  19920. */
  19921. x: number;
  19922. /**
  19923. * Y
  19924. */
  19925. y: number;
  19926. /**
  19927. * Z
  19928. */
  19929. z: number;
  19930. }
  19931. }
  19932. declare module BABYLON {
  19933. /**
  19934. * Interface used to describe a physics joint
  19935. */
  19936. export interface PhysicsImpostorJoint {
  19937. /** Defines the main impostor to which the joint is linked */
  19938. mainImpostor: PhysicsImpostor;
  19939. /** Defines the impostor that is connected to the main impostor using this joint */
  19940. connectedImpostor: PhysicsImpostor;
  19941. /** Defines the joint itself */
  19942. joint: PhysicsJoint;
  19943. }
  19944. /** @hidden */
  19945. export interface IPhysicsEnginePlugin {
  19946. world: any;
  19947. name: string;
  19948. setGravity(gravity: Vector3): void;
  19949. setTimeStep(timeStep: number): void;
  19950. getTimeStep(): number;
  19951. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19952. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19953. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19954. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19955. removePhysicsBody(impostor: PhysicsImpostor): void;
  19956. generateJoint(joint: PhysicsImpostorJoint): void;
  19957. removeJoint(joint: PhysicsImpostorJoint): void;
  19958. isSupported(): boolean;
  19959. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19960. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19961. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19962. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19963. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19964. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19965. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19966. getBodyMass(impostor: PhysicsImpostor): number;
  19967. getBodyFriction(impostor: PhysicsImpostor): number;
  19968. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19969. getBodyRestitution(impostor: PhysicsImpostor): number;
  19970. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19971. getBodyPressure?(impostor: PhysicsImpostor): number;
  19972. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  19973. getBodyStiffness?(impostor: PhysicsImpostor): number;
  19974. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  19975. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  19976. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  19977. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  19978. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  19979. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19980. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19981. sleepBody(impostor: PhysicsImpostor): void;
  19982. wakeUpBody(impostor: PhysicsImpostor): void;
  19983. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19984. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19985. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19986. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19987. getRadius(impostor: PhysicsImpostor): number;
  19988. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19989. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19990. dispose(): void;
  19991. }
  19992. /**
  19993. * Interface used to define a physics engine
  19994. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19995. */
  19996. export interface IPhysicsEngine {
  19997. /**
  19998. * Gets the gravity vector used by the simulation
  19999. */
  20000. gravity: Vector3;
  20001. /**
  20002. * Sets the gravity vector used by the simulation
  20003. * @param gravity defines the gravity vector to use
  20004. */
  20005. setGravity(gravity: Vector3): void;
  20006. /**
  20007. * Set the time step of the physics engine.
  20008. * Default is 1/60.
  20009. * To slow it down, enter 1/600 for example.
  20010. * To speed it up, 1/30
  20011. * @param newTimeStep the new timestep to apply to this world.
  20012. */
  20013. setTimeStep(newTimeStep: number): void;
  20014. /**
  20015. * Get the time step of the physics engine.
  20016. * @returns the current time step
  20017. */
  20018. getTimeStep(): number;
  20019. /**
  20020. * Release all resources
  20021. */
  20022. dispose(): void;
  20023. /**
  20024. * Gets the name of the current physics plugin
  20025. * @returns the name of the plugin
  20026. */
  20027. getPhysicsPluginName(): string;
  20028. /**
  20029. * Adding a new impostor for the impostor tracking.
  20030. * This will be done by the impostor itself.
  20031. * @param impostor the impostor to add
  20032. */
  20033. addImpostor(impostor: PhysicsImpostor): void;
  20034. /**
  20035. * Remove an impostor from the engine.
  20036. * This impostor and its mesh will not longer be updated by the physics engine.
  20037. * @param impostor the impostor to remove
  20038. */
  20039. removeImpostor(impostor: PhysicsImpostor): void;
  20040. /**
  20041. * Add a joint to the physics engine
  20042. * @param mainImpostor defines the main impostor to which the joint is added.
  20043. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20044. * @param joint defines the joint that will connect both impostors.
  20045. */
  20046. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20047. /**
  20048. * Removes a joint from the simulation
  20049. * @param mainImpostor defines the impostor used with the joint
  20050. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20051. * @param joint defines the joint to remove
  20052. */
  20053. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20054. /**
  20055. * Gets the current plugin used to run the simulation
  20056. * @returns current plugin
  20057. */
  20058. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20059. /**
  20060. * Gets the list of physic impostors
  20061. * @returns an array of PhysicsImpostor
  20062. */
  20063. getImpostors(): Array<PhysicsImpostor>;
  20064. /**
  20065. * Gets the impostor for a physics enabled object
  20066. * @param object defines the object impersonated by the impostor
  20067. * @returns the PhysicsImpostor or null if not found
  20068. */
  20069. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20070. /**
  20071. * Gets the impostor for a physics body object
  20072. * @param body defines physics body used by the impostor
  20073. * @returns the PhysicsImpostor or null if not found
  20074. */
  20075. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20076. /**
  20077. * Does a raycast in the physics world
  20078. * @param from when should the ray start?
  20079. * @param to when should the ray end?
  20080. * @returns PhysicsRaycastResult
  20081. */
  20082. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20083. /**
  20084. * Called by the scene. No need to call it.
  20085. * @param delta defines the timespam between frames
  20086. */
  20087. _step(delta: number): void;
  20088. }
  20089. }
  20090. declare module BABYLON {
  20091. /**
  20092. * The interface for the physics imposter parameters
  20093. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20094. */
  20095. export interface PhysicsImpostorParameters {
  20096. /**
  20097. * The mass of the physics imposter
  20098. */
  20099. mass: number;
  20100. /**
  20101. * The friction of the physics imposter
  20102. */
  20103. friction?: number;
  20104. /**
  20105. * The coefficient of restitution of the physics imposter
  20106. */
  20107. restitution?: number;
  20108. /**
  20109. * The native options of the physics imposter
  20110. */
  20111. nativeOptions?: any;
  20112. /**
  20113. * Specifies if the parent should be ignored
  20114. */
  20115. ignoreParent?: boolean;
  20116. /**
  20117. * Specifies if bi-directional transformations should be disabled
  20118. */
  20119. disableBidirectionalTransformation?: boolean;
  20120. /**
  20121. * The pressure inside the physics imposter, soft object only
  20122. */
  20123. pressure?: number;
  20124. /**
  20125. * The stiffness the physics imposter, soft object only
  20126. */
  20127. stiffness?: number;
  20128. /**
  20129. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20130. */
  20131. velocityIterations?: number;
  20132. /**
  20133. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20134. */
  20135. positionIterations?: number;
  20136. /**
  20137. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20138. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20139. * Add to fix multiple points
  20140. */
  20141. fixedPoints?: number;
  20142. /**
  20143. * The collision margin around a soft object
  20144. */
  20145. margin?: number;
  20146. /**
  20147. * The collision margin around a soft object
  20148. */
  20149. damping?: number;
  20150. /**
  20151. * The path for a rope based on an extrusion
  20152. */
  20153. path?: any;
  20154. /**
  20155. * The shape of an extrusion used for a rope based on an extrusion
  20156. */
  20157. shape?: any;
  20158. }
  20159. /**
  20160. * Interface for a physics-enabled object
  20161. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20162. */
  20163. export interface IPhysicsEnabledObject {
  20164. /**
  20165. * The position of the physics-enabled object
  20166. */
  20167. position: Vector3;
  20168. /**
  20169. * The rotation of the physics-enabled object
  20170. */
  20171. rotationQuaternion: Nullable<Quaternion>;
  20172. /**
  20173. * The scale of the physics-enabled object
  20174. */
  20175. scaling: Vector3;
  20176. /**
  20177. * The rotation of the physics-enabled object
  20178. */
  20179. rotation?: Vector3;
  20180. /**
  20181. * The parent of the physics-enabled object
  20182. */
  20183. parent?: any;
  20184. /**
  20185. * The bounding info of the physics-enabled object
  20186. * @returns The bounding info of the physics-enabled object
  20187. */
  20188. getBoundingInfo(): BoundingInfo;
  20189. /**
  20190. * Computes the world matrix
  20191. * @param force Specifies if the world matrix should be computed by force
  20192. * @returns A world matrix
  20193. */
  20194. computeWorldMatrix(force: boolean): Matrix;
  20195. /**
  20196. * Gets the world matrix
  20197. * @returns A world matrix
  20198. */
  20199. getWorldMatrix?(): Matrix;
  20200. /**
  20201. * Gets the child meshes
  20202. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20203. * @returns An array of abstract meshes
  20204. */
  20205. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20206. /**
  20207. * Gets the vertex data
  20208. * @param kind The type of vertex data
  20209. * @returns A nullable array of numbers, or a float32 array
  20210. */
  20211. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20212. /**
  20213. * Gets the indices from the mesh
  20214. * @returns A nullable array of index arrays
  20215. */
  20216. getIndices?(): Nullable<IndicesArray>;
  20217. /**
  20218. * Gets the scene from the mesh
  20219. * @returns the indices array or null
  20220. */
  20221. getScene?(): Scene;
  20222. /**
  20223. * Gets the absolute position from the mesh
  20224. * @returns the absolute position
  20225. */
  20226. getAbsolutePosition(): Vector3;
  20227. /**
  20228. * Gets the absolute pivot point from the mesh
  20229. * @returns the absolute pivot point
  20230. */
  20231. getAbsolutePivotPoint(): Vector3;
  20232. /**
  20233. * Rotates the mesh
  20234. * @param axis The axis of rotation
  20235. * @param amount The amount of rotation
  20236. * @param space The space of the rotation
  20237. * @returns The rotation transform node
  20238. */
  20239. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20240. /**
  20241. * Translates the mesh
  20242. * @param axis The axis of translation
  20243. * @param distance The distance of translation
  20244. * @param space The space of the translation
  20245. * @returns The transform node
  20246. */
  20247. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20248. /**
  20249. * Sets the absolute position of the mesh
  20250. * @param absolutePosition The absolute position of the mesh
  20251. * @returns The transform node
  20252. */
  20253. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20254. /**
  20255. * Gets the class name of the mesh
  20256. * @returns The class name
  20257. */
  20258. getClassName(): string;
  20259. }
  20260. /**
  20261. * Represents a physics imposter
  20262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20263. */
  20264. export class PhysicsImpostor {
  20265. /**
  20266. * The physics-enabled object used as the physics imposter
  20267. */
  20268. object: IPhysicsEnabledObject;
  20269. /**
  20270. * The type of the physics imposter
  20271. */
  20272. type: number;
  20273. private _options;
  20274. private _scene?;
  20275. /**
  20276. * The default object size of the imposter
  20277. */
  20278. static DEFAULT_OBJECT_SIZE: Vector3;
  20279. /**
  20280. * The identity quaternion of the imposter
  20281. */
  20282. static IDENTITY_QUATERNION: Quaternion;
  20283. /** @hidden */
  20284. _pluginData: any;
  20285. private _physicsEngine;
  20286. private _physicsBody;
  20287. private _bodyUpdateRequired;
  20288. private _onBeforePhysicsStepCallbacks;
  20289. private _onAfterPhysicsStepCallbacks;
  20290. /** @hidden */
  20291. _onPhysicsCollideCallbacks: Array<{
  20292. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20293. otherImpostors: Array<PhysicsImpostor>;
  20294. }>;
  20295. private _deltaPosition;
  20296. private _deltaRotation;
  20297. private _deltaRotationConjugated;
  20298. /** hidden */
  20299. _isFromLine: boolean;
  20300. private _parent;
  20301. private _isDisposed;
  20302. private static _tmpVecs;
  20303. private static _tmpQuat;
  20304. /**
  20305. * Specifies if the physics imposter is disposed
  20306. */
  20307. readonly isDisposed: boolean;
  20308. /**
  20309. * Gets the mass of the physics imposter
  20310. */
  20311. mass: number;
  20312. /**
  20313. * Gets the coefficient of friction
  20314. */
  20315. /**
  20316. * Sets the coefficient of friction
  20317. */
  20318. friction: number;
  20319. /**
  20320. * Gets the coefficient of restitution
  20321. */
  20322. /**
  20323. * Sets the coefficient of restitution
  20324. */
  20325. restitution: number;
  20326. /**
  20327. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20328. */
  20329. /**
  20330. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20331. */
  20332. pressure: number;
  20333. /**
  20334. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20335. */
  20336. /**
  20337. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20338. */
  20339. stiffness: number;
  20340. /**
  20341. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20342. */
  20343. /**
  20344. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20345. */
  20346. velocityIterations: number;
  20347. /**
  20348. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20349. */
  20350. /**
  20351. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20352. */
  20353. positionIterations: number;
  20354. /**
  20355. * The unique id of the physics imposter
  20356. * set by the physics engine when adding this impostor to the array
  20357. */
  20358. uniqueId: number;
  20359. /**
  20360. * @hidden
  20361. */
  20362. soft: boolean;
  20363. /**
  20364. * @hidden
  20365. */
  20366. segments: number;
  20367. private _joints;
  20368. /**
  20369. * Initializes the physics imposter
  20370. * @param object The physics-enabled object used as the physics imposter
  20371. * @param type The type of the physics imposter
  20372. * @param _options The options for the physics imposter
  20373. * @param _scene The Babylon scene
  20374. */
  20375. constructor(
  20376. /**
  20377. * The physics-enabled object used as the physics imposter
  20378. */
  20379. object: IPhysicsEnabledObject,
  20380. /**
  20381. * The type of the physics imposter
  20382. */
  20383. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20384. /**
  20385. * This function will completly initialize this impostor.
  20386. * It will create a new body - but only if this mesh has no parent.
  20387. * If it has, this impostor will not be used other than to define the impostor
  20388. * of the child mesh.
  20389. * @hidden
  20390. */
  20391. _init(): void;
  20392. private _getPhysicsParent;
  20393. /**
  20394. * Should a new body be generated.
  20395. * @returns boolean specifying if body initialization is required
  20396. */
  20397. isBodyInitRequired(): boolean;
  20398. /**
  20399. * Sets the updated scaling
  20400. * @param updated Specifies if the scaling is updated
  20401. */
  20402. setScalingUpdated(): void;
  20403. /**
  20404. * Force a regeneration of this or the parent's impostor's body.
  20405. * Use under cautious - This will remove all joints already implemented.
  20406. */
  20407. forceUpdate(): void;
  20408. /**
  20409. * Gets the body that holds this impostor. Either its own, or its parent.
  20410. */
  20411. /**
  20412. * Set the physics body. Used mainly by the physics engine/plugin
  20413. */
  20414. physicsBody: any;
  20415. /**
  20416. * Get the parent of the physics imposter
  20417. * @returns Physics imposter or null
  20418. */
  20419. /**
  20420. * Sets the parent of the physics imposter
  20421. */
  20422. parent: Nullable<PhysicsImpostor>;
  20423. /**
  20424. * Resets the update flags
  20425. */
  20426. resetUpdateFlags(): void;
  20427. /**
  20428. * Gets the object extend size
  20429. * @returns the object extend size
  20430. */
  20431. getObjectExtendSize(): Vector3;
  20432. /**
  20433. * Gets the object center
  20434. * @returns The object center
  20435. */
  20436. getObjectCenter(): Vector3;
  20437. /**
  20438. * Get a specific parametes from the options parameter
  20439. * @param paramName The object parameter name
  20440. * @returns The object parameter
  20441. */
  20442. getParam(paramName: string): any;
  20443. /**
  20444. * Sets a specific parameter in the options given to the physics plugin
  20445. * @param paramName The parameter name
  20446. * @param value The value of the parameter
  20447. */
  20448. setParam(paramName: string, value: number): void;
  20449. /**
  20450. * Specifically change the body's mass option. Won't recreate the physics body object
  20451. * @param mass The mass of the physics imposter
  20452. */
  20453. setMass(mass: number): void;
  20454. /**
  20455. * Gets the linear velocity
  20456. * @returns linear velocity or null
  20457. */
  20458. getLinearVelocity(): Nullable<Vector3>;
  20459. /**
  20460. * Sets the linear velocity
  20461. * @param velocity linear velocity or null
  20462. */
  20463. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20464. /**
  20465. * Gets the angular velocity
  20466. * @returns angular velocity or null
  20467. */
  20468. getAngularVelocity(): Nullable<Vector3>;
  20469. /**
  20470. * Sets the angular velocity
  20471. * @param velocity The velocity or null
  20472. */
  20473. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20474. /**
  20475. * Execute a function with the physics plugin native code
  20476. * Provide a function the will have two variables - the world object and the physics body object
  20477. * @param func The function to execute with the physics plugin native code
  20478. */
  20479. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20480. /**
  20481. * Register a function that will be executed before the physics world is stepping forward
  20482. * @param func The function to execute before the physics world is stepped forward
  20483. */
  20484. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20485. /**
  20486. * Unregister a function that will be executed before the physics world is stepping forward
  20487. * @param func The function to execute before the physics world is stepped forward
  20488. */
  20489. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20490. /**
  20491. * Register a function that will be executed after the physics step
  20492. * @param func The function to execute after physics step
  20493. */
  20494. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20495. /**
  20496. * Unregisters a function that will be executed after the physics step
  20497. * @param func The function to execute after physics step
  20498. */
  20499. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20500. /**
  20501. * register a function that will be executed when this impostor collides against a different body
  20502. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20503. * @param func Callback that is executed on collision
  20504. */
  20505. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20506. /**
  20507. * Unregisters the physics imposter on contact
  20508. * @param collideAgainst The physics object to collide against
  20509. * @param func Callback to execute on collision
  20510. */
  20511. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20512. private _tmpQuat;
  20513. private _tmpQuat2;
  20514. /**
  20515. * Get the parent rotation
  20516. * @returns The parent rotation
  20517. */
  20518. getParentsRotation(): Quaternion;
  20519. /**
  20520. * this function is executed by the physics engine.
  20521. */
  20522. beforeStep: () => void;
  20523. /**
  20524. * this function is executed by the physics engine
  20525. */
  20526. afterStep: () => void;
  20527. /**
  20528. * Legacy collision detection event support
  20529. */
  20530. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20531. /**
  20532. * event and body object due to cannon's event-based architecture.
  20533. */
  20534. onCollide: (e: {
  20535. body: any;
  20536. }) => void;
  20537. /**
  20538. * Apply a force
  20539. * @param force The force to apply
  20540. * @param contactPoint The contact point for the force
  20541. * @returns The physics imposter
  20542. */
  20543. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20544. /**
  20545. * Apply an impulse
  20546. * @param force The impulse force
  20547. * @param contactPoint The contact point for the impulse force
  20548. * @returns The physics imposter
  20549. */
  20550. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20551. /**
  20552. * A help function to create a joint
  20553. * @param otherImpostor A physics imposter used to create a joint
  20554. * @param jointType The type of joint
  20555. * @param jointData The data for the joint
  20556. * @returns The physics imposter
  20557. */
  20558. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20559. /**
  20560. * Add a joint to this impostor with a different impostor
  20561. * @param otherImpostor A physics imposter used to add a joint
  20562. * @param joint The joint to add
  20563. * @returns The physics imposter
  20564. */
  20565. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20566. /**
  20567. * Add an anchor to a cloth impostor
  20568. * @param otherImpostor rigid impostor to anchor to
  20569. * @param width ratio across width from 0 to 1
  20570. * @param height ratio up height from 0 to 1
  20571. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20572. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20573. * @returns impostor the soft imposter
  20574. */
  20575. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20576. /**
  20577. * Add a hook to a rope impostor
  20578. * @param otherImpostor rigid impostor to anchor to
  20579. * @param length ratio across rope from 0 to 1
  20580. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20581. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20582. * @returns impostor the rope imposter
  20583. */
  20584. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20585. /**
  20586. * Will keep this body still, in a sleep mode.
  20587. * @returns the physics imposter
  20588. */
  20589. sleep(): PhysicsImpostor;
  20590. /**
  20591. * Wake the body up.
  20592. * @returns The physics imposter
  20593. */
  20594. wakeUp(): PhysicsImpostor;
  20595. /**
  20596. * Clones the physics imposter
  20597. * @param newObject The physics imposter clones to this physics-enabled object
  20598. * @returns A nullable physics imposter
  20599. */
  20600. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20601. /**
  20602. * Disposes the physics imposter
  20603. */
  20604. dispose(): void;
  20605. /**
  20606. * Sets the delta position
  20607. * @param position The delta position amount
  20608. */
  20609. setDeltaPosition(position: Vector3): void;
  20610. /**
  20611. * Sets the delta rotation
  20612. * @param rotation The delta rotation amount
  20613. */
  20614. setDeltaRotation(rotation: Quaternion): void;
  20615. /**
  20616. * Gets the box size of the physics imposter and stores the result in the input parameter
  20617. * @param result Stores the box size
  20618. * @returns The physics imposter
  20619. */
  20620. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20621. /**
  20622. * Gets the radius of the physics imposter
  20623. * @returns Radius of the physics imposter
  20624. */
  20625. getRadius(): number;
  20626. /**
  20627. * Sync a bone with this impostor
  20628. * @param bone The bone to sync to the impostor.
  20629. * @param boneMesh The mesh that the bone is influencing.
  20630. * @param jointPivot The pivot of the joint / bone in local space.
  20631. * @param distToJoint Optional distance from the impostor to the joint.
  20632. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20633. */
  20634. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20635. /**
  20636. * Sync impostor to a bone
  20637. * @param bone The bone that the impostor will be synced to.
  20638. * @param boneMesh The mesh that the bone is influencing.
  20639. * @param jointPivot The pivot of the joint / bone in local space.
  20640. * @param distToJoint Optional distance from the impostor to the joint.
  20641. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20642. * @param boneAxis Optional vector3 axis the bone is aligned with
  20643. */
  20644. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20645. /**
  20646. * No-Imposter type
  20647. */
  20648. static NoImpostor: number;
  20649. /**
  20650. * Sphere-Imposter type
  20651. */
  20652. static SphereImpostor: number;
  20653. /**
  20654. * Box-Imposter type
  20655. */
  20656. static BoxImpostor: number;
  20657. /**
  20658. * Plane-Imposter type
  20659. */
  20660. static PlaneImpostor: number;
  20661. /**
  20662. * Mesh-imposter type
  20663. */
  20664. static MeshImpostor: number;
  20665. /**
  20666. * Cylinder-Imposter type
  20667. */
  20668. static CylinderImpostor: number;
  20669. /**
  20670. * Particle-Imposter type
  20671. */
  20672. static ParticleImpostor: number;
  20673. /**
  20674. * Heightmap-Imposter type
  20675. */
  20676. static HeightmapImpostor: number;
  20677. /**
  20678. * ConvexHull-Impostor type (Ammo.js plugin only)
  20679. */
  20680. static ConvexHullImpostor: number;
  20681. /**
  20682. * Rope-Imposter type
  20683. */
  20684. static RopeImpostor: number;
  20685. /**
  20686. * Cloth-Imposter type
  20687. */
  20688. static ClothImpostor: number;
  20689. /**
  20690. * Softbody-Imposter type
  20691. */
  20692. static SoftbodyImpostor: number;
  20693. }
  20694. }
  20695. declare module BABYLON {
  20696. /**
  20697. * @hidden
  20698. **/
  20699. export class _CreationDataStorage {
  20700. closePath?: boolean;
  20701. closeArray?: boolean;
  20702. idx: number[];
  20703. dashSize: number;
  20704. gapSize: number;
  20705. path3D: Path3D;
  20706. pathArray: Vector3[][];
  20707. arc: number;
  20708. radius: number;
  20709. cap: number;
  20710. tessellation: number;
  20711. }
  20712. /**
  20713. * @hidden
  20714. **/
  20715. class _InstanceDataStorage {
  20716. visibleInstances: any;
  20717. batchCache: _InstancesBatch;
  20718. instancesBufferSize: number;
  20719. instancesBuffer: Nullable<Buffer>;
  20720. instancesData: Float32Array;
  20721. overridenInstanceCount: number;
  20722. isFrozen: boolean;
  20723. previousBatch: _InstancesBatch;
  20724. hardwareInstancedRendering: boolean;
  20725. sideOrientation: number;
  20726. }
  20727. /**
  20728. * @hidden
  20729. **/
  20730. export class _InstancesBatch {
  20731. mustReturn: boolean;
  20732. visibleInstances: Nullable<InstancedMesh[]>[];
  20733. renderSelf: boolean[];
  20734. hardwareInstancedRendering: boolean[];
  20735. }
  20736. /**
  20737. * Class used to represent renderable models
  20738. */
  20739. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20740. /**
  20741. * Mesh side orientation : usually the external or front surface
  20742. */
  20743. static readonly FRONTSIDE: number;
  20744. /**
  20745. * Mesh side orientation : usually the internal or back surface
  20746. */
  20747. static readonly BACKSIDE: number;
  20748. /**
  20749. * Mesh side orientation : both internal and external or front and back surfaces
  20750. */
  20751. static readonly DOUBLESIDE: number;
  20752. /**
  20753. * Mesh side orientation : by default, `FRONTSIDE`
  20754. */
  20755. static readonly DEFAULTSIDE: number;
  20756. /**
  20757. * Mesh cap setting : no cap
  20758. */
  20759. static readonly NO_CAP: number;
  20760. /**
  20761. * Mesh cap setting : one cap at the beginning of the mesh
  20762. */
  20763. static readonly CAP_START: number;
  20764. /**
  20765. * Mesh cap setting : one cap at the end of the mesh
  20766. */
  20767. static readonly CAP_END: number;
  20768. /**
  20769. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20770. */
  20771. static readonly CAP_ALL: number;
  20772. /**
  20773. * Mesh pattern setting : no flip or rotate
  20774. */
  20775. static readonly NO_FLIP: number;
  20776. /**
  20777. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  20778. */
  20779. static readonly FLIP_TILE: number;
  20780. /**
  20781. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  20782. */
  20783. static readonly ROTATE_TILE: number;
  20784. /**
  20785. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  20786. */
  20787. static readonly FLIP_ROW: number;
  20788. /**
  20789. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  20790. */
  20791. static readonly ROTATE_ROW: number;
  20792. /**
  20793. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  20794. */
  20795. static readonly FLIP_N_ROTATE_TILE: number;
  20796. /**
  20797. * Mesh pattern setting : rotate pattern and rotate
  20798. */
  20799. static readonly FLIP_N_ROTATE_ROW: number;
  20800. /**
  20801. * Mesh tile positioning : part tiles same on left/right or top/bottom
  20802. */
  20803. static readonly CENTER: number;
  20804. /**
  20805. * Mesh tile positioning : part tiles on left
  20806. */
  20807. static readonly LEFT: number;
  20808. /**
  20809. * Mesh tile positioning : part tiles on right
  20810. */
  20811. static readonly RIGHT: number;
  20812. /**
  20813. * Mesh tile positioning : part tiles on top
  20814. */
  20815. static readonly TOP: number;
  20816. /**
  20817. * Mesh tile positioning : part tiles on bottom
  20818. */
  20819. static readonly BOTTOM: number;
  20820. /**
  20821. * Gets the default side orientation.
  20822. * @param orientation the orientation to value to attempt to get
  20823. * @returns the default orientation
  20824. * @hidden
  20825. */
  20826. static _GetDefaultSideOrientation(orientation?: number): number;
  20827. private _internalMeshDataInfo;
  20828. /**
  20829. * An event triggered before rendering the mesh
  20830. */
  20831. readonly onBeforeRenderObservable: Observable<Mesh>;
  20832. /**
  20833. * An event triggered before binding the mesh
  20834. */
  20835. readonly onBeforeBindObservable: Observable<Mesh>;
  20836. /**
  20837. * An event triggered after rendering the mesh
  20838. */
  20839. readonly onAfterRenderObservable: Observable<Mesh>;
  20840. /**
  20841. * An event triggered before drawing the mesh
  20842. */
  20843. readonly onBeforeDrawObservable: Observable<Mesh>;
  20844. private _onBeforeDrawObserver;
  20845. /**
  20846. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20847. */
  20848. onBeforeDraw: () => void;
  20849. /**
  20850. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20851. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20852. */
  20853. delayLoadState: number;
  20854. /**
  20855. * Gets the list of instances created from this mesh
  20856. * it is not supposed to be modified manually.
  20857. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20858. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20859. */
  20860. instances: InstancedMesh[];
  20861. /**
  20862. * Gets the file containing delay loading data for this mesh
  20863. */
  20864. delayLoadingFile: string;
  20865. /** @hidden */
  20866. _binaryInfo: any;
  20867. /**
  20868. * User defined function used to change how LOD level selection is done
  20869. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20870. */
  20871. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20872. /**
  20873. * Gets or sets the morph target manager
  20874. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20875. */
  20876. morphTargetManager: Nullable<MorphTargetManager>;
  20877. /** @hidden */
  20878. _creationDataStorage: Nullable<_CreationDataStorage>;
  20879. /** @hidden */
  20880. _geometry: Nullable<Geometry>;
  20881. /** @hidden */
  20882. _delayInfo: Array<string>;
  20883. /** @hidden */
  20884. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20885. /** @hidden */
  20886. _instanceDataStorage: _InstanceDataStorage;
  20887. private _effectiveMaterial;
  20888. /** @hidden */
  20889. _shouldGenerateFlatShading: boolean;
  20890. /** @hidden */
  20891. _originalBuilderSideOrientation: number;
  20892. /**
  20893. * Use this property to change the original side orientation defined at construction time
  20894. */
  20895. overrideMaterialSideOrientation: Nullable<number>;
  20896. /**
  20897. * Gets the source mesh (the one used to clone this one from)
  20898. */
  20899. readonly source: Nullable<Mesh>;
  20900. /**
  20901. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20902. */
  20903. isUnIndexed: boolean;
  20904. /**
  20905. * @constructor
  20906. * @param name The value used by scene.getMeshByName() to do a lookup.
  20907. * @param scene The scene to add this mesh to.
  20908. * @param parent The parent of this mesh, if it has one
  20909. * @param source An optional Mesh from which geometry is shared, cloned.
  20910. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20911. * When false, achieved by calling a clone(), also passing False.
  20912. * This will make creation of children, recursive.
  20913. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20914. */
  20915. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20916. /**
  20917. * Gets the class name
  20918. * @returns the string "Mesh".
  20919. */
  20920. getClassName(): string;
  20921. /** @hidden */
  20922. readonly _isMesh: boolean;
  20923. /**
  20924. * Returns a description of this mesh
  20925. * @param fullDetails define if full details about this mesh must be used
  20926. * @returns a descriptive string representing this mesh
  20927. */
  20928. toString(fullDetails?: boolean): string;
  20929. /** @hidden */
  20930. _unBindEffect(): void;
  20931. /**
  20932. * Gets a boolean indicating if this mesh has LOD
  20933. */
  20934. readonly hasLODLevels: boolean;
  20935. /**
  20936. * Gets the list of MeshLODLevel associated with the current mesh
  20937. * @returns an array of MeshLODLevel
  20938. */
  20939. getLODLevels(): MeshLODLevel[];
  20940. private _sortLODLevels;
  20941. /**
  20942. * Add a mesh as LOD level triggered at the given distance.
  20943. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20944. * @param distance The distance from the center of the object to show this level
  20945. * @param mesh The mesh to be added as LOD level (can be null)
  20946. * @return This mesh (for chaining)
  20947. */
  20948. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20949. /**
  20950. * Returns the LOD level mesh at the passed distance or null if not found.
  20951. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20952. * @param distance The distance from the center of the object to show this level
  20953. * @returns a Mesh or `null`
  20954. */
  20955. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20956. /**
  20957. * Remove a mesh from the LOD array
  20958. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20959. * @param mesh defines the mesh to be removed
  20960. * @return This mesh (for chaining)
  20961. */
  20962. removeLODLevel(mesh: Mesh): Mesh;
  20963. /**
  20964. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20965. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20966. * @param camera defines the camera to use to compute distance
  20967. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20968. * @return This mesh (for chaining)
  20969. */
  20970. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20971. /**
  20972. * Gets the mesh internal Geometry object
  20973. */
  20974. readonly geometry: Nullable<Geometry>;
  20975. /**
  20976. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20977. * @returns the total number of vertices
  20978. */
  20979. getTotalVertices(): number;
  20980. /**
  20981. * Returns the content of an associated vertex buffer
  20982. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20983. * - VertexBuffer.PositionKind
  20984. * - VertexBuffer.UVKind
  20985. * - VertexBuffer.UV2Kind
  20986. * - VertexBuffer.UV3Kind
  20987. * - VertexBuffer.UV4Kind
  20988. * - VertexBuffer.UV5Kind
  20989. * - VertexBuffer.UV6Kind
  20990. * - VertexBuffer.ColorKind
  20991. * - VertexBuffer.MatricesIndicesKind
  20992. * - VertexBuffer.MatricesIndicesExtraKind
  20993. * - VertexBuffer.MatricesWeightsKind
  20994. * - VertexBuffer.MatricesWeightsExtraKind
  20995. * @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
  20996. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20997. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20998. */
  20999. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21000. /**
  21001. * Returns the mesh VertexBuffer object from the requested `kind`
  21002. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21003. * - VertexBuffer.PositionKind
  21004. * - VertexBuffer.NormalKind
  21005. * - VertexBuffer.UVKind
  21006. * - VertexBuffer.UV2Kind
  21007. * - VertexBuffer.UV3Kind
  21008. * - VertexBuffer.UV4Kind
  21009. * - VertexBuffer.UV5Kind
  21010. * - VertexBuffer.UV6Kind
  21011. * - VertexBuffer.ColorKind
  21012. * - VertexBuffer.MatricesIndicesKind
  21013. * - VertexBuffer.MatricesIndicesExtraKind
  21014. * - VertexBuffer.MatricesWeightsKind
  21015. * - VertexBuffer.MatricesWeightsExtraKind
  21016. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21017. */
  21018. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21019. /**
  21020. * Tests if a specific vertex buffer is associated with this mesh
  21021. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21022. * - VertexBuffer.PositionKind
  21023. * - VertexBuffer.NormalKind
  21024. * - VertexBuffer.UVKind
  21025. * - VertexBuffer.UV2Kind
  21026. * - VertexBuffer.UV3Kind
  21027. * - VertexBuffer.UV4Kind
  21028. * - VertexBuffer.UV5Kind
  21029. * - VertexBuffer.UV6Kind
  21030. * - VertexBuffer.ColorKind
  21031. * - VertexBuffer.MatricesIndicesKind
  21032. * - VertexBuffer.MatricesIndicesExtraKind
  21033. * - VertexBuffer.MatricesWeightsKind
  21034. * - VertexBuffer.MatricesWeightsExtraKind
  21035. * @returns a boolean
  21036. */
  21037. isVerticesDataPresent(kind: string): boolean;
  21038. /**
  21039. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21040. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21041. * - VertexBuffer.PositionKind
  21042. * - VertexBuffer.UVKind
  21043. * - VertexBuffer.UV2Kind
  21044. * - VertexBuffer.UV3Kind
  21045. * - VertexBuffer.UV4Kind
  21046. * - VertexBuffer.UV5Kind
  21047. * - VertexBuffer.UV6Kind
  21048. * - VertexBuffer.ColorKind
  21049. * - VertexBuffer.MatricesIndicesKind
  21050. * - VertexBuffer.MatricesIndicesExtraKind
  21051. * - VertexBuffer.MatricesWeightsKind
  21052. * - VertexBuffer.MatricesWeightsExtraKind
  21053. * @returns a boolean
  21054. */
  21055. isVertexBufferUpdatable(kind: string): boolean;
  21056. /**
  21057. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21058. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21059. * - VertexBuffer.PositionKind
  21060. * - VertexBuffer.NormalKind
  21061. * - VertexBuffer.UVKind
  21062. * - VertexBuffer.UV2Kind
  21063. * - VertexBuffer.UV3Kind
  21064. * - VertexBuffer.UV4Kind
  21065. * - VertexBuffer.UV5Kind
  21066. * - VertexBuffer.UV6Kind
  21067. * - VertexBuffer.ColorKind
  21068. * - VertexBuffer.MatricesIndicesKind
  21069. * - VertexBuffer.MatricesIndicesExtraKind
  21070. * - VertexBuffer.MatricesWeightsKind
  21071. * - VertexBuffer.MatricesWeightsExtraKind
  21072. * @returns an array of strings
  21073. */
  21074. getVerticesDataKinds(): string[];
  21075. /**
  21076. * Returns a positive integer : the total number of indices in this mesh geometry.
  21077. * @returns the numner of indices or zero if the mesh has no geometry.
  21078. */
  21079. getTotalIndices(): number;
  21080. /**
  21081. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21082. * @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.
  21083. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21084. * @returns the indices array or an empty array if the mesh has no geometry
  21085. */
  21086. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21087. readonly isBlocked: boolean;
  21088. /**
  21089. * Determine if the current mesh is ready to be rendered
  21090. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21091. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21092. * @returns true if all associated assets are ready (material, textures, shaders)
  21093. */
  21094. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21095. /**
  21096. * 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.
  21097. */
  21098. readonly areNormalsFrozen: boolean;
  21099. /**
  21100. * 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.
  21101. * @returns the current mesh
  21102. */
  21103. freezeNormals(): Mesh;
  21104. /**
  21105. * 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
  21106. * @returns the current mesh
  21107. */
  21108. unfreezeNormals(): Mesh;
  21109. /**
  21110. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21111. */
  21112. overridenInstanceCount: number;
  21113. /** @hidden */
  21114. _preActivate(): Mesh;
  21115. /** @hidden */
  21116. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21117. /** @hidden */
  21118. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21119. /**
  21120. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21121. * This means the mesh underlying bounding box and sphere are recomputed.
  21122. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21123. * @returns the current mesh
  21124. */
  21125. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21126. /** @hidden */
  21127. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21128. /**
  21129. * This function will subdivide the mesh into multiple submeshes
  21130. * @param count defines the expected number of submeshes
  21131. */
  21132. subdivide(count: number): void;
  21133. /**
  21134. * Copy a FloatArray into a specific associated vertex buffer
  21135. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21136. * - VertexBuffer.PositionKind
  21137. * - VertexBuffer.UVKind
  21138. * - VertexBuffer.UV2Kind
  21139. * - VertexBuffer.UV3Kind
  21140. * - VertexBuffer.UV4Kind
  21141. * - VertexBuffer.UV5Kind
  21142. * - VertexBuffer.UV6Kind
  21143. * - VertexBuffer.ColorKind
  21144. * - VertexBuffer.MatricesIndicesKind
  21145. * - VertexBuffer.MatricesIndicesExtraKind
  21146. * - VertexBuffer.MatricesWeightsKind
  21147. * - VertexBuffer.MatricesWeightsExtraKind
  21148. * @param data defines the data source
  21149. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21150. * @param stride defines the data stride size (can be null)
  21151. * @returns the current mesh
  21152. */
  21153. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21154. /**
  21155. * Flags an associated vertex buffer as updatable
  21156. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21157. * - VertexBuffer.PositionKind
  21158. * - VertexBuffer.UVKind
  21159. * - VertexBuffer.UV2Kind
  21160. * - VertexBuffer.UV3Kind
  21161. * - VertexBuffer.UV4Kind
  21162. * - VertexBuffer.UV5Kind
  21163. * - VertexBuffer.UV6Kind
  21164. * - VertexBuffer.ColorKind
  21165. * - VertexBuffer.MatricesIndicesKind
  21166. * - VertexBuffer.MatricesIndicesExtraKind
  21167. * - VertexBuffer.MatricesWeightsKind
  21168. * - VertexBuffer.MatricesWeightsExtraKind
  21169. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21170. */
  21171. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21172. /**
  21173. * Sets the mesh global Vertex Buffer
  21174. * @param buffer defines the buffer to use
  21175. * @returns the current mesh
  21176. */
  21177. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21178. /**
  21179. * Update a specific associated vertex buffer
  21180. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21181. * - VertexBuffer.PositionKind
  21182. * - VertexBuffer.UVKind
  21183. * - VertexBuffer.UV2Kind
  21184. * - VertexBuffer.UV3Kind
  21185. * - VertexBuffer.UV4Kind
  21186. * - VertexBuffer.UV5Kind
  21187. * - VertexBuffer.UV6Kind
  21188. * - VertexBuffer.ColorKind
  21189. * - VertexBuffer.MatricesIndicesKind
  21190. * - VertexBuffer.MatricesIndicesExtraKind
  21191. * - VertexBuffer.MatricesWeightsKind
  21192. * - VertexBuffer.MatricesWeightsExtraKind
  21193. * @param data defines the data source
  21194. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21195. * @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)
  21196. * @returns the current mesh
  21197. */
  21198. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21199. /**
  21200. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21201. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21202. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21203. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21204. * @returns the current mesh
  21205. */
  21206. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21207. /**
  21208. * Creates a un-shared specific occurence of the geometry for the mesh.
  21209. * @returns the current mesh
  21210. */
  21211. makeGeometryUnique(): Mesh;
  21212. /**
  21213. * Set the index buffer of this mesh
  21214. * @param indices defines the source data
  21215. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21216. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21217. * @returns the current mesh
  21218. */
  21219. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21220. /**
  21221. * Update the current index buffer
  21222. * @param indices defines the source data
  21223. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21224. * @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)
  21225. * @returns the current mesh
  21226. */
  21227. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21228. /**
  21229. * Invert the geometry to move from a right handed system to a left handed one.
  21230. * @returns the current mesh
  21231. */
  21232. toLeftHanded(): Mesh;
  21233. /** @hidden */
  21234. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21235. /** @hidden */
  21236. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21237. /**
  21238. * Registers for this mesh a javascript function called just before the rendering process
  21239. * @param func defines the function to call before rendering this mesh
  21240. * @returns the current mesh
  21241. */
  21242. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21243. /**
  21244. * Disposes a previously registered javascript function called before the rendering
  21245. * @param func defines the function to remove
  21246. * @returns the current mesh
  21247. */
  21248. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21249. /**
  21250. * Registers for this mesh a javascript function called just after the rendering is complete
  21251. * @param func defines the function to call after rendering this mesh
  21252. * @returns the current mesh
  21253. */
  21254. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21255. /**
  21256. * Disposes a previously registered javascript function called after the rendering.
  21257. * @param func defines the function to remove
  21258. * @returns the current mesh
  21259. */
  21260. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21261. /** @hidden */
  21262. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21263. /** @hidden */
  21264. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21265. /** @hidden */
  21266. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21267. /** @hidden */
  21268. _freeze(): void;
  21269. /** @hidden */
  21270. _unFreeze(): void;
  21271. /**
  21272. * 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
  21273. * @param subMesh defines the subMesh to render
  21274. * @param enableAlphaMode defines if alpha mode can be changed
  21275. * @returns the current mesh
  21276. */
  21277. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21278. private _onBeforeDraw;
  21279. /**
  21280. * Renormalize the mesh and patch it up if there are no weights
  21281. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21282. * However in the case of zero weights then we set just a single influence to 1.
  21283. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21284. */
  21285. cleanMatrixWeights(): void;
  21286. private normalizeSkinFourWeights;
  21287. private normalizeSkinWeightsAndExtra;
  21288. /**
  21289. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21290. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21291. * the user know there was an issue with importing the mesh
  21292. * @returns a validation object with skinned, valid and report string
  21293. */
  21294. validateSkinning(): {
  21295. skinned: boolean;
  21296. valid: boolean;
  21297. report: string;
  21298. };
  21299. /** @hidden */
  21300. _checkDelayState(): Mesh;
  21301. private _queueLoad;
  21302. /**
  21303. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21304. * A mesh is in the frustum if its bounding box intersects the frustum
  21305. * @param frustumPlanes defines the frustum to test
  21306. * @returns true if the mesh is in the frustum planes
  21307. */
  21308. isInFrustum(frustumPlanes: Plane[]): boolean;
  21309. /**
  21310. * Sets the mesh material by the material or multiMaterial `id` property
  21311. * @param id is a string identifying the material or the multiMaterial
  21312. * @returns the current mesh
  21313. */
  21314. setMaterialByID(id: string): Mesh;
  21315. /**
  21316. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21317. * @returns an array of IAnimatable
  21318. */
  21319. getAnimatables(): IAnimatable[];
  21320. /**
  21321. * Modifies the mesh geometry according to the passed transformation matrix.
  21322. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21323. * The mesh normals are modified using the same transformation.
  21324. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21325. * @param transform defines the transform matrix to use
  21326. * @see http://doc.babylonjs.com/resources/baking_transformations
  21327. * @returns the current mesh
  21328. */
  21329. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21330. /**
  21331. * Modifies the mesh geometry according to its own current World Matrix.
  21332. * The mesh World Matrix is then reset.
  21333. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21334. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21335. * @see http://doc.babylonjs.com/resources/baking_transformations
  21336. * @returns the current mesh
  21337. */
  21338. bakeCurrentTransformIntoVertices(): Mesh;
  21339. /** @hidden */
  21340. readonly _positions: Nullable<Vector3[]>;
  21341. /** @hidden */
  21342. _resetPointsArrayCache(): Mesh;
  21343. /** @hidden */
  21344. _generatePointsArray(): boolean;
  21345. /**
  21346. * Returns a new Mesh object generated from the current mesh properties.
  21347. * This method must not get confused with createInstance()
  21348. * @param name is a string, the name given to the new mesh
  21349. * @param newParent can be any Node object (default `null`)
  21350. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21351. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21352. * @returns a new mesh
  21353. */
  21354. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21355. /**
  21356. * Releases resources associated with this mesh.
  21357. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21358. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21359. */
  21360. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21361. /**
  21362. * Modifies the mesh geometry according to a displacement map.
  21363. * 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.
  21364. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21365. * @param url is a string, the URL from the image file is to be downloaded.
  21366. * @param minHeight is the lower limit of the displacement.
  21367. * @param maxHeight is the upper limit of the displacement.
  21368. * @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.
  21369. * @param uvOffset is an optional vector2 used to offset UV.
  21370. * @param uvScale is an optional vector2 used to scale UV.
  21371. * @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.
  21372. * @returns the Mesh.
  21373. */
  21374. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21375. /**
  21376. * Modifies the mesh geometry according to a displacementMap buffer.
  21377. * 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.
  21378. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21379. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21380. * @param heightMapWidth is the width of the buffer image.
  21381. * @param heightMapHeight is the height of the buffer image.
  21382. * @param minHeight is the lower limit of the displacement.
  21383. * @param maxHeight is the upper limit of the displacement.
  21384. * @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.
  21385. * @param uvOffset is an optional vector2 used to offset UV.
  21386. * @param uvScale is an optional vector2 used to scale UV.
  21387. * @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.
  21388. * @returns the Mesh.
  21389. */
  21390. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21391. /**
  21392. * Modify the mesh to get a flat shading rendering.
  21393. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21394. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21395. * @returns current mesh
  21396. */
  21397. convertToFlatShadedMesh(): Mesh;
  21398. /**
  21399. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21400. * In other words, more vertices, no more indices and a single bigger VBO.
  21401. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21402. * @returns current mesh
  21403. */
  21404. convertToUnIndexedMesh(): Mesh;
  21405. /**
  21406. * Inverses facet orientations.
  21407. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21408. * @param flipNormals will also inverts the normals
  21409. * @returns current mesh
  21410. */
  21411. flipFaces(flipNormals?: boolean): Mesh;
  21412. /**
  21413. * Increase the number of facets and hence vertices in a mesh
  21414. * Vertex normals are interpolated from existing vertex normals
  21415. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21416. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21417. */
  21418. increaseVertices(numberPerEdge: number): void;
  21419. /**
  21420. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21421. * This will undo any application of covertToFlatShadedMesh
  21422. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21423. */
  21424. forceSharedVertices(): void;
  21425. /** @hidden */
  21426. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21427. /** @hidden */
  21428. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21429. /**
  21430. * Creates a new InstancedMesh object from the mesh model.
  21431. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21432. * @param name defines the name of the new instance
  21433. * @returns a new InstancedMesh
  21434. */
  21435. createInstance(name: string): InstancedMesh;
  21436. /**
  21437. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21438. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21439. * @returns the current mesh
  21440. */
  21441. synchronizeInstances(): Mesh;
  21442. /**
  21443. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21444. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21445. * This should be used together with the simplification to avoid disappearing triangles.
  21446. * @param successCallback an optional success callback to be called after the optimization finished.
  21447. * @returns the current mesh
  21448. */
  21449. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21450. /**
  21451. * Serialize current mesh
  21452. * @param serializationObject defines the object which will receive the serialization data
  21453. */
  21454. serialize(serializationObject: any): void;
  21455. /** @hidden */
  21456. _syncGeometryWithMorphTargetManager(): void;
  21457. /** @hidden */
  21458. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21459. /**
  21460. * Returns a new Mesh object parsed from the source provided.
  21461. * @param parsedMesh is the source
  21462. * @param scene defines the hosting scene
  21463. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21464. * @returns a new Mesh
  21465. */
  21466. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21467. /**
  21468. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21469. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21470. * @param name defines the name of the mesh to create
  21471. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21472. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21473. * @param closePath creates a seam between the first and the last points of each path of the path array
  21474. * @param offset is taken in account only if the `pathArray` is containing a single path
  21475. * @param scene defines the hosting scene
  21476. * @param updatable defines if the mesh must be flagged as updatable
  21477. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21478. * @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)
  21479. * @returns a new Mesh
  21480. */
  21481. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21482. /**
  21483. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21484. * @param name defines the name of the mesh to create
  21485. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21486. * @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
  21487. * @param scene defines the hosting scene
  21488. * @param updatable defines if the mesh must be flagged as updatable
  21489. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21490. * @returns a new Mesh
  21491. */
  21492. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21493. /**
  21494. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21495. * @param name defines the name of the mesh to create
  21496. * @param size sets the size (float) of each box side (default 1)
  21497. * @param scene defines the hosting scene
  21498. * @param updatable defines if the mesh must be flagged as updatable
  21499. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21500. * @returns a new Mesh
  21501. */
  21502. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21503. /**
  21504. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21505. * @param name defines the name of the mesh to create
  21506. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21507. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21508. * @param scene defines the hosting scene
  21509. * @param updatable defines if the mesh must be flagged as updatable
  21510. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21511. * @returns a new Mesh
  21512. */
  21513. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21514. /**
  21515. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21516. * @param name defines the name of the mesh to create
  21517. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21518. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21519. * @param scene defines the hosting scene
  21520. * @returns a new Mesh
  21521. */
  21522. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21523. /**
  21524. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21525. * @param name defines the name of the mesh to create
  21526. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21527. * @param diameterTop set the top cap diameter (floats, default 1)
  21528. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21529. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21530. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21531. * @param scene defines the hosting scene
  21532. * @param updatable defines if the mesh must be flagged as updatable
  21533. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21534. * @returns a new Mesh
  21535. */
  21536. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21537. /**
  21538. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21539. * @param name defines the name of the mesh to create
  21540. * @param diameter sets the diameter size (float) of the torus (default 1)
  21541. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21542. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21543. * @param scene defines the hosting scene
  21544. * @param updatable defines if the mesh must be flagged as updatable
  21545. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21546. * @returns a new Mesh
  21547. */
  21548. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21549. /**
  21550. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21551. * @param name defines the name of the mesh to create
  21552. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21553. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21554. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21555. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21556. * @param p the number of windings on X axis (positive integers, default 2)
  21557. * @param q the number of windings on Y axis (positive integers, default 3)
  21558. * @param scene defines the hosting scene
  21559. * @param updatable defines if the mesh must be flagged as updatable
  21560. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21561. * @returns a new Mesh
  21562. */
  21563. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21564. /**
  21565. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21566. * @param name defines the name of the mesh to create
  21567. * @param points is an array successive Vector3
  21568. * @param scene defines the hosting scene
  21569. * @param updatable defines if the mesh must be flagged as updatable
  21570. * @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).
  21571. * @returns a new Mesh
  21572. */
  21573. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21574. /**
  21575. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21576. * @param name defines the name of the mesh to create
  21577. * @param points is an array successive Vector3
  21578. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21579. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21580. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21581. * @param scene defines the hosting scene
  21582. * @param updatable defines if the mesh must be flagged as updatable
  21583. * @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)
  21584. * @returns a new Mesh
  21585. */
  21586. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21587. /**
  21588. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21589. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21590. * 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.
  21591. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21592. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21593. * Remember you can only change the shape positions, not their number when updating a polygon.
  21594. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21595. * @param name defines the name of the mesh to create
  21596. * @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
  21597. * @param scene defines the hosting scene
  21598. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21599. * @param updatable defines if the mesh must be flagged as updatable
  21600. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21601. * @param earcutInjection can be used to inject your own earcut reference
  21602. * @returns a new Mesh
  21603. */
  21604. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21605. /**
  21606. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21607. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21608. * @param name defines the name of the mesh to create
  21609. * @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
  21610. * @param depth defines the height of extrusion
  21611. * @param scene defines the hosting scene
  21612. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21613. * @param updatable defines if the mesh must be flagged as updatable
  21614. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21615. * @param earcutInjection can be used to inject your own earcut reference
  21616. * @returns a new Mesh
  21617. */
  21618. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21619. /**
  21620. * Creates an extruded shape mesh.
  21621. * 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
  21622. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21623. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21624. * @param name defines the name of the mesh to create
  21625. * @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
  21626. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21627. * @param scale is the value to scale the shape
  21628. * @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
  21629. * @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
  21630. * @param scene defines the hosting scene
  21631. * @param updatable defines if the mesh must be flagged as updatable
  21632. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21633. * @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)
  21634. * @returns a new Mesh
  21635. */
  21636. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21637. /**
  21638. * Creates an custom extruded shape mesh.
  21639. * The custom extrusion is a parametric shape.
  21640. * It has no predefined shape. Its final shape will depend on the input parameters.
  21641. * Please consider using the same method from the MeshBuilder class instead
  21642. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21643. * @param name defines the name of the mesh to create
  21644. * @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
  21645. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21646. * @param scaleFunction is a custom Javascript function called on each path point
  21647. * @param rotationFunction is a custom Javascript function called on each path point
  21648. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21649. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21650. * @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
  21651. * @param scene defines the hosting scene
  21652. * @param updatable defines if the mesh must be flagged as updatable
  21653. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21654. * @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)
  21655. * @returns a new Mesh
  21656. */
  21657. 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;
  21658. /**
  21659. * Creates lathe mesh.
  21660. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21661. * Please consider using the same method from the MeshBuilder class instead
  21662. * @param name defines the name of the mesh to create
  21663. * @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
  21664. * @param radius is the radius value of the lathe
  21665. * @param tessellation is the side number of the lathe.
  21666. * @param scene defines the hosting scene
  21667. * @param updatable defines if the mesh must be flagged as updatable
  21668. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21669. * @returns a new Mesh
  21670. */
  21671. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21672. /**
  21673. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21674. * @param name defines the name of the mesh to create
  21675. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21676. * @param scene defines the hosting scene
  21677. * @param updatable defines if the mesh must be flagged as updatable
  21678. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21679. * @returns a new Mesh
  21680. */
  21681. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21682. /**
  21683. * Creates a ground mesh.
  21684. * Please consider using the same method from the MeshBuilder class instead
  21685. * @param name defines the name of the mesh to create
  21686. * @param width set the width of the ground
  21687. * @param height set the height of the ground
  21688. * @param subdivisions sets the number of subdivisions per side
  21689. * @param scene defines the hosting scene
  21690. * @param updatable defines if the mesh must be flagged as updatable
  21691. * @returns a new Mesh
  21692. */
  21693. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21694. /**
  21695. * Creates a tiled ground mesh.
  21696. * Please consider using the same method from the MeshBuilder class instead
  21697. * @param name defines the name of the mesh to create
  21698. * @param xmin set the ground minimum X coordinate
  21699. * @param zmin set the ground minimum Y coordinate
  21700. * @param xmax set the ground maximum X coordinate
  21701. * @param zmax set the ground maximum Z coordinate
  21702. * @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
  21703. * @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
  21704. * @param scene defines the hosting scene
  21705. * @param updatable defines if the mesh must be flagged as updatable
  21706. * @returns a new Mesh
  21707. */
  21708. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21709. w: number;
  21710. h: number;
  21711. }, precision: {
  21712. w: number;
  21713. h: number;
  21714. }, scene: Scene, updatable?: boolean): Mesh;
  21715. /**
  21716. * Creates a ground mesh from a height map.
  21717. * Please consider using the same method from the MeshBuilder class instead
  21718. * @see http://doc.babylonjs.com/babylon101/height_map
  21719. * @param name defines the name of the mesh to create
  21720. * @param url sets the URL of the height map image resource
  21721. * @param width set the ground width size
  21722. * @param height set the ground height size
  21723. * @param subdivisions sets the number of subdivision per side
  21724. * @param minHeight is the minimum altitude on the ground
  21725. * @param maxHeight is the maximum altitude on the ground
  21726. * @param scene defines the hosting scene
  21727. * @param updatable defines if the mesh must be flagged as updatable
  21728. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21729. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21730. * @returns a new Mesh
  21731. */
  21732. 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;
  21733. /**
  21734. * Creates a tube mesh.
  21735. * The tube is a parametric shape.
  21736. * It has no predefined shape. Its final shape will depend on the input parameters.
  21737. * Please consider using the same method from the MeshBuilder class instead
  21738. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21739. * @param name defines the name of the mesh to create
  21740. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21741. * @param radius sets the tube radius size
  21742. * @param tessellation is the number of sides on the tubular surface
  21743. * @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
  21744. * @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
  21745. * @param scene defines the hosting scene
  21746. * @param updatable defines if the mesh must be flagged as updatable
  21747. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21748. * @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)
  21749. * @returns a new Mesh
  21750. */
  21751. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21752. (i: number, distance: number): number;
  21753. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21754. /**
  21755. * Creates a polyhedron mesh.
  21756. * Please consider using the same method from the MeshBuilder class instead.
  21757. * * 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
  21758. * * The parameter `size` (positive float, default 1) sets the polygon size
  21759. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21760. * * 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`
  21761. * * 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
  21762. * * 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)`)
  21763. * * 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
  21764. * * 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
  21765. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21766. * * 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
  21767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21768. * @param name defines the name of the mesh to create
  21769. * @param options defines the options used to create the mesh
  21770. * @param scene defines the hosting scene
  21771. * @returns a new Mesh
  21772. */
  21773. static CreatePolyhedron(name: string, options: {
  21774. type?: number;
  21775. size?: number;
  21776. sizeX?: number;
  21777. sizeY?: number;
  21778. sizeZ?: number;
  21779. custom?: any;
  21780. faceUV?: Vector4[];
  21781. faceColors?: Color4[];
  21782. updatable?: boolean;
  21783. sideOrientation?: number;
  21784. }, scene: Scene): Mesh;
  21785. /**
  21786. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21787. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21788. * * 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`)
  21789. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21790. * * 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
  21791. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21792. * * 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
  21793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21794. * @param name defines the name of the mesh
  21795. * @param options defines the options used to create the mesh
  21796. * @param scene defines the hosting scene
  21797. * @returns a new Mesh
  21798. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21799. */
  21800. static CreateIcoSphere(name: string, options: {
  21801. radius?: number;
  21802. flat?: boolean;
  21803. subdivisions?: number;
  21804. sideOrientation?: number;
  21805. updatable?: boolean;
  21806. }, scene: Scene): Mesh;
  21807. /**
  21808. * Creates a decal mesh.
  21809. * Please consider using the same method from the MeshBuilder class instead.
  21810. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21811. * @param name defines the name of the mesh
  21812. * @param sourceMesh defines the mesh receiving the decal
  21813. * @param position sets the position of the decal in world coordinates
  21814. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21815. * @param size sets the decal scaling
  21816. * @param angle sets the angle to rotate the decal
  21817. * @returns a new Mesh
  21818. */
  21819. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21820. /**
  21821. * Prepare internal position array for software CPU skinning
  21822. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21823. */
  21824. setPositionsForCPUSkinning(): Float32Array;
  21825. /**
  21826. * Prepare internal normal array for software CPU skinning
  21827. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21828. */
  21829. setNormalsForCPUSkinning(): Float32Array;
  21830. /**
  21831. * Updates the vertex buffer by applying transformation from the bones
  21832. * @param skeleton defines the skeleton to apply to current mesh
  21833. * @returns the current mesh
  21834. */
  21835. applySkeleton(skeleton: Skeleton): Mesh;
  21836. /**
  21837. * 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
  21838. * @param meshes defines the list of meshes to scan
  21839. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21840. */
  21841. static MinMax(meshes: AbstractMesh[]): {
  21842. min: Vector3;
  21843. max: Vector3;
  21844. };
  21845. /**
  21846. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21847. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21848. * @returns a vector3
  21849. */
  21850. static Center(meshesOrMinMaxVector: {
  21851. min: Vector3;
  21852. max: Vector3;
  21853. } | AbstractMesh[]): Vector3;
  21854. /**
  21855. * Merge the array of meshes into a single mesh for performance reasons.
  21856. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21857. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21858. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21859. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21860. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21861. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21862. * @returns a new mesh
  21863. */
  21864. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21865. /** @hidden */
  21866. addInstance(instance: InstancedMesh): void;
  21867. /** @hidden */
  21868. removeInstance(instance: InstancedMesh): void;
  21869. }
  21870. }
  21871. declare module BABYLON {
  21872. /**
  21873. * Base class for the main features of a material in Babylon.js
  21874. */
  21875. export class Material implements IAnimatable {
  21876. /**
  21877. * Returns the triangle fill mode
  21878. */
  21879. static readonly TriangleFillMode: number;
  21880. /**
  21881. * Returns the wireframe mode
  21882. */
  21883. static readonly WireFrameFillMode: number;
  21884. /**
  21885. * Returns the point fill mode
  21886. */
  21887. static readonly PointFillMode: number;
  21888. /**
  21889. * Returns the point list draw mode
  21890. */
  21891. static readonly PointListDrawMode: number;
  21892. /**
  21893. * Returns the line list draw mode
  21894. */
  21895. static readonly LineListDrawMode: number;
  21896. /**
  21897. * Returns the line loop draw mode
  21898. */
  21899. static readonly LineLoopDrawMode: number;
  21900. /**
  21901. * Returns the line strip draw mode
  21902. */
  21903. static readonly LineStripDrawMode: number;
  21904. /**
  21905. * Returns the triangle strip draw mode
  21906. */
  21907. static readonly TriangleStripDrawMode: number;
  21908. /**
  21909. * Returns the triangle fan draw mode
  21910. */
  21911. static readonly TriangleFanDrawMode: number;
  21912. /**
  21913. * Stores the clock-wise side orientation
  21914. */
  21915. static readonly ClockWiseSideOrientation: number;
  21916. /**
  21917. * Stores the counter clock-wise side orientation
  21918. */
  21919. static readonly CounterClockWiseSideOrientation: number;
  21920. /**
  21921. * The dirty texture flag value
  21922. */
  21923. static readonly TextureDirtyFlag: number;
  21924. /**
  21925. * The dirty light flag value
  21926. */
  21927. static readonly LightDirtyFlag: number;
  21928. /**
  21929. * The dirty fresnel flag value
  21930. */
  21931. static readonly FresnelDirtyFlag: number;
  21932. /**
  21933. * The dirty attribute flag value
  21934. */
  21935. static readonly AttributesDirtyFlag: number;
  21936. /**
  21937. * The dirty misc flag value
  21938. */
  21939. static readonly MiscDirtyFlag: number;
  21940. /**
  21941. * The all dirty flag value
  21942. */
  21943. static readonly AllDirtyFlag: number;
  21944. /**
  21945. * The ID of the material
  21946. */
  21947. id: string;
  21948. /**
  21949. * Gets or sets the unique id of the material
  21950. */
  21951. uniqueId: number;
  21952. /**
  21953. * The name of the material
  21954. */
  21955. name: string;
  21956. /**
  21957. * Gets or sets user defined metadata
  21958. */
  21959. metadata: any;
  21960. /**
  21961. * For internal use only. Please do not use.
  21962. */
  21963. reservedDataStore: any;
  21964. /**
  21965. * Specifies if the ready state should be checked on each call
  21966. */
  21967. checkReadyOnEveryCall: boolean;
  21968. /**
  21969. * Specifies if the ready state should be checked once
  21970. */
  21971. checkReadyOnlyOnce: boolean;
  21972. /**
  21973. * The state of the material
  21974. */
  21975. state: string;
  21976. /**
  21977. * The alpha value of the material
  21978. */
  21979. protected _alpha: number;
  21980. /**
  21981. * List of inspectable custom properties (used by the Inspector)
  21982. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21983. */
  21984. inspectableCustomProperties: IInspectable[];
  21985. /**
  21986. * Sets the alpha value of the material
  21987. */
  21988. /**
  21989. * Gets the alpha value of the material
  21990. */
  21991. alpha: number;
  21992. /**
  21993. * Specifies if back face culling is enabled
  21994. */
  21995. protected _backFaceCulling: boolean;
  21996. /**
  21997. * Sets the back-face culling state
  21998. */
  21999. /**
  22000. * Gets the back-face culling state
  22001. */
  22002. backFaceCulling: boolean;
  22003. /**
  22004. * Stores the value for side orientation
  22005. */
  22006. sideOrientation: number;
  22007. /**
  22008. * Callback triggered when the material is compiled
  22009. */
  22010. onCompiled: Nullable<(effect: Effect) => void>;
  22011. /**
  22012. * Callback triggered when an error occurs
  22013. */
  22014. onError: Nullable<(effect: Effect, errors: string) => void>;
  22015. /**
  22016. * Callback triggered to get the render target textures
  22017. */
  22018. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22019. /**
  22020. * Gets a boolean indicating that current material needs to register RTT
  22021. */
  22022. readonly hasRenderTargetTextures: boolean;
  22023. /**
  22024. * Specifies if the material should be serialized
  22025. */
  22026. doNotSerialize: boolean;
  22027. /**
  22028. * @hidden
  22029. */
  22030. _storeEffectOnSubMeshes: boolean;
  22031. /**
  22032. * Stores the animations for the material
  22033. */
  22034. animations: Nullable<Array<Animation>>;
  22035. /**
  22036. * An event triggered when the material is disposed
  22037. */
  22038. onDisposeObservable: Observable<Material>;
  22039. /**
  22040. * An observer which watches for dispose events
  22041. */
  22042. private _onDisposeObserver;
  22043. private _onUnBindObservable;
  22044. /**
  22045. * Called during a dispose event
  22046. */
  22047. onDispose: () => void;
  22048. private _onBindObservable;
  22049. /**
  22050. * An event triggered when the material is bound
  22051. */
  22052. readonly onBindObservable: Observable<AbstractMesh>;
  22053. /**
  22054. * An observer which watches for bind events
  22055. */
  22056. private _onBindObserver;
  22057. /**
  22058. * Called during a bind event
  22059. */
  22060. onBind: (Mesh: AbstractMesh) => void;
  22061. /**
  22062. * An event triggered when the material is unbound
  22063. */
  22064. readonly onUnBindObservable: Observable<Material>;
  22065. /**
  22066. * Stores the value of the alpha mode
  22067. */
  22068. private _alphaMode;
  22069. /**
  22070. * Sets the value of the alpha mode.
  22071. *
  22072. * | Value | Type | Description |
  22073. * | --- | --- | --- |
  22074. * | 0 | ALPHA_DISABLE | |
  22075. * | 1 | ALPHA_ADD | |
  22076. * | 2 | ALPHA_COMBINE | |
  22077. * | 3 | ALPHA_SUBTRACT | |
  22078. * | 4 | ALPHA_MULTIPLY | |
  22079. * | 5 | ALPHA_MAXIMIZED | |
  22080. * | 6 | ALPHA_ONEONE | |
  22081. * | 7 | ALPHA_PREMULTIPLIED | |
  22082. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22083. * | 9 | ALPHA_INTERPOLATE | |
  22084. * | 10 | ALPHA_SCREENMODE | |
  22085. *
  22086. */
  22087. /**
  22088. * Gets the value of the alpha mode
  22089. */
  22090. alphaMode: number;
  22091. /**
  22092. * Stores the state of the need depth pre-pass value
  22093. */
  22094. private _needDepthPrePass;
  22095. /**
  22096. * Sets the need depth pre-pass value
  22097. */
  22098. /**
  22099. * Gets the depth pre-pass value
  22100. */
  22101. needDepthPrePass: boolean;
  22102. /**
  22103. * Specifies if depth writing should be disabled
  22104. */
  22105. disableDepthWrite: boolean;
  22106. /**
  22107. * Specifies if depth writing should be forced
  22108. */
  22109. forceDepthWrite: boolean;
  22110. /**
  22111. * Specifies if there should be a separate pass for culling
  22112. */
  22113. separateCullingPass: boolean;
  22114. /**
  22115. * Stores the state specifing if fog should be enabled
  22116. */
  22117. private _fogEnabled;
  22118. /**
  22119. * Sets the state for enabling fog
  22120. */
  22121. /**
  22122. * Gets the value of the fog enabled state
  22123. */
  22124. fogEnabled: boolean;
  22125. /**
  22126. * Stores the size of points
  22127. */
  22128. pointSize: number;
  22129. /**
  22130. * Stores the z offset value
  22131. */
  22132. zOffset: number;
  22133. /**
  22134. * Gets a value specifying if wireframe mode is enabled
  22135. */
  22136. /**
  22137. * Sets the state of wireframe mode
  22138. */
  22139. wireframe: boolean;
  22140. /**
  22141. * Gets the value specifying if point clouds are enabled
  22142. */
  22143. /**
  22144. * Sets the state of point cloud mode
  22145. */
  22146. pointsCloud: boolean;
  22147. /**
  22148. * Gets the material fill mode
  22149. */
  22150. /**
  22151. * Sets the material fill mode
  22152. */
  22153. fillMode: number;
  22154. /**
  22155. * @hidden
  22156. * Stores the effects for the material
  22157. */
  22158. _effect: Nullable<Effect>;
  22159. /**
  22160. * @hidden
  22161. * Specifies if the material was previously ready
  22162. */
  22163. _wasPreviouslyReady: boolean;
  22164. /**
  22165. * Specifies if uniform buffers should be used
  22166. */
  22167. private _useUBO;
  22168. /**
  22169. * Stores a reference to the scene
  22170. */
  22171. private _scene;
  22172. /**
  22173. * Stores the fill mode state
  22174. */
  22175. private _fillMode;
  22176. /**
  22177. * Specifies if the depth write state should be cached
  22178. */
  22179. private _cachedDepthWriteState;
  22180. /**
  22181. * Stores the uniform buffer
  22182. */
  22183. protected _uniformBuffer: UniformBuffer;
  22184. /** @hidden */
  22185. _indexInSceneMaterialArray: number;
  22186. /** @hidden */
  22187. meshMap: Nullable<{
  22188. [id: string]: AbstractMesh | undefined;
  22189. }>;
  22190. /**
  22191. * Creates a material instance
  22192. * @param name defines the name of the material
  22193. * @param scene defines the scene to reference
  22194. * @param doNotAdd specifies if the material should be added to the scene
  22195. */
  22196. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22197. /**
  22198. * Returns a string representation of the current material
  22199. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22200. * @returns a string with material information
  22201. */
  22202. toString(fullDetails?: boolean): string;
  22203. /**
  22204. * Gets the class name of the material
  22205. * @returns a string with the class name of the material
  22206. */
  22207. getClassName(): string;
  22208. /**
  22209. * Specifies if updates for the material been locked
  22210. */
  22211. readonly isFrozen: boolean;
  22212. /**
  22213. * Locks updates for the material
  22214. */
  22215. freeze(): void;
  22216. /**
  22217. * Unlocks updates for the material
  22218. */
  22219. unfreeze(): void;
  22220. /**
  22221. * Specifies if the material is ready to be used
  22222. * @param mesh defines the mesh to check
  22223. * @param useInstances specifies if instances should be used
  22224. * @returns a boolean indicating if the material is ready to be used
  22225. */
  22226. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22227. /**
  22228. * Specifies that the submesh is ready to be used
  22229. * @param mesh defines the mesh to check
  22230. * @param subMesh defines which submesh to check
  22231. * @param useInstances specifies that instances should be used
  22232. * @returns a boolean indicating that the submesh is ready or not
  22233. */
  22234. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22235. /**
  22236. * Returns the material effect
  22237. * @returns the effect associated with the material
  22238. */
  22239. getEffect(): Nullable<Effect>;
  22240. /**
  22241. * Returns the current scene
  22242. * @returns a Scene
  22243. */
  22244. getScene(): Scene;
  22245. /**
  22246. * Specifies if the material will require alpha blending
  22247. * @returns a boolean specifying if alpha blending is needed
  22248. */
  22249. needAlphaBlending(): boolean;
  22250. /**
  22251. * Specifies if the mesh will require alpha blending
  22252. * @param mesh defines the mesh to check
  22253. * @returns a boolean specifying if alpha blending is needed for the mesh
  22254. */
  22255. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22256. /**
  22257. * Specifies if this material should be rendered in alpha test mode
  22258. * @returns a boolean specifying if an alpha test is needed.
  22259. */
  22260. needAlphaTesting(): boolean;
  22261. /**
  22262. * Gets the texture used for the alpha test
  22263. * @returns the texture to use for alpha testing
  22264. */
  22265. getAlphaTestTexture(): Nullable<BaseTexture>;
  22266. /**
  22267. * Marks the material to indicate that it needs to be re-calculated
  22268. */
  22269. markDirty(): void;
  22270. /** @hidden */
  22271. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22272. /**
  22273. * Binds the material to the mesh
  22274. * @param world defines the world transformation matrix
  22275. * @param mesh defines the mesh to bind the material to
  22276. */
  22277. bind(world: Matrix, mesh?: Mesh): void;
  22278. /**
  22279. * Binds the submesh to the material
  22280. * @param world defines the world transformation matrix
  22281. * @param mesh defines the mesh containing the submesh
  22282. * @param subMesh defines the submesh to bind the material to
  22283. */
  22284. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22285. /**
  22286. * Binds the world matrix to the material
  22287. * @param world defines the world transformation matrix
  22288. */
  22289. bindOnlyWorldMatrix(world: Matrix): void;
  22290. /**
  22291. * Binds the scene's uniform buffer to the effect.
  22292. * @param effect defines the effect to bind to the scene uniform buffer
  22293. * @param sceneUbo defines the uniform buffer storing scene data
  22294. */
  22295. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22296. /**
  22297. * Binds the view matrix to the effect
  22298. * @param effect defines the effect to bind the view matrix to
  22299. */
  22300. bindView(effect: Effect): void;
  22301. /**
  22302. * Binds the view projection matrix to the effect
  22303. * @param effect defines the effect to bind the view projection matrix to
  22304. */
  22305. bindViewProjection(effect: Effect): void;
  22306. /**
  22307. * Specifies if material alpha testing should be turned on for the mesh
  22308. * @param mesh defines the mesh to check
  22309. */
  22310. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22311. /**
  22312. * Processes to execute after binding the material to a mesh
  22313. * @param mesh defines the rendered mesh
  22314. */
  22315. protected _afterBind(mesh?: Mesh): void;
  22316. /**
  22317. * Unbinds the material from the mesh
  22318. */
  22319. unbind(): void;
  22320. /**
  22321. * Gets the active textures from the material
  22322. * @returns an array of textures
  22323. */
  22324. getActiveTextures(): BaseTexture[];
  22325. /**
  22326. * Specifies if the material uses a texture
  22327. * @param texture defines the texture to check against the material
  22328. * @returns a boolean specifying if the material uses the texture
  22329. */
  22330. hasTexture(texture: BaseTexture): boolean;
  22331. /**
  22332. * Makes a duplicate of the material, and gives it a new name
  22333. * @param name defines the new name for the duplicated material
  22334. * @returns the cloned material
  22335. */
  22336. clone(name: string): Nullable<Material>;
  22337. /**
  22338. * Gets the meshes bound to the material
  22339. * @returns an array of meshes bound to the material
  22340. */
  22341. getBindedMeshes(): AbstractMesh[];
  22342. /**
  22343. * Force shader compilation
  22344. * @param mesh defines the mesh associated with this material
  22345. * @param onCompiled defines a function to execute once the material is compiled
  22346. * @param options defines the options to configure the compilation
  22347. */
  22348. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22349. clipPlane: boolean;
  22350. }>): void;
  22351. /**
  22352. * Force shader compilation
  22353. * @param mesh defines the mesh that will use this material
  22354. * @param options defines additional options for compiling the shaders
  22355. * @returns a promise that resolves when the compilation completes
  22356. */
  22357. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22358. clipPlane: boolean;
  22359. }>): Promise<void>;
  22360. private static readonly _AllDirtyCallBack;
  22361. private static readonly _ImageProcessingDirtyCallBack;
  22362. private static readonly _TextureDirtyCallBack;
  22363. private static readonly _FresnelDirtyCallBack;
  22364. private static readonly _MiscDirtyCallBack;
  22365. private static readonly _LightsDirtyCallBack;
  22366. private static readonly _AttributeDirtyCallBack;
  22367. private static _FresnelAndMiscDirtyCallBack;
  22368. private static _TextureAndMiscDirtyCallBack;
  22369. private static readonly _DirtyCallbackArray;
  22370. private static readonly _RunDirtyCallBacks;
  22371. /**
  22372. * Marks a define in the material to indicate that it needs to be re-computed
  22373. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22374. */
  22375. markAsDirty(flag: number): void;
  22376. /**
  22377. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22378. * @param func defines a function which checks material defines against the submeshes
  22379. */
  22380. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22381. /**
  22382. * Indicates that we need to re-calculated for all submeshes
  22383. */
  22384. protected _markAllSubMeshesAsAllDirty(): void;
  22385. /**
  22386. * Indicates that image processing needs to be re-calculated for all submeshes
  22387. */
  22388. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22389. /**
  22390. * Indicates that textures need to be re-calculated for all submeshes
  22391. */
  22392. protected _markAllSubMeshesAsTexturesDirty(): void;
  22393. /**
  22394. * Indicates that fresnel needs to be re-calculated for all submeshes
  22395. */
  22396. protected _markAllSubMeshesAsFresnelDirty(): void;
  22397. /**
  22398. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22399. */
  22400. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22401. /**
  22402. * Indicates that lights need to be re-calculated for all submeshes
  22403. */
  22404. protected _markAllSubMeshesAsLightsDirty(): void;
  22405. /**
  22406. * Indicates that attributes need to be re-calculated for all submeshes
  22407. */
  22408. protected _markAllSubMeshesAsAttributesDirty(): void;
  22409. /**
  22410. * Indicates that misc needs to be re-calculated for all submeshes
  22411. */
  22412. protected _markAllSubMeshesAsMiscDirty(): void;
  22413. /**
  22414. * Indicates that textures and misc need to be re-calculated for all submeshes
  22415. */
  22416. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22417. /**
  22418. * Disposes the material
  22419. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22420. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22421. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22422. */
  22423. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22424. /** @hidden */
  22425. private releaseVertexArrayObject;
  22426. /**
  22427. * Serializes this material
  22428. * @returns the serialized material object
  22429. */
  22430. serialize(): any;
  22431. /**
  22432. * Creates a material from parsed material data
  22433. * @param parsedMaterial defines parsed material data
  22434. * @param scene defines the hosting scene
  22435. * @param rootUrl defines the root URL to use to load textures
  22436. * @returns a new material
  22437. */
  22438. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22439. }
  22440. }
  22441. declare module BABYLON {
  22442. /**
  22443. * Base class for submeshes
  22444. */
  22445. export class BaseSubMesh {
  22446. /** @hidden */
  22447. _materialDefines: Nullable<MaterialDefines>;
  22448. /** @hidden */
  22449. _materialEffect: Nullable<Effect>;
  22450. /**
  22451. * Gets associated effect
  22452. */
  22453. readonly effect: Nullable<Effect>;
  22454. /**
  22455. * Sets associated effect (effect used to render this submesh)
  22456. * @param effect defines the effect to associate with
  22457. * @param defines defines the set of defines used to compile this effect
  22458. */
  22459. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22460. }
  22461. /**
  22462. * Defines a subdivision inside a mesh
  22463. */
  22464. export class SubMesh extends BaseSubMesh implements ICullable {
  22465. /** the material index to use */
  22466. materialIndex: number;
  22467. /** vertex index start */
  22468. verticesStart: number;
  22469. /** vertices count */
  22470. verticesCount: number;
  22471. /** index start */
  22472. indexStart: number;
  22473. /** indices count */
  22474. indexCount: number;
  22475. /** @hidden */
  22476. _linesIndexCount: number;
  22477. private _mesh;
  22478. private _renderingMesh;
  22479. private _boundingInfo;
  22480. private _linesIndexBuffer;
  22481. /** @hidden */
  22482. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22483. /** @hidden */
  22484. _trianglePlanes: Plane[];
  22485. /** @hidden */
  22486. _lastColliderTransformMatrix: Nullable<Matrix>;
  22487. /** @hidden */
  22488. _renderId: number;
  22489. /** @hidden */
  22490. _alphaIndex: number;
  22491. /** @hidden */
  22492. _distanceToCamera: number;
  22493. /** @hidden */
  22494. _id: number;
  22495. private _currentMaterial;
  22496. /**
  22497. * Add a new submesh to a mesh
  22498. * @param materialIndex defines the material index to use
  22499. * @param verticesStart defines vertex index start
  22500. * @param verticesCount defines vertices count
  22501. * @param indexStart defines index start
  22502. * @param indexCount defines indices count
  22503. * @param mesh defines the parent mesh
  22504. * @param renderingMesh defines an optional rendering mesh
  22505. * @param createBoundingBox defines if bounding box should be created for this submesh
  22506. * @returns the new submesh
  22507. */
  22508. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22509. /**
  22510. * Creates a new submesh
  22511. * @param materialIndex defines the material index to use
  22512. * @param verticesStart defines vertex index start
  22513. * @param verticesCount defines vertices count
  22514. * @param indexStart defines index start
  22515. * @param indexCount defines indices count
  22516. * @param mesh defines the parent mesh
  22517. * @param renderingMesh defines an optional rendering mesh
  22518. * @param createBoundingBox defines if bounding box should be created for this submesh
  22519. */
  22520. constructor(
  22521. /** the material index to use */
  22522. materialIndex: number,
  22523. /** vertex index start */
  22524. verticesStart: number,
  22525. /** vertices count */
  22526. verticesCount: number,
  22527. /** index start */
  22528. indexStart: number,
  22529. /** indices count */
  22530. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22531. /**
  22532. * Returns true if this submesh covers the entire parent mesh
  22533. * @ignorenaming
  22534. */
  22535. readonly IsGlobal: boolean;
  22536. /**
  22537. * Returns the submesh BoudingInfo object
  22538. * @returns current bounding info (or mesh's one if the submesh is global)
  22539. */
  22540. getBoundingInfo(): BoundingInfo;
  22541. /**
  22542. * Sets the submesh BoundingInfo
  22543. * @param boundingInfo defines the new bounding info to use
  22544. * @returns the SubMesh
  22545. */
  22546. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22547. /**
  22548. * Returns the mesh of the current submesh
  22549. * @return the parent mesh
  22550. */
  22551. getMesh(): AbstractMesh;
  22552. /**
  22553. * Returns the rendering mesh of the submesh
  22554. * @returns the rendering mesh (could be different from parent mesh)
  22555. */
  22556. getRenderingMesh(): Mesh;
  22557. /**
  22558. * Returns the submesh material
  22559. * @returns null or the current material
  22560. */
  22561. getMaterial(): Nullable<Material>;
  22562. /**
  22563. * Sets a new updated BoundingInfo object to the submesh
  22564. * @param data defines an optional position array to use to determine the bounding info
  22565. * @returns the SubMesh
  22566. */
  22567. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22568. /** @hidden */
  22569. _checkCollision(collider: Collider): boolean;
  22570. /**
  22571. * Updates the submesh BoundingInfo
  22572. * @param world defines the world matrix to use to update the bounding info
  22573. * @returns the submesh
  22574. */
  22575. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22576. /**
  22577. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22578. * @param frustumPlanes defines the frustum planes
  22579. * @returns true if the submesh is intersecting with the frustum
  22580. */
  22581. isInFrustum(frustumPlanes: Plane[]): boolean;
  22582. /**
  22583. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22584. * @param frustumPlanes defines the frustum planes
  22585. * @returns true if the submesh is inside the frustum
  22586. */
  22587. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22588. /**
  22589. * Renders the submesh
  22590. * @param enableAlphaMode defines if alpha needs to be used
  22591. * @returns the submesh
  22592. */
  22593. render(enableAlphaMode: boolean): SubMesh;
  22594. /**
  22595. * @hidden
  22596. */
  22597. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22598. /**
  22599. * Checks if the submesh intersects with a ray
  22600. * @param ray defines the ray to test
  22601. * @returns true is the passed ray intersects the submesh bounding box
  22602. */
  22603. canIntersects(ray: Ray): boolean;
  22604. /**
  22605. * Intersects current submesh with a ray
  22606. * @param ray defines the ray to test
  22607. * @param positions defines mesh's positions array
  22608. * @param indices defines mesh's indices array
  22609. * @param fastCheck defines if only bounding info should be used
  22610. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22611. * @returns intersection info or null if no intersection
  22612. */
  22613. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22614. /** @hidden */
  22615. private _intersectLines;
  22616. /** @hidden */
  22617. private _intersectUnIndexedLines;
  22618. /** @hidden */
  22619. private _intersectTriangles;
  22620. /** @hidden */
  22621. private _intersectUnIndexedTriangles;
  22622. /** @hidden */
  22623. _rebuild(): void;
  22624. /**
  22625. * Creates a new submesh from the passed mesh
  22626. * @param newMesh defines the new hosting mesh
  22627. * @param newRenderingMesh defines an optional rendering mesh
  22628. * @returns the new submesh
  22629. */
  22630. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22631. /**
  22632. * Release associated resources
  22633. */
  22634. dispose(): void;
  22635. /**
  22636. * Gets the class name
  22637. * @returns the string "SubMesh".
  22638. */
  22639. getClassName(): string;
  22640. /**
  22641. * Creates a new submesh from indices data
  22642. * @param materialIndex the index of the main mesh material
  22643. * @param startIndex the index where to start the copy in the mesh indices array
  22644. * @param indexCount the number of indices to copy then from the startIndex
  22645. * @param mesh the main mesh to create the submesh from
  22646. * @param renderingMesh the optional rendering mesh
  22647. * @returns a new submesh
  22648. */
  22649. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22650. }
  22651. }
  22652. declare module BABYLON {
  22653. /**
  22654. * Class used to store geometry data (vertex buffers + index buffer)
  22655. */
  22656. export class Geometry implements IGetSetVerticesData {
  22657. /**
  22658. * Gets or sets the ID of the geometry
  22659. */
  22660. id: string;
  22661. /**
  22662. * Gets or sets the unique ID of the geometry
  22663. */
  22664. uniqueId: number;
  22665. /**
  22666. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22667. */
  22668. delayLoadState: number;
  22669. /**
  22670. * Gets the file containing the data to load when running in delay load state
  22671. */
  22672. delayLoadingFile: Nullable<string>;
  22673. /**
  22674. * Callback called when the geometry is updated
  22675. */
  22676. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22677. private _scene;
  22678. private _engine;
  22679. private _meshes;
  22680. private _totalVertices;
  22681. /** @hidden */
  22682. _indices: IndicesArray;
  22683. /** @hidden */
  22684. _vertexBuffers: {
  22685. [key: string]: VertexBuffer;
  22686. };
  22687. private _isDisposed;
  22688. private _extend;
  22689. private _boundingBias;
  22690. /** @hidden */
  22691. _delayInfo: Array<string>;
  22692. private _indexBuffer;
  22693. private _indexBufferIsUpdatable;
  22694. /** @hidden */
  22695. _boundingInfo: Nullable<BoundingInfo>;
  22696. /** @hidden */
  22697. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22698. /** @hidden */
  22699. _softwareSkinningFrameId: number;
  22700. private _vertexArrayObjects;
  22701. private _updatable;
  22702. /** @hidden */
  22703. _positions: Nullable<Vector3[]>;
  22704. /**
  22705. * 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
  22706. */
  22707. /**
  22708. * 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
  22709. */
  22710. boundingBias: Vector2;
  22711. /**
  22712. * Static function used to attach a new empty geometry to a mesh
  22713. * @param mesh defines the mesh to attach the geometry to
  22714. * @returns the new Geometry
  22715. */
  22716. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22717. /**
  22718. * Creates a new geometry
  22719. * @param id defines the unique ID
  22720. * @param scene defines the hosting scene
  22721. * @param vertexData defines the VertexData used to get geometry data
  22722. * @param updatable defines if geometry must be updatable (false by default)
  22723. * @param mesh defines the mesh that will be associated with the geometry
  22724. */
  22725. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22726. /**
  22727. * Gets the current extend of the geometry
  22728. */
  22729. readonly extend: {
  22730. minimum: Vector3;
  22731. maximum: Vector3;
  22732. };
  22733. /**
  22734. * Gets the hosting scene
  22735. * @returns the hosting Scene
  22736. */
  22737. getScene(): Scene;
  22738. /**
  22739. * Gets the hosting engine
  22740. * @returns the hosting Engine
  22741. */
  22742. getEngine(): Engine;
  22743. /**
  22744. * Defines if the geometry is ready to use
  22745. * @returns true if the geometry is ready to be used
  22746. */
  22747. isReady(): boolean;
  22748. /**
  22749. * Gets a value indicating that the geometry should not be serialized
  22750. */
  22751. readonly doNotSerialize: boolean;
  22752. /** @hidden */
  22753. _rebuild(): void;
  22754. /**
  22755. * Affects all geometry data in one call
  22756. * @param vertexData defines the geometry data
  22757. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22758. */
  22759. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22760. /**
  22761. * Set specific vertex data
  22762. * @param kind defines the data kind (Position, normal, etc...)
  22763. * @param data defines the vertex data to use
  22764. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22765. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22766. */
  22767. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22768. /**
  22769. * Removes a specific vertex data
  22770. * @param kind defines the data kind (Position, normal, etc...)
  22771. */
  22772. removeVerticesData(kind: string): void;
  22773. /**
  22774. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22775. * @param buffer defines the vertex buffer to use
  22776. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22777. */
  22778. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22779. /**
  22780. * Update a specific vertex buffer
  22781. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22782. * It will do nothing if the buffer is not updatable
  22783. * @param kind defines the data kind (Position, normal, etc...)
  22784. * @param data defines the data to use
  22785. * @param offset defines the offset in the target buffer where to store the data
  22786. * @param useBytes set to true if the offset is in bytes
  22787. */
  22788. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22789. /**
  22790. * Update a specific vertex buffer
  22791. * This function will create a new buffer if the current one is not updatable
  22792. * @param kind defines the data kind (Position, normal, etc...)
  22793. * @param data defines the data to use
  22794. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22795. */
  22796. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22797. private _updateBoundingInfo;
  22798. /** @hidden */
  22799. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22800. /**
  22801. * Gets total number of vertices
  22802. * @returns the total number of vertices
  22803. */
  22804. getTotalVertices(): number;
  22805. /**
  22806. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22807. * @param kind defines the data kind (Position, normal, etc...)
  22808. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22809. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22810. * @returns a float array containing vertex data
  22811. */
  22812. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22813. /**
  22814. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22815. * @param kind defines the data kind (Position, normal, etc...)
  22816. * @returns true if the vertex buffer with the specified kind is updatable
  22817. */
  22818. isVertexBufferUpdatable(kind: string): boolean;
  22819. /**
  22820. * Gets a specific vertex buffer
  22821. * @param kind defines the data kind (Position, normal, etc...)
  22822. * @returns a VertexBuffer
  22823. */
  22824. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22825. /**
  22826. * Returns all vertex buffers
  22827. * @return an object holding all vertex buffers indexed by kind
  22828. */
  22829. getVertexBuffers(): Nullable<{
  22830. [key: string]: VertexBuffer;
  22831. }>;
  22832. /**
  22833. * Gets a boolean indicating if specific vertex buffer is present
  22834. * @param kind defines the data kind (Position, normal, etc...)
  22835. * @returns true if data is present
  22836. */
  22837. isVerticesDataPresent(kind: string): boolean;
  22838. /**
  22839. * Gets a list of all attached data kinds (Position, normal, etc...)
  22840. * @returns a list of string containing all kinds
  22841. */
  22842. getVerticesDataKinds(): string[];
  22843. /**
  22844. * Update index buffer
  22845. * @param indices defines the indices to store in the index buffer
  22846. * @param offset defines the offset in the target buffer where to store the data
  22847. * @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)
  22848. */
  22849. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22850. /**
  22851. * Creates a new index buffer
  22852. * @param indices defines the indices to store in the index buffer
  22853. * @param totalVertices defines the total number of vertices (could be null)
  22854. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22855. */
  22856. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22857. /**
  22858. * Return the total number of indices
  22859. * @returns the total number of indices
  22860. */
  22861. getTotalIndices(): number;
  22862. /**
  22863. * Gets the index buffer array
  22864. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22865. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22866. * @returns the index buffer array
  22867. */
  22868. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22869. /**
  22870. * Gets the index buffer
  22871. * @return the index buffer
  22872. */
  22873. getIndexBuffer(): Nullable<DataBuffer>;
  22874. /** @hidden */
  22875. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22876. /**
  22877. * Release the associated resources for a specific mesh
  22878. * @param mesh defines the source mesh
  22879. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22880. */
  22881. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22882. /**
  22883. * Apply current geometry to a given mesh
  22884. * @param mesh defines the mesh to apply geometry to
  22885. */
  22886. applyToMesh(mesh: Mesh): void;
  22887. private _updateExtend;
  22888. private _applyToMesh;
  22889. private notifyUpdate;
  22890. /**
  22891. * Load the geometry if it was flagged as delay loaded
  22892. * @param scene defines the hosting scene
  22893. * @param onLoaded defines a callback called when the geometry is loaded
  22894. */
  22895. load(scene: Scene, onLoaded?: () => void): void;
  22896. private _queueLoad;
  22897. /**
  22898. * Invert the geometry to move from a right handed system to a left handed one.
  22899. */
  22900. toLeftHanded(): void;
  22901. /** @hidden */
  22902. _resetPointsArrayCache(): void;
  22903. /** @hidden */
  22904. _generatePointsArray(): boolean;
  22905. /**
  22906. * Gets a value indicating if the geometry is disposed
  22907. * @returns true if the geometry was disposed
  22908. */
  22909. isDisposed(): boolean;
  22910. private _disposeVertexArrayObjects;
  22911. /**
  22912. * Free all associated resources
  22913. */
  22914. dispose(): void;
  22915. /**
  22916. * Clone the current geometry into a new geometry
  22917. * @param id defines the unique ID of the new geometry
  22918. * @returns a new geometry object
  22919. */
  22920. copy(id: string): Geometry;
  22921. /**
  22922. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22923. * @return a JSON representation of the current geometry data (without the vertices data)
  22924. */
  22925. serialize(): any;
  22926. private toNumberArray;
  22927. /**
  22928. * Serialize all vertices data into a JSON oject
  22929. * @returns a JSON representation of the current geometry data
  22930. */
  22931. serializeVerticeData(): any;
  22932. /**
  22933. * Extracts a clone of a mesh geometry
  22934. * @param mesh defines the source mesh
  22935. * @param id defines the unique ID of the new geometry object
  22936. * @returns the new geometry object
  22937. */
  22938. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22939. /**
  22940. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22941. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22942. * Be aware Math.random() could cause collisions, but:
  22943. * "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"
  22944. * @returns a string containing a new GUID
  22945. */
  22946. static RandomId(): string;
  22947. /** @hidden */
  22948. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22949. private static _CleanMatricesWeights;
  22950. /**
  22951. * Create a new geometry from persisted data (Using .babylon file format)
  22952. * @param parsedVertexData defines the persisted data
  22953. * @param scene defines the hosting scene
  22954. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22955. * @returns the new geometry object
  22956. */
  22957. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22958. }
  22959. }
  22960. declare module BABYLON {
  22961. /**
  22962. * Define an interface for all classes that will get and set the data on vertices
  22963. */
  22964. export interface IGetSetVerticesData {
  22965. /**
  22966. * Gets a boolean indicating if specific vertex data is present
  22967. * @param kind defines the vertex data kind to use
  22968. * @returns true is data kind is present
  22969. */
  22970. isVerticesDataPresent(kind: string): boolean;
  22971. /**
  22972. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22973. * @param kind defines the data kind (Position, normal, etc...)
  22974. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22975. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22976. * @returns a float array containing vertex data
  22977. */
  22978. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22979. /**
  22980. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22981. * @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.
  22982. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22983. * @returns the indices array or an empty array if the mesh has no geometry
  22984. */
  22985. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22986. /**
  22987. * Set specific vertex data
  22988. * @param kind defines the data kind (Position, normal, etc...)
  22989. * @param data defines the vertex data to use
  22990. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22991. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22992. */
  22993. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22994. /**
  22995. * Update a specific associated vertex buffer
  22996. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22997. * - VertexBuffer.PositionKind
  22998. * - VertexBuffer.UVKind
  22999. * - VertexBuffer.UV2Kind
  23000. * - VertexBuffer.UV3Kind
  23001. * - VertexBuffer.UV4Kind
  23002. * - VertexBuffer.UV5Kind
  23003. * - VertexBuffer.UV6Kind
  23004. * - VertexBuffer.ColorKind
  23005. * - VertexBuffer.MatricesIndicesKind
  23006. * - VertexBuffer.MatricesIndicesExtraKind
  23007. * - VertexBuffer.MatricesWeightsKind
  23008. * - VertexBuffer.MatricesWeightsExtraKind
  23009. * @param data defines the data source
  23010. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23011. * @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)
  23012. */
  23013. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23014. /**
  23015. * Creates a new index buffer
  23016. * @param indices defines the indices to store in the index buffer
  23017. * @param totalVertices defines the total number of vertices (could be null)
  23018. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23019. */
  23020. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23021. }
  23022. /**
  23023. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23024. */
  23025. export class VertexData {
  23026. /**
  23027. * Mesh side orientation : usually the external or front surface
  23028. */
  23029. static readonly FRONTSIDE: number;
  23030. /**
  23031. * Mesh side orientation : usually the internal or back surface
  23032. */
  23033. static readonly BACKSIDE: number;
  23034. /**
  23035. * Mesh side orientation : both internal and external or front and back surfaces
  23036. */
  23037. static readonly DOUBLESIDE: number;
  23038. /**
  23039. * Mesh side orientation : by default, `FRONTSIDE`
  23040. */
  23041. static readonly DEFAULTSIDE: number;
  23042. /**
  23043. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23044. */
  23045. positions: Nullable<FloatArray>;
  23046. /**
  23047. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23048. */
  23049. normals: Nullable<FloatArray>;
  23050. /**
  23051. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23052. */
  23053. tangents: Nullable<FloatArray>;
  23054. /**
  23055. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23056. */
  23057. uvs: Nullable<FloatArray>;
  23058. /**
  23059. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23060. */
  23061. uvs2: Nullable<FloatArray>;
  23062. /**
  23063. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23064. */
  23065. uvs3: Nullable<FloatArray>;
  23066. /**
  23067. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23068. */
  23069. uvs4: Nullable<FloatArray>;
  23070. /**
  23071. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23072. */
  23073. uvs5: Nullable<FloatArray>;
  23074. /**
  23075. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23076. */
  23077. uvs6: Nullable<FloatArray>;
  23078. /**
  23079. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23080. */
  23081. colors: Nullable<FloatArray>;
  23082. /**
  23083. * 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).
  23084. */
  23085. matricesIndices: Nullable<FloatArray>;
  23086. /**
  23087. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23088. */
  23089. matricesWeights: Nullable<FloatArray>;
  23090. /**
  23091. * An array extending the number of possible indices
  23092. */
  23093. matricesIndicesExtra: Nullable<FloatArray>;
  23094. /**
  23095. * An array extending the number of possible weights when the number of indices is extended
  23096. */
  23097. matricesWeightsExtra: Nullable<FloatArray>;
  23098. /**
  23099. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23100. */
  23101. indices: Nullable<IndicesArray>;
  23102. /**
  23103. * Uses the passed data array to set the set the values for the specified kind of data
  23104. * @param data a linear array of floating numbers
  23105. * @param kind the type of data that is being set, eg positions, colors etc
  23106. */
  23107. set(data: FloatArray, kind: string): void;
  23108. /**
  23109. * Associates the vertexData to the passed Mesh.
  23110. * Sets it as updatable or not (default `false`)
  23111. * @param mesh the mesh the vertexData is applied to
  23112. * @param updatable when used and having the value true allows new data to update the vertexData
  23113. * @returns the VertexData
  23114. */
  23115. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23116. /**
  23117. * Associates the vertexData to the passed Geometry.
  23118. * Sets it as updatable or not (default `false`)
  23119. * @param geometry the geometry the vertexData is applied to
  23120. * @param updatable when used and having the value true allows new data to update the vertexData
  23121. * @returns VertexData
  23122. */
  23123. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23124. /**
  23125. * Updates the associated mesh
  23126. * @param mesh the mesh to be updated
  23127. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23128. * @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
  23129. * @returns VertexData
  23130. */
  23131. updateMesh(mesh: Mesh): VertexData;
  23132. /**
  23133. * Updates the associated geometry
  23134. * @param geometry the geometry to be updated
  23135. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23136. * @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
  23137. * @returns VertexData.
  23138. */
  23139. updateGeometry(geometry: Geometry): VertexData;
  23140. private _applyTo;
  23141. private _update;
  23142. /**
  23143. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23144. * @param matrix the transforming matrix
  23145. * @returns the VertexData
  23146. */
  23147. transform(matrix: Matrix): VertexData;
  23148. /**
  23149. * Merges the passed VertexData into the current one
  23150. * @param other the VertexData to be merged into the current one
  23151. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23152. * @returns the modified VertexData
  23153. */
  23154. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23155. private _mergeElement;
  23156. private _validate;
  23157. /**
  23158. * Serializes the VertexData
  23159. * @returns a serialized object
  23160. */
  23161. serialize(): any;
  23162. /**
  23163. * Extracts the vertexData from a mesh
  23164. * @param mesh the mesh from which to extract the VertexData
  23165. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23166. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23167. * @returns the object VertexData associated to the passed mesh
  23168. */
  23169. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23170. /**
  23171. * Extracts the vertexData from the geometry
  23172. * @param geometry the geometry from which to extract the VertexData
  23173. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23174. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23175. * @returns the object VertexData associated to the passed mesh
  23176. */
  23177. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23178. private static _ExtractFrom;
  23179. /**
  23180. * Creates the VertexData for a Ribbon
  23181. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23182. * * pathArray array of paths, each of which an array of successive Vector3
  23183. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23184. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23185. * * 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
  23186. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23187. * * 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)
  23188. * * 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)
  23189. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23190. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23191. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23192. * @returns the VertexData of the ribbon
  23193. */
  23194. static CreateRibbon(options: {
  23195. pathArray: Vector3[][];
  23196. closeArray?: boolean;
  23197. closePath?: boolean;
  23198. offset?: number;
  23199. sideOrientation?: number;
  23200. frontUVs?: Vector4;
  23201. backUVs?: Vector4;
  23202. invertUV?: boolean;
  23203. uvs?: Vector2[];
  23204. colors?: Color4[];
  23205. }): VertexData;
  23206. /**
  23207. * Creates the VertexData for a box
  23208. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23209. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23210. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23211. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23212. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23213. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23214. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23215. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23216. * * 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)
  23217. * * 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)
  23218. * @returns the VertexData of the box
  23219. */
  23220. static CreateBox(options: {
  23221. size?: number;
  23222. width?: number;
  23223. height?: number;
  23224. depth?: number;
  23225. faceUV?: Vector4[];
  23226. faceColors?: Color4[];
  23227. sideOrientation?: number;
  23228. frontUVs?: Vector4;
  23229. backUVs?: Vector4;
  23230. }): VertexData;
  23231. /**
  23232. * Creates the VertexData for a tiled box
  23233. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23234. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23235. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23236. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23237. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23238. * @returns the VertexData of the box
  23239. */
  23240. static CreateTiledBox(options: {
  23241. pattern?: number;
  23242. width?: number;
  23243. height?: number;
  23244. depth?: number;
  23245. tileSize?: number;
  23246. tileWidth?: number;
  23247. tileHeight?: number;
  23248. alignHorizontal?: number;
  23249. alignVertical?: number;
  23250. faceUV?: Vector4[];
  23251. faceColors?: Color4[];
  23252. sideOrientation?: number;
  23253. }): VertexData;
  23254. /**
  23255. * Creates the VertexData for a tiled plane
  23256. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23257. * * pattern a limited pattern arrangement depending on the number
  23258. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23259. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23260. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23261. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23262. * * 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)
  23263. * * 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)
  23264. * @returns the VertexData of the tiled plane
  23265. */
  23266. static CreateTiledPlane(options: {
  23267. pattern?: number;
  23268. tileSize?: number;
  23269. tileWidth?: number;
  23270. tileHeight?: number;
  23271. size?: number;
  23272. width?: number;
  23273. height?: number;
  23274. alignHorizontal?: number;
  23275. alignVertical?: number;
  23276. sideOrientation?: number;
  23277. frontUVs?: Vector4;
  23278. backUVs?: Vector4;
  23279. }): VertexData;
  23280. /**
  23281. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23282. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23283. * * segments sets the number of horizontal strips optional, default 32
  23284. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23285. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23286. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23287. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23288. * * 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
  23289. * * 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
  23290. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23291. * * 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)
  23292. * * 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)
  23293. * @returns the VertexData of the ellipsoid
  23294. */
  23295. static CreateSphere(options: {
  23296. segments?: number;
  23297. diameter?: number;
  23298. diameterX?: number;
  23299. diameterY?: number;
  23300. diameterZ?: number;
  23301. arc?: number;
  23302. slice?: number;
  23303. sideOrientation?: number;
  23304. frontUVs?: Vector4;
  23305. backUVs?: Vector4;
  23306. }): VertexData;
  23307. /**
  23308. * Creates the VertexData for a cylinder, cone or prism
  23309. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23310. * * height sets the height (y direction) of the cylinder, optional, default 2
  23311. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23312. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23313. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23314. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23315. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23316. * * 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
  23317. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23318. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23319. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23320. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23321. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23322. * * 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)
  23323. * * 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)
  23324. * @returns the VertexData of the cylinder, cone or prism
  23325. */
  23326. static CreateCylinder(options: {
  23327. height?: number;
  23328. diameterTop?: number;
  23329. diameterBottom?: number;
  23330. diameter?: number;
  23331. tessellation?: number;
  23332. subdivisions?: number;
  23333. arc?: number;
  23334. faceColors?: Color4[];
  23335. faceUV?: Vector4[];
  23336. hasRings?: boolean;
  23337. enclose?: boolean;
  23338. sideOrientation?: number;
  23339. frontUVs?: Vector4;
  23340. backUVs?: Vector4;
  23341. }): VertexData;
  23342. /**
  23343. * Creates the VertexData for a torus
  23344. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23345. * * diameter the diameter of the torus, optional default 1
  23346. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23347. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23348. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23349. * * 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)
  23350. * * 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)
  23351. * @returns the VertexData of the torus
  23352. */
  23353. static CreateTorus(options: {
  23354. diameter?: number;
  23355. thickness?: number;
  23356. tessellation?: number;
  23357. sideOrientation?: number;
  23358. frontUVs?: Vector4;
  23359. backUVs?: Vector4;
  23360. }): VertexData;
  23361. /**
  23362. * Creates the VertexData of the LineSystem
  23363. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23364. * - lines an array of lines, each line being an array of successive Vector3
  23365. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23366. * @returns the VertexData of the LineSystem
  23367. */
  23368. static CreateLineSystem(options: {
  23369. lines: Vector3[][];
  23370. colors?: Nullable<Color4[][]>;
  23371. }): VertexData;
  23372. /**
  23373. * Create the VertexData for a DashedLines
  23374. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23375. * - points an array successive Vector3
  23376. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23377. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23378. * - dashNb the intended total number of dashes, optional, default 200
  23379. * @returns the VertexData for the DashedLines
  23380. */
  23381. static CreateDashedLines(options: {
  23382. points: Vector3[];
  23383. dashSize?: number;
  23384. gapSize?: number;
  23385. dashNb?: number;
  23386. }): VertexData;
  23387. /**
  23388. * Creates the VertexData for a Ground
  23389. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23390. * - width the width (x direction) of the ground, optional, default 1
  23391. * - height the height (z direction) of the ground, optional, default 1
  23392. * - subdivisions the number of subdivisions per side, optional, default 1
  23393. * @returns the VertexData of the Ground
  23394. */
  23395. static CreateGround(options: {
  23396. width?: number;
  23397. height?: number;
  23398. subdivisions?: number;
  23399. subdivisionsX?: number;
  23400. subdivisionsY?: number;
  23401. }): VertexData;
  23402. /**
  23403. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23404. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23405. * * xmin the ground minimum X coordinate, optional, default -1
  23406. * * zmin the ground minimum Z coordinate, optional, default -1
  23407. * * xmax the ground maximum X coordinate, optional, default 1
  23408. * * zmax the ground maximum Z coordinate, optional, default 1
  23409. * * 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}
  23410. * * 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}
  23411. * @returns the VertexData of the TiledGround
  23412. */
  23413. static CreateTiledGround(options: {
  23414. xmin: number;
  23415. zmin: number;
  23416. xmax: number;
  23417. zmax: number;
  23418. subdivisions?: {
  23419. w: number;
  23420. h: number;
  23421. };
  23422. precision?: {
  23423. w: number;
  23424. h: number;
  23425. };
  23426. }): VertexData;
  23427. /**
  23428. * Creates the VertexData of the Ground designed from a heightmap
  23429. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23430. * * width the width (x direction) of the ground
  23431. * * height the height (z direction) of the ground
  23432. * * subdivisions the number of subdivisions per side
  23433. * * minHeight the minimum altitude on the ground, optional, default 0
  23434. * * maxHeight the maximum altitude on the ground, optional default 1
  23435. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23436. * * buffer the array holding the image color data
  23437. * * bufferWidth the width of image
  23438. * * bufferHeight the height of image
  23439. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23440. * @returns the VertexData of the Ground designed from a heightmap
  23441. */
  23442. static CreateGroundFromHeightMap(options: {
  23443. width: number;
  23444. height: number;
  23445. subdivisions: number;
  23446. minHeight: number;
  23447. maxHeight: number;
  23448. colorFilter: Color3;
  23449. buffer: Uint8Array;
  23450. bufferWidth: number;
  23451. bufferHeight: number;
  23452. alphaFilter: number;
  23453. }): VertexData;
  23454. /**
  23455. * Creates the VertexData for a Plane
  23456. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23457. * * size sets the width and height of the plane to the value of size, optional default 1
  23458. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23459. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23460. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23461. * * 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)
  23462. * * 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)
  23463. * @returns the VertexData of the box
  23464. */
  23465. static CreatePlane(options: {
  23466. size?: number;
  23467. width?: number;
  23468. height?: number;
  23469. sideOrientation?: number;
  23470. frontUVs?: Vector4;
  23471. backUVs?: Vector4;
  23472. }): VertexData;
  23473. /**
  23474. * Creates the VertexData of the Disc or regular Polygon
  23475. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23476. * * radius the radius of the disc, optional default 0.5
  23477. * * tessellation the number of polygon sides, optional, default 64
  23478. * * 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
  23479. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23480. * * 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)
  23481. * * 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)
  23482. * @returns the VertexData of the box
  23483. */
  23484. static CreateDisc(options: {
  23485. radius?: number;
  23486. tessellation?: number;
  23487. arc?: number;
  23488. sideOrientation?: number;
  23489. frontUVs?: Vector4;
  23490. backUVs?: Vector4;
  23491. }): VertexData;
  23492. /**
  23493. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23494. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23495. * @param polygon a mesh built from polygonTriangulation.build()
  23496. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23497. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23498. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23499. * @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)
  23500. * @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)
  23501. * @returns the VertexData of the Polygon
  23502. */
  23503. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23504. /**
  23505. * Creates the VertexData of the IcoSphere
  23506. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23507. * * radius the radius of the IcoSphere, optional default 1
  23508. * * radiusX allows stretching in the x direction, optional, default radius
  23509. * * radiusY allows stretching in the y direction, optional, default radius
  23510. * * radiusZ allows stretching in the z direction, optional, default radius
  23511. * * flat when true creates a flat shaded mesh, optional, default true
  23512. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23513. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23514. * * 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)
  23515. * * 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)
  23516. * @returns the VertexData of the IcoSphere
  23517. */
  23518. static CreateIcoSphere(options: {
  23519. radius?: number;
  23520. radiusX?: number;
  23521. radiusY?: number;
  23522. radiusZ?: number;
  23523. flat?: boolean;
  23524. subdivisions?: number;
  23525. sideOrientation?: number;
  23526. frontUVs?: Vector4;
  23527. backUVs?: Vector4;
  23528. }): VertexData;
  23529. /**
  23530. * Creates the VertexData for a Polyhedron
  23531. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23532. * * type provided types are:
  23533. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23534. * * 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)
  23535. * * size the size of the IcoSphere, optional default 1
  23536. * * sizeX allows stretching in the x direction, optional, default size
  23537. * * sizeY allows stretching in the y direction, optional, default size
  23538. * * sizeZ allows stretching in the z direction, optional, default size
  23539. * * 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
  23540. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23541. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23542. * * flat when true creates a flat shaded mesh, optional, default true
  23543. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23544. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23545. * * 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)
  23546. * * 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)
  23547. * @returns the VertexData of the Polyhedron
  23548. */
  23549. static CreatePolyhedron(options: {
  23550. type?: number;
  23551. size?: number;
  23552. sizeX?: number;
  23553. sizeY?: number;
  23554. sizeZ?: number;
  23555. custom?: any;
  23556. faceUV?: Vector4[];
  23557. faceColors?: Color4[];
  23558. flat?: boolean;
  23559. sideOrientation?: number;
  23560. frontUVs?: Vector4;
  23561. backUVs?: Vector4;
  23562. }): VertexData;
  23563. /**
  23564. * Creates the VertexData for a TorusKnot
  23565. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23566. * * radius the radius of the torus knot, optional, default 2
  23567. * * tube the thickness of the tube, optional, default 0.5
  23568. * * radialSegments the number of sides on each tube segments, optional, default 32
  23569. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23570. * * p the number of windings around the z axis, optional, default 2
  23571. * * q the number of windings around the x axis, optional, default 3
  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 Torus Knot
  23576. */
  23577. static CreateTorusKnot(options: {
  23578. radius?: number;
  23579. tube?: number;
  23580. radialSegments?: number;
  23581. tubularSegments?: number;
  23582. p?: number;
  23583. q?: number;
  23584. sideOrientation?: number;
  23585. frontUVs?: Vector4;
  23586. backUVs?: Vector4;
  23587. }): VertexData;
  23588. /**
  23589. * Compute normals for given positions and indices
  23590. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23591. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23592. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23593. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23594. * * facetNormals : optional array of facet normals (vector3)
  23595. * * facetPositions : optional array of facet positions (vector3)
  23596. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23597. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23598. * * bInfo : optional bounding info, required for facetPartitioning computation
  23599. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23600. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23601. * * useRightHandedSystem: optional boolean to for right handed system computation
  23602. * * depthSort : optional boolean to enable the facet depth sort computation
  23603. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23604. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23605. */
  23606. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23607. facetNormals?: any;
  23608. facetPositions?: any;
  23609. facetPartitioning?: any;
  23610. ratio?: number;
  23611. bInfo?: any;
  23612. bbSize?: Vector3;
  23613. subDiv?: any;
  23614. useRightHandedSystem?: boolean;
  23615. depthSort?: boolean;
  23616. distanceTo?: Vector3;
  23617. depthSortedFacets?: any;
  23618. }): void;
  23619. /** @hidden */
  23620. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23621. /**
  23622. * Applies VertexData created from the imported parameters to the geometry
  23623. * @param parsedVertexData the parsed data from an imported file
  23624. * @param geometry the geometry to apply the VertexData to
  23625. */
  23626. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23627. }
  23628. }
  23629. declare module BABYLON {
  23630. /**
  23631. * Class containing static functions to help procedurally build meshes
  23632. */
  23633. export class DiscBuilder {
  23634. /**
  23635. * Creates a plane polygonal mesh. By default, this is a disc
  23636. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23637. * * 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
  23638. * * 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
  23639. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23640. * * 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
  23641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23642. * @param name defines the name of the mesh
  23643. * @param options defines the options used to create the mesh
  23644. * @param scene defines the hosting scene
  23645. * @returns the plane polygonal mesh
  23646. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23647. */
  23648. static CreateDisc(name: string, options: {
  23649. radius?: number;
  23650. tessellation?: number;
  23651. arc?: number;
  23652. updatable?: boolean;
  23653. sideOrientation?: number;
  23654. frontUVs?: Vector4;
  23655. backUVs?: Vector4;
  23656. }, scene?: Nullable<Scene>): Mesh;
  23657. }
  23658. }
  23659. declare module BABYLON {
  23660. /**
  23661. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23662. *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.
  23663. * The SPS is also a particle system. It provides some methods to manage the particles.
  23664. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23665. *
  23666. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23667. */
  23668. export class SolidParticleSystem implements IDisposable {
  23669. /**
  23670. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23671. * Example : var p = SPS.particles[i];
  23672. */
  23673. particles: SolidParticle[];
  23674. /**
  23675. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23676. */
  23677. nbParticles: number;
  23678. /**
  23679. * If the particles must ever face the camera (default false). Useful for planar particles.
  23680. */
  23681. billboard: boolean;
  23682. /**
  23683. * Recompute normals when adding a shape
  23684. */
  23685. recomputeNormals: boolean;
  23686. /**
  23687. * This a counter ofr your own usage. It's not set by any SPS functions.
  23688. */
  23689. counter: number;
  23690. /**
  23691. * The SPS name. This name is also given to the underlying mesh.
  23692. */
  23693. name: string;
  23694. /**
  23695. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23696. */
  23697. mesh: Mesh;
  23698. /**
  23699. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23700. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23701. */
  23702. vars: any;
  23703. /**
  23704. * This array is populated when the SPS is set as 'pickable'.
  23705. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23706. * Each element of this array is an object `{idx: int, faceId: int}`.
  23707. * `idx` is the picked particle index in the `SPS.particles` array
  23708. * `faceId` is the picked face index counted within this particle.
  23709. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23710. */
  23711. pickedParticles: {
  23712. idx: number;
  23713. faceId: number;
  23714. }[];
  23715. /**
  23716. * This array is populated when `enableDepthSort` is set to true.
  23717. * Each element of this array is an instance of the class DepthSortedParticle.
  23718. */
  23719. depthSortedParticles: DepthSortedParticle[];
  23720. /**
  23721. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23722. * @hidden
  23723. */
  23724. _bSphereOnly: boolean;
  23725. /**
  23726. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23727. * @hidden
  23728. */
  23729. _bSphereRadiusFactor: number;
  23730. private _scene;
  23731. private _positions;
  23732. private _indices;
  23733. private _normals;
  23734. private _colors;
  23735. private _uvs;
  23736. private _indices32;
  23737. private _positions32;
  23738. private _normals32;
  23739. private _fixedNormal32;
  23740. private _colors32;
  23741. private _uvs32;
  23742. private _index;
  23743. private _updatable;
  23744. private _pickable;
  23745. private _isVisibilityBoxLocked;
  23746. private _alwaysVisible;
  23747. private _depthSort;
  23748. private _shapeCounter;
  23749. private _copy;
  23750. private _color;
  23751. private _computeParticleColor;
  23752. private _computeParticleTexture;
  23753. private _computeParticleRotation;
  23754. private _computeParticleVertex;
  23755. private _computeBoundingBox;
  23756. private _depthSortParticles;
  23757. private _camera;
  23758. private _mustUnrotateFixedNormals;
  23759. private _particlesIntersect;
  23760. private _needs32Bits;
  23761. /**
  23762. * Creates a SPS (Solid Particle System) object.
  23763. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23764. * @param scene (Scene) is the scene in which the SPS is added.
  23765. * @param options defines the options of the sps e.g.
  23766. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23767. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23768. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23769. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23770. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23771. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23772. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23773. */
  23774. constructor(name: string, scene: Scene, options?: {
  23775. updatable?: boolean;
  23776. isPickable?: boolean;
  23777. enableDepthSort?: boolean;
  23778. particleIntersection?: boolean;
  23779. boundingSphereOnly?: boolean;
  23780. bSphereRadiusFactor?: number;
  23781. });
  23782. /**
  23783. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23784. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23785. * @returns the created mesh
  23786. */
  23787. buildMesh(): Mesh;
  23788. /**
  23789. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23790. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23791. * Thus the particles generated from `digest()` have their property `position` set yet.
  23792. * @param mesh ( Mesh ) is the mesh to be digested
  23793. * @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
  23794. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23795. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23796. * @returns the current SPS
  23797. */
  23798. digest(mesh: Mesh, options?: {
  23799. facetNb?: number;
  23800. number?: number;
  23801. delta?: number;
  23802. }): SolidParticleSystem;
  23803. private _unrotateFixedNormals;
  23804. private _resetCopy;
  23805. private _meshBuilder;
  23806. private _posToShape;
  23807. private _uvsToShapeUV;
  23808. private _addParticle;
  23809. /**
  23810. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23811. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23812. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23813. * @param nb (positive integer) the number of particles to be created from this model
  23814. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23815. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23816. * @returns the number of shapes in the system
  23817. */
  23818. addShape(mesh: Mesh, nb: number, options?: {
  23819. positionFunction?: any;
  23820. vertexFunction?: any;
  23821. }): number;
  23822. private _rebuildParticle;
  23823. /**
  23824. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23825. * @returns the SPS.
  23826. */
  23827. rebuildMesh(): SolidParticleSystem;
  23828. /**
  23829. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23830. * This method calls `updateParticle()` for each particle of the SPS.
  23831. * For an animated SPS, it is usually called within the render loop.
  23832. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23833. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23834. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23835. * @returns the SPS.
  23836. */
  23837. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23838. /**
  23839. * Disposes the SPS.
  23840. */
  23841. dispose(): void;
  23842. /**
  23843. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23844. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23845. * @returns the SPS.
  23846. */
  23847. refreshVisibleSize(): SolidParticleSystem;
  23848. /**
  23849. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23850. * @param size the size (float) of the visibility box
  23851. * note : this doesn't lock the SPS mesh bounding box.
  23852. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23853. */
  23854. setVisibilityBox(size: number): void;
  23855. /**
  23856. * Gets whether the SPS as always visible or not
  23857. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23858. */
  23859. /**
  23860. * Sets the SPS as always visible or not
  23861. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23862. */
  23863. isAlwaysVisible: boolean;
  23864. /**
  23865. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23866. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23867. */
  23868. /**
  23869. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23870. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23871. */
  23872. isVisibilityBoxLocked: boolean;
  23873. /**
  23874. * Tells to `setParticles()` to compute the particle rotations or not.
  23875. * Default value : true. The SPS is faster when it's set to false.
  23876. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23877. */
  23878. /**
  23879. * Gets if `setParticles()` computes the particle rotations or not.
  23880. * Default value : true. The SPS is faster when it's set to false.
  23881. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23882. */
  23883. computeParticleRotation: boolean;
  23884. /**
  23885. * Tells to `setParticles()` to compute the particle colors or not.
  23886. * Default value : true. The SPS is faster when it's set to false.
  23887. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23888. */
  23889. /**
  23890. * Gets if `setParticles()` computes the particle colors or not.
  23891. * Default value : true. The SPS is faster when it's set to false.
  23892. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23893. */
  23894. computeParticleColor: boolean;
  23895. /**
  23896. * Gets if `setParticles()` computes the particle textures or not.
  23897. * Default value : true. The SPS is faster when it's set to false.
  23898. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23899. */
  23900. computeParticleTexture: boolean;
  23901. /**
  23902. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23903. * Default value : false. The SPS is faster when it's set to false.
  23904. * Note : the particle custom vertex positions aren't stored values.
  23905. */
  23906. /**
  23907. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23908. * Default value : false. The SPS is faster when it's set to false.
  23909. * Note : the particle custom vertex positions aren't stored values.
  23910. */
  23911. computeParticleVertex: boolean;
  23912. /**
  23913. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23914. */
  23915. /**
  23916. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23917. */
  23918. computeBoundingBox: boolean;
  23919. /**
  23920. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23921. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23922. * Default : `true`
  23923. */
  23924. /**
  23925. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23926. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23927. * Default : `true`
  23928. */
  23929. depthSortParticles: boolean;
  23930. /**
  23931. * This function does nothing. It may be overwritten to set all the particle first values.
  23932. * The SPS doesn't call this function, you may have to call it by your own.
  23933. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23934. */
  23935. initParticles(): void;
  23936. /**
  23937. * This function does nothing. It may be overwritten to recycle a particle.
  23938. * The SPS doesn't call this function, you may have to call it by your own.
  23939. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23940. * @param particle The particle to recycle
  23941. * @returns the recycled particle
  23942. */
  23943. recycleParticle(particle: SolidParticle): SolidParticle;
  23944. /**
  23945. * Updates a particle : this function should be overwritten by the user.
  23946. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23947. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23948. * @example : just set a particle position or velocity and recycle conditions
  23949. * @param particle The particle to update
  23950. * @returns the updated particle
  23951. */
  23952. updateParticle(particle: SolidParticle): SolidParticle;
  23953. /**
  23954. * Updates a vertex of a particle : it can be overwritten by the user.
  23955. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23956. * @param particle the current particle
  23957. * @param vertex the current index of the current particle
  23958. * @param pt the index of the current vertex in the particle shape
  23959. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23960. * @example : just set a vertex particle position
  23961. * @returns the updated vertex
  23962. */
  23963. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23964. /**
  23965. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23966. * This does nothing and may be overwritten by the user.
  23967. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23968. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23969. * @param update the boolean update value actually passed to setParticles()
  23970. */
  23971. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23972. /**
  23973. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23974. * This will be passed three parameters.
  23975. * This does nothing and may be overwritten by the user.
  23976. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23977. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23978. * @param update the boolean update value actually passed to setParticles()
  23979. */
  23980. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23981. }
  23982. }
  23983. declare module BABYLON {
  23984. /**
  23985. * Represents one particle of a solid particle system.
  23986. */
  23987. export class SolidParticle {
  23988. /**
  23989. * particle global index
  23990. */
  23991. idx: number;
  23992. /**
  23993. * The color of the particle
  23994. */
  23995. color: Nullable<Color4>;
  23996. /**
  23997. * The world space position of the particle.
  23998. */
  23999. position: Vector3;
  24000. /**
  24001. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24002. */
  24003. rotation: Vector3;
  24004. /**
  24005. * The world space rotation quaternion of the particle.
  24006. */
  24007. rotationQuaternion: Nullable<Quaternion>;
  24008. /**
  24009. * The scaling of the particle.
  24010. */
  24011. scaling: Vector3;
  24012. /**
  24013. * The uvs of the particle.
  24014. */
  24015. uvs: Vector4;
  24016. /**
  24017. * The current speed of the particle.
  24018. */
  24019. velocity: Vector3;
  24020. /**
  24021. * The pivot point in the particle local space.
  24022. */
  24023. pivot: Vector3;
  24024. /**
  24025. * Must the particle be translated from its pivot point in its local space ?
  24026. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24027. * Default : false
  24028. */
  24029. translateFromPivot: boolean;
  24030. /**
  24031. * Is the particle active or not ?
  24032. */
  24033. alive: boolean;
  24034. /**
  24035. * Is the particle visible or not ?
  24036. */
  24037. isVisible: boolean;
  24038. /**
  24039. * Index of this particle in the global "positions" array (Internal use)
  24040. * @hidden
  24041. */
  24042. _pos: number;
  24043. /**
  24044. * @hidden Index of this particle in the global "indices" array (Internal use)
  24045. */
  24046. _ind: number;
  24047. /**
  24048. * @hidden ModelShape of this particle (Internal use)
  24049. */
  24050. _model: ModelShape;
  24051. /**
  24052. * ModelShape id of this particle
  24053. */
  24054. shapeId: number;
  24055. /**
  24056. * Index of the particle in its shape id (Internal use)
  24057. */
  24058. idxInShape: number;
  24059. /**
  24060. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24061. */
  24062. _modelBoundingInfo: BoundingInfo;
  24063. /**
  24064. * @hidden Particle BoundingInfo object (Internal use)
  24065. */
  24066. _boundingInfo: BoundingInfo;
  24067. /**
  24068. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24069. */
  24070. _sps: SolidParticleSystem;
  24071. /**
  24072. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24073. */
  24074. _stillInvisible: boolean;
  24075. /**
  24076. * @hidden Last computed particle rotation matrix
  24077. */
  24078. _rotationMatrix: number[];
  24079. /**
  24080. * Parent particle Id, if any.
  24081. * Default null.
  24082. */
  24083. parentId: Nullable<number>;
  24084. /**
  24085. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24086. * The possible values are :
  24087. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24088. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24089. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24090. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24091. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24092. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24093. * */
  24094. cullingStrategy: number;
  24095. /**
  24096. * @hidden Internal global position in the SPS.
  24097. */
  24098. _globalPosition: Vector3;
  24099. /**
  24100. * Creates a Solid Particle object.
  24101. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24102. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24103. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24104. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24105. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24106. * @param shapeId (integer) is the model shape identifier in the SPS.
  24107. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24108. * @param sps defines the sps it is associated to
  24109. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24110. */
  24111. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24112. /**
  24113. * Legacy support, changed scale to scaling
  24114. */
  24115. /**
  24116. * Legacy support, changed scale to scaling
  24117. */
  24118. scale: Vector3;
  24119. /**
  24120. * Legacy support, changed quaternion to rotationQuaternion
  24121. */
  24122. /**
  24123. * Legacy support, changed quaternion to rotationQuaternion
  24124. */
  24125. quaternion: Nullable<Quaternion>;
  24126. /**
  24127. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24128. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24129. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24130. * @returns true if it intersects
  24131. */
  24132. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24133. /**
  24134. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24135. * A particle is in the frustum if its bounding box intersects the frustum
  24136. * @param frustumPlanes defines the frustum to test
  24137. * @returns true if the particle is in the frustum planes
  24138. */
  24139. isInFrustum(frustumPlanes: Plane[]): boolean;
  24140. /**
  24141. * get the rotation matrix of the particle
  24142. * @hidden
  24143. */
  24144. getRotationMatrix(m: Matrix): void;
  24145. }
  24146. /**
  24147. * Represents the shape of the model used by one particle of a solid particle system.
  24148. * SPS internal tool, don't use it manually.
  24149. */
  24150. export class ModelShape {
  24151. /**
  24152. * The shape id
  24153. * @hidden
  24154. */
  24155. shapeID: number;
  24156. /**
  24157. * flat array of model positions (internal use)
  24158. * @hidden
  24159. */
  24160. _shape: Vector3[];
  24161. /**
  24162. * flat array of model UVs (internal use)
  24163. * @hidden
  24164. */
  24165. _shapeUV: number[];
  24166. /**
  24167. * length of the shape in the model indices array (internal use)
  24168. * @hidden
  24169. */
  24170. _indicesLength: number;
  24171. /**
  24172. * Custom position function (internal use)
  24173. * @hidden
  24174. */
  24175. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24176. /**
  24177. * Custom vertex function (internal use)
  24178. * @hidden
  24179. */
  24180. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24181. /**
  24182. * 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.
  24183. * SPS internal tool, don't use it manually.
  24184. * @hidden
  24185. */
  24186. 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>);
  24187. }
  24188. /**
  24189. * Represents a Depth Sorted Particle in the solid particle system.
  24190. */
  24191. export class DepthSortedParticle {
  24192. /**
  24193. * Index of the particle in the "indices" array
  24194. */
  24195. ind: number;
  24196. /**
  24197. * Length of the particle shape in the "indices" array
  24198. */
  24199. indicesLength: number;
  24200. /**
  24201. * Squared distance from the particle to the camera
  24202. */
  24203. sqDistance: number;
  24204. }
  24205. }
  24206. declare module BABYLON {
  24207. /**
  24208. * @hidden
  24209. */
  24210. export class _MeshCollisionData {
  24211. _checkCollisions: boolean;
  24212. _collisionMask: number;
  24213. _collisionGroup: number;
  24214. _collider: Nullable<Collider>;
  24215. _oldPositionForCollisions: Vector3;
  24216. _diffPositionForCollisions: Vector3;
  24217. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  24218. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  24219. }
  24220. }
  24221. declare module BABYLON {
  24222. /** @hidden */
  24223. class _FacetDataStorage {
  24224. facetPositions: Vector3[];
  24225. facetNormals: Vector3[];
  24226. facetPartitioning: number[][];
  24227. facetNb: number;
  24228. partitioningSubdivisions: number;
  24229. partitioningBBoxRatio: number;
  24230. facetDataEnabled: boolean;
  24231. facetParameters: any;
  24232. bbSize: Vector3;
  24233. subDiv: {
  24234. max: number;
  24235. X: number;
  24236. Y: number;
  24237. Z: number;
  24238. };
  24239. facetDepthSort: boolean;
  24240. facetDepthSortEnabled: boolean;
  24241. depthSortedIndices: IndicesArray;
  24242. depthSortedFacets: {
  24243. ind: number;
  24244. sqDistance: number;
  24245. }[];
  24246. facetDepthSortFunction: (f1: {
  24247. ind: number;
  24248. sqDistance: number;
  24249. }, f2: {
  24250. ind: number;
  24251. sqDistance: number;
  24252. }) => number;
  24253. facetDepthSortFrom: Vector3;
  24254. facetDepthSortOrigin: Vector3;
  24255. invertedMatrix: Matrix;
  24256. }
  24257. /**
  24258. * @hidden
  24259. **/
  24260. class _InternalAbstractMeshDataInfo {
  24261. _hasVertexAlpha: boolean;
  24262. _useVertexColors: boolean;
  24263. _numBoneInfluencers: number;
  24264. _applyFog: boolean;
  24265. _receiveShadows: boolean;
  24266. _facetData: _FacetDataStorage;
  24267. _visibility: number;
  24268. _skeleton: Nullable<Skeleton>;
  24269. _layerMask: number;
  24270. _computeBonesUsingShaders: boolean;
  24271. _isActive: boolean;
  24272. _onlyForInstances: boolean;
  24273. _isActiveIntermediate: boolean;
  24274. _onlyForInstancesIntermediate: boolean;
  24275. }
  24276. /**
  24277. * Class used to store all common mesh properties
  24278. */
  24279. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24280. /** No occlusion */
  24281. static OCCLUSION_TYPE_NONE: number;
  24282. /** Occlusion set to optimisitic */
  24283. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24284. /** Occlusion set to strict */
  24285. static OCCLUSION_TYPE_STRICT: number;
  24286. /** Use an accurante occlusion algorithm */
  24287. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24288. /** Use a conservative occlusion algorithm */
  24289. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24290. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24291. * Test order :
  24292. * Is the bounding sphere outside the frustum ?
  24293. * If not, are the bounding box vertices outside the frustum ?
  24294. * It not, then the cullable object is in the frustum.
  24295. */
  24296. static readonly CULLINGSTRATEGY_STANDARD: number;
  24297. /** Culling strategy : Bounding Sphere Only.
  24298. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24299. * It's also less accurate than the standard because some not visible objects can still be selected.
  24300. * Test : is the bounding sphere outside the frustum ?
  24301. * If not, then the cullable object is in the frustum.
  24302. */
  24303. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24304. /** Culling strategy : Optimistic Inclusion.
  24305. * This in an inclusion test first, then the standard exclusion test.
  24306. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24307. * 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.
  24308. * Anyway, it's as accurate as the standard strategy.
  24309. * Test :
  24310. * Is the cullable object bounding sphere center in the frustum ?
  24311. * If not, apply the default culling strategy.
  24312. */
  24313. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24314. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24315. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24316. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24317. * 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.
  24318. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24319. * Test :
  24320. * Is the cullable object bounding sphere center in the frustum ?
  24321. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24322. */
  24323. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24324. /**
  24325. * No billboard
  24326. */
  24327. static readonly BILLBOARDMODE_NONE: number;
  24328. /** Billboard on X axis */
  24329. static readonly BILLBOARDMODE_X: number;
  24330. /** Billboard on Y axis */
  24331. static readonly BILLBOARDMODE_Y: number;
  24332. /** Billboard on Z axis */
  24333. static readonly BILLBOARDMODE_Z: number;
  24334. /** Billboard on all axes */
  24335. static readonly BILLBOARDMODE_ALL: number;
  24336. /** @hidden */
  24337. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  24338. /**
  24339. * The culling strategy to use to check whether the mesh must be rendered or not.
  24340. * This value can be changed at any time and will be used on the next render mesh selection.
  24341. * The possible values are :
  24342. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24343. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24344. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24345. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24346. * Please read each static variable documentation to get details about the culling process.
  24347. * */
  24348. cullingStrategy: number;
  24349. /**
  24350. * Gets the number of facets in the mesh
  24351. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24352. */
  24353. readonly facetNb: number;
  24354. /**
  24355. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24356. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24357. */
  24358. partitioningSubdivisions: number;
  24359. /**
  24360. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24361. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24362. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24363. */
  24364. partitioningBBoxRatio: number;
  24365. /**
  24366. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24367. * Works only for updatable meshes.
  24368. * Doesn't work with multi-materials
  24369. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24370. */
  24371. mustDepthSortFacets: boolean;
  24372. /**
  24373. * The location (Vector3) where the facet depth sort must be computed from.
  24374. * By default, the active camera position.
  24375. * Used only when facet depth sort is enabled
  24376. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24377. */
  24378. facetDepthSortFrom: Vector3;
  24379. /**
  24380. * gets a boolean indicating if facetData is enabled
  24381. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24382. */
  24383. readonly isFacetDataEnabled: boolean;
  24384. /** @hidden */
  24385. _updateNonUniformScalingState(value: boolean): boolean;
  24386. /**
  24387. * An event triggered when this mesh collides with another one
  24388. */
  24389. onCollideObservable: Observable<AbstractMesh>;
  24390. /** Set a function to call when this mesh collides with another one */
  24391. onCollide: () => void;
  24392. /**
  24393. * An event triggered when the collision's position changes
  24394. */
  24395. onCollisionPositionChangeObservable: Observable<Vector3>;
  24396. /** Set a function to call when the collision's position changes */
  24397. onCollisionPositionChange: () => void;
  24398. /**
  24399. * An event triggered when material is changed
  24400. */
  24401. onMaterialChangedObservable: Observable<AbstractMesh>;
  24402. /**
  24403. * Gets or sets the orientation for POV movement & rotation
  24404. */
  24405. definedFacingForward: boolean;
  24406. /** @hidden */
  24407. _occlusionQuery: Nullable<WebGLQuery>;
  24408. /** @hidden */
  24409. _renderingGroup: Nullable<RenderingGroup>;
  24410. /**
  24411. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24412. */
  24413. /**
  24414. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24415. */
  24416. visibility: number;
  24417. /** Gets or sets the alpha index used to sort transparent meshes
  24418. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24419. */
  24420. alphaIndex: number;
  24421. /**
  24422. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24423. */
  24424. isVisible: boolean;
  24425. /**
  24426. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24427. */
  24428. isPickable: boolean;
  24429. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24430. showSubMeshesBoundingBox: boolean;
  24431. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24432. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24433. */
  24434. isBlocker: boolean;
  24435. /**
  24436. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24437. */
  24438. enablePointerMoveEvents: boolean;
  24439. /**
  24440. * Specifies the rendering group id for this mesh (0 by default)
  24441. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24442. */
  24443. renderingGroupId: number;
  24444. private _material;
  24445. /** Gets or sets current material */
  24446. material: Nullable<Material>;
  24447. /**
  24448. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24449. * @see http://doc.babylonjs.com/babylon101/shadows
  24450. */
  24451. receiveShadows: boolean;
  24452. /** Defines color to use when rendering outline */
  24453. outlineColor: Color3;
  24454. /** Define width to use when rendering outline */
  24455. outlineWidth: number;
  24456. /** Defines color to use when rendering overlay */
  24457. overlayColor: Color3;
  24458. /** Defines alpha to use when rendering overlay */
  24459. overlayAlpha: number;
  24460. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24461. hasVertexAlpha: boolean;
  24462. /** 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) */
  24463. useVertexColors: boolean;
  24464. /**
  24465. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24466. */
  24467. computeBonesUsingShaders: boolean;
  24468. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24469. numBoneInfluencers: number;
  24470. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24471. applyFog: boolean;
  24472. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24473. useOctreeForRenderingSelection: boolean;
  24474. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24475. useOctreeForPicking: boolean;
  24476. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24477. useOctreeForCollisions: boolean;
  24478. /**
  24479. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24480. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24481. */
  24482. layerMask: number;
  24483. /**
  24484. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24485. */
  24486. alwaysSelectAsActiveMesh: boolean;
  24487. /**
  24488. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24489. */
  24490. doNotSyncBoundingInfo: boolean;
  24491. /**
  24492. * Gets or sets the current action manager
  24493. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24494. */
  24495. actionManager: Nullable<AbstractActionManager>;
  24496. private _meshCollisionData;
  24497. /**
  24498. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24499. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24500. */
  24501. ellipsoid: Vector3;
  24502. /**
  24503. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24504. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24505. */
  24506. ellipsoidOffset: Vector3;
  24507. /**
  24508. * Gets or sets a collision mask used to mask collisions (default is -1).
  24509. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24510. */
  24511. collisionMask: number;
  24512. /**
  24513. * Gets or sets the current collision group mask (-1 by default).
  24514. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24515. */
  24516. collisionGroup: number;
  24517. /**
  24518. * Defines edge width used when edgesRenderer is enabled
  24519. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24520. */
  24521. edgesWidth: number;
  24522. /**
  24523. * Defines edge color used when edgesRenderer is enabled
  24524. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24525. */
  24526. edgesColor: Color4;
  24527. /** @hidden */
  24528. _edgesRenderer: Nullable<IEdgesRenderer>;
  24529. /** @hidden */
  24530. _masterMesh: Nullable<AbstractMesh>;
  24531. /** @hidden */
  24532. _boundingInfo: Nullable<BoundingInfo>;
  24533. /** @hidden */
  24534. _renderId: number;
  24535. /**
  24536. * Gets or sets the list of subMeshes
  24537. * @see http://doc.babylonjs.com/how_to/multi_materials
  24538. */
  24539. subMeshes: SubMesh[];
  24540. /** @hidden */
  24541. _intersectionsInProgress: AbstractMesh[];
  24542. /** @hidden */
  24543. _unIndexed: boolean;
  24544. /** @hidden */
  24545. _lightSources: Light[];
  24546. /** Gets the list of lights affecting that mesh */
  24547. readonly lightSources: Light[];
  24548. /** @hidden */
  24549. readonly _positions: Nullable<Vector3[]>;
  24550. /** @hidden */
  24551. _waitingData: {
  24552. lods: Nullable<any>;
  24553. actions: Nullable<any>;
  24554. freezeWorldMatrix: Nullable<boolean>;
  24555. };
  24556. /** @hidden */
  24557. _bonesTransformMatrices: Nullable<Float32Array>;
  24558. /**
  24559. * Gets or sets a skeleton to apply skining transformations
  24560. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24561. */
  24562. skeleton: Nullable<Skeleton>;
  24563. /**
  24564. * An event triggered when the mesh is rebuilt.
  24565. */
  24566. onRebuildObservable: Observable<AbstractMesh>;
  24567. /**
  24568. * Creates a new AbstractMesh
  24569. * @param name defines the name of the mesh
  24570. * @param scene defines the hosting scene
  24571. */
  24572. constructor(name: string, scene?: Nullable<Scene>);
  24573. /**
  24574. * Returns the string "AbstractMesh"
  24575. * @returns "AbstractMesh"
  24576. */
  24577. getClassName(): string;
  24578. /**
  24579. * Gets a string representation of the current mesh
  24580. * @param fullDetails defines a boolean indicating if full details must be included
  24581. * @returns a string representation of the current mesh
  24582. */
  24583. toString(fullDetails?: boolean): string;
  24584. /**
  24585. * @hidden
  24586. */
  24587. protected _getEffectiveParent(): Nullable<Node>;
  24588. /** @hidden */
  24589. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24590. /** @hidden */
  24591. _rebuild(): void;
  24592. /** @hidden */
  24593. _resyncLightSources(): void;
  24594. /** @hidden */
  24595. _resyncLighSource(light: Light): void;
  24596. /** @hidden */
  24597. _unBindEffect(): void;
  24598. /** @hidden */
  24599. _removeLightSource(light: Light): void;
  24600. private _markSubMeshesAsDirty;
  24601. /** @hidden */
  24602. _markSubMeshesAsLightDirty(): void;
  24603. /** @hidden */
  24604. _markSubMeshesAsAttributesDirty(): void;
  24605. /** @hidden */
  24606. _markSubMeshesAsMiscDirty(): void;
  24607. /**
  24608. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24609. */
  24610. scaling: Vector3;
  24611. /**
  24612. * Returns true if the mesh is blocked. Implemented by child classes
  24613. */
  24614. readonly isBlocked: boolean;
  24615. /**
  24616. * Returns the mesh itself by default. Implemented by child classes
  24617. * @param camera defines the camera to use to pick the right LOD level
  24618. * @returns the currentAbstractMesh
  24619. */
  24620. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24621. /**
  24622. * Returns 0 by default. Implemented by child classes
  24623. * @returns an integer
  24624. */
  24625. getTotalVertices(): number;
  24626. /**
  24627. * Returns a positive integer : the total number of indices in this mesh geometry.
  24628. * @returns the numner of indices or zero if the mesh has no geometry.
  24629. */
  24630. getTotalIndices(): number;
  24631. /**
  24632. * Returns null by default. Implemented by child classes
  24633. * @returns null
  24634. */
  24635. getIndices(): Nullable<IndicesArray>;
  24636. /**
  24637. * Returns the array of the requested vertex data kind. Implemented by child classes
  24638. * @param kind defines the vertex data kind to use
  24639. * @returns null
  24640. */
  24641. getVerticesData(kind: string): Nullable<FloatArray>;
  24642. /**
  24643. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24644. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24645. * Note that a new underlying VertexBuffer object is created each call.
  24646. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24647. * @param kind defines vertex data kind:
  24648. * * VertexBuffer.PositionKind
  24649. * * VertexBuffer.UVKind
  24650. * * VertexBuffer.UV2Kind
  24651. * * VertexBuffer.UV3Kind
  24652. * * VertexBuffer.UV4Kind
  24653. * * VertexBuffer.UV5Kind
  24654. * * VertexBuffer.UV6Kind
  24655. * * VertexBuffer.ColorKind
  24656. * * VertexBuffer.MatricesIndicesKind
  24657. * * VertexBuffer.MatricesIndicesExtraKind
  24658. * * VertexBuffer.MatricesWeightsKind
  24659. * * VertexBuffer.MatricesWeightsExtraKind
  24660. * @param data defines the data source
  24661. * @param updatable defines if the data must be flagged as updatable (or static)
  24662. * @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
  24663. * @returns the current mesh
  24664. */
  24665. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24666. /**
  24667. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24668. * If the mesh has no geometry, it is simply returned as it is.
  24669. * @param kind defines vertex data kind:
  24670. * * VertexBuffer.PositionKind
  24671. * * VertexBuffer.UVKind
  24672. * * VertexBuffer.UV2Kind
  24673. * * VertexBuffer.UV3Kind
  24674. * * VertexBuffer.UV4Kind
  24675. * * VertexBuffer.UV5Kind
  24676. * * VertexBuffer.UV6Kind
  24677. * * VertexBuffer.ColorKind
  24678. * * VertexBuffer.MatricesIndicesKind
  24679. * * VertexBuffer.MatricesIndicesExtraKind
  24680. * * VertexBuffer.MatricesWeightsKind
  24681. * * VertexBuffer.MatricesWeightsExtraKind
  24682. * @param data defines the data source
  24683. * @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
  24684. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24685. * @returns the current mesh
  24686. */
  24687. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24688. /**
  24689. * Sets the mesh indices,
  24690. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24691. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24692. * @param totalVertices Defines the total number of vertices
  24693. * @returns the current mesh
  24694. */
  24695. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24696. /**
  24697. * Gets a boolean indicating if specific vertex data is present
  24698. * @param kind defines the vertex data kind to use
  24699. * @returns true is data kind is present
  24700. */
  24701. isVerticesDataPresent(kind: string): boolean;
  24702. /**
  24703. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24704. * @returns a BoundingInfo
  24705. */
  24706. getBoundingInfo(): BoundingInfo;
  24707. /**
  24708. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24709. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24710. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24711. * @returns the current mesh
  24712. */
  24713. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24714. /**
  24715. * Overwrite the current bounding info
  24716. * @param boundingInfo defines the new bounding info
  24717. * @returns the current mesh
  24718. */
  24719. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24720. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24721. readonly useBones: boolean;
  24722. /** @hidden */
  24723. _preActivate(): void;
  24724. /** @hidden */
  24725. _preActivateForIntermediateRendering(renderId: number): void;
  24726. /** @hidden */
  24727. _activate(renderId: number, intermediateRendering: boolean): boolean;
  24728. /** @hidden */
  24729. _postActivate(): void;
  24730. /** @hidden */
  24731. _freeze(): void;
  24732. /** @hidden */
  24733. _unFreeze(): void;
  24734. /**
  24735. * Gets the current world matrix
  24736. * @returns a Matrix
  24737. */
  24738. getWorldMatrix(): Matrix;
  24739. /** @hidden */
  24740. _getWorldMatrixDeterminant(): number;
  24741. /**
  24742. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  24743. */
  24744. readonly isAnInstance: boolean;
  24745. /**
  24746. * Perform relative position change from the point of view of behind the front of the mesh.
  24747. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24748. * Supports definition of mesh facing forward or backward
  24749. * @param amountRight defines the distance on the right axis
  24750. * @param amountUp defines the distance on the up axis
  24751. * @param amountForward defines the distance on the forward axis
  24752. * @returns the current mesh
  24753. */
  24754. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24755. /**
  24756. * Calculate relative position change from the point of view of behind the front of the mesh.
  24757. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24758. * Supports definition of mesh facing forward or backward
  24759. * @param amountRight defines the distance on the right axis
  24760. * @param amountUp defines the distance on the up axis
  24761. * @param amountForward defines the distance on the forward axis
  24762. * @returns the new displacement vector
  24763. */
  24764. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24765. /**
  24766. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24767. * Supports definition of mesh facing forward or backward
  24768. * @param flipBack defines the flip
  24769. * @param twirlClockwise defines the twirl
  24770. * @param tiltRight defines the tilt
  24771. * @returns the current mesh
  24772. */
  24773. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24774. /**
  24775. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24776. * Supports definition of mesh facing forward or backward.
  24777. * @param flipBack defines the flip
  24778. * @param twirlClockwise defines the twirl
  24779. * @param tiltRight defines the tilt
  24780. * @returns the new rotation vector
  24781. */
  24782. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24783. /**
  24784. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24785. * This means the mesh underlying bounding box and sphere are recomputed.
  24786. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24787. * @returns the current mesh
  24788. */
  24789. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24790. /** @hidden */
  24791. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24792. /** @hidden */
  24793. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24794. /** @hidden */
  24795. _updateBoundingInfo(): AbstractMesh;
  24796. /** @hidden */
  24797. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24798. /** @hidden */
  24799. protected _afterComputeWorldMatrix(): void;
  24800. /** @hidden */
  24801. readonly _effectiveMesh: AbstractMesh;
  24802. /**
  24803. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24804. * A mesh is in the frustum if its bounding box intersects the frustum
  24805. * @param frustumPlanes defines the frustum to test
  24806. * @returns true if the mesh is in the frustum planes
  24807. */
  24808. isInFrustum(frustumPlanes: Plane[]): boolean;
  24809. /**
  24810. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24811. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24812. * @param frustumPlanes defines the frustum to test
  24813. * @returns true if the mesh is completely in the frustum planes
  24814. */
  24815. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24816. /**
  24817. * True if the mesh intersects another mesh or a SolidParticle object
  24818. * @param mesh defines a target mesh or SolidParticle to test
  24819. * @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)
  24820. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24821. * @returns true if there is an intersection
  24822. */
  24823. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24824. /**
  24825. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24826. * @param point defines the point to test
  24827. * @returns true if there is an intersection
  24828. */
  24829. intersectsPoint(point: Vector3): boolean;
  24830. /**
  24831. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24832. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24833. */
  24834. checkCollisions: boolean;
  24835. /**
  24836. * Gets Collider object used to compute collisions (not physics)
  24837. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24838. */
  24839. readonly collider: Nullable<Collider>;
  24840. /**
  24841. * Move the mesh using collision engine
  24842. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24843. * @param displacement defines the requested displacement vector
  24844. * @returns the current mesh
  24845. */
  24846. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24847. private _onCollisionPositionChange;
  24848. /** @hidden */
  24849. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24850. /** @hidden */
  24851. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24852. /** @hidden */
  24853. _checkCollision(collider: Collider): AbstractMesh;
  24854. /** @hidden */
  24855. _generatePointsArray(): boolean;
  24856. /**
  24857. * Checks if the passed Ray intersects with the mesh
  24858. * @param ray defines the ray to use
  24859. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24860. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24861. * @returns the picking info
  24862. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24863. */
  24864. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24865. /**
  24866. * Clones the current mesh
  24867. * @param name defines the mesh name
  24868. * @param newParent defines the new mesh parent
  24869. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24870. * @returns the new mesh
  24871. */
  24872. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24873. /**
  24874. * Disposes all the submeshes of the current meshnp
  24875. * @returns the current mesh
  24876. */
  24877. releaseSubMeshes(): AbstractMesh;
  24878. /**
  24879. * Releases resources associated with this abstract mesh.
  24880. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24881. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24882. */
  24883. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24884. /**
  24885. * Adds the passed mesh as a child to the current mesh
  24886. * @param mesh defines the child mesh
  24887. * @returns the current mesh
  24888. */
  24889. addChild(mesh: AbstractMesh): AbstractMesh;
  24890. /**
  24891. * Removes the passed mesh from the current mesh children list
  24892. * @param mesh defines the child mesh
  24893. * @returns the current mesh
  24894. */
  24895. removeChild(mesh: AbstractMesh): AbstractMesh;
  24896. /** @hidden */
  24897. private _initFacetData;
  24898. /**
  24899. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24900. * This method can be called within the render loop.
  24901. * 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
  24902. * @returns the current mesh
  24903. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24904. */
  24905. updateFacetData(): AbstractMesh;
  24906. /**
  24907. * Returns the facetLocalNormals array.
  24908. * The normals are expressed in the mesh local spac
  24909. * @returns an array of Vector3
  24910. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24911. */
  24912. getFacetLocalNormals(): Vector3[];
  24913. /**
  24914. * Returns the facetLocalPositions array.
  24915. * The facet positions are expressed in the mesh local space
  24916. * @returns an array of Vector3
  24917. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24918. */
  24919. getFacetLocalPositions(): Vector3[];
  24920. /**
  24921. * Returns the facetLocalPartioning array
  24922. * @returns an array of array of numbers
  24923. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24924. */
  24925. getFacetLocalPartitioning(): number[][];
  24926. /**
  24927. * Returns the i-th facet position in the world system.
  24928. * This method allocates a new Vector3 per call
  24929. * @param i defines the facet index
  24930. * @returns a new Vector3
  24931. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24932. */
  24933. getFacetPosition(i: number): Vector3;
  24934. /**
  24935. * Sets the reference Vector3 with the i-th facet position in the world system
  24936. * @param i defines the facet index
  24937. * @param ref defines the target vector
  24938. * @returns the current mesh
  24939. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24940. */
  24941. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24942. /**
  24943. * Returns the i-th facet normal in the world system.
  24944. * This method allocates a new Vector3 per call
  24945. * @param i defines the facet index
  24946. * @returns a new Vector3
  24947. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24948. */
  24949. getFacetNormal(i: number): Vector3;
  24950. /**
  24951. * Sets the reference Vector3 with the i-th facet normal in the world system
  24952. * @param i defines the facet index
  24953. * @param ref defines the target vector
  24954. * @returns the current mesh
  24955. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24956. */
  24957. getFacetNormalToRef(i: number, ref: Vector3): this;
  24958. /**
  24959. * 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)
  24960. * @param x defines x coordinate
  24961. * @param y defines y coordinate
  24962. * @param z defines z coordinate
  24963. * @returns the array of facet indexes
  24964. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24965. */
  24966. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24967. /**
  24968. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24969. * @param projected sets as the (x,y,z) world projection on the facet
  24970. * @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
  24971. * @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
  24972. * @param x defines x coordinate
  24973. * @param y defines y coordinate
  24974. * @param z defines z coordinate
  24975. * @returns the face index if found (or null instead)
  24976. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24977. */
  24978. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24979. /**
  24980. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24981. * @param projected sets as the (x,y,z) local projection on the facet
  24982. * @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
  24983. * @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
  24984. * @param x defines x coordinate
  24985. * @param y defines y coordinate
  24986. * @param z defines z coordinate
  24987. * @returns the face index if found (or null instead)
  24988. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24989. */
  24990. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24991. /**
  24992. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24993. * @returns the parameters
  24994. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24995. */
  24996. getFacetDataParameters(): any;
  24997. /**
  24998. * Disables the feature FacetData and frees the related memory
  24999. * @returns the current mesh
  25000. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25001. */
  25002. disableFacetData(): AbstractMesh;
  25003. /**
  25004. * Updates the AbstractMesh indices array
  25005. * @param indices defines the data source
  25006. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25007. * @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)
  25008. * @returns the current mesh
  25009. */
  25010. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25011. /**
  25012. * Creates new normals data for the mesh
  25013. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25014. * @returns the current mesh
  25015. */
  25016. createNormals(updatable: boolean): AbstractMesh;
  25017. /**
  25018. * Align the mesh with a normal
  25019. * @param normal defines the normal to use
  25020. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25021. * @returns the current mesh
  25022. */
  25023. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25024. /** @hidden */
  25025. _checkOcclusionQuery(): boolean;
  25026. /**
  25027. * Disables the mesh edge rendering mode
  25028. * @returns the currentAbstractMesh
  25029. */
  25030. disableEdgesRendering(): AbstractMesh;
  25031. /**
  25032. * Enables the edge rendering mode on the mesh.
  25033. * This mode makes the mesh edges visible
  25034. * @param epsilon defines the maximal distance between two angles to detect a face
  25035. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25036. * @returns the currentAbstractMesh
  25037. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25038. */
  25039. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25040. }
  25041. }
  25042. declare module BABYLON {
  25043. /**
  25044. * Interface used to define ActionEvent
  25045. */
  25046. export interface IActionEvent {
  25047. /** The mesh or sprite that triggered the action */
  25048. source: any;
  25049. /** The X mouse cursor position at the time of the event */
  25050. pointerX: number;
  25051. /** The Y mouse cursor position at the time of the event */
  25052. pointerY: number;
  25053. /** The mesh that is currently pointed at (can be null) */
  25054. meshUnderPointer: Nullable<AbstractMesh>;
  25055. /** the original (browser) event that triggered the ActionEvent */
  25056. sourceEvent?: any;
  25057. /** additional data for the event */
  25058. additionalData?: any;
  25059. }
  25060. /**
  25061. * ActionEvent is the event being sent when an action is triggered.
  25062. */
  25063. export class ActionEvent implements IActionEvent {
  25064. /** The mesh or sprite that triggered the action */
  25065. source: any;
  25066. /** The X mouse cursor position at the time of the event */
  25067. pointerX: number;
  25068. /** The Y mouse cursor position at the time of the event */
  25069. pointerY: number;
  25070. /** The mesh that is currently pointed at (can be null) */
  25071. meshUnderPointer: Nullable<AbstractMesh>;
  25072. /** the original (browser) event that triggered the ActionEvent */
  25073. sourceEvent?: any;
  25074. /** additional data for the event */
  25075. additionalData?: any;
  25076. /**
  25077. * Creates a new ActionEvent
  25078. * @param source The mesh or sprite that triggered the action
  25079. * @param pointerX The X mouse cursor position at the time of the event
  25080. * @param pointerY The Y mouse cursor position at the time of the event
  25081. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25082. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25083. * @param additionalData additional data for the event
  25084. */
  25085. constructor(
  25086. /** The mesh or sprite that triggered the action */
  25087. source: any,
  25088. /** The X mouse cursor position at the time of the event */
  25089. pointerX: number,
  25090. /** The Y mouse cursor position at the time of the event */
  25091. pointerY: number,
  25092. /** The mesh that is currently pointed at (can be null) */
  25093. meshUnderPointer: Nullable<AbstractMesh>,
  25094. /** the original (browser) event that triggered the ActionEvent */
  25095. sourceEvent?: any,
  25096. /** additional data for the event */
  25097. additionalData?: any);
  25098. /**
  25099. * Helper function to auto-create an ActionEvent from a source mesh.
  25100. * @param source The source mesh that triggered the event
  25101. * @param evt The original (browser) event
  25102. * @param additionalData additional data for the event
  25103. * @returns the new ActionEvent
  25104. */
  25105. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25106. /**
  25107. * Helper function to auto-create an ActionEvent from a source sprite
  25108. * @param source The source sprite that triggered the event
  25109. * @param scene Scene associated with the sprite
  25110. * @param evt The original (browser) event
  25111. * @param additionalData additional data for the event
  25112. * @returns the new ActionEvent
  25113. */
  25114. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25115. /**
  25116. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25117. * @param scene the scene where the event occurred
  25118. * @param evt The original (browser) event
  25119. * @returns the new ActionEvent
  25120. */
  25121. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25122. /**
  25123. * Helper function to auto-create an ActionEvent from a primitive
  25124. * @param prim defines the target primitive
  25125. * @param pointerPos defines the pointer position
  25126. * @param evt The original (browser) event
  25127. * @param additionalData additional data for the event
  25128. * @returns the new ActionEvent
  25129. */
  25130. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25131. }
  25132. }
  25133. declare module BABYLON {
  25134. /**
  25135. * Abstract class used to decouple action Manager from scene and meshes.
  25136. * Do not instantiate.
  25137. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25138. */
  25139. export abstract class AbstractActionManager implements IDisposable {
  25140. /** Gets the list of active triggers */
  25141. static Triggers: {
  25142. [key: string]: number;
  25143. };
  25144. /** Gets the cursor to use when hovering items */
  25145. hoverCursor: string;
  25146. /** Gets the list of actions */
  25147. actions: IAction[];
  25148. /**
  25149. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25150. */
  25151. isRecursive: boolean;
  25152. /**
  25153. * Releases all associated resources
  25154. */
  25155. abstract dispose(): void;
  25156. /**
  25157. * Does this action manager has pointer triggers
  25158. */
  25159. abstract readonly hasPointerTriggers: boolean;
  25160. /**
  25161. * Does this action manager has pick triggers
  25162. */
  25163. abstract readonly hasPickTriggers: boolean;
  25164. /**
  25165. * Process a specific trigger
  25166. * @param trigger defines the trigger to process
  25167. * @param evt defines the event details to be processed
  25168. */
  25169. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25170. /**
  25171. * Does this action manager handles actions of any of the given triggers
  25172. * @param triggers defines the triggers to be tested
  25173. * @return a boolean indicating whether one (or more) of the triggers is handled
  25174. */
  25175. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25176. /**
  25177. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25178. * speed.
  25179. * @param triggerA defines the trigger to be tested
  25180. * @param triggerB defines the trigger to be tested
  25181. * @return a boolean indicating whether one (or more) of the triggers is handled
  25182. */
  25183. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25184. /**
  25185. * Does this action manager handles actions of a given trigger
  25186. * @param trigger defines the trigger to be tested
  25187. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25188. * @return whether the trigger is handled
  25189. */
  25190. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25191. /**
  25192. * Serialize this manager to a JSON object
  25193. * @param name defines the property name to store this manager
  25194. * @returns a JSON representation of this manager
  25195. */
  25196. abstract serialize(name: string): any;
  25197. /**
  25198. * Registers an action to this action manager
  25199. * @param action defines the action to be registered
  25200. * @return the action amended (prepared) after registration
  25201. */
  25202. abstract registerAction(action: IAction): Nullable<IAction>;
  25203. /**
  25204. * Unregisters an action to this action manager
  25205. * @param action defines the action to be unregistered
  25206. * @return a boolean indicating whether the action has been unregistered
  25207. */
  25208. abstract unregisterAction(action: IAction): Boolean;
  25209. /**
  25210. * Does exist one action manager with at least one trigger
  25211. **/
  25212. static readonly HasTriggers: boolean;
  25213. /**
  25214. * Does exist one action manager with at least one pick trigger
  25215. **/
  25216. static readonly HasPickTriggers: boolean;
  25217. /**
  25218. * Does exist one action manager that handles actions of a given trigger
  25219. * @param trigger defines the trigger to be tested
  25220. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25221. **/
  25222. static HasSpecificTrigger(trigger: number): boolean;
  25223. }
  25224. }
  25225. declare module BABYLON {
  25226. /**
  25227. * Defines how a node can be built from a string name.
  25228. */
  25229. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25230. /**
  25231. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25232. */
  25233. export class Node implements IBehaviorAware<Node> {
  25234. /** @hidden */
  25235. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  25236. private static _NodeConstructors;
  25237. /**
  25238. * Add a new node constructor
  25239. * @param type defines the type name of the node to construct
  25240. * @param constructorFunc defines the constructor function
  25241. */
  25242. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25243. /**
  25244. * Returns a node constructor based on type name
  25245. * @param type defines the type name
  25246. * @param name defines the new node name
  25247. * @param scene defines the hosting scene
  25248. * @param options defines optional options to transmit to constructors
  25249. * @returns the new constructor or null
  25250. */
  25251. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25252. /**
  25253. * Gets or sets the name of the node
  25254. */
  25255. name: string;
  25256. /**
  25257. * Gets or sets the id of the node
  25258. */
  25259. id: string;
  25260. /**
  25261. * Gets or sets the unique id of the node
  25262. */
  25263. uniqueId: number;
  25264. /**
  25265. * Gets or sets a string used to store user defined state for the node
  25266. */
  25267. state: string;
  25268. /**
  25269. * Gets or sets an object used to store user defined information for the node
  25270. */
  25271. metadata: any;
  25272. /**
  25273. * For internal use only. Please do not use.
  25274. */
  25275. reservedDataStore: any;
  25276. /**
  25277. * List of inspectable custom properties (used by the Inspector)
  25278. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25279. */
  25280. inspectableCustomProperties: IInspectable[];
  25281. /**
  25282. * Gets or sets a boolean used to define if the node must be serialized
  25283. */
  25284. doNotSerialize: boolean;
  25285. /** @hidden */
  25286. _isDisposed: boolean;
  25287. /**
  25288. * Gets a list of Animations associated with the node
  25289. */
  25290. animations: Animation[];
  25291. protected _ranges: {
  25292. [name: string]: Nullable<AnimationRange>;
  25293. };
  25294. /**
  25295. * Callback raised when the node is ready to be used
  25296. */
  25297. onReady: Nullable<(node: Node) => void>;
  25298. private _isEnabled;
  25299. private _isParentEnabled;
  25300. private _isReady;
  25301. /** @hidden */
  25302. _currentRenderId: number;
  25303. private _parentUpdateId;
  25304. /** @hidden */
  25305. _childUpdateId: number;
  25306. /** @hidden */
  25307. _waitingParentId: Nullable<string>;
  25308. /** @hidden */
  25309. _scene: Scene;
  25310. /** @hidden */
  25311. _cache: any;
  25312. private _parentNode;
  25313. private _children;
  25314. /** @hidden */
  25315. _worldMatrix: Matrix;
  25316. /** @hidden */
  25317. _worldMatrixDeterminant: number;
  25318. /** @hidden */
  25319. _worldMatrixDeterminantIsDirty: boolean;
  25320. /** @hidden */
  25321. private _sceneRootNodesIndex;
  25322. /**
  25323. * Gets a boolean indicating if the node has been disposed
  25324. * @returns true if the node was disposed
  25325. */
  25326. isDisposed(): boolean;
  25327. /**
  25328. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25329. * @see https://doc.babylonjs.com/how_to/parenting
  25330. */
  25331. parent: Nullable<Node>;
  25332. private addToSceneRootNodes;
  25333. private removeFromSceneRootNodes;
  25334. private _animationPropertiesOverride;
  25335. /**
  25336. * Gets or sets the animation properties override
  25337. */
  25338. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25339. /**
  25340. * Gets a string idenfifying the name of the class
  25341. * @returns "Node" string
  25342. */
  25343. getClassName(): string;
  25344. /** @hidden */
  25345. readonly _isNode: boolean;
  25346. /**
  25347. * An event triggered when the mesh is disposed
  25348. */
  25349. onDisposeObservable: Observable<Node>;
  25350. private _onDisposeObserver;
  25351. /**
  25352. * Sets a callback that will be raised when the node will be disposed
  25353. */
  25354. onDispose: () => void;
  25355. /**
  25356. * Creates a new Node
  25357. * @param name the name and id to be given to this node
  25358. * @param scene the scene this node will be added to
  25359. * @param addToRootNodes the node will be added to scene.rootNodes
  25360. */
  25361. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25362. /**
  25363. * Gets the scene of the node
  25364. * @returns a scene
  25365. */
  25366. getScene(): Scene;
  25367. /**
  25368. * Gets the engine of the node
  25369. * @returns a Engine
  25370. */
  25371. getEngine(): Engine;
  25372. private _behaviors;
  25373. /**
  25374. * Attach a behavior to the node
  25375. * @see http://doc.babylonjs.com/features/behaviour
  25376. * @param behavior defines the behavior to attach
  25377. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25378. * @returns the current Node
  25379. */
  25380. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25381. /**
  25382. * Remove an attached behavior
  25383. * @see http://doc.babylonjs.com/features/behaviour
  25384. * @param behavior defines the behavior to attach
  25385. * @returns the current Node
  25386. */
  25387. removeBehavior(behavior: Behavior<Node>): Node;
  25388. /**
  25389. * Gets the list of attached behaviors
  25390. * @see http://doc.babylonjs.com/features/behaviour
  25391. */
  25392. readonly behaviors: Behavior<Node>[];
  25393. /**
  25394. * Gets an attached behavior by name
  25395. * @param name defines the name of the behavior to look for
  25396. * @see http://doc.babylonjs.com/features/behaviour
  25397. * @returns null if behavior was not found else the requested behavior
  25398. */
  25399. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25400. /**
  25401. * Returns the latest update of the World matrix
  25402. * @returns a Matrix
  25403. */
  25404. getWorldMatrix(): Matrix;
  25405. /** @hidden */
  25406. _getWorldMatrixDeterminant(): number;
  25407. /**
  25408. * Returns directly the latest state of the mesh World matrix.
  25409. * A Matrix is returned.
  25410. */
  25411. readonly worldMatrixFromCache: Matrix;
  25412. /** @hidden */
  25413. _initCache(): void;
  25414. /** @hidden */
  25415. updateCache(force?: boolean): void;
  25416. /** @hidden */
  25417. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25418. /** @hidden */
  25419. _updateCache(ignoreParentClass?: boolean): void;
  25420. /** @hidden */
  25421. _isSynchronized(): boolean;
  25422. /** @hidden */
  25423. _markSyncedWithParent(): void;
  25424. /** @hidden */
  25425. isSynchronizedWithParent(): boolean;
  25426. /** @hidden */
  25427. isSynchronized(): boolean;
  25428. /**
  25429. * Is this node ready to be used/rendered
  25430. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25431. * @return true if the node is ready
  25432. */
  25433. isReady(completeCheck?: boolean): boolean;
  25434. /**
  25435. * Is this node enabled?
  25436. * 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
  25437. * @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
  25438. * @return whether this node (and its parent) is enabled
  25439. */
  25440. isEnabled(checkAncestors?: boolean): boolean;
  25441. /** @hidden */
  25442. protected _syncParentEnabledState(): void;
  25443. /**
  25444. * Set the enabled state of this node
  25445. * @param value defines the new enabled state
  25446. */
  25447. setEnabled(value: boolean): void;
  25448. /**
  25449. * Is this node a descendant of the given node?
  25450. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25451. * @param ancestor defines the parent node to inspect
  25452. * @returns a boolean indicating if this node is a descendant of the given node
  25453. */
  25454. isDescendantOf(ancestor: Node): boolean;
  25455. /** @hidden */
  25456. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25457. /**
  25458. * Will return all nodes that have this node as ascendant
  25459. * @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
  25460. * @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
  25461. * @return all children nodes of all types
  25462. */
  25463. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25464. /**
  25465. * Get all child-meshes of this node
  25466. * @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)
  25467. * @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
  25468. * @returns an array of AbstractMesh
  25469. */
  25470. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25471. /**
  25472. * Get all direct children of this node
  25473. * @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
  25474. * @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)
  25475. * @returns an array of Node
  25476. */
  25477. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25478. /** @hidden */
  25479. _setReady(state: boolean): void;
  25480. /**
  25481. * Get an animation by name
  25482. * @param name defines the name of the animation to look for
  25483. * @returns null if not found else the requested animation
  25484. */
  25485. getAnimationByName(name: string): Nullable<Animation>;
  25486. /**
  25487. * Creates an animation range for this node
  25488. * @param name defines the name of the range
  25489. * @param from defines the starting key
  25490. * @param to defines the end key
  25491. */
  25492. createAnimationRange(name: string, from: number, to: number): void;
  25493. /**
  25494. * Delete a specific animation range
  25495. * @param name defines the name of the range to delete
  25496. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25497. */
  25498. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25499. /**
  25500. * Get an animation range by name
  25501. * @param name defines the name of the animation range to look for
  25502. * @returns null if not found else the requested animation range
  25503. */
  25504. getAnimationRange(name: string): Nullable<AnimationRange>;
  25505. /**
  25506. * Gets the list of all animation ranges defined on this node
  25507. * @returns an array
  25508. */
  25509. getAnimationRanges(): Nullable<AnimationRange>[];
  25510. /**
  25511. * Will start the animation sequence
  25512. * @param name defines the range frames for animation sequence
  25513. * @param loop defines if the animation should loop (false by default)
  25514. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25515. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25516. * @returns the object created for this animation. If range does not exist, it will return null
  25517. */
  25518. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25519. /**
  25520. * Serialize animation ranges into a JSON compatible object
  25521. * @returns serialization object
  25522. */
  25523. serializeAnimationRanges(): any;
  25524. /**
  25525. * Computes the world matrix of the node
  25526. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25527. * @returns the world matrix
  25528. */
  25529. computeWorldMatrix(force?: boolean): Matrix;
  25530. /**
  25531. * Releases resources associated with this node.
  25532. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25533. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25534. */
  25535. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25536. /**
  25537. * Parse animation range data from a serialization object and store them into a given node
  25538. * @param node defines where to store the animation ranges
  25539. * @param parsedNode defines the serialization object to read data from
  25540. * @param scene defines the hosting scene
  25541. */
  25542. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25543. /**
  25544. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25545. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25546. * @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
  25547. * @returns the new bounding vectors
  25548. */
  25549. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25550. min: Vector3;
  25551. max: Vector3;
  25552. };
  25553. }
  25554. }
  25555. declare module BABYLON {
  25556. /**
  25557. * @hidden
  25558. */
  25559. export class _IAnimationState {
  25560. key: number;
  25561. repeatCount: number;
  25562. workValue?: any;
  25563. loopMode?: number;
  25564. offsetValue?: any;
  25565. highLimitValue?: any;
  25566. }
  25567. /**
  25568. * Class used to store any kind of animation
  25569. */
  25570. export class Animation {
  25571. /**Name of the animation */
  25572. name: string;
  25573. /**Property to animate */
  25574. targetProperty: string;
  25575. /**The frames per second of the animation */
  25576. framePerSecond: number;
  25577. /**The data type of the animation */
  25578. dataType: number;
  25579. /**The loop mode of the animation */
  25580. loopMode?: number | undefined;
  25581. /**Specifies if blending should be enabled */
  25582. enableBlending?: boolean | undefined;
  25583. /**
  25584. * Use matrix interpolation instead of using direct key value when animating matrices
  25585. */
  25586. static AllowMatricesInterpolation: boolean;
  25587. /**
  25588. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25589. */
  25590. static AllowMatrixDecomposeForInterpolation: boolean;
  25591. /**
  25592. * Stores the key frames of the animation
  25593. */
  25594. private _keys;
  25595. /**
  25596. * Stores the easing function of the animation
  25597. */
  25598. private _easingFunction;
  25599. /**
  25600. * @hidden Internal use only
  25601. */
  25602. _runtimeAnimations: RuntimeAnimation[];
  25603. /**
  25604. * The set of event that will be linked to this animation
  25605. */
  25606. private _events;
  25607. /**
  25608. * Stores an array of target property paths
  25609. */
  25610. targetPropertyPath: string[];
  25611. /**
  25612. * Stores the blending speed of the animation
  25613. */
  25614. blendingSpeed: number;
  25615. /**
  25616. * Stores the animation ranges for the animation
  25617. */
  25618. private _ranges;
  25619. /**
  25620. * @hidden Internal use
  25621. */
  25622. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25623. /**
  25624. * Sets up an animation
  25625. * @param property The property to animate
  25626. * @param animationType The animation type to apply
  25627. * @param framePerSecond The frames per second of the animation
  25628. * @param easingFunction The easing function used in the animation
  25629. * @returns The created animation
  25630. */
  25631. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25632. /**
  25633. * Create and start an animation on a node
  25634. * @param name defines the name of the global animation that will be run on all nodes
  25635. * @param node defines the root node where the animation will take place
  25636. * @param targetProperty defines property to animate
  25637. * @param framePerSecond defines the number of frame per second yo use
  25638. * @param totalFrame defines the number of frames in total
  25639. * @param from defines the initial value
  25640. * @param to defines the final value
  25641. * @param loopMode defines which loop mode you want to use (off by default)
  25642. * @param easingFunction defines the easing function to use (linear by default)
  25643. * @param onAnimationEnd defines the callback to call when animation end
  25644. * @returns the animatable created for this animation
  25645. */
  25646. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25647. /**
  25648. * Create and start an animation on a node and its descendants
  25649. * @param name defines the name of the global animation that will be run on all nodes
  25650. * @param node defines the root node where the animation will take place
  25651. * @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
  25652. * @param targetProperty defines property to animate
  25653. * @param framePerSecond defines the number of frame per second to use
  25654. * @param totalFrame defines the number of frames in total
  25655. * @param from defines the initial value
  25656. * @param to defines the final value
  25657. * @param loopMode defines which loop mode you want to use (off by default)
  25658. * @param easingFunction defines the easing function to use (linear by default)
  25659. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25660. * @returns the list of animatables created for all nodes
  25661. * @example https://www.babylonjs-playground.com/#MH0VLI
  25662. */
  25663. 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[]>;
  25664. /**
  25665. * Creates a new animation, merges it with the existing animations and starts it
  25666. * @param name Name of the animation
  25667. * @param node Node which contains the scene that begins the animations
  25668. * @param targetProperty Specifies which property to animate
  25669. * @param framePerSecond The frames per second of the animation
  25670. * @param totalFrame The total number of frames
  25671. * @param from The frame at the beginning of the animation
  25672. * @param to The frame at the end of the animation
  25673. * @param loopMode Specifies the loop mode of the animation
  25674. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25675. * @param onAnimationEnd Callback to run once the animation is complete
  25676. * @returns Nullable animation
  25677. */
  25678. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25679. /**
  25680. * Transition property of an host to the target Value
  25681. * @param property The property to transition
  25682. * @param targetValue The target Value of the property
  25683. * @param host The object where the property to animate belongs
  25684. * @param scene Scene used to run the animation
  25685. * @param frameRate Framerate (in frame/s) to use
  25686. * @param transition The transition type we want to use
  25687. * @param duration The duration of the animation, in milliseconds
  25688. * @param onAnimationEnd Callback trigger at the end of the animation
  25689. * @returns Nullable animation
  25690. */
  25691. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25692. /**
  25693. * Return the array of runtime animations currently using this animation
  25694. */
  25695. readonly runtimeAnimations: RuntimeAnimation[];
  25696. /**
  25697. * Specifies if any of the runtime animations are currently running
  25698. */
  25699. readonly hasRunningRuntimeAnimations: boolean;
  25700. /**
  25701. * Initializes the animation
  25702. * @param name Name of the animation
  25703. * @param targetProperty Property to animate
  25704. * @param framePerSecond The frames per second of the animation
  25705. * @param dataType The data type of the animation
  25706. * @param loopMode The loop mode of the animation
  25707. * @param enableBlending Specifies if blending should be enabled
  25708. */
  25709. constructor(
  25710. /**Name of the animation */
  25711. name: string,
  25712. /**Property to animate */
  25713. targetProperty: string,
  25714. /**The frames per second of the animation */
  25715. framePerSecond: number,
  25716. /**The data type of the animation */
  25717. dataType: number,
  25718. /**The loop mode of the animation */
  25719. loopMode?: number | undefined,
  25720. /**Specifies if blending should be enabled */
  25721. enableBlending?: boolean | undefined);
  25722. /**
  25723. * Converts the animation to a string
  25724. * @param fullDetails support for multiple levels of logging within scene loading
  25725. * @returns String form of the animation
  25726. */
  25727. toString(fullDetails?: boolean): string;
  25728. /**
  25729. * Add an event to this animation
  25730. * @param event Event to add
  25731. */
  25732. addEvent(event: AnimationEvent): void;
  25733. /**
  25734. * Remove all events found at the given frame
  25735. * @param frame The frame to remove events from
  25736. */
  25737. removeEvents(frame: number): void;
  25738. /**
  25739. * Retrieves all the events from the animation
  25740. * @returns Events from the animation
  25741. */
  25742. getEvents(): AnimationEvent[];
  25743. /**
  25744. * Creates an animation range
  25745. * @param name Name of the animation range
  25746. * @param from Starting frame of the animation range
  25747. * @param to Ending frame of the animation
  25748. */
  25749. createRange(name: string, from: number, to: number): void;
  25750. /**
  25751. * Deletes an animation range by name
  25752. * @param name Name of the animation range to delete
  25753. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25754. */
  25755. deleteRange(name: string, deleteFrames?: boolean): void;
  25756. /**
  25757. * Gets the animation range by name, or null if not defined
  25758. * @param name Name of the animation range
  25759. * @returns Nullable animation range
  25760. */
  25761. getRange(name: string): Nullable<AnimationRange>;
  25762. /**
  25763. * Gets the key frames from the animation
  25764. * @returns The key frames of the animation
  25765. */
  25766. getKeys(): Array<IAnimationKey>;
  25767. /**
  25768. * Gets the highest frame rate of the animation
  25769. * @returns Highest frame rate of the animation
  25770. */
  25771. getHighestFrame(): number;
  25772. /**
  25773. * Gets the easing function of the animation
  25774. * @returns Easing function of the animation
  25775. */
  25776. getEasingFunction(): IEasingFunction;
  25777. /**
  25778. * Sets the easing function of the animation
  25779. * @param easingFunction A custom mathematical formula for animation
  25780. */
  25781. setEasingFunction(easingFunction: EasingFunction): void;
  25782. /**
  25783. * Interpolates a scalar linearly
  25784. * @param startValue Start value of the animation curve
  25785. * @param endValue End value of the animation curve
  25786. * @param gradient Scalar amount to interpolate
  25787. * @returns Interpolated scalar value
  25788. */
  25789. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25790. /**
  25791. * Interpolates a scalar cubically
  25792. * @param startValue Start value of the animation curve
  25793. * @param outTangent End tangent of the animation
  25794. * @param endValue End value of the animation curve
  25795. * @param inTangent Start tangent of the animation curve
  25796. * @param gradient Scalar amount to interpolate
  25797. * @returns Interpolated scalar value
  25798. */
  25799. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25800. /**
  25801. * Interpolates a quaternion using a spherical linear interpolation
  25802. * @param startValue Start value of the animation curve
  25803. * @param endValue End value of the animation curve
  25804. * @param gradient Scalar amount to interpolate
  25805. * @returns Interpolated quaternion value
  25806. */
  25807. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25808. /**
  25809. * Interpolates a quaternion cubically
  25810. * @param startValue Start value of the animation curve
  25811. * @param outTangent End tangent of the animation curve
  25812. * @param endValue End value of the animation curve
  25813. * @param inTangent Start tangent of the animation curve
  25814. * @param gradient Scalar amount to interpolate
  25815. * @returns Interpolated quaternion value
  25816. */
  25817. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25818. /**
  25819. * Interpolates a Vector3 linearl
  25820. * @param startValue Start value of the animation curve
  25821. * @param endValue End value of the animation curve
  25822. * @param gradient Scalar amount to interpolate
  25823. * @returns Interpolated scalar value
  25824. */
  25825. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25826. /**
  25827. * Interpolates a Vector3 cubically
  25828. * @param startValue Start value of the animation curve
  25829. * @param outTangent End tangent of the animation
  25830. * @param endValue End value of the animation curve
  25831. * @param inTangent Start tangent of the animation curve
  25832. * @param gradient Scalar amount to interpolate
  25833. * @returns InterpolatedVector3 value
  25834. */
  25835. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25836. /**
  25837. * Interpolates a Vector2 linearly
  25838. * @param startValue Start value of the animation curve
  25839. * @param endValue End value of the animation curve
  25840. * @param gradient Scalar amount to interpolate
  25841. * @returns Interpolated Vector2 value
  25842. */
  25843. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25844. /**
  25845. * Interpolates a Vector2 cubically
  25846. * @param startValue Start value of the animation curve
  25847. * @param outTangent End tangent of the animation
  25848. * @param endValue End value of the animation curve
  25849. * @param inTangent Start tangent of the animation curve
  25850. * @param gradient Scalar amount to interpolate
  25851. * @returns Interpolated Vector2 value
  25852. */
  25853. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25854. /**
  25855. * Interpolates a size linearly
  25856. * @param startValue Start value of the animation curve
  25857. * @param endValue End value of the animation curve
  25858. * @param gradient Scalar amount to interpolate
  25859. * @returns Interpolated Size value
  25860. */
  25861. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25862. /**
  25863. * Interpolates a Color3 linearly
  25864. * @param startValue Start value of the animation curve
  25865. * @param endValue End value of the animation curve
  25866. * @param gradient Scalar amount to interpolate
  25867. * @returns Interpolated Color3 value
  25868. */
  25869. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25870. /**
  25871. * @hidden Internal use only
  25872. */
  25873. _getKeyValue(value: any): any;
  25874. /**
  25875. * @hidden Internal use only
  25876. */
  25877. _interpolate(currentFrame: number, state: _IAnimationState): any;
  25878. /**
  25879. * Defines the function to use to interpolate matrices
  25880. * @param startValue defines the start matrix
  25881. * @param endValue defines the end matrix
  25882. * @param gradient defines the gradient between both matrices
  25883. * @param result defines an optional target matrix where to store the interpolation
  25884. * @returns the interpolated matrix
  25885. */
  25886. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25887. /**
  25888. * Makes a copy of the animation
  25889. * @returns Cloned animation
  25890. */
  25891. clone(): Animation;
  25892. /**
  25893. * Sets the key frames of the animation
  25894. * @param values The animation key frames to set
  25895. */
  25896. setKeys(values: Array<IAnimationKey>): void;
  25897. /**
  25898. * Serializes the animation to an object
  25899. * @returns Serialized object
  25900. */
  25901. serialize(): any;
  25902. /**
  25903. * Float animation type
  25904. */
  25905. private static _ANIMATIONTYPE_FLOAT;
  25906. /**
  25907. * Vector3 animation type
  25908. */
  25909. private static _ANIMATIONTYPE_VECTOR3;
  25910. /**
  25911. * Quaternion animation type
  25912. */
  25913. private static _ANIMATIONTYPE_QUATERNION;
  25914. /**
  25915. * Matrix animation type
  25916. */
  25917. private static _ANIMATIONTYPE_MATRIX;
  25918. /**
  25919. * Color3 animation type
  25920. */
  25921. private static _ANIMATIONTYPE_COLOR3;
  25922. /**
  25923. * Vector2 animation type
  25924. */
  25925. private static _ANIMATIONTYPE_VECTOR2;
  25926. /**
  25927. * Size animation type
  25928. */
  25929. private static _ANIMATIONTYPE_SIZE;
  25930. /**
  25931. * Relative Loop Mode
  25932. */
  25933. private static _ANIMATIONLOOPMODE_RELATIVE;
  25934. /**
  25935. * Cycle Loop Mode
  25936. */
  25937. private static _ANIMATIONLOOPMODE_CYCLE;
  25938. /**
  25939. * Constant Loop Mode
  25940. */
  25941. private static _ANIMATIONLOOPMODE_CONSTANT;
  25942. /**
  25943. * Get the float animation type
  25944. */
  25945. static readonly ANIMATIONTYPE_FLOAT: number;
  25946. /**
  25947. * Get the Vector3 animation type
  25948. */
  25949. static readonly ANIMATIONTYPE_VECTOR3: number;
  25950. /**
  25951. * Get the Vector2 animation type
  25952. */
  25953. static readonly ANIMATIONTYPE_VECTOR2: number;
  25954. /**
  25955. * Get the Size animation type
  25956. */
  25957. static readonly ANIMATIONTYPE_SIZE: number;
  25958. /**
  25959. * Get the Quaternion animation type
  25960. */
  25961. static readonly ANIMATIONTYPE_QUATERNION: number;
  25962. /**
  25963. * Get the Matrix animation type
  25964. */
  25965. static readonly ANIMATIONTYPE_MATRIX: number;
  25966. /**
  25967. * Get the Color3 animation type
  25968. */
  25969. static readonly ANIMATIONTYPE_COLOR3: number;
  25970. /**
  25971. * Get the Relative Loop Mode
  25972. */
  25973. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25974. /**
  25975. * Get the Cycle Loop Mode
  25976. */
  25977. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25978. /**
  25979. * Get the Constant Loop Mode
  25980. */
  25981. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25982. /** @hidden */
  25983. static _UniversalLerp(left: any, right: any, amount: number): any;
  25984. /**
  25985. * Parses an animation object and creates an animation
  25986. * @param parsedAnimation Parsed animation object
  25987. * @returns Animation object
  25988. */
  25989. static Parse(parsedAnimation: any): Animation;
  25990. /**
  25991. * Appends the serialized animations from the source animations
  25992. * @param source Source containing the animations
  25993. * @param destination Target to store the animations
  25994. */
  25995. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25996. }
  25997. }
  25998. declare module BABYLON {
  25999. /**
  26000. * Base class of all the textures in babylon.
  26001. * It groups all the common properties the materials, post process, lights... might need
  26002. * in order to make a correct use of the texture.
  26003. */
  26004. export class BaseTexture implements IAnimatable {
  26005. /**
  26006. * Default anisotropic filtering level for the application.
  26007. * It is set to 4 as a good tradeoff between perf and quality.
  26008. */
  26009. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26010. /**
  26011. * Gets or sets the unique id of the texture
  26012. */
  26013. uniqueId: number;
  26014. /**
  26015. * Define the name of the texture.
  26016. */
  26017. name: string;
  26018. /**
  26019. * Gets or sets an object used to store user defined information.
  26020. */
  26021. metadata: any;
  26022. /**
  26023. * For internal use only. Please do not use.
  26024. */
  26025. reservedDataStore: any;
  26026. private _hasAlpha;
  26027. /**
  26028. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26029. */
  26030. hasAlpha: boolean;
  26031. /**
  26032. * Defines if the alpha value should be determined via the rgb values.
  26033. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26034. */
  26035. getAlphaFromRGB: boolean;
  26036. /**
  26037. * Intensity or strength of the texture.
  26038. * It is commonly used by materials to fine tune the intensity of the texture
  26039. */
  26040. level: number;
  26041. /**
  26042. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26043. * This is part of the texture as textures usually maps to one uv set.
  26044. */
  26045. coordinatesIndex: number;
  26046. private _coordinatesMode;
  26047. /**
  26048. * How a texture is mapped.
  26049. *
  26050. * | Value | Type | Description |
  26051. * | ----- | ----------------------------------- | ----------- |
  26052. * | 0 | EXPLICIT_MODE | |
  26053. * | 1 | SPHERICAL_MODE | |
  26054. * | 2 | PLANAR_MODE | |
  26055. * | 3 | CUBIC_MODE | |
  26056. * | 4 | PROJECTION_MODE | |
  26057. * | 5 | SKYBOX_MODE | |
  26058. * | 6 | INVCUBIC_MODE | |
  26059. * | 7 | EQUIRECTANGULAR_MODE | |
  26060. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26061. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26062. */
  26063. coordinatesMode: number;
  26064. /**
  26065. * | Value | Type | Description |
  26066. * | ----- | ------------------ | ----------- |
  26067. * | 0 | CLAMP_ADDRESSMODE | |
  26068. * | 1 | WRAP_ADDRESSMODE | |
  26069. * | 2 | MIRROR_ADDRESSMODE | |
  26070. */
  26071. wrapU: number;
  26072. /**
  26073. * | Value | Type | Description |
  26074. * | ----- | ------------------ | ----------- |
  26075. * | 0 | CLAMP_ADDRESSMODE | |
  26076. * | 1 | WRAP_ADDRESSMODE | |
  26077. * | 2 | MIRROR_ADDRESSMODE | |
  26078. */
  26079. wrapV: number;
  26080. /**
  26081. * | Value | Type | Description |
  26082. * | ----- | ------------------ | ----------- |
  26083. * | 0 | CLAMP_ADDRESSMODE | |
  26084. * | 1 | WRAP_ADDRESSMODE | |
  26085. * | 2 | MIRROR_ADDRESSMODE | |
  26086. */
  26087. wrapR: number;
  26088. /**
  26089. * With compliant hardware and browser (supporting anisotropic filtering)
  26090. * this defines the level of anisotropic filtering in the texture.
  26091. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26092. */
  26093. anisotropicFilteringLevel: number;
  26094. /**
  26095. * Define if the texture is a cube texture or if false a 2d texture.
  26096. */
  26097. isCube: boolean;
  26098. /**
  26099. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26100. */
  26101. is3D: boolean;
  26102. /**
  26103. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26104. * HDR texture are usually stored in linear space.
  26105. * This only impacts the PBR and Background materials
  26106. */
  26107. gammaSpace: boolean;
  26108. /**
  26109. * Gets whether or not the texture contains RGBD data.
  26110. */
  26111. readonly isRGBD: boolean;
  26112. /**
  26113. * Is Z inverted in the texture (useful in a cube texture).
  26114. */
  26115. invertZ: boolean;
  26116. /**
  26117. * Are mip maps generated for this texture or not.
  26118. */
  26119. readonly noMipmap: boolean;
  26120. /**
  26121. * @hidden
  26122. */
  26123. lodLevelInAlpha: boolean;
  26124. /**
  26125. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26126. */
  26127. lodGenerationOffset: number;
  26128. /**
  26129. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26130. */
  26131. lodGenerationScale: number;
  26132. /**
  26133. * Define if the texture is a render target.
  26134. */
  26135. isRenderTarget: boolean;
  26136. /**
  26137. * Define the unique id of the texture in the scene.
  26138. */
  26139. readonly uid: string;
  26140. /**
  26141. * Return a string representation of the texture.
  26142. * @returns the texture as a string
  26143. */
  26144. toString(): string;
  26145. /**
  26146. * Get the class name of the texture.
  26147. * @returns "BaseTexture"
  26148. */
  26149. getClassName(): string;
  26150. /**
  26151. * Define the list of animation attached to the texture.
  26152. */
  26153. animations: Animation[];
  26154. /**
  26155. * An event triggered when the texture is disposed.
  26156. */
  26157. onDisposeObservable: Observable<BaseTexture>;
  26158. private _onDisposeObserver;
  26159. /**
  26160. * Callback triggered when the texture has been disposed.
  26161. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26162. */
  26163. onDispose: () => void;
  26164. /**
  26165. * Define the current state of the loading sequence when in delayed load mode.
  26166. */
  26167. delayLoadState: number;
  26168. private _scene;
  26169. /** @hidden */
  26170. _texture: Nullable<InternalTexture>;
  26171. private _uid;
  26172. /**
  26173. * Define if the texture is preventinga material to render or not.
  26174. * If not and the texture is not ready, the engine will use a default black texture instead.
  26175. */
  26176. readonly isBlocking: boolean;
  26177. /**
  26178. * Instantiates a new BaseTexture.
  26179. * Base class of all the textures in babylon.
  26180. * It groups all the common properties the materials, post process, lights... might need
  26181. * in order to make a correct use of the texture.
  26182. * @param scene Define the scene the texture blongs to
  26183. */
  26184. constructor(scene: Nullable<Scene>);
  26185. /**
  26186. * Get the scene the texture belongs to.
  26187. * @returns the scene or null if undefined
  26188. */
  26189. getScene(): Nullable<Scene>;
  26190. /**
  26191. * Get the texture transform matrix used to offset tile the texture for istance.
  26192. * @returns the transformation matrix
  26193. */
  26194. getTextureMatrix(): Matrix;
  26195. /**
  26196. * Get the texture reflection matrix used to rotate/transform the reflection.
  26197. * @returns the reflection matrix
  26198. */
  26199. getReflectionTextureMatrix(): Matrix;
  26200. /**
  26201. * Get the underlying lower level texture from Babylon.
  26202. * @returns the insternal texture
  26203. */
  26204. getInternalTexture(): Nullable<InternalTexture>;
  26205. /**
  26206. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26207. * @returns true if ready or not blocking
  26208. */
  26209. isReadyOrNotBlocking(): boolean;
  26210. /**
  26211. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26212. * @returns true if fully ready
  26213. */
  26214. isReady(): boolean;
  26215. private _cachedSize;
  26216. /**
  26217. * Get the size of the texture.
  26218. * @returns the texture size.
  26219. */
  26220. getSize(): ISize;
  26221. /**
  26222. * Get the base size of the texture.
  26223. * It can be different from the size if the texture has been resized for POT for instance
  26224. * @returns the base size
  26225. */
  26226. getBaseSize(): ISize;
  26227. /**
  26228. * Update the sampling mode of the texture.
  26229. * Default is Trilinear mode.
  26230. *
  26231. * | Value | Type | Description |
  26232. * | ----- | ------------------ | ----------- |
  26233. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26234. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26235. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26236. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26237. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26238. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26239. * | 7 | NEAREST_LINEAR | |
  26240. * | 8 | NEAREST_NEAREST | |
  26241. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26242. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26243. * | 11 | LINEAR_LINEAR | |
  26244. * | 12 | LINEAR_NEAREST | |
  26245. *
  26246. * > _mag_: magnification filter (close to the viewer)
  26247. * > _min_: minification filter (far from the viewer)
  26248. * > _mip_: filter used between mip map levels
  26249. *@param samplingMode Define the new sampling mode of the texture
  26250. */
  26251. updateSamplingMode(samplingMode: number): void;
  26252. /**
  26253. * Scales the texture if is `canRescale()`
  26254. * @param ratio the resize factor we want to use to rescale
  26255. */
  26256. scale(ratio: number): void;
  26257. /**
  26258. * Get if the texture can rescale.
  26259. */
  26260. readonly canRescale: boolean;
  26261. /** @hidden */
  26262. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26263. /** @hidden */
  26264. _rebuild(): void;
  26265. /**
  26266. * Triggers the load sequence in delayed load mode.
  26267. */
  26268. delayLoad(): void;
  26269. /**
  26270. * Clones the texture.
  26271. * @returns the cloned texture
  26272. */
  26273. clone(): Nullable<BaseTexture>;
  26274. /**
  26275. * Get the texture underlying type (INT, FLOAT...)
  26276. */
  26277. readonly textureType: number;
  26278. /**
  26279. * Get the texture underlying format (RGB, RGBA...)
  26280. */
  26281. readonly textureFormat: number;
  26282. /**
  26283. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26284. * This will returns an RGBA array buffer containing either in values (0-255) or
  26285. * float values (0-1) depending of the underlying buffer type.
  26286. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26287. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26288. * @param buffer defines a user defined buffer to fill with data (can be null)
  26289. * @returns The Array buffer containing the pixels data.
  26290. */
  26291. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26292. /**
  26293. * Release and destroy the underlying lower level texture aka internalTexture.
  26294. */
  26295. releaseInternalTexture(): void;
  26296. /**
  26297. * Get the polynomial representation of the texture data.
  26298. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26299. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26300. */
  26301. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26302. /** @hidden */
  26303. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26304. /** @hidden */
  26305. readonly _lodTextureMid: Nullable<BaseTexture>;
  26306. /** @hidden */
  26307. readonly _lodTextureLow: Nullable<BaseTexture>;
  26308. /**
  26309. * Dispose the texture and release its associated resources.
  26310. */
  26311. dispose(): void;
  26312. /**
  26313. * Serialize the texture into a JSON representation that can be parsed later on.
  26314. * @returns the JSON representation of the texture
  26315. */
  26316. serialize(): any;
  26317. /**
  26318. * Helper function to be called back once a list of texture contains only ready textures.
  26319. * @param textures Define the list of textures to wait for
  26320. * @param callback Define the callback triggered once the entire list will be ready
  26321. */
  26322. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26323. }
  26324. }
  26325. declare module BABYLON {
  26326. /**
  26327. * Uniform buffer objects.
  26328. *
  26329. * Handles blocks of uniform on the GPU.
  26330. *
  26331. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26332. *
  26333. * For more information, please refer to :
  26334. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26335. */
  26336. export class UniformBuffer {
  26337. private _engine;
  26338. private _buffer;
  26339. private _data;
  26340. private _bufferData;
  26341. private _dynamic?;
  26342. private _uniformLocations;
  26343. private _uniformSizes;
  26344. private _uniformLocationPointer;
  26345. private _needSync;
  26346. private _noUBO;
  26347. private _currentEffect;
  26348. private static _MAX_UNIFORM_SIZE;
  26349. private static _tempBuffer;
  26350. /**
  26351. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26352. * This is dynamic to allow compat with webgl 1 and 2.
  26353. * You will need to pass the name of the uniform as well as the value.
  26354. */
  26355. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26356. /**
  26357. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26358. * This is dynamic to allow compat with webgl 1 and 2.
  26359. * You will need to pass the name of the uniform as well as the value.
  26360. */
  26361. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26362. /**
  26363. * Lambda to Update a single float in a uniform buffer.
  26364. * This is dynamic to allow compat with webgl 1 and 2.
  26365. * You will need to pass the name of the uniform as well as the value.
  26366. */
  26367. updateFloat: (name: string, x: number) => void;
  26368. /**
  26369. * Lambda to Update a vec2 of float in a uniform buffer.
  26370. * This is dynamic to allow compat with webgl 1 and 2.
  26371. * You will need to pass the name of the uniform as well as the value.
  26372. */
  26373. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26374. /**
  26375. * Lambda to Update a vec3 of float in a uniform buffer.
  26376. * This is dynamic to allow compat with webgl 1 and 2.
  26377. * You will need to pass the name of the uniform as well as the value.
  26378. */
  26379. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26380. /**
  26381. * Lambda to Update a vec4 of float in a uniform buffer.
  26382. * This is dynamic to allow compat with webgl 1 and 2.
  26383. * You will need to pass the name of the uniform as well as the value.
  26384. */
  26385. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26386. /**
  26387. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26388. * This is dynamic to allow compat with webgl 1 and 2.
  26389. * You will need to pass the name of the uniform as well as the value.
  26390. */
  26391. updateMatrix: (name: string, mat: Matrix) => void;
  26392. /**
  26393. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26394. * This is dynamic to allow compat with webgl 1 and 2.
  26395. * You will need to pass the name of the uniform as well as the value.
  26396. */
  26397. updateVector3: (name: string, vector: Vector3) => void;
  26398. /**
  26399. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26400. * This is dynamic to allow compat with webgl 1 and 2.
  26401. * You will need to pass the name of the uniform as well as the value.
  26402. */
  26403. updateVector4: (name: string, vector: Vector4) => void;
  26404. /**
  26405. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26406. * This is dynamic to allow compat with webgl 1 and 2.
  26407. * You will need to pass the name of the uniform as well as the value.
  26408. */
  26409. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26410. /**
  26411. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26412. * This is dynamic to allow compat with webgl 1 and 2.
  26413. * You will need to pass the name of the uniform as well as the value.
  26414. */
  26415. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26416. /**
  26417. * Instantiates a new Uniform buffer objects.
  26418. *
  26419. * Handles blocks of uniform on the GPU.
  26420. *
  26421. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26422. *
  26423. * For more information, please refer to :
  26424. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26425. * @param engine Define the engine the buffer is associated with
  26426. * @param data Define the data contained in the buffer
  26427. * @param dynamic Define if the buffer is updatable
  26428. */
  26429. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26430. /**
  26431. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26432. * or just falling back on setUniformXXX calls.
  26433. */
  26434. readonly useUbo: boolean;
  26435. /**
  26436. * Indicates if the WebGL underlying uniform buffer is in sync
  26437. * with the javascript cache data.
  26438. */
  26439. readonly isSync: boolean;
  26440. /**
  26441. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26442. * Also, a dynamic UniformBuffer will disable cache verification and always
  26443. * update the underlying WebGL uniform buffer to the GPU.
  26444. * @returns if Dynamic, otherwise false
  26445. */
  26446. isDynamic(): boolean;
  26447. /**
  26448. * The data cache on JS side.
  26449. * @returns the underlying data as a float array
  26450. */
  26451. getData(): Float32Array;
  26452. /**
  26453. * The underlying WebGL Uniform buffer.
  26454. * @returns the webgl buffer
  26455. */
  26456. getBuffer(): Nullable<DataBuffer>;
  26457. /**
  26458. * std140 layout specifies how to align data within an UBO structure.
  26459. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26460. * for specs.
  26461. */
  26462. private _fillAlignment;
  26463. /**
  26464. * Adds an uniform in the buffer.
  26465. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26466. * for the layout to be correct !
  26467. * @param name Name of the uniform, as used in the uniform block in the shader.
  26468. * @param size Data size, or data directly.
  26469. */
  26470. addUniform(name: string, size: number | number[]): void;
  26471. /**
  26472. * Adds a Matrix 4x4 to the uniform buffer.
  26473. * @param name Name of the uniform, as used in the uniform block in the shader.
  26474. * @param mat A 4x4 matrix.
  26475. */
  26476. addMatrix(name: string, mat: Matrix): void;
  26477. /**
  26478. * Adds a vec2 to the uniform buffer.
  26479. * @param name Name of the uniform, as used in the uniform block in the shader.
  26480. * @param x Define the x component value of the vec2
  26481. * @param y Define the y component value of the vec2
  26482. */
  26483. addFloat2(name: string, x: number, y: number): void;
  26484. /**
  26485. * Adds a vec3 to the uniform buffer.
  26486. * @param name Name of the uniform, as used in the uniform block in the shader.
  26487. * @param x Define the x component value of the vec3
  26488. * @param y Define the y component value of the vec3
  26489. * @param z Define the z component value of the vec3
  26490. */
  26491. addFloat3(name: string, x: number, y: number, z: number): void;
  26492. /**
  26493. * Adds a vec3 to the uniform buffer.
  26494. * @param name Name of the uniform, as used in the uniform block in the shader.
  26495. * @param color Define the vec3 from a Color
  26496. */
  26497. addColor3(name: string, color: Color3): void;
  26498. /**
  26499. * Adds a vec4 to the uniform buffer.
  26500. * @param name Name of the uniform, as used in the uniform block in the shader.
  26501. * @param color Define the rgb components from a Color
  26502. * @param alpha Define the a component of the vec4
  26503. */
  26504. addColor4(name: string, color: Color3, alpha: number): void;
  26505. /**
  26506. * Adds a vec3 to the uniform buffer.
  26507. * @param name Name of the uniform, as used in the uniform block in the shader.
  26508. * @param vector Define the vec3 components from a Vector
  26509. */
  26510. addVector3(name: string, vector: Vector3): void;
  26511. /**
  26512. * Adds a Matrix 3x3 to the uniform buffer.
  26513. * @param name Name of the uniform, as used in the uniform block in the shader.
  26514. */
  26515. addMatrix3x3(name: string): void;
  26516. /**
  26517. * Adds a Matrix 2x2 to the uniform buffer.
  26518. * @param name Name of the uniform, as used in the uniform block in the shader.
  26519. */
  26520. addMatrix2x2(name: string): void;
  26521. /**
  26522. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26523. */
  26524. create(): void;
  26525. /** @hidden */
  26526. _rebuild(): void;
  26527. /**
  26528. * Updates the WebGL Uniform Buffer on the GPU.
  26529. * If the `dynamic` flag is set to true, no cache comparison is done.
  26530. * Otherwise, the buffer will be updated only if the cache differs.
  26531. */
  26532. update(): void;
  26533. /**
  26534. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26535. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26536. * @param data Define the flattened data
  26537. * @param size Define the size of the data.
  26538. */
  26539. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26540. private _updateMatrix3x3ForUniform;
  26541. private _updateMatrix3x3ForEffect;
  26542. private _updateMatrix2x2ForEffect;
  26543. private _updateMatrix2x2ForUniform;
  26544. private _updateFloatForEffect;
  26545. private _updateFloatForUniform;
  26546. private _updateFloat2ForEffect;
  26547. private _updateFloat2ForUniform;
  26548. private _updateFloat3ForEffect;
  26549. private _updateFloat3ForUniform;
  26550. private _updateFloat4ForEffect;
  26551. private _updateFloat4ForUniform;
  26552. private _updateMatrixForEffect;
  26553. private _updateMatrixForUniform;
  26554. private _updateVector3ForEffect;
  26555. private _updateVector3ForUniform;
  26556. private _updateVector4ForEffect;
  26557. private _updateVector4ForUniform;
  26558. private _updateColor3ForEffect;
  26559. private _updateColor3ForUniform;
  26560. private _updateColor4ForEffect;
  26561. private _updateColor4ForUniform;
  26562. /**
  26563. * Sets a sampler uniform on the effect.
  26564. * @param name Define the name of the sampler.
  26565. * @param texture Define the texture to set in the sampler
  26566. */
  26567. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26568. /**
  26569. * Directly updates the value of the uniform in the cache AND on the GPU.
  26570. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26571. * @param data Define the flattened data
  26572. */
  26573. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26574. /**
  26575. * Binds this uniform buffer to an effect.
  26576. * @param effect Define the effect to bind the buffer to
  26577. * @param name Name of the uniform block in the shader.
  26578. */
  26579. bindToEffect(effect: Effect, name: string): void;
  26580. /**
  26581. * Disposes the uniform buffer.
  26582. */
  26583. dispose(): void;
  26584. }
  26585. }
  26586. declare module BABYLON {
  26587. /**
  26588. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26589. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26590. */
  26591. export class Analyser {
  26592. /**
  26593. * Gets or sets the smoothing
  26594. * @ignorenaming
  26595. */
  26596. SMOOTHING: number;
  26597. /**
  26598. * Gets or sets the FFT table size
  26599. * @ignorenaming
  26600. */
  26601. FFT_SIZE: number;
  26602. /**
  26603. * Gets or sets the bar graph amplitude
  26604. * @ignorenaming
  26605. */
  26606. BARGRAPHAMPLITUDE: number;
  26607. /**
  26608. * Gets or sets the position of the debug canvas
  26609. * @ignorenaming
  26610. */
  26611. DEBUGCANVASPOS: {
  26612. x: number;
  26613. y: number;
  26614. };
  26615. /**
  26616. * Gets or sets the debug canvas size
  26617. * @ignorenaming
  26618. */
  26619. DEBUGCANVASSIZE: {
  26620. width: number;
  26621. height: number;
  26622. };
  26623. private _byteFreqs;
  26624. private _byteTime;
  26625. private _floatFreqs;
  26626. private _webAudioAnalyser;
  26627. private _debugCanvas;
  26628. private _debugCanvasContext;
  26629. private _scene;
  26630. private _registerFunc;
  26631. private _audioEngine;
  26632. /**
  26633. * Creates a new analyser
  26634. * @param scene defines hosting scene
  26635. */
  26636. constructor(scene: Scene);
  26637. /**
  26638. * Get the number of data values you will have to play with for the visualization
  26639. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26640. * @returns a number
  26641. */
  26642. getFrequencyBinCount(): number;
  26643. /**
  26644. * Gets the current frequency data as a byte array
  26645. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26646. * @returns a Uint8Array
  26647. */
  26648. getByteFrequencyData(): Uint8Array;
  26649. /**
  26650. * Gets the current waveform as a byte array
  26651. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26652. * @returns a Uint8Array
  26653. */
  26654. getByteTimeDomainData(): Uint8Array;
  26655. /**
  26656. * Gets the current frequency data as a float array
  26657. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26658. * @returns a Float32Array
  26659. */
  26660. getFloatFrequencyData(): Float32Array;
  26661. /**
  26662. * Renders the debug canvas
  26663. */
  26664. drawDebugCanvas(): void;
  26665. /**
  26666. * Stops rendering the debug canvas and removes it
  26667. */
  26668. stopDebugCanvas(): void;
  26669. /**
  26670. * Connects two audio nodes
  26671. * @param inputAudioNode defines first node to connect
  26672. * @param outputAudioNode defines second node to connect
  26673. */
  26674. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26675. /**
  26676. * Releases all associated resources
  26677. */
  26678. dispose(): void;
  26679. }
  26680. }
  26681. declare module BABYLON {
  26682. /**
  26683. * This represents an audio engine and it is responsible
  26684. * to play, synchronize and analyse sounds throughout the application.
  26685. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26686. */
  26687. export interface IAudioEngine extends IDisposable {
  26688. /**
  26689. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26690. */
  26691. readonly canUseWebAudio: boolean;
  26692. /**
  26693. * Gets the current AudioContext if available.
  26694. */
  26695. readonly audioContext: Nullable<AudioContext>;
  26696. /**
  26697. * The master gain node defines the global audio volume of your audio engine.
  26698. */
  26699. readonly masterGain: GainNode;
  26700. /**
  26701. * Gets whether or not mp3 are supported by your browser.
  26702. */
  26703. readonly isMP3supported: boolean;
  26704. /**
  26705. * Gets whether or not ogg are supported by your browser.
  26706. */
  26707. readonly isOGGsupported: boolean;
  26708. /**
  26709. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26710. * @ignoreNaming
  26711. */
  26712. WarnedWebAudioUnsupported: boolean;
  26713. /**
  26714. * Defines if the audio engine relies on a custom unlocked button.
  26715. * In this case, the embedded button will not be displayed.
  26716. */
  26717. useCustomUnlockedButton: boolean;
  26718. /**
  26719. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26720. */
  26721. readonly unlocked: boolean;
  26722. /**
  26723. * Event raised when audio has been unlocked on the browser.
  26724. */
  26725. onAudioUnlockedObservable: Observable<AudioEngine>;
  26726. /**
  26727. * Event raised when audio has been locked on the browser.
  26728. */
  26729. onAudioLockedObservable: Observable<AudioEngine>;
  26730. /**
  26731. * Flags the audio engine in Locked state.
  26732. * This happens due to new browser policies preventing audio to autoplay.
  26733. */
  26734. lock(): void;
  26735. /**
  26736. * Unlocks the audio engine once a user action has been done on the dom.
  26737. * This is helpful to resume play once browser policies have been satisfied.
  26738. */
  26739. unlock(): void;
  26740. }
  26741. /**
  26742. * This represents the default audio engine used in babylon.
  26743. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26744. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26745. */
  26746. export class AudioEngine implements IAudioEngine {
  26747. private _audioContext;
  26748. private _audioContextInitialized;
  26749. private _muteButton;
  26750. private _hostElement;
  26751. /**
  26752. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26753. */
  26754. canUseWebAudio: boolean;
  26755. /**
  26756. * The master gain node defines the global audio volume of your audio engine.
  26757. */
  26758. masterGain: GainNode;
  26759. /**
  26760. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26761. * @ignoreNaming
  26762. */
  26763. WarnedWebAudioUnsupported: boolean;
  26764. /**
  26765. * Gets whether or not mp3 are supported by your browser.
  26766. */
  26767. isMP3supported: boolean;
  26768. /**
  26769. * Gets whether or not ogg are supported by your browser.
  26770. */
  26771. isOGGsupported: boolean;
  26772. /**
  26773. * Gets whether audio has been unlocked on the device.
  26774. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26775. * a user interaction has happened.
  26776. */
  26777. unlocked: boolean;
  26778. /**
  26779. * Defines if the audio engine relies on a custom unlocked button.
  26780. * In this case, the embedded button will not be displayed.
  26781. */
  26782. useCustomUnlockedButton: boolean;
  26783. /**
  26784. * Event raised when audio has been unlocked on the browser.
  26785. */
  26786. onAudioUnlockedObservable: Observable<AudioEngine>;
  26787. /**
  26788. * Event raised when audio has been locked on the browser.
  26789. */
  26790. onAudioLockedObservable: Observable<AudioEngine>;
  26791. /**
  26792. * Gets the current AudioContext if available.
  26793. */
  26794. readonly audioContext: Nullable<AudioContext>;
  26795. private _connectedAnalyser;
  26796. /**
  26797. * Instantiates a new audio engine.
  26798. *
  26799. * There should be only one per page as some browsers restrict the number
  26800. * of audio contexts you can create.
  26801. * @param hostElement defines the host element where to display the mute icon if necessary
  26802. */
  26803. constructor(hostElement?: Nullable<HTMLElement>);
  26804. /**
  26805. * Flags the audio engine in Locked state.
  26806. * This happens due to new browser policies preventing audio to autoplay.
  26807. */
  26808. lock(): void;
  26809. /**
  26810. * Unlocks the audio engine once a user action has been done on the dom.
  26811. * This is helpful to resume play once browser policies have been satisfied.
  26812. */
  26813. unlock(): void;
  26814. private _resumeAudioContext;
  26815. private _initializeAudioContext;
  26816. private _tryToRun;
  26817. private _triggerRunningState;
  26818. private _triggerSuspendedState;
  26819. private _displayMuteButton;
  26820. private _moveButtonToTopLeft;
  26821. private _onResize;
  26822. private _hideMuteButton;
  26823. /**
  26824. * Destroy and release the resources associated with the audio ccontext.
  26825. */
  26826. dispose(): void;
  26827. /**
  26828. * Gets the global volume sets on the master gain.
  26829. * @returns the global volume if set or -1 otherwise
  26830. */
  26831. getGlobalVolume(): number;
  26832. /**
  26833. * Sets the global volume of your experience (sets on the master gain).
  26834. * @param newVolume Defines the new global volume of the application
  26835. */
  26836. setGlobalVolume(newVolume: number): void;
  26837. /**
  26838. * Connect the audio engine to an audio analyser allowing some amazing
  26839. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26840. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26841. * @param analyser The analyser to connect to the engine
  26842. */
  26843. connectToAnalyser(analyser: Analyser): void;
  26844. }
  26845. }
  26846. declare module BABYLON {
  26847. /**
  26848. * Interface used to present a loading screen while loading a scene
  26849. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26850. */
  26851. export interface ILoadingScreen {
  26852. /**
  26853. * Function called to display the loading screen
  26854. */
  26855. displayLoadingUI: () => void;
  26856. /**
  26857. * Function called to hide the loading screen
  26858. */
  26859. hideLoadingUI: () => void;
  26860. /**
  26861. * Gets or sets the color to use for the background
  26862. */
  26863. loadingUIBackgroundColor: string;
  26864. /**
  26865. * Gets or sets the text to display while loading
  26866. */
  26867. loadingUIText: string;
  26868. }
  26869. /**
  26870. * Class used for the default loading screen
  26871. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26872. */
  26873. export class DefaultLoadingScreen implements ILoadingScreen {
  26874. private _renderingCanvas;
  26875. private _loadingText;
  26876. private _loadingDivBackgroundColor;
  26877. private _loadingDiv;
  26878. private _loadingTextDiv;
  26879. /** Gets or sets the logo url to use for the default loading screen */
  26880. static DefaultLogoUrl: string;
  26881. /** Gets or sets the spinner url to use for the default loading screen */
  26882. static DefaultSpinnerUrl: string;
  26883. /**
  26884. * Creates a new default loading screen
  26885. * @param _renderingCanvas defines the canvas used to render the scene
  26886. * @param _loadingText defines the default text to display
  26887. * @param _loadingDivBackgroundColor defines the default background color
  26888. */
  26889. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26890. /**
  26891. * Function called to display the loading screen
  26892. */
  26893. displayLoadingUI(): void;
  26894. /**
  26895. * Function called to hide the loading screen
  26896. */
  26897. hideLoadingUI(): void;
  26898. /**
  26899. * Gets or sets the text to display while loading
  26900. */
  26901. loadingUIText: string;
  26902. /**
  26903. * Gets or sets the color to use for the background
  26904. */
  26905. loadingUIBackgroundColor: string;
  26906. private _resizeLoadingUI;
  26907. }
  26908. }
  26909. declare module BABYLON {
  26910. /** @hidden */
  26911. export class WebGLPipelineContext implements IPipelineContext {
  26912. engine: Engine;
  26913. program: Nullable<WebGLProgram>;
  26914. context?: WebGLRenderingContext;
  26915. vertexShader?: WebGLShader;
  26916. fragmentShader?: WebGLShader;
  26917. isParallelCompiled: boolean;
  26918. onCompiled?: () => void;
  26919. transformFeedback?: WebGLTransformFeedback | null;
  26920. readonly isAsync: boolean;
  26921. readonly isReady: boolean;
  26922. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  26923. }
  26924. }
  26925. declare module BABYLON {
  26926. /** @hidden */
  26927. export class WebGLDataBuffer extends DataBuffer {
  26928. private _buffer;
  26929. constructor(resource: WebGLBuffer);
  26930. readonly underlyingResource: any;
  26931. }
  26932. }
  26933. declare module BABYLON {
  26934. /**
  26935. * Settings for finer control over video usage
  26936. */
  26937. export interface VideoTextureSettings {
  26938. /**
  26939. * Applies `autoplay` to video, if specified
  26940. */
  26941. autoPlay?: boolean;
  26942. /**
  26943. * Applies `loop` to video, if specified
  26944. */
  26945. loop?: boolean;
  26946. /**
  26947. * Automatically updates internal texture from video at every frame in the render loop
  26948. */
  26949. autoUpdateTexture: boolean;
  26950. /**
  26951. * Image src displayed during the video loading or until the user interacts with the video.
  26952. */
  26953. poster?: string;
  26954. }
  26955. /**
  26956. * If you want to display a video in your scene, this is the special texture for that.
  26957. * This special texture works similar to other textures, with the exception of a few parameters.
  26958. * @see https://doc.babylonjs.com/how_to/video_texture
  26959. */
  26960. export class VideoTexture extends Texture {
  26961. /**
  26962. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26963. */
  26964. readonly autoUpdateTexture: boolean;
  26965. /**
  26966. * The video instance used by the texture internally
  26967. */
  26968. readonly video: HTMLVideoElement;
  26969. private _onUserActionRequestedObservable;
  26970. /**
  26971. * Event triggerd when a dom action is required by the user to play the video.
  26972. * This happens due to recent changes in browser policies preventing video to auto start.
  26973. */
  26974. readonly onUserActionRequestedObservable: Observable<Texture>;
  26975. private _generateMipMaps;
  26976. private _engine;
  26977. private _stillImageCaptured;
  26978. private _displayingPosterTexture;
  26979. private _settings;
  26980. private _createInternalTextureOnEvent;
  26981. /**
  26982. * Creates a video texture.
  26983. * If you want to display a video in your scene, this is the special texture for that.
  26984. * This special texture works similar to other textures, with the exception of a few parameters.
  26985. * @see https://doc.babylonjs.com/how_to/video_texture
  26986. * @param name optional name, will detect from video source, if not defined
  26987. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26988. * @param scene is obviously the current scene.
  26989. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26990. * @param invertY is false by default but can be used to invert video on Y axis
  26991. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26992. * @param settings allows finer control over video usage
  26993. */
  26994. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26995. private _getName;
  26996. private _getVideo;
  26997. private _createInternalTexture;
  26998. private reset;
  26999. /**
  27000. * @hidden Internal method to initiate `update`.
  27001. */
  27002. _rebuild(): void;
  27003. /**
  27004. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27005. */
  27006. update(): void;
  27007. /**
  27008. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27009. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27010. */
  27011. updateTexture(isVisible: boolean): void;
  27012. protected _updateInternalTexture: () => void;
  27013. /**
  27014. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27015. * @param url New url.
  27016. */
  27017. updateURL(url: string): void;
  27018. /**
  27019. * Dispose the texture and release its associated resources.
  27020. */
  27021. dispose(): void;
  27022. /**
  27023. * Creates a video texture straight from a stream.
  27024. * @param scene Define the scene the texture should be created in
  27025. * @param stream Define the stream the texture should be created from
  27026. * @returns The created video texture as a promise
  27027. */
  27028. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27029. /**
  27030. * Creates a video texture straight from your WebCam video feed.
  27031. * @param scene Define the scene the texture should be created in
  27032. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27033. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27034. * @returns The created video texture as a promise
  27035. */
  27036. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27037. minWidth: number;
  27038. maxWidth: number;
  27039. minHeight: number;
  27040. maxHeight: number;
  27041. deviceId: string;
  27042. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27043. /**
  27044. * Creates a video texture straight from your WebCam video feed.
  27045. * @param scene Define the scene the texture should be created in
  27046. * @param onReady Define a callback to triggered once the texture will be ready
  27047. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27048. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27049. */
  27050. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27051. minWidth: number;
  27052. maxWidth: number;
  27053. minHeight: number;
  27054. maxHeight: number;
  27055. deviceId: string;
  27056. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27057. }
  27058. }
  27059. declare module BABYLON {
  27060. /**
  27061. * Interface for attribute information associated with buffer instanciation
  27062. */
  27063. export class InstancingAttributeInfo {
  27064. /**
  27065. * Index/offset of the attribute in the vertex shader
  27066. */
  27067. index: number;
  27068. /**
  27069. * size of the attribute, 1, 2, 3 or 4
  27070. */
  27071. attributeSize: number;
  27072. /**
  27073. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27074. * default is FLOAT
  27075. */
  27076. attribyteType: number;
  27077. /**
  27078. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27079. */
  27080. normalized: boolean;
  27081. /**
  27082. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27083. */
  27084. offset: number;
  27085. /**
  27086. * Name of the GLSL attribute, for debugging purpose only
  27087. */
  27088. attributeName: string;
  27089. }
  27090. /**
  27091. * Define options used to create a depth texture
  27092. */
  27093. export class DepthTextureCreationOptions {
  27094. /** Specifies whether or not a stencil should be allocated in the texture */
  27095. generateStencil?: boolean;
  27096. /** Specifies whether or not bilinear filtering is enable on the texture */
  27097. bilinearFiltering?: boolean;
  27098. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27099. comparisonFunction?: number;
  27100. /** Specifies if the created texture is a cube texture */
  27101. isCube?: boolean;
  27102. }
  27103. /**
  27104. * Class used to describe the capabilities of the engine relatively to the current browser
  27105. */
  27106. export class EngineCapabilities {
  27107. /** Maximum textures units per fragment shader */
  27108. maxTexturesImageUnits: number;
  27109. /** Maximum texture units per vertex shader */
  27110. maxVertexTextureImageUnits: number;
  27111. /** Maximum textures units in the entire pipeline */
  27112. maxCombinedTexturesImageUnits: number;
  27113. /** Maximum texture size */
  27114. maxTextureSize: number;
  27115. /** Maximum cube texture size */
  27116. maxCubemapTextureSize: number;
  27117. /** Maximum render texture size */
  27118. maxRenderTextureSize: number;
  27119. /** Maximum number of vertex attributes */
  27120. maxVertexAttribs: number;
  27121. /** Maximum number of varyings */
  27122. maxVaryingVectors: number;
  27123. /** Maximum number of uniforms per vertex shader */
  27124. maxVertexUniformVectors: number;
  27125. /** Maximum number of uniforms per fragment shader */
  27126. maxFragmentUniformVectors: number;
  27127. /** Defines if standard derivates (dx/dy) are supported */
  27128. standardDerivatives: boolean;
  27129. /** Defines if s3tc texture compression is supported */
  27130. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27131. /** Defines if pvrtc texture compression is supported */
  27132. pvrtc: any;
  27133. /** Defines if etc1 texture compression is supported */
  27134. etc1: any;
  27135. /** Defines if etc2 texture compression is supported */
  27136. etc2: any;
  27137. /** Defines if astc texture compression is supported */
  27138. astc: any;
  27139. /** Defines if float textures are supported */
  27140. textureFloat: boolean;
  27141. /** Defines if vertex array objects are supported */
  27142. vertexArrayObject: boolean;
  27143. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27144. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27145. /** Gets the maximum level of anisotropy supported */
  27146. maxAnisotropy: number;
  27147. /** Defines if instancing is supported */
  27148. instancedArrays: boolean;
  27149. /** Defines if 32 bits indices are supported */
  27150. uintIndices: boolean;
  27151. /** Defines if high precision shaders are supported */
  27152. highPrecisionShaderSupported: boolean;
  27153. /** Defines if depth reading in the fragment shader is supported */
  27154. fragmentDepthSupported: boolean;
  27155. /** Defines if float texture linear filtering is supported*/
  27156. textureFloatLinearFiltering: boolean;
  27157. /** Defines if rendering to float textures is supported */
  27158. textureFloatRender: boolean;
  27159. /** Defines if half float textures are supported*/
  27160. textureHalfFloat: boolean;
  27161. /** Defines if half float texture linear filtering is supported*/
  27162. textureHalfFloatLinearFiltering: boolean;
  27163. /** Defines if rendering to half float textures is supported */
  27164. textureHalfFloatRender: boolean;
  27165. /** Defines if textureLOD shader command is supported */
  27166. textureLOD: boolean;
  27167. /** Defines if draw buffers extension is supported */
  27168. drawBuffersExtension: boolean;
  27169. /** Defines if depth textures are supported */
  27170. depthTextureExtension: boolean;
  27171. /** Defines if float color buffer are supported */
  27172. colorBufferFloat: boolean;
  27173. /** Gets disjoint timer query extension (null if not supported) */
  27174. timerQuery: EXT_disjoint_timer_query;
  27175. /** Defines if timestamp can be used with timer query */
  27176. canUseTimestampForTimerQuery: boolean;
  27177. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27178. multiview: any;
  27179. /** Function used to let the system compiles shaders in background */
  27180. parallelShaderCompile: {
  27181. COMPLETION_STATUS_KHR: number;
  27182. };
  27183. }
  27184. /** Interface defining initialization parameters for Engine class */
  27185. export interface EngineOptions extends WebGLContextAttributes {
  27186. /**
  27187. * Defines if the engine should no exceed a specified device ratio
  27188. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27189. */
  27190. limitDeviceRatio?: number;
  27191. /**
  27192. * Defines if webvr should be enabled automatically
  27193. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27194. */
  27195. autoEnableWebVR?: boolean;
  27196. /**
  27197. * Defines if webgl2 should be turned off even if supported
  27198. * @see http://doc.babylonjs.com/features/webgl2
  27199. */
  27200. disableWebGL2Support?: boolean;
  27201. /**
  27202. * Defines if webaudio should be initialized as well
  27203. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27204. */
  27205. audioEngine?: boolean;
  27206. /**
  27207. * Defines if animations should run using a deterministic lock step
  27208. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27209. */
  27210. deterministicLockstep?: boolean;
  27211. /** Defines the maximum steps to use with deterministic lock step mode */
  27212. lockstepMaxSteps?: number;
  27213. /**
  27214. * Defines that engine should ignore context lost events
  27215. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27216. */
  27217. doNotHandleContextLost?: boolean;
  27218. /**
  27219. * Defines that engine should ignore modifying touch action attribute and style
  27220. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27221. */
  27222. doNotHandleTouchAction?: boolean;
  27223. /**
  27224. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27225. */
  27226. useHighPrecisionFloats?: boolean;
  27227. }
  27228. /**
  27229. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27230. */
  27231. export class Engine {
  27232. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27233. static ExceptionList: ({
  27234. key: string;
  27235. capture: string;
  27236. captureConstraint: number;
  27237. targets: string[];
  27238. } | {
  27239. key: string;
  27240. capture: null;
  27241. captureConstraint: null;
  27242. targets: string[];
  27243. })[];
  27244. /** Gets the list of created engines */
  27245. static readonly Instances: Engine[];
  27246. /**
  27247. * Gets the latest created engine
  27248. */
  27249. static readonly LastCreatedEngine: Nullable<Engine>;
  27250. /**
  27251. * Gets the latest created scene
  27252. */
  27253. static readonly LastCreatedScene: Nullable<Scene>;
  27254. /**
  27255. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27256. * @param flag defines which part of the materials must be marked as dirty
  27257. * @param predicate defines a predicate used to filter which materials should be affected
  27258. */
  27259. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27260. /**
  27261. * Hidden
  27262. */
  27263. static _TextureLoaders: IInternalTextureLoader[];
  27264. /** Defines that alpha blending is disabled */
  27265. static readonly ALPHA_DISABLE: number;
  27266. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27267. static readonly ALPHA_ADD: number;
  27268. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27269. static readonly ALPHA_COMBINE: number;
  27270. /** Defines that alpha blending to DEST - SRC * DEST */
  27271. static readonly ALPHA_SUBTRACT: number;
  27272. /** Defines that alpha blending to SRC * DEST */
  27273. static readonly ALPHA_MULTIPLY: number;
  27274. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27275. static readonly ALPHA_MAXIMIZED: number;
  27276. /** Defines that alpha blending to SRC + DEST */
  27277. static readonly ALPHA_ONEONE: number;
  27278. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27279. static readonly ALPHA_PREMULTIPLIED: number;
  27280. /**
  27281. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27282. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27283. */
  27284. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27285. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27286. static readonly ALPHA_INTERPOLATE: number;
  27287. /**
  27288. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27289. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27290. */
  27291. static readonly ALPHA_SCREENMODE: number;
  27292. /** Defines that the ressource is not delayed*/
  27293. static readonly DELAYLOADSTATE_NONE: number;
  27294. /** Defines that the ressource was successfully delay loaded */
  27295. static readonly DELAYLOADSTATE_LOADED: number;
  27296. /** Defines that the ressource is currently delay loading */
  27297. static readonly DELAYLOADSTATE_LOADING: number;
  27298. /** Defines that the ressource is delayed and has not started loading */
  27299. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27300. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27301. static readonly NEVER: number;
  27302. /** 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 */
  27303. static readonly ALWAYS: number;
  27304. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27305. static readonly LESS: number;
  27306. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27307. static readonly EQUAL: number;
  27308. /** 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 */
  27309. static readonly LEQUAL: number;
  27310. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27311. static readonly GREATER: number;
  27312. /** 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 */
  27313. static readonly GEQUAL: number;
  27314. /** 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 */
  27315. static readonly NOTEQUAL: number;
  27316. /** Passed to stencilOperation to specify that stencil value must be kept */
  27317. static readonly KEEP: number;
  27318. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27319. static readonly REPLACE: number;
  27320. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27321. static readonly INCR: number;
  27322. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27323. static readonly DECR: number;
  27324. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27325. static readonly INVERT: number;
  27326. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27327. static readonly INCR_WRAP: number;
  27328. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27329. static readonly DECR_WRAP: number;
  27330. /** Texture is not repeating outside of 0..1 UVs */
  27331. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27332. /** Texture is repeating outside of 0..1 UVs */
  27333. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27334. /** Texture is repeating and mirrored */
  27335. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27336. /** ALPHA */
  27337. static readonly TEXTUREFORMAT_ALPHA: number;
  27338. /** LUMINANCE */
  27339. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27340. /** LUMINANCE_ALPHA */
  27341. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27342. /** RGB */
  27343. static readonly TEXTUREFORMAT_RGB: number;
  27344. /** RGBA */
  27345. static readonly TEXTUREFORMAT_RGBA: number;
  27346. /** RED */
  27347. static readonly TEXTUREFORMAT_RED: number;
  27348. /** RED (2nd reference) */
  27349. static readonly TEXTUREFORMAT_R: number;
  27350. /** RG */
  27351. static readonly TEXTUREFORMAT_RG: number;
  27352. /** RED_INTEGER */
  27353. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27354. /** RED_INTEGER (2nd reference) */
  27355. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27356. /** RG_INTEGER */
  27357. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27358. /** RGB_INTEGER */
  27359. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27360. /** RGBA_INTEGER */
  27361. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27362. /** UNSIGNED_BYTE */
  27363. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27364. /** UNSIGNED_BYTE (2nd reference) */
  27365. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27366. /** FLOAT */
  27367. static readonly TEXTURETYPE_FLOAT: number;
  27368. /** HALF_FLOAT */
  27369. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27370. /** BYTE */
  27371. static readonly TEXTURETYPE_BYTE: number;
  27372. /** SHORT */
  27373. static readonly TEXTURETYPE_SHORT: number;
  27374. /** UNSIGNED_SHORT */
  27375. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27376. /** INT */
  27377. static readonly TEXTURETYPE_INT: number;
  27378. /** UNSIGNED_INT */
  27379. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27380. /** UNSIGNED_SHORT_4_4_4_4 */
  27381. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27382. /** UNSIGNED_SHORT_5_5_5_1 */
  27383. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27384. /** UNSIGNED_SHORT_5_6_5 */
  27385. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27386. /** UNSIGNED_INT_2_10_10_10_REV */
  27387. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27388. /** UNSIGNED_INT_24_8 */
  27389. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27390. /** UNSIGNED_INT_10F_11F_11F_REV */
  27391. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27392. /** UNSIGNED_INT_5_9_9_9_REV */
  27393. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27394. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27395. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27396. /** nearest is mag = nearest and min = nearest and mip = linear */
  27397. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27398. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27399. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27400. /** Trilinear is mag = linear and min = linear and mip = linear */
  27401. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27402. /** nearest is mag = nearest and min = nearest and mip = linear */
  27403. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27404. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27405. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27406. /** Trilinear is mag = linear and min = linear and mip = linear */
  27407. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27408. /** mag = nearest and min = nearest and mip = nearest */
  27409. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27410. /** mag = nearest and min = linear and mip = nearest */
  27411. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27412. /** mag = nearest and min = linear and mip = linear */
  27413. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27414. /** mag = nearest and min = linear and mip = none */
  27415. static readonly TEXTURE_NEAREST_LINEAR: number;
  27416. /** mag = nearest and min = nearest and mip = none */
  27417. static readonly TEXTURE_NEAREST_NEAREST: number;
  27418. /** mag = linear and min = nearest and mip = nearest */
  27419. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27420. /** mag = linear and min = nearest and mip = linear */
  27421. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27422. /** mag = linear and min = linear and mip = none */
  27423. static readonly TEXTURE_LINEAR_LINEAR: number;
  27424. /** mag = linear and min = nearest and mip = none */
  27425. static readonly TEXTURE_LINEAR_NEAREST: number;
  27426. /** Explicit coordinates mode */
  27427. static readonly TEXTURE_EXPLICIT_MODE: number;
  27428. /** Spherical coordinates mode */
  27429. static readonly TEXTURE_SPHERICAL_MODE: number;
  27430. /** Planar coordinates mode */
  27431. static readonly TEXTURE_PLANAR_MODE: number;
  27432. /** Cubic coordinates mode */
  27433. static readonly TEXTURE_CUBIC_MODE: number;
  27434. /** Projection coordinates mode */
  27435. static readonly TEXTURE_PROJECTION_MODE: number;
  27436. /** Skybox coordinates mode */
  27437. static readonly TEXTURE_SKYBOX_MODE: number;
  27438. /** Inverse Cubic coordinates mode */
  27439. static readonly TEXTURE_INVCUBIC_MODE: number;
  27440. /** Equirectangular coordinates mode */
  27441. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27442. /** Equirectangular Fixed coordinates mode */
  27443. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27444. /** Equirectangular Fixed Mirrored coordinates mode */
  27445. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27446. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27447. static readonly SCALEMODE_FLOOR: number;
  27448. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27449. static readonly SCALEMODE_NEAREST: number;
  27450. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27451. static readonly SCALEMODE_CEILING: number;
  27452. /**
  27453. * Returns the current npm package of the sdk
  27454. */
  27455. static readonly NpmPackage: string;
  27456. /**
  27457. * Returns the current version of the framework
  27458. */
  27459. static readonly Version: string;
  27460. /**
  27461. * Returns a string describing the current engine
  27462. */
  27463. readonly description: string;
  27464. /**
  27465. * Gets or sets the epsilon value used by collision engine
  27466. */
  27467. static CollisionsEpsilon: number;
  27468. /**
  27469. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27470. */
  27471. static ShadersRepository: string;
  27472. /**
  27473. * Method called to create the default loading screen.
  27474. * This can be overriden in your own app.
  27475. * @param canvas The rendering canvas element
  27476. * @returns The loading screen
  27477. */
  27478. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27479. /**
  27480. * Method called to create the default rescale post process on each engine.
  27481. */
  27482. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27483. /**
  27484. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27485. */
  27486. forcePOTTextures: boolean;
  27487. /**
  27488. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27489. */
  27490. isFullscreen: boolean;
  27491. /**
  27492. * Gets a boolean indicating if the pointer is currently locked
  27493. */
  27494. isPointerLock: boolean;
  27495. /**
  27496. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27497. */
  27498. cullBackFaces: boolean;
  27499. /**
  27500. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27501. */
  27502. renderEvenInBackground: boolean;
  27503. /**
  27504. * Gets or sets a boolean indicating that cache can be kept between frames
  27505. */
  27506. preventCacheWipeBetweenFrames: boolean;
  27507. /**
  27508. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27509. **/
  27510. enableOfflineSupport: boolean;
  27511. /**
  27512. * 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)
  27513. **/
  27514. disableManifestCheck: boolean;
  27515. /**
  27516. * Gets the list of created scenes
  27517. */
  27518. scenes: Scene[];
  27519. /**
  27520. * Event raised when a new scene is created
  27521. */
  27522. onNewSceneAddedObservable: Observable<Scene>;
  27523. /**
  27524. * Gets the list of created postprocesses
  27525. */
  27526. postProcesses: PostProcess[];
  27527. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27528. validateShaderPrograms: boolean;
  27529. /**
  27530. * Observable event triggered each time the rendering canvas is resized
  27531. */
  27532. onResizeObservable: Observable<Engine>;
  27533. /**
  27534. * Observable event triggered each time the canvas loses focus
  27535. */
  27536. onCanvasBlurObservable: Observable<Engine>;
  27537. /**
  27538. * Observable event triggered each time the canvas gains focus
  27539. */
  27540. onCanvasFocusObservable: Observable<Engine>;
  27541. /**
  27542. * Observable event triggered each time the canvas receives pointerout event
  27543. */
  27544. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27545. /**
  27546. * Observable event triggered before each texture is initialized
  27547. */
  27548. onBeforeTextureInitObservable: Observable<Texture>;
  27549. /**
  27550. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27551. */
  27552. disableUniformBuffers: boolean;
  27553. /** @hidden */
  27554. _uniformBuffers: UniformBuffer[];
  27555. /**
  27556. * Gets a boolean indicating that the engine supports uniform buffers
  27557. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27558. */
  27559. readonly supportsUniformBuffers: boolean;
  27560. /**
  27561. * Observable raised when the engine begins a new frame
  27562. */
  27563. onBeginFrameObservable: Observable<Engine>;
  27564. /**
  27565. * If set, will be used to request the next animation frame for the render loop
  27566. */
  27567. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27568. /**
  27569. * Observable raised when the engine ends the current frame
  27570. */
  27571. onEndFrameObservable: Observable<Engine>;
  27572. /**
  27573. * Observable raised when the engine is about to compile a shader
  27574. */
  27575. onBeforeShaderCompilationObservable: Observable<Engine>;
  27576. /**
  27577. * Observable raised when the engine has jsut compiled a shader
  27578. */
  27579. onAfterShaderCompilationObservable: Observable<Engine>;
  27580. /** @hidden */
  27581. _gl: WebGLRenderingContext;
  27582. private _renderingCanvas;
  27583. private _windowIsBackground;
  27584. private _webGLVersion;
  27585. protected _highPrecisionShadersAllowed: boolean;
  27586. /** @hidden */
  27587. readonly _shouldUseHighPrecisionShader: boolean;
  27588. /**
  27589. * Gets a boolean indicating that only power of 2 textures are supported
  27590. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27591. */
  27592. readonly needPOTTextures: boolean;
  27593. /** @hidden */
  27594. _badOS: boolean;
  27595. /** @hidden */
  27596. _badDesktopOS: boolean;
  27597. /**
  27598. * Gets the audio engine
  27599. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27600. * @ignorenaming
  27601. */
  27602. static audioEngine: IAudioEngine;
  27603. /**
  27604. * Default AudioEngine factory responsible of creating the Audio Engine.
  27605. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27606. */
  27607. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27608. /**
  27609. * Default offline support factory responsible of creating a tool used to store data locally.
  27610. * By default, this will create a Database object if the workload has been embedded.
  27611. */
  27612. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27613. private _onFocus;
  27614. private _onBlur;
  27615. private _onCanvasPointerOut;
  27616. private _onCanvasBlur;
  27617. private _onCanvasFocus;
  27618. private _onFullscreenChange;
  27619. private _onPointerLockChange;
  27620. private _hardwareScalingLevel;
  27621. /** @hidden */
  27622. _caps: EngineCapabilities;
  27623. private _pointerLockRequested;
  27624. private _isStencilEnable;
  27625. private _colorWrite;
  27626. private _loadingScreen;
  27627. /** @hidden */
  27628. _drawCalls: PerfCounter;
  27629. private _glVersion;
  27630. private _glRenderer;
  27631. private _glVendor;
  27632. private _videoTextureSupported;
  27633. private _renderingQueueLaunched;
  27634. private _activeRenderLoops;
  27635. private _deterministicLockstep;
  27636. private _lockstepMaxSteps;
  27637. /**
  27638. * Observable signaled when a context lost event is raised
  27639. */
  27640. onContextLostObservable: Observable<Engine>;
  27641. /**
  27642. * Observable signaled when a context restored event is raised
  27643. */
  27644. onContextRestoredObservable: Observable<Engine>;
  27645. private _onContextLost;
  27646. private _onContextRestored;
  27647. private _contextWasLost;
  27648. /** @hidden */
  27649. _doNotHandleContextLost: boolean;
  27650. /**
  27651. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27652. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27653. */
  27654. doNotHandleContextLost: boolean;
  27655. private _performanceMonitor;
  27656. private _fps;
  27657. private _deltaTime;
  27658. /**
  27659. * Turn this value on if you want to pause FPS computation when in background
  27660. */
  27661. disablePerformanceMonitorInBackground: boolean;
  27662. /**
  27663. * Gets the performance monitor attached to this engine
  27664. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27665. */
  27666. readonly performanceMonitor: PerformanceMonitor;
  27667. /**
  27668. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27669. */
  27670. disableVertexArrayObjects: boolean;
  27671. /** @hidden */
  27672. protected _depthCullingState: _DepthCullingState;
  27673. /** @hidden */
  27674. protected _stencilState: _StencilState;
  27675. /** @hidden */
  27676. protected _alphaState: _AlphaState;
  27677. /** @hidden */
  27678. protected _alphaMode: number;
  27679. /** @hidden */
  27680. _internalTexturesCache: InternalTexture[];
  27681. /** @hidden */
  27682. protected _activeChannel: number;
  27683. private _currentTextureChannel;
  27684. /** @hidden */
  27685. protected _boundTexturesCache: {
  27686. [key: string]: Nullable<InternalTexture>;
  27687. };
  27688. /** @hidden */
  27689. protected _currentEffect: Nullable<Effect>;
  27690. /** @hidden */
  27691. protected _currentProgram: Nullable<WebGLProgram>;
  27692. private _compiledEffects;
  27693. private _vertexAttribArraysEnabled;
  27694. /** @hidden */
  27695. protected _cachedViewport: Nullable<Viewport>;
  27696. private _cachedVertexArrayObject;
  27697. /** @hidden */
  27698. protected _cachedVertexBuffers: any;
  27699. /** @hidden */
  27700. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27701. /** @hidden */
  27702. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27703. /** @hidden */
  27704. _currentRenderTarget: Nullable<InternalTexture>;
  27705. private _uintIndicesCurrentlySet;
  27706. private _currentBoundBuffer;
  27707. /** @hidden */
  27708. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27709. private _currentBufferPointers;
  27710. private _currentInstanceLocations;
  27711. private _currentInstanceBuffers;
  27712. private _textureUnits;
  27713. /** @hidden */
  27714. _workingCanvas: Nullable<HTMLCanvasElement>;
  27715. /** @hidden */
  27716. _workingContext: Nullable<CanvasRenderingContext2D>;
  27717. private _rescalePostProcess;
  27718. private _dummyFramebuffer;
  27719. private _externalData;
  27720. /** @hidden */
  27721. _bindedRenderFunction: any;
  27722. private _vaoRecordInProgress;
  27723. private _mustWipeVertexAttributes;
  27724. private _emptyTexture;
  27725. private _emptyCubeTexture;
  27726. private _emptyTexture3D;
  27727. /** @hidden */
  27728. _frameHandler: number;
  27729. private _nextFreeTextureSlots;
  27730. private _maxSimultaneousTextures;
  27731. private _activeRequests;
  27732. private _texturesSupported;
  27733. /** @hidden */
  27734. _textureFormatInUse: Nullable<string>;
  27735. /**
  27736. * Gets the list of texture formats supported
  27737. */
  27738. readonly texturesSupported: Array<string>;
  27739. /**
  27740. * Gets the list of texture formats in use
  27741. */
  27742. readonly textureFormatInUse: Nullable<string>;
  27743. /**
  27744. * Gets the current viewport
  27745. */
  27746. readonly currentViewport: Nullable<Viewport>;
  27747. /**
  27748. * Gets the default empty texture
  27749. */
  27750. readonly emptyTexture: InternalTexture;
  27751. /**
  27752. * Gets the default empty 3D texture
  27753. */
  27754. readonly emptyTexture3D: InternalTexture;
  27755. /**
  27756. * Gets the default empty cube texture
  27757. */
  27758. readonly emptyCubeTexture: InternalTexture;
  27759. /**
  27760. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27761. */
  27762. readonly premultipliedAlpha: boolean;
  27763. /**
  27764. * Creates a new engine
  27765. * @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
  27766. * @param antialias defines enable antialiasing (default: false)
  27767. * @param options defines further options to be sent to the getContext() function
  27768. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27769. */
  27770. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27771. /**
  27772. * Initializes a webVR display and starts listening to display change events
  27773. * The onVRDisplayChangedObservable will be notified upon these changes
  27774. * @returns The onVRDisplayChangedObservable
  27775. */
  27776. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27777. /** @hidden */
  27778. _prepareVRComponent(): void;
  27779. /** @hidden */
  27780. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  27781. /** @hidden */
  27782. _submitVRFrame(): void;
  27783. /**
  27784. * Call this function to leave webVR mode
  27785. * Will do nothing if webVR is not supported or if there is no webVR device
  27786. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27787. */
  27788. disableVR(): void;
  27789. /**
  27790. * Gets a boolean indicating that the system is in VR mode and is presenting
  27791. * @returns true if VR mode is engaged
  27792. */
  27793. isVRPresenting(): boolean;
  27794. /** @hidden */
  27795. _requestVRFrame(): void;
  27796. private _disableTouchAction;
  27797. private _rebuildInternalTextures;
  27798. private _rebuildEffects;
  27799. /**
  27800. * Gets a boolean indicating if all created effects are ready
  27801. * @returns true if all effects are ready
  27802. */
  27803. areAllEffectsReady(): boolean;
  27804. private _rebuildBuffers;
  27805. private _initGLContext;
  27806. /**
  27807. * Gets version of the current webGL context
  27808. */
  27809. readonly webGLVersion: number;
  27810. /**
  27811. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27812. */
  27813. readonly isStencilEnable: boolean;
  27814. /** @hidden */
  27815. _prepareWorkingCanvas(): void;
  27816. /**
  27817. * Reset the texture cache to empty state
  27818. */
  27819. resetTextureCache(): void;
  27820. /**
  27821. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27822. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27823. * @returns true if engine is in deterministic lock step mode
  27824. */
  27825. isDeterministicLockStep(): boolean;
  27826. /**
  27827. * Gets the max steps when engine is running in deterministic lock step
  27828. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27829. * @returns the max steps
  27830. */
  27831. getLockstepMaxSteps(): number;
  27832. /**
  27833. * Gets an object containing information about the current webGL context
  27834. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27835. */
  27836. getGlInfo(): {
  27837. vendor: string;
  27838. renderer: string;
  27839. version: string;
  27840. };
  27841. /**
  27842. * Gets current aspect ratio
  27843. * @param camera defines the camera to use to get the aspect ratio
  27844. * @param useScreen defines if screen size must be used (or the current render target if any)
  27845. * @returns a number defining the aspect ratio
  27846. */
  27847. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27848. /**
  27849. * Gets current screen aspect ratio
  27850. * @returns a number defining the aspect ratio
  27851. */
  27852. getScreenAspectRatio(): number;
  27853. /**
  27854. * Gets the current render width
  27855. * @param useScreen defines if screen size must be used (or the current render target if any)
  27856. * @returns a number defining the current render width
  27857. */
  27858. getRenderWidth(useScreen?: boolean): number;
  27859. /**
  27860. * Gets the current render height
  27861. * @param useScreen defines if screen size must be used (or the current render target if any)
  27862. * @returns a number defining the current render height
  27863. */
  27864. getRenderHeight(useScreen?: boolean): number;
  27865. /**
  27866. * Gets the HTML canvas attached with the current webGL context
  27867. * @returns a HTML canvas
  27868. */
  27869. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27870. /**
  27871. * Gets the client rect of the HTML canvas attached with the current webGL context
  27872. * @returns a client rectanglee
  27873. */
  27874. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27875. /**
  27876. * Defines the hardware scaling level.
  27877. * By default the hardware scaling level is computed from the window device ratio.
  27878. * 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.
  27879. * @param level defines the level to use
  27880. */
  27881. setHardwareScalingLevel(level: number): void;
  27882. /**
  27883. * Gets the current hardware scaling level.
  27884. * By default the hardware scaling level is computed from the window device ratio.
  27885. * 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.
  27886. * @returns a number indicating the current hardware scaling level
  27887. */
  27888. getHardwareScalingLevel(): number;
  27889. /**
  27890. * Gets the list of loaded textures
  27891. * @returns an array containing all loaded textures
  27892. */
  27893. getLoadedTexturesCache(): InternalTexture[];
  27894. /**
  27895. * Gets the object containing all engine capabilities
  27896. * @returns the EngineCapabilities object
  27897. */
  27898. getCaps(): EngineCapabilities;
  27899. /**
  27900. * Gets the current depth function
  27901. * @returns a number defining the depth function
  27902. */
  27903. getDepthFunction(): Nullable<number>;
  27904. /**
  27905. * Sets the current depth function
  27906. * @param depthFunc defines the function to use
  27907. */
  27908. setDepthFunction(depthFunc: number): void;
  27909. /**
  27910. * Sets the current depth function to GREATER
  27911. */
  27912. setDepthFunctionToGreater(): void;
  27913. /**
  27914. * Sets the current depth function to GEQUAL
  27915. */
  27916. setDepthFunctionToGreaterOrEqual(): void;
  27917. /**
  27918. * Sets the current depth function to LESS
  27919. */
  27920. setDepthFunctionToLess(): void;
  27921. private _cachedStencilBuffer;
  27922. private _cachedStencilFunction;
  27923. private _cachedStencilMask;
  27924. private _cachedStencilOperationPass;
  27925. private _cachedStencilOperationFail;
  27926. private _cachedStencilOperationDepthFail;
  27927. private _cachedStencilReference;
  27928. /**
  27929. * Caches the the state of the stencil buffer
  27930. */
  27931. cacheStencilState(): void;
  27932. /**
  27933. * Restores the state of the stencil buffer
  27934. */
  27935. restoreStencilState(): void;
  27936. /**
  27937. * Sets the current depth function to LEQUAL
  27938. */
  27939. setDepthFunctionToLessOrEqual(): void;
  27940. /**
  27941. * Gets a boolean indicating if stencil buffer is enabled
  27942. * @returns the current stencil buffer state
  27943. */
  27944. getStencilBuffer(): boolean;
  27945. /**
  27946. * Enable or disable the stencil buffer
  27947. * @param enable defines if the stencil buffer must be enabled or disabled
  27948. */
  27949. setStencilBuffer(enable: boolean): void;
  27950. /**
  27951. * Gets the current stencil mask
  27952. * @returns a number defining the new stencil mask to use
  27953. */
  27954. getStencilMask(): number;
  27955. /**
  27956. * Sets the current stencil mask
  27957. * @param mask defines the new stencil mask to use
  27958. */
  27959. setStencilMask(mask: number): void;
  27960. /**
  27961. * Gets the current stencil function
  27962. * @returns a number defining the stencil function to use
  27963. */
  27964. getStencilFunction(): number;
  27965. /**
  27966. * Gets the current stencil reference value
  27967. * @returns a number defining the stencil reference value to use
  27968. */
  27969. getStencilFunctionReference(): number;
  27970. /**
  27971. * Gets the current stencil mask
  27972. * @returns a number defining the stencil mask to use
  27973. */
  27974. getStencilFunctionMask(): number;
  27975. /**
  27976. * Sets the current stencil function
  27977. * @param stencilFunc defines the new stencil function to use
  27978. */
  27979. setStencilFunction(stencilFunc: number): void;
  27980. /**
  27981. * Sets the current stencil reference
  27982. * @param reference defines the new stencil reference to use
  27983. */
  27984. setStencilFunctionReference(reference: number): void;
  27985. /**
  27986. * Sets the current stencil mask
  27987. * @param mask defines the new stencil mask to use
  27988. */
  27989. setStencilFunctionMask(mask: number): void;
  27990. /**
  27991. * Gets the current stencil operation when stencil fails
  27992. * @returns a number defining stencil operation to use when stencil fails
  27993. */
  27994. getStencilOperationFail(): number;
  27995. /**
  27996. * Gets the current stencil operation when depth fails
  27997. * @returns a number defining stencil operation to use when depth fails
  27998. */
  27999. getStencilOperationDepthFail(): number;
  28000. /**
  28001. * Gets the current stencil operation when stencil passes
  28002. * @returns a number defining stencil operation to use when stencil passes
  28003. */
  28004. getStencilOperationPass(): number;
  28005. /**
  28006. * Sets the stencil operation to use when stencil fails
  28007. * @param operation defines the stencil operation to use when stencil fails
  28008. */
  28009. setStencilOperationFail(operation: number): void;
  28010. /**
  28011. * Sets the stencil operation to use when depth fails
  28012. * @param operation defines the stencil operation to use when depth fails
  28013. */
  28014. setStencilOperationDepthFail(operation: number): void;
  28015. /**
  28016. * Sets the stencil operation to use when stencil passes
  28017. * @param operation defines the stencil operation to use when stencil passes
  28018. */
  28019. setStencilOperationPass(operation: number): void;
  28020. /**
  28021. * Sets a boolean indicating if the dithering state is enabled or disabled
  28022. * @param value defines the dithering state
  28023. */
  28024. setDitheringState(value: boolean): void;
  28025. /**
  28026. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28027. * @param value defines the rasterizer state
  28028. */
  28029. setRasterizerState(value: boolean): void;
  28030. /**
  28031. * stop executing a render loop function and remove it from the execution array
  28032. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28033. */
  28034. stopRenderLoop(renderFunction?: () => void): void;
  28035. /** @hidden */
  28036. _renderLoop(): void;
  28037. /**
  28038. * Register and execute a render loop. The engine can have more than one render function
  28039. * @param renderFunction defines the function to continuously execute
  28040. */
  28041. runRenderLoop(renderFunction: () => void): void;
  28042. /**
  28043. * Toggle full screen mode
  28044. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28045. */
  28046. switchFullscreen(requestPointerLock: boolean): void;
  28047. /**
  28048. * Enters full screen mode
  28049. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28050. */
  28051. enterFullscreen(requestPointerLock: boolean): void;
  28052. /**
  28053. * Exits full screen mode
  28054. */
  28055. exitFullscreen(): void;
  28056. /**
  28057. * Clear the current render buffer or the current render target (if any is set up)
  28058. * @param color defines the color to use
  28059. * @param backBuffer defines if the back buffer must be cleared
  28060. * @param depth defines if the depth buffer must be cleared
  28061. * @param stencil defines if the stencil buffer must be cleared
  28062. */
  28063. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28064. /**
  28065. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28066. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28067. * @param y defines the y-coordinate of the corner of the clear rectangle
  28068. * @param width defines the width of the clear rectangle
  28069. * @param height defines the height of the clear rectangle
  28070. * @param clearColor defines the clear color
  28071. */
  28072. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28073. /**
  28074. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28075. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28076. * @param y defines the y-coordinate of the corner of the clear rectangle
  28077. * @param width defines the width of the clear rectangle
  28078. * @param height defines the height of the clear rectangle
  28079. */
  28080. enableScissor(x: number, y: number, width: number, height: number): void;
  28081. /**
  28082. * Disable previously set scissor test rectangle
  28083. */
  28084. disableScissor(): void;
  28085. private _viewportCached;
  28086. /** @hidden */
  28087. _viewport(x: number, y: number, width: number, height: number): void;
  28088. /**
  28089. * Set the WebGL's viewport
  28090. * @param viewport defines the viewport element to be used
  28091. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28092. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28093. */
  28094. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28095. /**
  28096. * Directly set the WebGL Viewport
  28097. * @param x defines the x coordinate of the viewport (in screen space)
  28098. * @param y defines the y coordinate of the viewport (in screen space)
  28099. * @param width defines the width of the viewport (in screen space)
  28100. * @param height defines the height of the viewport (in screen space)
  28101. * @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
  28102. */
  28103. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28104. /**
  28105. * Begin a new frame
  28106. */
  28107. beginFrame(): void;
  28108. /**
  28109. * Enf the current frame
  28110. */
  28111. endFrame(): void;
  28112. /**
  28113. * Resize the view according to the canvas' size
  28114. */
  28115. resize(): void;
  28116. /**
  28117. * Force a specific size of the canvas
  28118. * @param width defines the new canvas' width
  28119. * @param height defines the new canvas' height
  28120. */
  28121. setSize(width: number, height: number): void;
  28122. /**
  28123. * Binds the frame buffer to the specified texture.
  28124. * @param texture The texture to render to or null for the default canvas
  28125. * @param faceIndex The face of the texture to render to in case of cube texture
  28126. * @param requiredWidth The width of the target to render to
  28127. * @param requiredHeight The height of the target to render to
  28128. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28129. * @param depthStencilTexture The depth stencil texture to use to render
  28130. * @param lodLevel defines le lod level to bind to the frame buffer
  28131. */
  28132. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28133. /** @hidden */
  28134. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28135. /**
  28136. * Unbind the current render target texture from the webGL context
  28137. * @param texture defines the render target texture to unbind
  28138. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28139. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28140. */
  28141. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28142. /**
  28143. * Force the mipmap generation for the given render target texture
  28144. * @param texture defines the render target texture to use
  28145. */
  28146. generateMipMapsForCubemap(texture: InternalTexture): void;
  28147. /**
  28148. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28149. */
  28150. flushFramebuffer(): void;
  28151. /**
  28152. * Unbind the current render target and bind the default framebuffer
  28153. */
  28154. restoreDefaultFramebuffer(): void;
  28155. /**
  28156. * Create an uniform buffer
  28157. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28158. * @param elements defines the content of the uniform buffer
  28159. * @returns the webGL uniform buffer
  28160. */
  28161. createUniformBuffer(elements: FloatArray): DataBuffer;
  28162. /**
  28163. * Create a dynamic uniform buffer
  28164. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28165. * @param elements defines the content of the uniform buffer
  28166. * @returns the webGL uniform buffer
  28167. */
  28168. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28169. /**
  28170. * Update an existing uniform buffer
  28171. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28172. * @param uniformBuffer defines the target uniform buffer
  28173. * @param elements defines the content to update
  28174. * @param offset defines the offset in the uniform buffer where update should start
  28175. * @param count defines the size of the data to update
  28176. */
  28177. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28178. private _resetVertexBufferBinding;
  28179. /**
  28180. * Creates a vertex buffer
  28181. * @param data the data for the vertex buffer
  28182. * @returns the new WebGL static buffer
  28183. */
  28184. createVertexBuffer(data: DataArray): DataBuffer;
  28185. /**
  28186. * Creates a dynamic vertex buffer
  28187. * @param data the data for the dynamic vertex buffer
  28188. * @returns the new WebGL dynamic buffer
  28189. */
  28190. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28191. /**
  28192. * Update a dynamic index buffer
  28193. * @param indexBuffer defines the target index buffer
  28194. * @param indices defines the data to update
  28195. * @param offset defines the offset in the target index buffer where update should start
  28196. */
  28197. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28198. /**
  28199. * Updates a dynamic vertex buffer.
  28200. * @param vertexBuffer the vertex buffer to update
  28201. * @param data the data used to update the vertex buffer
  28202. * @param byteOffset the byte offset of the data
  28203. * @param byteLength the byte length of the data
  28204. */
  28205. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28206. private _resetIndexBufferBinding;
  28207. /**
  28208. * Creates a new index buffer
  28209. * @param indices defines the content of the index buffer
  28210. * @param updatable defines if the index buffer must be updatable
  28211. * @returns a new webGL buffer
  28212. */
  28213. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28214. /**
  28215. * Bind a webGL buffer to the webGL context
  28216. * @param buffer defines the buffer to bind
  28217. */
  28218. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28219. /**
  28220. * Bind an uniform buffer to the current webGL context
  28221. * @param buffer defines the buffer to bind
  28222. */
  28223. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28224. /**
  28225. * Bind a buffer to the current webGL context at a given location
  28226. * @param buffer defines the buffer to bind
  28227. * @param location defines the index where to bind the buffer
  28228. */
  28229. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28230. /**
  28231. * Bind a specific block at a given index in a specific shader program
  28232. * @param pipelineContext defines the pipeline context to use
  28233. * @param blockName defines the block name
  28234. * @param index defines the index where to bind the block
  28235. */
  28236. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28237. private bindIndexBuffer;
  28238. private bindBuffer;
  28239. /**
  28240. * update the bound buffer with the given data
  28241. * @param data defines the data to update
  28242. */
  28243. updateArrayBuffer(data: Float32Array): void;
  28244. private _vertexAttribPointer;
  28245. private _bindIndexBufferWithCache;
  28246. private _bindVertexBuffersAttributes;
  28247. /**
  28248. * Records a vertex array object
  28249. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28250. * @param vertexBuffers defines the list of vertex buffers to store
  28251. * @param indexBuffer defines the index buffer to store
  28252. * @param effect defines the effect to store
  28253. * @returns the new vertex array object
  28254. */
  28255. recordVertexArrayObject(vertexBuffers: {
  28256. [key: string]: VertexBuffer;
  28257. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28258. /**
  28259. * Bind a specific vertex array object
  28260. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28261. * @param vertexArrayObject defines the vertex array object to bind
  28262. * @param indexBuffer defines the index buffer to bind
  28263. */
  28264. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28265. /**
  28266. * Bind webGl buffers directly to the webGL context
  28267. * @param vertexBuffer defines the vertex buffer to bind
  28268. * @param indexBuffer defines the index buffer to bind
  28269. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28270. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28271. * @param effect defines the effect associated with the vertex buffer
  28272. */
  28273. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28274. private _unbindVertexArrayObject;
  28275. /**
  28276. * Bind a list of vertex buffers to the webGL context
  28277. * @param vertexBuffers defines the list of vertex buffers to bind
  28278. * @param indexBuffer defines the index buffer to bind
  28279. * @param effect defines the effect associated with the vertex buffers
  28280. */
  28281. bindBuffers(vertexBuffers: {
  28282. [key: string]: Nullable<VertexBuffer>;
  28283. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28284. /**
  28285. * Unbind all instance attributes
  28286. */
  28287. unbindInstanceAttributes(): void;
  28288. /**
  28289. * Release and free the memory of a vertex array object
  28290. * @param vao defines the vertex array object to delete
  28291. */
  28292. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28293. /** @hidden */
  28294. _releaseBuffer(buffer: DataBuffer): boolean;
  28295. /**
  28296. * Creates a webGL buffer to use with instanciation
  28297. * @param capacity defines the size of the buffer
  28298. * @returns the webGL buffer
  28299. */
  28300. createInstancesBuffer(capacity: number): DataBuffer;
  28301. /**
  28302. * Delete a webGL buffer used with instanciation
  28303. * @param buffer defines the webGL buffer to delete
  28304. */
  28305. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28306. /**
  28307. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28308. * @param instancesBuffer defines the webGL buffer to update and bind
  28309. * @param data defines the data to store in the buffer
  28310. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28311. */
  28312. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28313. /**
  28314. * Apply all cached states (depth, culling, stencil and alpha)
  28315. */
  28316. applyStates(): void;
  28317. /**
  28318. * Send a draw order
  28319. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28320. * @param indexStart defines the starting index
  28321. * @param indexCount defines the number of index to draw
  28322. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28323. */
  28324. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28325. /**
  28326. * Draw a list of points
  28327. * @param verticesStart defines the index of first vertex to draw
  28328. * @param verticesCount defines the count of vertices to draw
  28329. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28330. */
  28331. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28332. /**
  28333. * Draw a list of unindexed primitives
  28334. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28335. * @param verticesStart defines the index of first vertex to draw
  28336. * @param verticesCount defines the count of vertices to draw
  28337. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28338. */
  28339. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28340. /**
  28341. * Draw a list of indexed primitives
  28342. * @param fillMode defines the primitive to use
  28343. * @param indexStart defines the starting index
  28344. * @param indexCount defines the number of index to draw
  28345. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28346. */
  28347. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28348. /**
  28349. * Draw a list of unindexed primitives
  28350. * @param fillMode defines the primitive to use
  28351. * @param verticesStart defines the index of first vertex to draw
  28352. * @param verticesCount defines the count of vertices to draw
  28353. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28354. */
  28355. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28356. private _drawMode;
  28357. /** @hidden */
  28358. _releaseEffect(effect: Effect): void;
  28359. /** @hidden */
  28360. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  28361. /**
  28362. * Create a new effect (used to store vertex/fragment shaders)
  28363. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28364. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28365. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28366. * @param samplers defines an array of string used to represent textures
  28367. * @param defines defines the string containing the defines to use to compile the shaders
  28368. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28369. * @param onCompiled defines a function to call when the effect creation is successful
  28370. * @param onError defines a function to call when the effect creation has failed
  28371. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28372. * @returns the new Effect
  28373. */
  28374. 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;
  28375. private _compileShader;
  28376. private _compileRawShader;
  28377. /**
  28378. * Directly creates a webGL program
  28379. * @param pipelineContext defines the pipeline context to attach to
  28380. * @param vertexCode defines the vertex shader code to use
  28381. * @param fragmentCode defines the fragment shader code to use
  28382. * @param context defines the webGL context to use (if not set, the current one will be used)
  28383. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28384. * @returns the new webGL program
  28385. */
  28386. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28387. /**
  28388. * Creates a webGL program
  28389. * @param pipelineContext defines the pipeline context to attach to
  28390. * @param vertexCode defines the vertex shader code to use
  28391. * @param fragmentCode defines the fragment shader code to use
  28392. * @param defines defines the string containing the defines to use to compile the shaders
  28393. * @param context defines the webGL context to use (if not set, the current one will be used)
  28394. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28395. * @returns the new webGL program
  28396. */
  28397. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28398. /**
  28399. * Creates a new pipeline context
  28400. * @returns the new pipeline
  28401. */
  28402. createPipelineContext(): WebGLPipelineContext;
  28403. private _createShaderProgram;
  28404. private _finalizePipelineContext;
  28405. /** @hidden */
  28406. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  28407. /** @hidden */
  28408. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  28409. /** @hidden */
  28410. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  28411. /**
  28412. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28413. * @param pipelineContext defines the pipeline context to use
  28414. * @param uniformsNames defines the list of uniform names
  28415. * @returns an array of webGL uniform locations
  28416. */
  28417. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28418. /**
  28419. * Gets the lsit of active attributes for a given webGL program
  28420. * @param pipelineContext defines the pipeline context to use
  28421. * @param attributesNames defines the list of attribute names to get
  28422. * @returns an array of indices indicating the offset of each attribute
  28423. */
  28424. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  28425. /**
  28426. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28427. * @param effect defines the effect to activate
  28428. */
  28429. enableEffect(effect: Nullable<Effect>): void;
  28430. /**
  28431. * Set the value of an uniform to an array of int32
  28432. * @param uniform defines the webGL uniform location where to store the value
  28433. * @param array defines the array of int32 to store
  28434. */
  28435. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28436. /**
  28437. * Set the value of an uniform to an array of int32 (stored as vec2)
  28438. * @param uniform defines the webGL uniform location where to store the value
  28439. * @param array defines the array of int32 to store
  28440. */
  28441. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28442. /**
  28443. * Set the value of an uniform to an array of int32 (stored as vec3)
  28444. * @param uniform defines the webGL uniform location where to store the value
  28445. * @param array defines the array of int32 to store
  28446. */
  28447. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28448. /**
  28449. * Set the value of an uniform to an array of int32 (stored as vec4)
  28450. * @param uniform defines the webGL uniform location where to store the value
  28451. * @param array defines the array of int32 to store
  28452. */
  28453. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28454. /**
  28455. * Set the value of an uniform to an array of float32
  28456. * @param uniform defines the webGL uniform location where to store the value
  28457. * @param array defines the array of float32 to store
  28458. */
  28459. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28460. /**
  28461. * Set the value of an uniform to an array of float32 (stored as vec2)
  28462. * @param uniform defines the webGL uniform location where to store the value
  28463. * @param array defines the array of float32 to store
  28464. */
  28465. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28466. /**
  28467. * Set the value of an uniform to an array of float32 (stored as vec3)
  28468. * @param uniform defines the webGL uniform location where to store the value
  28469. * @param array defines the array of float32 to store
  28470. */
  28471. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28472. /**
  28473. * Set the value of an uniform to an array of float32 (stored as vec4)
  28474. * @param uniform defines the webGL uniform location where to store the value
  28475. * @param array defines the array of float32 to store
  28476. */
  28477. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28478. /**
  28479. * Set the value of an uniform to an array of number
  28480. * @param uniform defines the webGL uniform location where to store the value
  28481. * @param array defines the array of number to store
  28482. */
  28483. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28484. /**
  28485. * Set the value of an uniform to an array of number (stored as vec2)
  28486. * @param uniform defines the webGL uniform location where to store the value
  28487. * @param array defines the array of number to store
  28488. */
  28489. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28490. /**
  28491. * Set the value of an uniform to an array of number (stored as vec3)
  28492. * @param uniform defines the webGL uniform location where to store the value
  28493. * @param array defines the array of number to store
  28494. */
  28495. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28496. /**
  28497. * Set the value of an uniform to an array of number (stored as vec4)
  28498. * @param uniform defines the webGL uniform location where to store the value
  28499. * @param array defines the array of number to store
  28500. */
  28501. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28502. /**
  28503. * Set the value of an uniform to an array of float32 (stored as matrices)
  28504. * @param uniform defines the webGL uniform location where to store the value
  28505. * @param matrices defines the array of float32 to store
  28506. */
  28507. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28508. /**
  28509. * Set the value of an uniform to a matrix
  28510. * @param uniform defines the webGL uniform location where to store the value
  28511. * @param matrix defines the matrix to store
  28512. */
  28513. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28514. /**
  28515. * Set the value of an uniform to a matrix (3x3)
  28516. * @param uniform defines the webGL uniform location where to store the value
  28517. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28518. */
  28519. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28520. /**
  28521. * Set the value of an uniform to a matrix (2x2)
  28522. * @param uniform defines the webGL uniform location where to store the value
  28523. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28524. */
  28525. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28526. /**
  28527. * Set the value of an uniform to a number (int)
  28528. * @param uniform defines the webGL uniform location where to store the value
  28529. * @param value defines the int number to store
  28530. */
  28531. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28532. /**
  28533. * Set the value of an uniform to a number (float)
  28534. * @param uniform defines the webGL uniform location where to store the value
  28535. * @param value defines the float number to store
  28536. */
  28537. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28538. /**
  28539. * Set the value of an uniform to a vec2
  28540. * @param uniform defines the webGL uniform location where to store the value
  28541. * @param x defines the 1st component of the value
  28542. * @param y defines the 2nd component of the value
  28543. */
  28544. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28545. /**
  28546. * Set the value of an uniform to a vec3
  28547. * @param uniform defines the webGL uniform location where to store the value
  28548. * @param x defines the 1st component of the value
  28549. * @param y defines the 2nd component of the value
  28550. * @param z defines the 3rd component of the value
  28551. */
  28552. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28553. /**
  28554. * Set the value of an uniform to a boolean
  28555. * @param uniform defines the webGL uniform location where to store the value
  28556. * @param bool defines the boolean to store
  28557. */
  28558. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28559. /**
  28560. * Set the value of an uniform to a vec4
  28561. * @param uniform defines the webGL uniform location where to store the value
  28562. * @param x defines the 1st component of the value
  28563. * @param y defines the 2nd component of the value
  28564. * @param z defines the 3rd component of the value
  28565. * @param w defines the 4th component of the value
  28566. */
  28567. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28568. /**
  28569. * Set the value of an uniform to a Color3
  28570. * @param uniform defines the webGL uniform location where to store the value
  28571. * @param color3 defines the color to store
  28572. */
  28573. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28574. /**
  28575. * Set the value of an uniform to a Color3 and an alpha value
  28576. * @param uniform defines the webGL uniform location where to store the value
  28577. * @param color3 defines the color to store
  28578. * @param alpha defines the alpha component to store
  28579. */
  28580. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28581. /**
  28582. * Sets a Color4 on a uniform variable
  28583. * @param uniform defines the uniform location
  28584. * @param color4 defines the value to be set
  28585. */
  28586. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28587. /**
  28588. * Set various states to the webGL context
  28589. * @param culling defines backface culling state
  28590. * @param zOffset defines the value to apply to zOffset (0 by default)
  28591. * @param force defines if states must be applied even if cache is up to date
  28592. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28593. */
  28594. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28595. /**
  28596. * Set the z offset to apply to current rendering
  28597. * @param value defines the offset to apply
  28598. */
  28599. setZOffset(value: number): void;
  28600. /**
  28601. * Gets the current value of the zOffset
  28602. * @returns the current zOffset state
  28603. */
  28604. getZOffset(): number;
  28605. /**
  28606. * Enable or disable depth buffering
  28607. * @param enable defines the state to set
  28608. */
  28609. setDepthBuffer(enable: boolean): void;
  28610. /**
  28611. * Gets a boolean indicating if depth writing is enabled
  28612. * @returns the current depth writing state
  28613. */
  28614. getDepthWrite(): boolean;
  28615. /**
  28616. * Enable or disable depth writing
  28617. * @param enable defines the state to set
  28618. */
  28619. setDepthWrite(enable: boolean): void;
  28620. /**
  28621. * Enable or disable color writing
  28622. * @param enable defines the state to set
  28623. */
  28624. setColorWrite(enable: boolean): void;
  28625. /**
  28626. * Gets a boolean indicating if color writing is enabled
  28627. * @returns the current color writing state
  28628. */
  28629. getColorWrite(): boolean;
  28630. /**
  28631. * Sets alpha constants used by some alpha blending modes
  28632. * @param r defines the red component
  28633. * @param g defines the green component
  28634. * @param b defines the blue component
  28635. * @param a defines the alpha component
  28636. */
  28637. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28638. /**
  28639. * Sets the current alpha mode
  28640. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28641. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28642. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28643. */
  28644. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28645. /**
  28646. * Gets the current alpha mode
  28647. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28648. * @returns the current alpha mode
  28649. */
  28650. getAlphaMode(): number;
  28651. /**
  28652. * Clears the list of texture accessible through engine.
  28653. * This can help preventing texture load conflict due to name collision.
  28654. */
  28655. clearInternalTexturesCache(): void;
  28656. /**
  28657. * Force the entire cache to be cleared
  28658. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28659. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28660. */
  28661. wipeCaches(bruteForce?: boolean): void;
  28662. /**
  28663. * Set the compressed texture format to use, based on the formats you have, and the formats
  28664. * supported by the hardware / browser.
  28665. *
  28666. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28667. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28668. * to API arguments needed to compressed textures. This puts the burden on the container
  28669. * generator to house the arcane code for determining these for current & future formats.
  28670. *
  28671. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28672. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28673. *
  28674. * Note: The result of this call is not taken into account when a texture is base64.
  28675. *
  28676. * @param formatsAvailable defines the list of those format families you have created
  28677. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28678. *
  28679. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28680. * @returns The extension selected.
  28681. */
  28682. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28683. /** @hidden */
  28684. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28685. min: number;
  28686. mag: number;
  28687. };
  28688. /** @hidden */
  28689. _createTexture(): WebGLTexture;
  28690. /**
  28691. * Usually called from Texture.ts.
  28692. * Passed information to create a WebGLTexture
  28693. * @param urlArg defines a value which contains one of the following:
  28694. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28695. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28696. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28697. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28698. * @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)
  28699. * @param scene needed for loading to the correct scene
  28700. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28701. * @param onLoad optional callback to be called upon successful completion
  28702. * @param onError optional callback to be called upon failure
  28703. * @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
  28704. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28705. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28706. * @param forcedExtension defines the extension to use to pick the right loader
  28707. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28708. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28709. */
  28710. 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;
  28711. private _rescaleTexture;
  28712. private _unpackFlipYCached;
  28713. /**
  28714. * In case you are sharing the context with other applications, it might
  28715. * be interested to not cache the unpack flip y state to ensure a consistent
  28716. * value would be set.
  28717. */
  28718. enableUnpackFlipYCached: boolean;
  28719. /** @hidden */
  28720. _unpackFlipY(value: boolean): void;
  28721. /** @hidden */
  28722. _getUnpackAlignement(): number;
  28723. /**
  28724. * Creates a dynamic texture
  28725. * @param width defines the width of the texture
  28726. * @param height defines the height of the texture
  28727. * @param generateMipMaps defines if the engine should generate the mip levels
  28728. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28729. * @returns the dynamic texture inside an InternalTexture
  28730. */
  28731. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28732. /**
  28733. * Update the sampling mode of a given texture
  28734. * @param samplingMode defines the required sampling mode
  28735. * @param texture defines the texture to update
  28736. */
  28737. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28738. /**
  28739. * Update the content of a dynamic texture
  28740. * @param texture defines the texture to update
  28741. * @param canvas defines the canvas containing the source
  28742. * @param invertY defines if data must be stored with Y axis inverted
  28743. * @param premulAlpha defines if alpha is stored as premultiplied
  28744. * @param format defines the format of the data
  28745. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28746. */
  28747. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28748. /**
  28749. * Update a video texture
  28750. * @param texture defines the texture to update
  28751. * @param video defines the video element to use
  28752. * @param invertY defines if data must be stored with Y axis inverted
  28753. */
  28754. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28755. /**
  28756. * Updates a depth texture Comparison Mode and Function.
  28757. * If the comparison Function is equal to 0, the mode will be set to none.
  28758. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28759. * @param texture The texture to set the comparison function for
  28760. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28761. */
  28762. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28763. /** @hidden */
  28764. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  28765. width: number;
  28766. height: number;
  28767. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  28768. /**
  28769. * Creates a depth stencil texture.
  28770. * This is only available in WebGL 2 or with the depth texture extension available.
  28771. * @param size The size of face edge in the texture.
  28772. * @param options The options defining the texture.
  28773. * @returns The texture
  28774. */
  28775. createDepthStencilTexture(size: number | {
  28776. width: number;
  28777. height: number;
  28778. }, options: DepthTextureCreationOptions): InternalTexture;
  28779. /**
  28780. * Creates a depth stencil texture.
  28781. * This is only available in WebGL 2 or with the depth texture extension available.
  28782. * @param size The size of face edge in the texture.
  28783. * @param options The options defining the texture.
  28784. * @returns The texture
  28785. */
  28786. private _createDepthStencilTexture;
  28787. /**
  28788. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28789. * @param renderTarget The render target to set the frame buffer for
  28790. */
  28791. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28792. /**
  28793. * Creates a new render target texture
  28794. * @param size defines the size of the texture
  28795. * @param options defines the options used to create the texture
  28796. * @returns a new render target texture stored in an InternalTexture
  28797. */
  28798. createRenderTargetTexture(size: number | {
  28799. width: number;
  28800. height: number;
  28801. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28802. /** @hidden */
  28803. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  28804. /**
  28805. * Updates the sample count of a render target texture
  28806. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28807. * @param texture defines the texture to update
  28808. * @param samples defines the sample count to set
  28809. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28810. */
  28811. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28812. /** @hidden */
  28813. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28814. /** @hidden */
  28815. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28816. /** @hidden */
  28817. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28818. /** @hidden */
  28819. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28820. /**
  28821. * @hidden
  28822. */
  28823. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28824. private _prepareWebGLTextureContinuation;
  28825. private _prepareWebGLTexture;
  28826. /** @hidden */
  28827. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  28828. /** @hidden */
  28829. _releaseFramebufferObjects(texture: InternalTexture): void;
  28830. /** @hidden */
  28831. _releaseTexture(texture: InternalTexture): void;
  28832. private setProgram;
  28833. private _boundUniforms;
  28834. /**
  28835. * Binds an effect to the webGL context
  28836. * @param effect defines the effect to bind
  28837. */
  28838. bindSamplers(effect: Effect): void;
  28839. private _activateCurrentTexture;
  28840. /** @hidden */
  28841. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28842. /** @hidden */
  28843. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28844. /**
  28845. * Sets a texture to the webGL context from a postprocess
  28846. * @param channel defines the channel to use
  28847. * @param postProcess defines the source postprocess
  28848. */
  28849. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28850. /**
  28851. * Binds the output of the passed in post process to the texture channel specified
  28852. * @param channel The channel the texture should be bound to
  28853. * @param postProcess The post process which's output should be bound
  28854. */
  28855. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28856. /**
  28857. * Unbind all textures from the webGL context
  28858. */
  28859. unbindAllTextures(): void;
  28860. /**
  28861. * Sets a texture to the according uniform.
  28862. * @param channel The texture channel
  28863. * @param uniform The uniform to set
  28864. * @param texture The texture to apply
  28865. */
  28866. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28867. /**
  28868. * Sets a depth stencil texture from a render target to the according uniform.
  28869. * @param channel The texture channel
  28870. * @param uniform The uniform to set
  28871. * @param texture The render target texture containing the depth stencil texture to apply
  28872. */
  28873. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28874. private _bindSamplerUniformToChannel;
  28875. private _getTextureWrapMode;
  28876. private _setTexture;
  28877. /**
  28878. * Sets an array of texture to the webGL context
  28879. * @param channel defines the channel where the texture array must be set
  28880. * @param uniform defines the associated uniform location
  28881. * @param textures defines the array of textures to bind
  28882. */
  28883. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28884. /** @hidden */
  28885. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28886. private _setTextureParameterFloat;
  28887. private _setTextureParameterInteger;
  28888. /**
  28889. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28890. * @param x defines the x coordinate of the rectangle where pixels must be read
  28891. * @param y defines the y coordinate of the rectangle where pixels must be read
  28892. * @param width defines the width of the rectangle where pixels must be read
  28893. * @param height defines the height of the rectangle where pixels must be read
  28894. * @returns a Uint8Array containing RGBA colors
  28895. */
  28896. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28897. /**
  28898. * Add an externaly attached data from its key.
  28899. * This method call will fail and return false, if such key already exists.
  28900. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28901. * @param key the unique key that identifies the data
  28902. * @param data the data object to associate to the key for this Engine instance
  28903. * @return true if no such key were already present and the data was added successfully, false otherwise
  28904. */
  28905. addExternalData<T>(key: string, data: T): boolean;
  28906. /**
  28907. * Get an externaly attached data from its key
  28908. * @param key the unique key that identifies the data
  28909. * @return the associated data, if present (can be null), or undefined if not present
  28910. */
  28911. getExternalData<T>(key: string): T;
  28912. /**
  28913. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28914. * @param key the unique key that identifies the data
  28915. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28916. * @return the associated data, can be null if the factory returned null.
  28917. */
  28918. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28919. /**
  28920. * Remove an externaly attached data from the Engine instance
  28921. * @param key the unique key that identifies the data
  28922. * @return true if the data was successfully removed, false if it doesn't exist
  28923. */
  28924. removeExternalData(key: string): boolean;
  28925. /**
  28926. * Unbind all vertex attributes from the webGL context
  28927. */
  28928. unbindAllAttributes(): void;
  28929. /**
  28930. * 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
  28931. */
  28932. releaseEffects(): void;
  28933. /**
  28934. * Dispose and release all associated resources
  28935. */
  28936. dispose(): void;
  28937. /**
  28938. * Display the loading screen
  28939. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28940. */
  28941. displayLoadingUI(): void;
  28942. /**
  28943. * Hide the loading screen
  28944. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28945. */
  28946. hideLoadingUI(): void;
  28947. /**
  28948. * Gets the current loading screen object
  28949. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28950. */
  28951. /**
  28952. * Sets the current loading screen object
  28953. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28954. */
  28955. loadingScreen: ILoadingScreen;
  28956. /**
  28957. * Sets the current loading screen text
  28958. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28959. */
  28960. loadingUIText: string;
  28961. /**
  28962. * Sets the current loading screen background color
  28963. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28964. */
  28965. loadingUIBackgroundColor: string;
  28966. /**
  28967. * Attach a new callback raised when context lost event is fired
  28968. * @param callback defines the callback to call
  28969. */
  28970. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28971. /**
  28972. * Attach a new callback raised when context restored event is fired
  28973. * @param callback defines the callback to call
  28974. */
  28975. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28976. /**
  28977. * Gets the source code of the vertex shader associated with a specific webGL program
  28978. * @param program defines the program to use
  28979. * @returns a string containing the source code of the vertex shader associated with the program
  28980. */
  28981. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28982. /**
  28983. * Gets the source code of the fragment shader associated with a specific webGL program
  28984. * @param program defines the program to use
  28985. * @returns a string containing the source code of the fragment shader associated with the program
  28986. */
  28987. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28988. /**
  28989. * Get the current error code of the webGL context
  28990. * @returns the error code
  28991. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28992. */
  28993. getError(): number;
  28994. /**
  28995. * Gets the current framerate
  28996. * @returns a number representing the framerate
  28997. */
  28998. getFps(): number;
  28999. /**
  29000. * Gets the time spent between current and previous frame
  29001. * @returns a number representing the delta time in ms
  29002. */
  29003. getDeltaTime(): number;
  29004. private _measureFps;
  29005. /** @hidden */
  29006. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29007. private _canRenderToFloatFramebuffer;
  29008. private _canRenderToHalfFloatFramebuffer;
  29009. private _canRenderToFramebuffer;
  29010. /** @hidden */
  29011. _getWebGLTextureType(type: number): number;
  29012. /** @hidden */
  29013. _getInternalFormat(format: number): number;
  29014. /** @hidden */
  29015. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29016. /** @hidden */
  29017. _getRGBAMultiSampleBufferFormat(type: number): number;
  29018. /** @hidden */
  29019. _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;
  29020. /** @hidden */
  29021. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29022. /**
  29023. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29024. * @returns true if the engine can be created
  29025. * @ignorenaming
  29026. */
  29027. static isSupported(): boolean;
  29028. }
  29029. }
  29030. declare module BABYLON {
  29031. /**
  29032. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29033. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29034. */
  29035. export class EffectFallbacks {
  29036. private _defines;
  29037. private _currentRank;
  29038. private _maxRank;
  29039. private _mesh;
  29040. /**
  29041. * Removes the fallback from the bound mesh.
  29042. */
  29043. unBindMesh(): void;
  29044. /**
  29045. * Adds a fallback on the specified property.
  29046. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29047. * @param define The name of the define in the shader
  29048. */
  29049. addFallback(rank: number, define: string): void;
  29050. /**
  29051. * Sets the mesh to use CPU skinning when needing to fallback.
  29052. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29053. * @param mesh The mesh to use the fallbacks.
  29054. */
  29055. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29056. /**
  29057. * Checks to see if more fallbacks are still availible.
  29058. */
  29059. readonly isMoreFallbacks: boolean;
  29060. /**
  29061. * Removes the defines that shoould be removed when falling back.
  29062. * @param currentDefines defines the current define statements for the shader.
  29063. * @param effect defines the current effect we try to compile
  29064. * @returns The resulting defines with defines of the current rank removed.
  29065. */
  29066. reduce(currentDefines: string, effect: Effect): string;
  29067. }
  29068. /**
  29069. * Options to be used when creating an effect.
  29070. */
  29071. export class EffectCreationOptions {
  29072. /**
  29073. * Atrributes that will be used in the shader.
  29074. */
  29075. attributes: string[];
  29076. /**
  29077. * Uniform varible names that will be set in the shader.
  29078. */
  29079. uniformsNames: string[];
  29080. /**
  29081. * Uniform buffer varible names that will be set in the shader.
  29082. */
  29083. uniformBuffersNames: string[];
  29084. /**
  29085. * Sampler texture variable names that will be set in the shader.
  29086. */
  29087. samplers: string[];
  29088. /**
  29089. * Define statements that will be set in the shader.
  29090. */
  29091. defines: any;
  29092. /**
  29093. * Possible fallbacks for this effect to improve performance when needed.
  29094. */
  29095. fallbacks: Nullable<EffectFallbacks>;
  29096. /**
  29097. * Callback that will be called when the shader is compiled.
  29098. */
  29099. onCompiled: Nullable<(effect: Effect) => void>;
  29100. /**
  29101. * Callback that will be called if an error occurs during shader compilation.
  29102. */
  29103. onError: Nullable<(effect: Effect, errors: string) => void>;
  29104. /**
  29105. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29106. */
  29107. indexParameters: any;
  29108. /**
  29109. * Max number of lights that can be used in the shader.
  29110. */
  29111. maxSimultaneousLights: number;
  29112. /**
  29113. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29114. */
  29115. transformFeedbackVaryings: Nullable<string[]>;
  29116. }
  29117. /**
  29118. * Effect containing vertex and fragment shader that can be executed on an object.
  29119. */
  29120. export class Effect implements IDisposable {
  29121. /**
  29122. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29123. */
  29124. static ShadersRepository: string;
  29125. /**
  29126. * Name of the effect.
  29127. */
  29128. name: any;
  29129. /**
  29130. * String container all the define statements that should be set on the shader.
  29131. */
  29132. defines: string;
  29133. /**
  29134. * Callback that will be called when the shader is compiled.
  29135. */
  29136. onCompiled: Nullable<(effect: Effect) => void>;
  29137. /**
  29138. * Callback that will be called if an error occurs during shader compilation.
  29139. */
  29140. onError: Nullable<(effect: Effect, errors: string) => void>;
  29141. /**
  29142. * Callback that will be called when effect is bound.
  29143. */
  29144. onBind: Nullable<(effect: Effect) => void>;
  29145. /**
  29146. * Unique ID of the effect.
  29147. */
  29148. uniqueId: number;
  29149. /**
  29150. * Observable that will be called when the shader is compiled.
  29151. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29152. */
  29153. onCompileObservable: Observable<Effect>;
  29154. /**
  29155. * Observable that will be called if an error occurs during shader compilation.
  29156. */
  29157. onErrorObservable: Observable<Effect>;
  29158. /** @hidden */
  29159. _onBindObservable: Nullable<Observable<Effect>>;
  29160. /**
  29161. * Observable that will be called when effect is bound.
  29162. */
  29163. readonly onBindObservable: Observable<Effect>;
  29164. /** @hidden */
  29165. _bonesComputationForcedToCPU: boolean;
  29166. private static _uniqueIdSeed;
  29167. private _engine;
  29168. private _uniformBuffersNames;
  29169. private _uniformsNames;
  29170. private _samplerList;
  29171. private _samplers;
  29172. private _isReady;
  29173. private _compilationError;
  29174. private _attributesNames;
  29175. private _attributes;
  29176. private _uniforms;
  29177. /**
  29178. * Key for the effect.
  29179. * @hidden
  29180. */
  29181. _key: string;
  29182. private _indexParameters;
  29183. private _fallbacks;
  29184. private _vertexSourceCode;
  29185. private _fragmentSourceCode;
  29186. private _vertexSourceCodeOverride;
  29187. private _fragmentSourceCodeOverride;
  29188. private _transformFeedbackVaryings;
  29189. /**
  29190. * Compiled shader to webGL program.
  29191. * @hidden
  29192. */
  29193. _pipelineContext: Nullable<IPipelineContext>;
  29194. private _valueCache;
  29195. private static _baseCache;
  29196. /**
  29197. * Instantiates an effect.
  29198. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29199. * @param baseName Name of the effect.
  29200. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29201. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29202. * @param samplers List of sampler variables that will be passed to the shader.
  29203. * @param engine Engine to be used to render the effect
  29204. * @param defines Define statements to be added to the shader.
  29205. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29206. * @param onCompiled Callback that will be called when the shader is compiled.
  29207. * @param onError Callback that will be called if an error occurs during shader compilation.
  29208. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29209. */
  29210. 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);
  29211. /**
  29212. * Unique key for this effect
  29213. */
  29214. readonly key: string;
  29215. /**
  29216. * If the effect has been compiled and prepared.
  29217. * @returns if the effect is compiled and prepared.
  29218. */
  29219. isReady(): boolean;
  29220. /**
  29221. * The engine the effect was initialized with.
  29222. * @returns the engine.
  29223. */
  29224. getEngine(): Engine;
  29225. /**
  29226. * The pipeline context for this effect
  29227. * @returns the associated pipeline context
  29228. */
  29229. getPipelineContext(): Nullable<IPipelineContext>;
  29230. /**
  29231. * The set of names of attribute variables for the shader.
  29232. * @returns An array of attribute names.
  29233. */
  29234. getAttributesNames(): string[];
  29235. /**
  29236. * Returns the attribute at the given index.
  29237. * @param index The index of the attribute.
  29238. * @returns The location of the attribute.
  29239. */
  29240. getAttributeLocation(index: number): number;
  29241. /**
  29242. * Returns the attribute based on the name of the variable.
  29243. * @param name of the attribute to look up.
  29244. * @returns the attribute location.
  29245. */
  29246. getAttributeLocationByName(name: string): number;
  29247. /**
  29248. * The number of attributes.
  29249. * @returns the numnber of attributes.
  29250. */
  29251. getAttributesCount(): number;
  29252. /**
  29253. * Gets the index of a uniform variable.
  29254. * @param uniformName of the uniform to look up.
  29255. * @returns the index.
  29256. */
  29257. getUniformIndex(uniformName: string): number;
  29258. /**
  29259. * Returns the attribute based on the name of the variable.
  29260. * @param uniformName of the uniform to look up.
  29261. * @returns the location of the uniform.
  29262. */
  29263. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29264. /**
  29265. * Returns an array of sampler variable names
  29266. * @returns The array of sampler variable neames.
  29267. */
  29268. getSamplers(): string[];
  29269. /**
  29270. * The error from the last compilation.
  29271. * @returns the error string.
  29272. */
  29273. getCompilationError(): string;
  29274. /**
  29275. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29276. * @param func The callback to be used.
  29277. */
  29278. executeWhenCompiled(func: (effect: Effect) => void): void;
  29279. private _checkIsReady;
  29280. /** @hidden */
  29281. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29282. /** @hidden */
  29283. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29284. /** @hidden */
  29285. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29286. private _processShaderConversion;
  29287. private _processIncludes;
  29288. private _processPrecision;
  29289. /**
  29290. * Recompiles the webGL program
  29291. * @param vertexSourceCode The source code for the vertex shader.
  29292. * @param fragmentSourceCode The source code for the fragment shader.
  29293. * @param onCompiled Callback called when completed.
  29294. * @param onError Callback called on error.
  29295. * @hidden
  29296. */
  29297. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29298. /**
  29299. * Prepares the effect
  29300. * @hidden
  29301. */
  29302. _prepareEffect(): void;
  29303. /**
  29304. * Checks if the effect is supported. (Must be called after compilation)
  29305. */
  29306. readonly isSupported: boolean;
  29307. /**
  29308. * Binds a texture to the engine to be used as output of the shader.
  29309. * @param channel Name of the output variable.
  29310. * @param texture Texture to bind.
  29311. * @hidden
  29312. */
  29313. _bindTexture(channel: string, texture: InternalTexture): void;
  29314. /**
  29315. * Sets a texture on the engine to be used in the shader.
  29316. * @param channel Name of the sampler variable.
  29317. * @param texture Texture to set.
  29318. */
  29319. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29320. /**
  29321. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29322. * @param channel Name of the sampler variable.
  29323. * @param texture Texture to set.
  29324. */
  29325. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29326. /**
  29327. * Sets an array of textures on the engine to be used in the shader.
  29328. * @param channel Name of the variable.
  29329. * @param textures Textures to set.
  29330. */
  29331. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29332. /**
  29333. * 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)
  29334. * @param channel Name of the sampler variable.
  29335. * @param postProcess Post process to get the input texture from.
  29336. */
  29337. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29338. /**
  29339. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29340. * 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)
  29341. * @param channel Name of the sampler variable.
  29342. * @param postProcess Post process to get the output texture from.
  29343. */
  29344. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29345. /** @hidden */
  29346. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29347. /** @hidden */
  29348. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29349. /** @hidden */
  29350. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29351. /** @hidden */
  29352. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29353. /**
  29354. * Binds a buffer to a uniform.
  29355. * @param buffer Buffer to bind.
  29356. * @param name Name of the uniform variable to bind to.
  29357. */
  29358. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29359. /**
  29360. * Binds block to a uniform.
  29361. * @param blockName Name of the block to bind.
  29362. * @param index Index to bind.
  29363. */
  29364. bindUniformBlock(blockName: string, index: number): void;
  29365. /**
  29366. * Sets an interger value on a uniform variable.
  29367. * @param uniformName Name of the variable.
  29368. * @param value Value to be set.
  29369. * @returns this effect.
  29370. */
  29371. setInt(uniformName: string, value: number): Effect;
  29372. /**
  29373. * Sets an int array on a uniform variable.
  29374. * @param uniformName Name of the variable.
  29375. * @param array array to be set.
  29376. * @returns this effect.
  29377. */
  29378. setIntArray(uniformName: string, array: Int32Array): Effect;
  29379. /**
  29380. * 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)
  29381. * @param uniformName Name of the variable.
  29382. * @param array array to be set.
  29383. * @returns this effect.
  29384. */
  29385. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29386. /**
  29387. * 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)
  29388. * @param uniformName Name of the variable.
  29389. * @param array array to be set.
  29390. * @returns this effect.
  29391. */
  29392. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29393. /**
  29394. * 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)
  29395. * @param uniformName Name of the variable.
  29396. * @param array array to be set.
  29397. * @returns this effect.
  29398. */
  29399. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29400. /**
  29401. * Sets an float array on a uniform variable.
  29402. * @param uniformName Name of the variable.
  29403. * @param array array to be set.
  29404. * @returns this effect.
  29405. */
  29406. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29407. /**
  29408. * 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)
  29409. * @param uniformName Name of the variable.
  29410. * @param array array to be set.
  29411. * @returns this effect.
  29412. */
  29413. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29414. /**
  29415. * 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)
  29416. * @param uniformName Name of the variable.
  29417. * @param array array to be set.
  29418. * @returns this effect.
  29419. */
  29420. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29421. /**
  29422. * 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)
  29423. * @param uniformName Name of the variable.
  29424. * @param array array to be set.
  29425. * @returns this effect.
  29426. */
  29427. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29428. /**
  29429. * Sets an array on a uniform variable.
  29430. * @param uniformName Name of the variable.
  29431. * @param array array to be set.
  29432. * @returns this effect.
  29433. */
  29434. setArray(uniformName: string, array: number[]): Effect;
  29435. /**
  29436. * 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)
  29437. * @param uniformName Name of the variable.
  29438. * @param array array to be set.
  29439. * @returns this effect.
  29440. */
  29441. setArray2(uniformName: string, array: number[]): Effect;
  29442. /**
  29443. * 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)
  29444. * @param uniformName Name of the variable.
  29445. * @param array array to be set.
  29446. * @returns this effect.
  29447. */
  29448. setArray3(uniformName: string, array: number[]): Effect;
  29449. /**
  29450. * 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)
  29451. * @param uniformName Name of the variable.
  29452. * @param array array to be set.
  29453. * @returns this effect.
  29454. */
  29455. setArray4(uniformName: string, array: number[]): Effect;
  29456. /**
  29457. * Sets matrices on a uniform variable.
  29458. * @param uniformName Name of the variable.
  29459. * @param matrices matrices to be set.
  29460. * @returns this effect.
  29461. */
  29462. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29463. /**
  29464. * Sets matrix on a uniform variable.
  29465. * @param uniformName Name of the variable.
  29466. * @param matrix matrix to be set.
  29467. * @returns this effect.
  29468. */
  29469. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29470. /**
  29471. * 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)
  29472. * @param uniformName Name of the variable.
  29473. * @param matrix matrix to be set.
  29474. * @returns this effect.
  29475. */
  29476. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29477. /**
  29478. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29479. * @param uniformName Name of the variable.
  29480. * @param matrix matrix to be set.
  29481. * @returns this effect.
  29482. */
  29483. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29484. /**
  29485. * Sets a float on a uniform variable.
  29486. * @param uniformName Name of the variable.
  29487. * @param value value to be set.
  29488. * @returns this effect.
  29489. */
  29490. setFloat(uniformName: string, value: number): Effect;
  29491. /**
  29492. * Sets a boolean on a uniform variable.
  29493. * @param uniformName Name of the variable.
  29494. * @param bool value to be set.
  29495. * @returns this effect.
  29496. */
  29497. setBool(uniformName: string, bool: boolean): Effect;
  29498. /**
  29499. * Sets a Vector2 on a uniform variable.
  29500. * @param uniformName Name of the variable.
  29501. * @param vector2 vector2 to be set.
  29502. * @returns this effect.
  29503. */
  29504. setVector2(uniformName: string, vector2: Vector2): Effect;
  29505. /**
  29506. * Sets a float2 on a uniform variable.
  29507. * @param uniformName Name of the variable.
  29508. * @param x First float in float2.
  29509. * @param y Second float in float2.
  29510. * @returns this effect.
  29511. */
  29512. setFloat2(uniformName: string, x: number, y: number): Effect;
  29513. /**
  29514. * Sets a Vector3 on a uniform variable.
  29515. * @param uniformName Name of the variable.
  29516. * @param vector3 Value to be set.
  29517. * @returns this effect.
  29518. */
  29519. setVector3(uniformName: string, vector3: Vector3): Effect;
  29520. /**
  29521. * Sets a float3 on a uniform variable.
  29522. * @param uniformName Name of the variable.
  29523. * @param x First float in float3.
  29524. * @param y Second float in float3.
  29525. * @param z Third float in float3.
  29526. * @returns this effect.
  29527. */
  29528. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29529. /**
  29530. * Sets a Vector4 on a uniform variable.
  29531. * @param uniformName Name of the variable.
  29532. * @param vector4 Value to be set.
  29533. * @returns this effect.
  29534. */
  29535. setVector4(uniformName: string, vector4: Vector4): Effect;
  29536. /**
  29537. * Sets a float4 on a uniform variable.
  29538. * @param uniformName Name of the variable.
  29539. * @param x First float in float4.
  29540. * @param y Second float in float4.
  29541. * @param z Third float in float4.
  29542. * @param w Fourth float in float4.
  29543. * @returns this effect.
  29544. */
  29545. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29546. /**
  29547. * Sets a Color3 on a uniform variable.
  29548. * @param uniformName Name of the variable.
  29549. * @param color3 Value to be set.
  29550. * @returns this effect.
  29551. */
  29552. setColor3(uniformName: string, color3: Color3): Effect;
  29553. /**
  29554. * Sets a Color4 on a uniform variable.
  29555. * @param uniformName Name of the variable.
  29556. * @param color3 Value to be set.
  29557. * @param alpha Alpha value to be set.
  29558. * @returns this effect.
  29559. */
  29560. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29561. /**
  29562. * Sets a Color4 on a uniform variable
  29563. * @param uniformName defines the name of the variable
  29564. * @param color4 defines the value to be set
  29565. * @returns this effect.
  29566. */
  29567. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29568. /** Release all associated resources */
  29569. dispose(): void;
  29570. /**
  29571. * This function will add a new shader to the shader store
  29572. * @param name the name of the shader
  29573. * @param pixelShader optional pixel shader content
  29574. * @param vertexShader optional vertex shader content
  29575. */
  29576. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29577. /**
  29578. * Store of each shader (The can be looked up using effect.key)
  29579. */
  29580. static ShadersStore: {
  29581. [key: string]: string;
  29582. };
  29583. /**
  29584. * Store of each included file for a shader (The can be looked up using effect.key)
  29585. */
  29586. static IncludesShadersStore: {
  29587. [key: string]: string;
  29588. };
  29589. /**
  29590. * Resets the cache of effects.
  29591. */
  29592. static ResetCache(): void;
  29593. }
  29594. }
  29595. declare module BABYLON {
  29596. /**
  29597. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29598. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29599. * 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;
  29600. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29601. */
  29602. export class ColorCurves {
  29603. private _dirty;
  29604. private _tempColor;
  29605. private _globalCurve;
  29606. private _highlightsCurve;
  29607. private _midtonesCurve;
  29608. private _shadowsCurve;
  29609. private _positiveCurve;
  29610. private _negativeCurve;
  29611. private _globalHue;
  29612. private _globalDensity;
  29613. private _globalSaturation;
  29614. private _globalExposure;
  29615. /**
  29616. * Gets the global Hue value.
  29617. * 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).
  29618. */
  29619. /**
  29620. * Sets the global Hue value.
  29621. * 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).
  29622. */
  29623. globalHue: number;
  29624. /**
  29625. * Gets the global Density value.
  29626. * 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.
  29627. * Values less than zero provide a filter of opposite hue.
  29628. */
  29629. /**
  29630. * Sets the global Density value.
  29631. * 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.
  29632. * Values less than zero provide a filter of opposite hue.
  29633. */
  29634. globalDensity: number;
  29635. /**
  29636. * Gets the global Saturation value.
  29637. * 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.
  29638. */
  29639. /**
  29640. * Sets the global Saturation value.
  29641. * 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.
  29642. */
  29643. globalSaturation: number;
  29644. /**
  29645. * Gets the global Exposure value.
  29646. * 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.
  29647. */
  29648. /**
  29649. * Sets the global Exposure value.
  29650. * 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.
  29651. */
  29652. globalExposure: number;
  29653. private _highlightsHue;
  29654. private _highlightsDensity;
  29655. private _highlightsSaturation;
  29656. private _highlightsExposure;
  29657. /**
  29658. * Gets the highlights Hue value.
  29659. * 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).
  29660. */
  29661. /**
  29662. * Sets the highlights Hue value.
  29663. * 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).
  29664. */
  29665. highlightsHue: number;
  29666. /**
  29667. * Gets the highlights Density value.
  29668. * 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.
  29669. * Values less than zero provide a filter of opposite hue.
  29670. */
  29671. /**
  29672. * Sets the highlights Density value.
  29673. * 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.
  29674. * Values less than zero provide a filter of opposite hue.
  29675. */
  29676. highlightsDensity: number;
  29677. /**
  29678. * Gets the highlights Saturation value.
  29679. * 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.
  29680. */
  29681. /**
  29682. * Sets the highlights Saturation value.
  29683. * 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.
  29684. */
  29685. highlightsSaturation: number;
  29686. /**
  29687. * Gets the highlights Exposure value.
  29688. * 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.
  29689. */
  29690. /**
  29691. * Sets the highlights Exposure value.
  29692. * 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.
  29693. */
  29694. highlightsExposure: number;
  29695. private _midtonesHue;
  29696. private _midtonesDensity;
  29697. private _midtonesSaturation;
  29698. private _midtonesExposure;
  29699. /**
  29700. * Gets the midtones Hue value.
  29701. * 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).
  29702. */
  29703. /**
  29704. * Sets the midtones Hue value.
  29705. * 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).
  29706. */
  29707. midtonesHue: number;
  29708. /**
  29709. * Gets the midtones Density value.
  29710. * 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.
  29711. * Values less than zero provide a filter of opposite hue.
  29712. */
  29713. /**
  29714. * Sets the midtones Density value.
  29715. * 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.
  29716. * Values less than zero provide a filter of opposite hue.
  29717. */
  29718. midtonesDensity: number;
  29719. /**
  29720. * Gets the midtones Saturation value.
  29721. * 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.
  29722. */
  29723. /**
  29724. * Sets the midtones Saturation value.
  29725. * 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.
  29726. */
  29727. midtonesSaturation: number;
  29728. /**
  29729. * Gets the midtones Exposure value.
  29730. * 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.
  29731. */
  29732. /**
  29733. * Sets the midtones Exposure value.
  29734. * 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.
  29735. */
  29736. midtonesExposure: number;
  29737. private _shadowsHue;
  29738. private _shadowsDensity;
  29739. private _shadowsSaturation;
  29740. private _shadowsExposure;
  29741. /**
  29742. * Gets the shadows Hue value.
  29743. * 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).
  29744. */
  29745. /**
  29746. * Sets the shadows Hue value.
  29747. * 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).
  29748. */
  29749. shadowsHue: number;
  29750. /**
  29751. * Gets the shadows Density value.
  29752. * 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.
  29753. * Values less than zero provide a filter of opposite hue.
  29754. */
  29755. /**
  29756. * Sets the shadows Density value.
  29757. * 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.
  29758. * Values less than zero provide a filter of opposite hue.
  29759. */
  29760. shadowsDensity: number;
  29761. /**
  29762. * Gets the shadows Saturation value.
  29763. * 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.
  29764. */
  29765. /**
  29766. * Sets the shadows Saturation value.
  29767. * 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.
  29768. */
  29769. shadowsSaturation: number;
  29770. /**
  29771. * Gets the shadows Exposure value.
  29772. * 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.
  29773. */
  29774. /**
  29775. * Sets the shadows Exposure value.
  29776. * 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.
  29777. */
  29778. shadowsExposure: number;
  29779. /**
  29780. * Returns the class name
  29781. * @returns The class name
  29782. */
  29783. getClassName(): string;
  29784. /**
  29785. * Binds the color curves to the shader.
  29786. * @param colorCurves The color curve to bind
  29787. * @param effect The effect to bind to
  29788. * @param positiveUniform The positive uniform shader parameter
  29789. * @param neutralUniform The neutral uniform shader parameter
  29790. * @param negativeUniform The negative uniform shader parameter
  29791. */
  29792. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29793. /**
  29794. * Prepare the list of uniforms associated with the ColorCurves effects.
  29795. * @param uniformsList The list of uniforms used in the effect
  29796. */
  29797. static PrepareUniforms(uniformsList: string[]): void;
  29798. /**
  29799. * Returns color grading data based on a hue, density, saturation and exposure value.
  29800. * @param filterHue The hue of the color filter.
  29801. * @param filterDensity The density of the color filter.
  29802. * @param saturation The saturation.
  29803. * @param exposure The exposure.
  29804. * @param result The result data container.
  29805. */
  29806. private getColorGradingDataToRef;
  29807. /**
  29808. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29809. * @param value The input slider value in range [-100,100].
  29810. * @returns Adjusted value.
  29811. */
  29812. private static applyColorGradingSliderNonlinear;
  29813. /**
  29814. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29815. * @param hue The hue (H) input.
  29816. * @param saturation The saturation (S) input.
  29817. * @param brightness The brightness (B) input.
  29818. * @result An RGBA color represented as Vector4.
  29819. */
  29820. private static fromHSBToRef;
  29821. /**
  29822. * Returns a value clamped between min and max
  29823. * @param value The value to clamp
  29824. * @param min The minimum of value
  29825. * @param max The maximum of value
  29826. * @returns The clamped value.
  29827. */
  29828. private static clamp;
  29829. /**
  29830. * Clones the current color curve instance.
  29831. * @return The cloned curves
  29832. */
  29833. clone(): ColorCurves;
  29834. /**
  29835. * Serializes the current color curve instance to a json representation.
  29836. * @return a JSON representation
  29837. */
  29838. serialize(): any;
  29839. /**
  29840. * Parses the color curve from a json representation.
  29841. * @param source the JSON source to parse
  29842. * @return The parsed curves
  29843. */
  29844. static Parse(source: any): ColorCurves;
  29845. }
  29846. }
  29847. declare module BABYLON {
  29848. /**
  29849. * Interface to follow in your material defines to integrate easily the
  29850. * Image proccessing functions.
  29851. * @hidden
  29852. */
  29853. export interface IImageProcessingConfigurationDefines {
  29854. IMAGEPROCESSING: boolean;
  29855. VIGNETTE: boolean;
  29856. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29857. VIGNETTEBLENDMODEOPAQUE: boolean;
  29858. TONEMAPPING: boolean;
  29859. TONEMAPPING_ACES: boolean;
  29860. CONTRAST: boolean;
  29861. EXPOSURE: boolean;
  29862. COLORCURVES: boolean;
  29863. COLORGRADING: boolean;
  29864. COLORGRADING3D: boolean;
  29865. SAMPLER3DGREENDEPTH: boolean;
  29866. SAMPLER3DBGRMAP: boolean;
  29867. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29868. }
  29869. /**
  29870. * @hidden
  29871. */
  29872. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29873. IMAGEPROCESSING: boolean;
  29874. VIGNETTE: boolean;
  29875. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29876. VIGNETTEBLENDMODEOPAQUE: boolean;
  29877. TONEMAPPING: boolean;
  29878. TONEMAPPING_ACES: boolean;
  29879. CONTRAST: boolean;
  29880. COLORCURVES: boolean;
  29881. COLORGRADING: boolean;
  29882. COLORGRADING3D: boolean;
  29883. SAMPLER3DGREENDEPTH: boolean;
  29884. SAMPLER3DBGRMAP: boolean;
  29885. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29886. EXPOSURE: boolean;
  29887. constructor();
  29888. }
  29889. /**
  29890. * This groups together the common properties used for image processing either in direct forward pass
  29891. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29892. * or not.
  29893. */
  29894. export class ImageProcessingConfiguration {
  29895. /**
  29896. * Default tone mapping applied in BabylonJS.
  29897. */
  29898. static readonly TONEMAPPING_STANDARD: number;
  29899. /**
  29900. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29901. * to other engines rendering to increase portability.
  29902. */
  29903. static readonly TONEMAPPING_ACES: number;
  29904. /**
  29905. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29906. */
  29907. colorCurves: Nullable<ColorCurves>;
  29908. private _colorCurvesEnabled;
  29909. /**
  29910. * Gets wether the color curves effect is enabled.
  29911. */
  29912. /**
  29913. * Sets wether the color curves effect is enabled.
  29914. */
  29915. colorCurvesEnabled: boolean;
  29916. private _colorGradingTexture;
  29917. /**
  29918. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29919. */
  29920. /**
  29921. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29922. */
  29923. colorGradingTexture: Nullable<BaseTexture>;
  29924. private _colorGradingEnabled;
  29925. /**
  29926. * Gets wether the color grading effect is enabled.
  29927. */
  29928. /**
  29929. * Sets wether the color grading effect is enabled.
  29930. */
  29931. colorGradingEnabled: boolean;
  29932. private _colorGradingWithGreenDepth;
  29933. /**
  29934. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29935. */
  29936. /**
  29937. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29938. */
  29939. colorGradingWithGreenDepth: boolean;
  29940. private _colorGradingBGR;
  29941. /**
  29942. * Gets wether the color grading texture contains BGR values.
  29943. */
  29944. /**
  29945. * Sets wether the color grading texture contains BGR values.
  29946. */
  29947. colorGradingBGR: boolean;
  29948. /** @hidden */
  29949. _exposure: number;
  29950. /**
  29951. * Gets the Exposure used in the effect.
  29952. */
  29953. /**
  29954. * Sets the Exposure used in the effect.
  29955. */
  29956. exposure: number;
  29957. private _toneMappingEnabled;
  29958. /**
  29959. * Gets wether the tone mapping effect is enabled.
  29960. */
  29961. /**
  29962. * Sets wether the tone mapping effect is enabled.
  29963. */
  29964. toneMappingEnabled: boolean;
  29965. private _toneMappingType;
  29966. /**
  29967. * Gets the type of tone mapping effect.
  29968. */
  29969. /**
  29970. * Sets the type of tone mapping effect used in BabylonJS.
  29971. */
  29972. toneMappingType: number;
  29973. protected _contrast: number;
  29974. /**
  29975. * Gets the contrast used in the effect.
  29976. */
  29977. /**
  29978. * Sets the contrast used in the effect.
  29979. */
  29980. contrast: number;
  29981. /**
  29982. * Vignette stretch size.
  29983. */
  29984. vignetteStretch: number;
  29985. /**
  29986. * Vignette centre X Offset.
  29987. */
  29988. vignetteCentreX: number;
  29989. /**
  29990. * Vignette centre Y Offset.
  29991. */
  29992. vignetteCentreY: number;
  29993. /**
  29994. * Vignette weight or intensity of the vignette effect.
  29995. */
  29996. vignetteWeight: number;
  29997. /**
  29998. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29999. * if vignetteEnabled is set to true.
  30000. */
  30001. vignetteColor: Color4;
  30002. /**
  30003. * Camera field of view used by the Vignette effect.
  30004. */
  30005. vignetteCameraFov: number;
  30006. private _vignetteBlendMode;
  30007. /**
  30008. * Gets the vignette blend mode allowing different kind of effect.
  30009. */
  30010. /**
  30011. * Sets the vignette blend mode allowing different kind of effect.
  30012. */
  30013. vignetteBlendMode: number;
  30014. private _vignetteEnabled;
  30015. /**
  30016. * Gets wether the vignette effect is enabled.
  30017. */
  30018. /**
  30019. * Sets wether the vignette effect is enabled.
  30020. */
  30021. vignetteEnabled: boolean;
  30022. private _applyByPostProcess;
  30023. /**
  30024. * Gets wether the image processing is applied through a post process or not.
  30025. */
  30026. /**
  30027. * Sets wether the image processing is applied through a post process or not.
  30028. */
  30029. applyByPostProcess: boolean;
  30030. private _isEnabled;
  30031. /**
  30032. * Gets wether the image processing is enabled or not.
  30033. */
  30034. /**
  30035. * Sets wether the image processing is enabled or not.
  30036. */
  30037. isEnabled: boolean;
  30038. /**
  30039. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30040. */
  30041. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30042. /**
  30043. * Method called each time the image processing information changes requires to recompile the effect.
  30044. */
  30045. protected _updateParameters(): void;
  30046. /**
  30047. * Gets the current class name.
  30048. * @return "ImageProcessingConfiguration"
  30049. */
  30050. getClassName(): string;
  30051. /**
  30052. * Prepare the list of uniforms associated with the Image Processing effects.
  30053. * @param uniforms The list of uniforms used in the effect
  30054. * @param defines the list of defines currently in use
  30055. */
  30056. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30057. /**
  30058. * Prepare the list of samplers associated with the Image Processing effects.
  30059. * @param samplersList The list of uniforms used in the effect
  30060. * @param defines the list of defines currently in use
  30061. */
  30062. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30063. /**
  30064. * Prepare the list of defines associated to the shader.
  30065. * @param defines the list of defines to complete
  30066. * @param forPostProcess Define if we are currently in post process mode or not
  30067. */
  30068. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30069. /**
  30070. * Returns true if all the image processing information are ready.
  30071. * @returns True if ready, otherwise, false
  30072. */
  30073. isReady(): boolean;
  30074. /**
  30075. * Binds the image processing to the shader.
  30076. * @param effect The effect to bind to
  30077. * @param aspectRatio Define the current aspect ratio of the effect
  30078. */
  30079. bind(effect: Effect, aspectRatio?: number): void;
  30080. /**
  30081. * Clones the current image processing instance.
  30082. * @return The cloned image processing
  30083. */
  30084. clone(): ImageProcessingConfiguration;
  30085. /**
  30086. * Serializes the current image processing instance to a json representation.
  30087. * @return a JSON representation
  30088. */
  30089. serialize(): any;
  30090. /**
  30091. * Parses the image processing from a json representation.
  30092. * @param source the JSON source to parse
  30093. * @return The parsed image processing
  30094. */
  30095. static Parse(source: any): ImageProcessingConfiguration;
  30096. private static _VIGNETTEMODE_MULTIPLY;
  30097. private static _VIGNETTEMODE_OPAQUE;
  30098. /**
  30099. * Used to apply the vignette as a mix with the pixel color.
  30100. */
  30101. static readonly VIGNETTEMODE_MULTIPLY: number;
  30102. /**
  30103. * Used to apply the vignette as a replacement of the pixel color.
  30104. */
  30105. static readonly VIGNETTEMODE_OPAQUE: number;
  30106. }
  30107. }
  30108. declare module BABYLON {
  30109. /**
  30110. * This represents all the required information to add a fresnel effect on a material:
  30111. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30112. */
  30113. export class FresnelParameters {
  30114. private _isEnabled;
  30115. /**
  30116. * Define if the fresnel effect is enable or not.
  30117. */
  30118. isEnabled: boolean;
  30119. /**
  30120. * Define the color used on edges (grazing angle)
  30121. */
  30122. leftColor: Color3;
  30123. /**
  30124. * Define the color used on center
  30125. */
  30126. rightColor: Color3;
  30127. /**
  30128. * Define bias applied to computed fresnel term
  30129. */
  30130. bias: number;
  30131. /**
  30132. * Defined the power exponent applied to fresnel term
  30133. */
  30134. power: number;
  30135. /**
  30136. * Clones the current fresnel and its valuues
  30137. * @returns a clone fresnel configuration
  30138. */
  30139. clone(): FresnelParameters;
  30140. /**
  30141. * Serializes the current fresnel parameters to a JSON representation.
  30142. * @return the JSON serialization
  30143. */
  30144. serialize(): any;
  30145. /**
  30146. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30147. * @param parsedFresnelParameters Define the JSON representation
  30148. * @returns the parsed parameters
  30149. */
  30150. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30151. }
  30152. }
  30153. declare module BABYLON {
  30154. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30155. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30156. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30157. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30158. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30159. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30160. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30161. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30162. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30163. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30164. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30165. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30166. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30167. /**
  30168. * Decorator used to define property that can be serialized as reference to a camera
  30169. * @param sourceName defines the name of the property to decorate
  30170. */
  30171. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30172. /**
  30173. * Class used to help serialization objects
  30174. */
  30175. export class SerializationHelper {
  30176. /** hidden */
  30177. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30178. /** hidden */
  30179. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30180. /** hidden */
  30181. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30182. /** hidden */
  30183. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30184. /**
  30185. * Appends the serialized animations from the source animations
  30186. * @param source Source containing the animations
  30187. * @param destination Target to store the animations
  30188. */
  30189. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30190. /**
  30191. * Static function used to serialized a specific entity
  30192. * @param entity defines the entity to serialize
  30193. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30194. * @returns a JSON compatible object representing the serialization of the entity
  30195. */
  30196. static Serialize<T>(entity: T, serializationObject?: any): any;
  30197. /**
  30198. * Creates a new entity from a serialization data object
  30199. * @param creationFunction defines a function used to instanciated the new entity
  30200. * @param source defines the source serialization data
  30201. * @param scene defines the hosting scene
  30202. * @param rootUrl defines the root url for resources
  30203. * @returns a new entity
  30204. */
  30205. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30206. /**
  30207. * Clones an object
  30208. * @param creationFunction defines the function used to instanciate the new object
  30209. * @param source defines the source object
  30210. * @returns the cloned object
  30211. */
  30212. static Clone<T>(creationFunction: () => T, source: T): T;
  30213. /**
  30214. * Instanciates a new object based on a source one (some data will be shared between both object)
  30215. * @param creationFunction defines the function used to instanciate the new object
  30216. * @param source defines the source object
  30217. * @returns the new object
  30218. */
  30219. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30220. }
  30221. }
  30222. declare module BABYLON {
  30223. /**
  30224. * This is the base class of all the camera used in the application.
  30225. * @see http://doc.babylonjs.com/features/cameras
  30226. */
  30227. export class Camera extends Node {
  30228. /** @hidden */
  30229. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30230. /**
  30231. * This is the default projection mode used by the cameras.
  30232. * It helps recreating a feeling of perspective and better appreciate depth.
  30233. * This is the best way to simulate real life cameras.
  30234. */
  30235. static readonly PERSPECTIVE_CAMERA: number;
  30236. /**
  30237. * This helps creating camera with an orthographic mode.
  30238. * 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.
  30239. */
  30240. static readonly ORTHOGRAPHIC_CAMERA: number;
  30241. /**
  30242. * This is the default FOV mode for perspective cameras.
  30243. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30244. */
  30245. static readonly FOVMODE_VERTICAL_FIXED: number;
  30246. /**
  30247. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30248. */
  30249. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30250. /**
  30251. * This specifies ther is no need for a camera rig.
  30252. * Basically only one eye is rendered corresponding to the camera.
  30253. */
  30254. static readonly RIG_MODE_NONE: number;
  30255. /**
  30256. * Simulates a camera Rig with one blue eye and one red eye.
  30257. * This can be use with 3d blue and red glasses.
  30258. */
  30259. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30260. /**
  30261. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30262. */
  30263. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30264. /**
  30265. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30266. */
  30267. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30268. /**
  30269. * Defines that both eyes of the camera will be rendered over under each other.
  30270. */
  30271. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30272. /**
  30273. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30274. */
  30275. static readonly RIG_MODE_VR: number;
  30276. /**
  30277. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30278. */
  30279. static readonly RIG_MODE_WEBVR: number;
  30280. /**
  30281. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30282. */
  30283. static readonly RIG_MODE_CUSTOM: number;
  30284. /**
  30285. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30286. */
  30287. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30288. /**
  30289. * Define the input manager associated with the camera.
  30290. */
  30291. inputs: CameraInputsManager<Camera>;
  30292. /** @hidden */
  30293. _position: Vector3;
  30294. /**
  30295. * Define the current local position of the camera in the scene
  30296. */
  30297. position: Vector3;
  30298. /**
  30299. * The vector the camera should consider as up.
  30300. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30301. */
  30302. upVector: Vector3;
  30303. /**
  30304. * Define the current limit on the left side for an orthographic camera
  30305. * In scene unit
  30306. */
  30307. orthoLeft: Nullable<number>;
  30308. /**
  30309. * Define the current limit on the right side for an orthographic camera
  30310. * In scene unit
  30311. */
  30312. orthoRight: Nullable<number>;
  30313. /**
  30314. * Define the current limit on the bottom side for an orthographic camera
  30315. * In scene unit
  30316. */
  30317. orthoBottom: Nullable<number>;
  30318. /**
  30319. * Define the current limit on the top side for an orthographic camera
  30320. * In scene unit
  30321. */
  30322. orthoTop: Nullable<number>;
  30323. /**
  30324. * Field Of View is set in Radians. (default is 0.8)
  30325. */
  30326. fov: number;
  30327. /**
  30328. * Define the minimum distance the camera can see from.
  30329. * This is important to note that the depth buffer are not infinite and the closer it starts
  30330. * the more your scene might encounter depth fighting issue.
  30331. */
  30332. minZ: number;
  30333. /**
  30334. * Define the maximum distance the camera can see to.
  30335. * This is important to note that the depth buffer are not infinite and the further it end
  30336. * the more your scene might encounter depth fighting issue.
  30337. */
  30338. maxZ: number;
  30339. /**
  30340. * Define the default inertia of the camera.
  30341. * This helps giving a smooth feeling to the camera movement.
  30342. */
  30343. inertia: number;
  30344. /**
  30345. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30346. */
  30347. mode: number;
  30348. /**
  30349. * Define wether the camera is intermediate.
  30350. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30351. */
  30352. isIntermediate: boolean;
  30353. /**
  30354. * Define the viewport of the camera.
  30355. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30356. */
  30357. viewport: Viewport;
  30358. /**
  30359. * Restricts the camera to viewing objects with the same layerMask.
  30360. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30361. */
  30362. layerMask: number;
  30363. /**
  30364. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30365. */
  30366. fovMode: number;
  30367. /**
  30368. * Rig mode of the camera.
  30369. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30370. * This is normally controlled byt the camera themselves as internal use.
  30371. */
  30372. cameraRigMode: number;
  30373. /**
  30374. * Defines the distance between both "eyes" in case of a RIG
  30375. */
  30376. interaxialDistance: number;
  30377. /**
  30378. * Defines if stereoscopic rendering is done side by side or over under.
  30379. */
  30380. isStereoscopicSideBySide: boolean;
  30381. /**
  30382. * 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
  30383. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30384. * else in the scene.
  30385. */
  30386. customRenderTargets: RenderTargetTexture[];
  30387. /**
  30388. * When set, the camera will render to this render target instead of the default canvas
  30389. */
  30390. outputRenderTarget: Nullable<RenderTargetTexture>;
  30391. /**
  30392. * Observable triggered when the camera view matrix has changed.
  30393. */
  30394. onViewMatrixChangedObservable: Observable<Camera>;
  30395. /**
  30396. * Observable triggered when the camera Projection matrix has changed.
  30397. */
  30398. onProjectionMatrixChangedObservable: Observable<Camera>;
  30399. /**
  30400. * Observable triggered when the inputs have been processed.
  30401. */
  30402. onAfterCheckInputsObservable: Observable<Camera>;
  30403. /**
  30404. * Observable triggered when reset has been called and applied to the camera.
  30405. */
  30406. onRestoreStateObservable: Observable<Camera>;
  30407. /** @hidden */
  30408. _cameraRigParams: any;
  30409. /** @hidden */
  30410. _rigCameras: Camera[];
  30411. /** @hidden */
  30412. _rigPostProcess: Nullable<PostProcess>;
  30413. protected _webvrViewMatrix: Matrix;
  30414. /** @hidden */
  30415. _skipRendering: boolean;
  30416. /** @hidden */
  30417. _projectionMatrix: Matrix;
  30418. /** @hidden */
  30419. _postProcesses: Nullable<PostProcess>[];
  30420. /** @hidden */
  30421. _activeMeshes: SmartArray<AbstractMesh>;
  30422. protected _globalPosition: Vector3;
  30423. /** hidden */
  30424. _computedViewMatrix: Matrix;
  30425. private _doNotComputeProjectionMatrix;
  30426. private _transformMatrix;
  30427. private _frustumPlanes;
  30428. private _refreshFrustumPlanes;
  30429. private _storedFov;
  30430. private _stateStored;
  30431. /**
  30432. * Instantiates a new camera object.
  30433. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30434. * @see http://doc.babylonjs.com/features/cameras
  30435. * @param name Defines the name of the camera in the scene
  30436. * @param position Defines the position of the camera
  30437. * @param scene Defines the scene the camera belongs too
  30438. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30439. */
  30440. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30441. /**
  30442. * Store current camera state (fov, position, etc..)
  30443. * @returns the camera
  30444. */
  30445. storeState(): Camera;
  30446. /**
  30447. * Restores the camera state values if it has been stored. You must call storeState() first
  30448. */
  30449. protected _restoreStateValues(): boolean;
  30450. /**
  30451. * Restored camera state. You must call storeState() first.
  30452. * @returns true if restored and false otherwise
  30453. */
  30454. restoreState(): boolean;
  30455. /**
  30456. * Gets the class name of the camera.
  30457. * @returns the class name
  30458. */
  30459. getClassName(): string;
  30460. /** @hidden */
  30461. readonly _isCamera: boolean;
  30462. /**
  30463. * Gets a string representation of the camera useful for debug purpose.
  30464. * @param fullDetails Defines that a more verboe level of logging is required
  30465. * @returns the string representation
  30466. */
  30467. toString(fullDetails?: boolean): string;
  30468. /**
  30469. * Gets the current world space position of the camera.
  30470. */
  30471. readonly globalPosition: Vector3;
  30472. /**
  30473. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30474. * @returns the active meshe list
  30475. */
  30476. getActiveMeshes(): SmartArray<AbstractMesh>;
  30477. /**
  30478. * Check wether a mesh is part of the current active mesh list of the camera
  30479. * @param mesh Defines the mesh to check
  30480. * @returns true if active, false otherwise
  30481. */
  30482. isActiveMesh(mesh: Mesh): boolean;
  30483. /**
  30484. * Is this camera ready to be used/rendered
  30485. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30486. * @return true if the camera is ready
  30487. */
  30488. isReady(completeCheck?: boolean): boolean;
  30489. /** @hidden */
  30490. _initCache(): void;
  30491. /** @hidden */
  30492. _updateCache(ignoreParentClass?: boolean): void;
  30493. /** @hidden */
  30494. _isSynchronized(): boolean;
  30495. /** @hidden */
  30496. _isSynchronizedViewMatrix(): boolean;
  30497. /** @hidden */
  30498. _isSynchronizedProjectionMatrix(): boolean;
  30499. /**
  30500. * Attach the input controls to a specific dom element to get the input from.
  30501. * @param element Defines the element the controls should be listened from
  30502. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30503. */
  30504. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30505. /**
  30506. * Detach the current controls from the specified dom element.
  30507. * @param element Defines the element to stop listening the inputs from
  30508. */
  30509. detachControl(element: HTMLElement): void;
  30510. /**
  30511. * Update the camera state according to the different inputs gathered during the frame.
  30512. */
  30513. update(): void;
  30514. /** @hidden */
  30515. _checkInputs(): void;
  30516. /** @hidden */
  30517. readonly rigCameras: Camera[];
  30518. /**
  30519. * Gets the post process used by the rig cameras
  30520. */
  30521. readonly rigPostProcess: Nullable<PostProcess>;
  30522. /**
  30523. * Internal, gets the first post proces.
  30524. * @returns the first post process to be run on this camera.
  30525. */
  30526. _getFirstPostProcess(): Nullable<PostProcess>;
  30527. private _cascadePostProcessesToRigCams;
  30528. /**
  30529. * Attach a post process to the camera.
  30530. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30531. * @param postProcess The post process to attach to the camera
  30532. * @param insertAt The position of the post process in case several of them are in use in the scene
  30533. * @returns the position the post process has been inserted at
  30534. */
  30535. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30536. /**
  30537. * Detach a post process to the camera.
  30538. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30539. * @param postProcess The post process to detach from the camera
  30540. */
  30541. detachPostProcess(postProcess: PostProcess): void;
  30542. /**
  30543. * Gets the current world matrix of the camera
  30544. */
  30545. getWorldMatrix(): Matrix;
  30546. /** @hidden */
  30547. _getViewMatrix(): Matrix;
  30548. /**
  30549. * Gets the current view matrix of the camera.
  30550. * @param force forces the camera to recompute the matrix without looking at the cached state
  30551. * @returns the view matrix
  30552. */
  30553. getViewMatrix(force?: boolean): Matrix;
  30554. /**
  30555. * Freeze the projection matrix.
  30556. * It will prevent the cache check of the camera projection compute and can speed up perf
  30557. * if no parameter of the camera are meant to change
  30558. * @param projection Defines manually a projection if necessary
  30559. */
  30560. freezeProjectionMatrix(projection?: Matrix): void;
  30561. /**
  30562. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30563. */
  30564. unfreezeProjectionMatrix(): void;
  30565. /**
  30566. * Gets the current projection matrix of the camera.
  30567. * @param force forces the camera to recompute the matrix without looking at the cached state
  30568. * @returns the projection matrix
  30569. */
  30570. getProjectionMatrix(force?: boolean): Matrix;
  30571. /**
  30572. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30573. * @returns a Matrix
  30574. */
  30575. getTransformationMatrix(): Matrix;
  30576. private _updateFrustumPlanes;
  30577. /**
  30578. * Checks if a cullable object (mesh...) is in the camera frustum
  30579. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30580. * @param target The object to check
  30581. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30582. * @returns true if the object is in frustum otherwise false
  30583. */
  30584. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30585. /**
  30586. * Checks if a cullable object (mesh...) is in the camera frustum
  30587. * Unlike isInFrustum this cheks the full bounding box
  30588. * @param target The object to check
  30589. * @returns true if the object is in frustum otherwise false
  30590. */
  30591. isCompletelyInFrustum(target: ICullable): boolean;
  30592. /**
  30593. * Gets a ray in the forward direction from the camera.
  30594. * @param length Defines the length of the ray to create
  30595. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30596. * @param origin Defines the start point of the ray which defaults to the camera position
  30597. * @returns the forward ray
  30598. */
  30599. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30600. /**
  30601. * Releases resources associated with this node.
  30602. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30603. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30604. */
  30605. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30606. /** @hidden */
  30607. _isLeftCamera: boolean;
  30608. /**
  30609. * Gets the left camera of a rig setup in case of Rigged Camera
  30610. */
  30611. readonly isLeftCamera: boolean;
  30612. /** @hidden */
  30613. _isRightCamera: boolean;
  30614. /**
  30615. * Gets the right camera of a rig setup in case of Rigged Camera
  30616. */
  30617. readonly isRightCamera: boolean;
  30618. /**
  30619. * Gets the left camera of a rig setup in case of Rigged Camera
  30620. */
  30621. readonly leftCamera: Nullable<FreeCamera>;
  30622. /**
  30623. * Gets the right camera of a rig setup in case of Rigged Camera
  30624. */
  30625. readonly rightCamera: Nullable<FreeCamera>;
  30626. /**
  30627. * Gets the left camera target of a rig setup in case of Rigged Camera
  30628. * @returns the target position
  30629. */
  30630. getLeftTarget(): Nullable<Vector3>;
  30631. /**
  30632. * Gets the right camera target of a rig setup in case of Rigged Camera
  30633. * @returns the target position
  30634. */
  30635. getRightTarget(): Nullable<Vector3>;
  30636. /**
  30637. * @hidden
  30638. */
  30639. setCameraRigMode(mode: number, rigParams: any): void;
  30640. /** @hidden */
  30641. static _setStereoscopicRigMode(camera: Camera): void;
  30642. /** @hidden */
  30643. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30644. /** @hidden */
  30645. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30646. /** @hidden */
  30647. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30648. /** @hidden */
  30649. _getVRProjectionMatrix(): Matrix;
  30650. protected _updateCameraRotationMatrix(): void;
  30651. protected _updateWebVRCameraRotationMatrix(): void;
  30652. /**
  30653. * This function MUST be overwritten by the different WebVR cameras available.
  30654. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30655. * @hidden
  30656. */
  30657. _getWebVRProjectionMatrix(): Matrix;
  30658. /**
  30659. * This function MUST be overwritten by the different WebVR cameras available.
  30660. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30661. * @hidden
  30662. */
  30663. _getWebVRViewMatrix(): Matrix;
  30664. /** @hidden */
  30665. setCameraRigParameter(name: string, value: any): void;
  30666. /**
  30667. * needs to be overridden by children so sub has required properties to be copied
  30668. * @hidden
  30669. */
  30670. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30671. /**
  30672. * May need to be overridden by children
  30673. * @hidden
  30674. */
  30675. _updateRigCameras(): void;
  30676. /** @hidden */
  30677. _setupInputs(): void;
  30678. /**
  30679. * Serialiaze the camera setup to a json represention
  30680. * @returns the JSON representation
  30681. */
  30682. serialize(): any;
  30683. /**
  30684. * Clones the current camera.
  30685. * @param name The cloned camera name
  30686. * @returns the cloned camera
  30687. */
  30688. clone(name: string): Camera;
  30689. /**
  30690. * Gets the direction of the camera relative to a given local axis.
  30691. * @param localAxis Defines the reference axis to provide a relative direction.
  30692. * @return the direction
  30693. */
  30694. getDirection(localAxis: Vector3): Vector3;
  30695. /**
  30696. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30697. * @param localAxis Defines the reference axis to provide a relative direction.
  30698. * @param result Defines the vector to store the result in
  30699. */
  30700. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30701. /**
  30702. * Gets a camera constructor for a given camera type
  30703. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30704. * @param name The name of the camera the result will be able to instantiate
  30705. * @param scene The scene the result will construct the camera in
  30706. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30707. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30708. * @returns a factory method to construc the camera
  30709. */
  30710. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30711. /**
  30712. * Compute the world matrix of the camera.
  30713. * @returns the camera workd matrix
  30714. */
  30715. computeWorldMatrix(): Matrix;
  30716. /**
  30717. * Parse a JSON and creates the camera from the parsed information
  30718. * @param parsedCamera The JSON to parse
  30719. * @param scene The scene to instantiate the camera in
  30720. * @returns the newly constructed camera
  30721. */
  30722. static Parse(parsedCamera: any, scene: Scene): Camera;
  30723. }
  30724. }
  30725. declare module BABYLON {
  30726. /**
  30727. * Interface for any object that can request an animation frame
  30728. */
  30729. export interface ICustomAnimationFrameRequester {
  30730. /**
  30731. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30732. */
  30733. renderFunction?: Function;
  30734. /**
  30735. * Called to request the next frame to render to
  30736. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30737. */
  30738. requestAnimationFrame: Function;
  30739. /**
  30740. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30741. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30742. */
  30743. requestID?: number;
  30744. }
  30745. /**
  30746. * Interface containing an array of animations
  30747. */
  30748. export interface IAnimatable {
  30749. /**
  30750. * Array of animations
  30751. */
  30752. animations: Nullable<Array<Animation>>;
  30753. }
  30754. /** Interface used by value gradients (color, factor, ...) */
  30755. export interface IValueGradient {
  30756. /**
  30757. * Gets or sets the gradient value (between 0 and 1)
  30758. */
  30759. gradient: number;
  30760. }
  30761. /** Class used to store color4 gradient */
  30762. export class ColorGradient implements IValueGradient {
  30763. /**
  30764. * Gets or sets the gradient value (between 0 and 1)
  30765. */
  30766. gradient: number;
  30767. /**
  30768. * Gets or sets first associated color
  30769. */
  30770. color1: Color4;
  30771. /**
  30772. * Gets or sets second associated color
  30773. */
  30774. color2?: Color4;
  30775. /**
  30776. * Will get a color picked randomly between color1 and color2.
  30777. * If color2 is undefined then color1 will be used
  30778. * @param result defines the target Color4 to store the result in
  30779. */
  30780. getColorToRef(result: Color4): void;
  30781. }
  30782. /** Class used to store color 3 gradient */
  30783. export class Color3Gradient implements IValueGradient {
  30784. /**
  30785. * Gets or sets the gradient value (between 0 and 1)
  30786. */
  30787. gradient: number;
  30788. /**
  30789. * Gets or sets the associated color
  30790. */
  30791. color: Color3;
  30792. }
  30793. /** Class used to store factor gradient */
  30794. export class FactorGradient implements IValueGradient {
  30795. /**
  30796. * Gets or sets the gradient value (between 0 and 1)
  30797. */
  30798. gradient: number;
  30799. /**
  30800. * Gets or sets first associated factor
  30801. */
  30802. factor1: number;
  30803. /**
  30804. * Gets or sets second associated factor
  30805. */
  30806. factor2?: number;
  30807. /**
  30808. * Will get a number picked randomly between factor1 and factor2.
  30809. * If factor2 is undefined then factor1 will be used
  30810. * @returns the picked number
  30811. */
  30812. getFactor(): number;
  30813. }
  30814. /**
  30815. * @ignore
  30816. * Application error to support additional information when loading a file
  30817. */
  30818. export class LoadFileError extends Error {
  30819. /** defines the optional web request */
  30820. request?: WebRequest | undefined;
  30821. private static _setPrototypeOf;
  30822. /**
  30823. * Creates a new LoadFileError
  30824. * @param message defines the message of the error
  30825. * @param request defines the optional web request
  30826. */
  30827. constructor(message: string,
  30828. /** defines the optional web request */
  30829. request?: WebRequest | undefined);
  30830. }
  30831. /**
  30832. * Class used to define a retry strategy when error happens while loading assets
  30833. */
  30834. export class RetryStrategy {
  30835. /**
  30836. * Function used to defines an exponential back off strategy
  30837. * @param maxRetries defines the maximum number of retries (3 by default)
  30838. * @param baseInterval defines the interval between retries
  30839. * @returns the strategy function to use
  30840. */
  30841. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30842. }
  30843. /**
  30844. * File request interface
  30845. */
  30846. export interface IFileRequest {
  30847. /**
  30848. * Raised when the request is complete (success or error).
  30849. */
  30850. onCompleteObservable: Observable<IFileRequest>;
  30851. /**
  30852. * Aborts the request for a file.
  30853. */
  30854. abort: () => void;
  30855. }
  30856. /**
  30857. * Class containing a set of static utilities functions
  30858. */
  30859. export class Tools {
  30860. /**
  30861. * Gets or sets the base URL to use to load assets
  30862. */
  30863. static BaseUrl: string;
  30864. /**
  30865. * Enable/Disable Custom HTTP Request Headers globally.
  30866. * default = false
  30867. * @see CustomRequestHeaders
  30868. */
  30869. static UseCustomRequestHeaders: boolean;
  30870. /**
  30871. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30872. * i.e. when loading files, where the server/service expects an Authorization header
  30873. */
  30874. static CustomRequestHeaders: {
  30875. [key: string]: string;
  30876. };
  30877. /**
  30878. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30879. */
  30880. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30881. /**
  30882. * Default behaviour for cors in the application.
  30883. * It can be a string if the expected behavior is identical in the entire app.
  30884. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30885. */
  30886. static CorsBehavior: string | ((url: string | string[]) => string);
  30887. /**
  30888. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30889. * @ignorenaming
  30890. */
  30891. static UseFallbackTexture: boolean;
  30892. /**
  30893. * Use this object to register external classes like custom textures or material
  30894. * to allow the laoders to instantiate them
  30895. */
  30896. static RegisteredExternalClasses: {
  30897. [key: string]: Object;
  30898. };
  30899. /**
  30900. * Texture content used if a texture cannot loaded
  30901. * @ignorenaming
  30902. */
  30903. static fallbackTexture: string;
  30904. /**
  30905. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30906. * @param u defines the coordinate on X axis
  30907. * @param v defines the coordinate on Y axis
  30908. * @param width defines the width of the source data
  30909. * @param height defines the height of the source data
  30910. * @param pixels defines the source byte array
  30911. * @param color defines the output color
  30912. */
  30913. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30914. /**
  30915. * Interpolates between a and b via alpha
  30916. * @param a The lower value (returned when alpha = 0)
  30917. * @param b The upper value (returned when alpha = 1)
  30918. * @param alpha The interpolation-factor
  30919. * @return The mixed value
  30920. */
  30921. static Mix(a: number, b: number, alpha: number): number;
  30922. /**
  30923. * Tries to instantiate a new object from a given class name
  30924. * @param className defines the class name to instantiate
  30925. * @returns the new object or null if the system was not able to do the instantiation
  30926. */
  30927. static Instantiate(className: string): any;
  30928. /**
  30929. * Provides a slice function that will work even on IE
  30930. * @param data defines the array to slice
  30931. * @param start defines the start of the data (optional)
  30932. * @param end defines the end of the data (optional)
  30933. * @returns the new sliced array
  30934. */
  30935. static Slice<T>(data: T, start?: number, end?: number): T;
  30936. /**
  30937. * Polyfill for setImmediate
  30938. * @param action defines the action to execute after the current execution block
  30939. */
  30940. static SetImmediate(action: () => void): void;
  30941. /**
  30942. * Function indicating if a number is an exponent of 2
  30943. * @param value defines the value to test
  30944. * @returns true if the value is an exponent of 2
  30945. */
  30946. static IsExponentOfTwo(value: number): boolean;
  30947. private static _tmpFloatArray;
  30948. /**
  30949. * Returns the nearest 32-bit single precision float representation of a Number
  30950. * @param value A Number. If the parameter is of a different type, it will get converted
  30951. * to a number or to NaN if it cannot be converted
  30952. * @returns number
  30953. */
  30954. static FloatRound(value: number): number;
  30955. /**
  30956. * Find the next highest power of two.
  30957. * @param x Number to start search from.
  30958. * @return Next highest power of two.
  30959. */
  30960. static CeilingPOT(x: number): number;
  30961. /**
  30962. * Find the next lowest power of two.
  30963. * @param x Number to start search from.
  30964. * @return Next lowest power of two.
  30965. */
  30966. static FloorPOT(x: number): number;
  30967. /**
  30968. * Find the nearest power of two.
  30969. * @param x Number to start search from.
  30970. * @return Next nearest power of two.
  30971. */
  30972. static NearestPOT(x: number): number;
  30973. /**
  30974. * Get the closest exponent of two
  30975. * @param value defines the value to approximate
  30976. * @param max defines the maximum value to return
  30977. * @param mode defines how to define the closest value
  30978. * @returns closest exponent of two of the given value
  30979. */
  30980. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30981. /**
  30982. * Extracts the filename from a path
  30983. * @param path defines the path to use
  30984. * @returns the filename
  30985. */
  30986. static GetFilename(path: string): string;
  30987. /**
  30988. * Extracts the "folder" part of a path (everything before the filename).
  30989. * @param uri The URI to extract the info from
  30990. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30991. * @returns The "folder" part of the path
  30992. */
  30993. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30994. /**
  30995. * Extracts text content from a DOM element hierarchy
  30996. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30997. */
  30998. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30999. /**
  31000. * Convert an angle in radians to degrees
  31001. * @param angle defines the angle to convert
  31002. * @returns the angle in degrees
  31003. */
  31004. static ToDegrees(angle: number): number;
  31005. /**
  31006. * Convert an angle in degrees to radians
  31007. * @param angle defines the angle to convert
  31008. * @returns the angle in radians
  31009. */
  31010. static ToRadians(angle: number): number;
  31011. /**
  31012. * Encode a buffer to a base64 string
  31013. * @param buffer defines the buffer to encode
  31014. * @returns the encoded string
  31015. */
  31016. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31017. /**
  31018. * Extracts minimum and maximum values from a list of indexed positions
  31019. * @param positions defines the positions to use
  31020. * @param indices defines the indices to the positions
  31021. * @param indexStart defines the start index
  31022. * @param indexCount defines the end index
  31023. * @param bias defines bias value to add to the result
  31024. * @return minimum and maximum values
  31025. */
  31026. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31027. minimum: Vector3;
  31028. maximum: Vector3;
  31029. };
  31030. /**
  31031. * Extracts minimum and maximum values from a list of positions
  31032. * @param positions defines the positions to use
  31033. * @param start defines the start index in the positions array
  31034. * @param count defines the number of positions to handle
  31035. * @param bias defines bias value to add to the result
  31036. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31037. * @return minimum and maximum values
  31038. */
  31039. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31040. minimum: Vector3;
  31041. maximum: Vector3;
  31042. };
  31043. /**
  31044. * Returns an array if obj is not an array
  31045. * @param obj defines the object to evaluate as an array
  31046. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31047. * @returns either obj directly if obj is an array or a new array containing obj
  31048. */
  31049. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31050. /**
  31051. * Gets the pointer prefix to use
  31052. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31053. */
  31054. static GetPointerPrefix(): string;
  31055. /**
  31056. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31057. * @param func - the function to be called
  31058. * @param requester - the object that will request the next frame. Falls back to window.
  31059. * @returns frame number
  31060. */
  31061. static QueueNewFrame(func: () => void, requester?: any): number;
  31062. /**
  31063. * Ask the browser to promote the current element to fullscreen rendering mode
  31064. * @param element defines the DOM element to promote
  31065. */
  31066. static RequestFullscreen(element: HTMLElement): void;
  31067. /**
  31068. * Asks the browser to exit fullscreen mode
  31069. */
  31070. static ExitFullscreen(): void;
  31071. /**
  31072. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31073. * @param url define the url we are trying
  31074. * @param element define the dom element where to configure the cors policy
  31075. */
  31076. static SetCorsBehavior(url: string | string[], element: {
  31077. crossOrigin: string | null;
  31078. }): void;
  31079. /**
  31080. * Removes unwanted characters from an url
  31081. * @param url defines the url to clean
  31082. * @returns the cleaned url
  31083. */
  31084. static CleanUrl(url: string): string;
  31085. /**
  31086. * Gets or sets a function used to pre-process url before using them to load assets
  31087. */
  31088. static PreprocessUrl: (url: string) => string;
  31089. /**
  31090. * Loads an image as an HTMLImageElement.
  31091. * @param input url string, ArrayBuffer, or Blob to load
  31092. * @param onLoad callback called when the image successfully loads
  31093. * @param onError callback called when the image fails to load
  31094. * @param offlineProvider offline provider for caching
  31095. * @returns the HTMLImageElement of the loaded image
  31096. */
  31097. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31098. /**
  31099. * Loads a file
  31100. * @param url url string, ArrayBuffer, or Blob to load
  31101. * @param onSuccess callback called when the file successfully loads
  31102. * @param onProgress callback called while file is loading (if the server supports this mode)
  31103. * @param offlineProvider defines the offline provider for caching
  31104. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31105. * @param onError callback called when the file fails to load
  31106. * @returns a file request object
  31107. */
  31108. 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;
  31109. /**
  31110. * Load a script (identified by an url). When the url returns, the
  31111. * content of this file is added into a new script element, attached to the DOM (body element)
  31112. * @param scriptUrl defines the url of the script to laod
  31113. * @param onSuccess defines the callback called when the script is loaded
  31114. * @param onError defines the callback to call if an error occurs
  31115. * @param scriptId defines the id of the script element
  31116. */
  31117. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31118. /**
  31119. * Load an asynchronous script (identified by an url). When the url returns, the
  31120. * content of this file is added into a new script element, attached to the DOM (body element)
  31121. * @param scriptUrl defines the url of the script to laod
  31122. * @param scriptId defines the id of the script element
  31123. * @returns a promise request object
  31124. */
  31125. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31126. /**
  31127. * Loads a file from a blob
  31128. * @param fileToLoad defines the blob to use
  31129. * @param callback defines the callback to call when data is loaded
  31130. * @param progressCallback defines the callback to call during loading process
  31131. * @returns a file request object
  31132. */
  31133. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31134. /**
  31135. * Loads a file
  31136. * @param fileToLoad defines the file to load
  31137. * @param callback defines the callback to call when data is loaded
  31138. * @param progressCallBack defines the callback to call during loading process
  31139. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31140. * @returns a file request object
  31141. */
  31142. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31143. /**
  31144. * Creates a data url from a given string content
  31145. * @param content defines the content to convert
  31146. * @returns the new data url link
  31147. */
  31148. static FileAsURL(content: string): string;
  31149. /**
  31150. * Format the given number to a specific decimal format
  31151. * @param value defines the number to format
  31152. * @param decimals defines the number of decimals to use
  31153. * @returns the formatted string
  31154. */
  31155. static Format(value: number, decimals?: number): string;
  31156. /**
  31157. * Checks if a given vector is inside a specific range
  31158. * @param v defines the vector to test
  31159. * @param min defines the minimum range
  31160. * @param max defines the maximum range
  31161. */
  31162. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31163. /**
  31164. * Tries to copy an object by duplicating every property
  31165. * @param source defines the source object
  31166. * @param destination defines the target object
  31167. * @param doNotCopyList defines a list of properties to avoid
  31168. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31169. */
  31170. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31171. /**
  31172. * Gets a boolean indicating if the given object has no own property
  31173. * @param obj defines the object to test
  31174. * @returns true if object has no own property
  31175. */
  31176. static IsEmpty(obj: any): boolean;
  31177. /**
  31178. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31179. * @param str Source string
  31180. * @param suffix Suffix to search for in the source string
  31181. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31182. */
  31183. static EndsWith(str: string, suffix: string): boolean;
  31184. /**
  31185. * Function used to register events at window level
  31186. * @param events defines the events to register
  31187. */
  31188. static RegisterTopRootEvents(events: {
  31189. name: string;
  31190. handler: Nullable<(e: FocusEvent) => any>;
  31191. }[]): void;
  31192. /**
  31193. * Function used to unregister events from window level
  31194. * @param events defines the events to unregister
  31195. */
  31196. static UnregisterTopRootEvents(events: {
  31197. name: string;
  31198. handler: Nullable<(e: FocusEvent) => any>;
  31199. }[]): void;
  31200. /**
  31201. * @ignore
  31202. */
  31203. static _ScreenshotCanvas: HTMLCanvasElement;
  31204. /**
  31205. * Dumps the current bound framebuffer
  31206. * @param width defines the rendering width
  31207. * @param height defines the rendering height
  31208. * @param engine defines the hosting engine
  31209. * @param successCallback defines the callback triggered once the data are available
  31210. * @param mimeType defines the mime type of the result
  31211. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31212. */
  31213. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31214. /**
  31215. * Converts the canvas data to blob.
  31216. * This acts as a polyfill for browsers not supporting the to blob function.
  31217. * @param canvas Defines the canvas to extract the data from
  31218. * @param successCallback Defines the callback triggered once the data are available
  31219. * @param mimeType Defines the mime type of the result
  31220. */
  31221. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31222. /**
  31223. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31224. * @param successCallback defines the callback triggered once the data are available
  31225. * @param mimeType defines the mime type of the result
  31226. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31227. */
  31228. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31229. /**
  31230. * Downloads a blob in the browser
  31231. * @param blob defines the blob to download
  31232. * @param fileName defines the name of the downloaded file
  31233. */
  31234. static Download(blob: Blob, fileName: string): void;
  31235. /**
  31236. * Captures a screenshot of the current rendering
  31237. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31238. * @param engine defines the rendering engine
  31239. * @param camera defines the source camera
  31240. * @param size This parameter can be set to a single number or to an object with the
  31241. * following (optional) properties: precision, width, height. If a single number is passed,
  31242. * it will be used for both width and height. If an object is passed, the screenshot size
  31243. * will be derived from the parameters. The precision property is a multiplier allowing
  31244. * rendering at a higher or lower resolution
  31245. * @param successCallback defines the callback receives a single parameter which contains the
  31246. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31247. * src parameter of an <img> to display it
  31248. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31249. * Check your browser for supported MIME types
  31250. */
  31251. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31252. /**
  31253. * Generates an image screenshot from the specified camera.
  31254. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31255. * @param engine The engine to use for rendering
  31256. * @param camera The camera to use for rendering
  31257. * @param size This parameter can be set to a single number or to an object with the
  31258. * following (optional) properties: precision, width, height. If a single number is passed,
  31259. * it will be used for both width and height. If an object is passed, the screenshot size
  31260. * will be derived from the parameters. The precision property is a multiplier allowing
  31261. * rendering at a higher or lower resolution
  31262. * @param successCallback The callback receives a single parameter which contains the
  31263. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31264. * src parameter of an <img> to display it
  31265. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31266. * Check your browser for supported MIME types
  31267. * @param samples Texture samples (default: 1)
  31268. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31269. * @param fileName A name for for the downloaded file.
  31270. */
  31271. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31272. /**
  31273. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31274. * Be aware Math.random() could cause collisions, but:
  31275. * "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"
  31276. * @returns a pseudo random id
  31277. */
  31278. static RandomId(): string;
  31279. /**
  31280. * Test if the given uri is a base64 string
  31281. * @param uri The uri to test
  31282. * @return True if the uri is a base64 string or false otherwise
  31283. */
  31284. static IsBase64(uri: string): boolean;
  31285. /**
  31286. * Decode the given base64 uri.
  31287. * @param uri The uri to decode
  31288. * @return The decoded base64 data.
  31289. */
  31290. static DecodeBase64(uri: string): ArrayBuffer;
  31291. /**
  31292. * Gets the absolute url.
  31293. * @param url the input url
  31294. * @return the absolute url
  31295. */
  31296. static GetAbsoluteUrl(url: string): string;
  31297. /**
  31298. * No log
  31299. */
  31300. static readonly NoneLogLevel: number;
  31301. /**
  31302. * Only message logs
  31303. */
  31304. static readonly MessageLogLevel: number;
  31305. /**
  31306. * Only warning logs
  31307. */
  31308. static readonly WarningLogLevel: number;
  31309. /**
  31310. * Only error logs
  31311. */
  31312. static readonly ErrorLogLevel: number;
  31313. /**
  31314. * All logs
  31315. */
  31316. static readonly AllLogLevel: number;
  31317. /**
  31318. * Gets a value indicating the number of loading errors
  31319. * @ignorenaming
  31320. */
  31321. static readonly errorsCount: number;
  31322. /**
  31323. * Callback called when a new log is added
  31324. */
  31325. static OnNewCacheEntry: (entry: string) => void;
  31326. /**
  31327. * Log a message to the console
  31328. * @param message defines the message to log
  31329. */
  31330. static Log(message: string): void;
  31331. /**
  31332. * Write a warning message to the console
  31333. * @param message defines the message to log
  31334. */
  31335. static Warn(message: string): void;
  31336. /**
  31337. * Write an error message to the console
  31338. * @param message defines the message to log
  31339. */
  31340. static Error(message: string): void;
  31341. /**
  31342. * Gets current log cache (list of logs)
  31343. */
  31344. static readonly LogCache: string;
  31345. /**
  31346. * Clears the log cache
  31347. */
  31348. static ClearLogCache(): void;
  31349. /**
  31350. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31351. */
  31352. static LogLevels: number;
  31353. /**
  31354. * Checks if the loaded document was accessed via `file:`-Protocol.
  31355. * @returns boolean
  31356. */
  31357. static IsFileURL(): boolean;
  31358. /**
  31359. * Checks if the window object exists
  31360. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31361. */
  31362. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31363. /**
  31364. * No performance log
  31365. */
  31366. static readonly PerformanceNoneLogLevel: number;
  31367. /**
  31368. * Use user marks to log performance
  31369. */
  31370. static readonly PerformanceUserMarkLogLevel: number;
  31371. /**
  31372. * Log performance to the console
  31373. */
  31374. static readonly PerformanceConsoleLogLevel: number;
  31375. private static _performance;
  31376. /**
  31377. * Sets the current performance log level
  31378. */
  31379. static PerformanceLogLevel: number;
  31380. private static _StartPerformanceCounterDisabled;
  31381. private static _EndPerformanceCounterDisabled;
  31382. private static _StartUserMark;
  31383. private static _EndUserMark;
  31384. private static _StartPerformanceConsole;
  31385. private static _EndPerformanceConsole;
  31386. /**
  31387. * Starts a performance counter
  31388. */
  31389. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31390. /**
  31391. * Ends a specific performance coutner
  31392. */
  31393. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31394. /**
  31395. * Gets either window.performance.now() if supported or Date.now() else
  31396. */
  31397. static readonly Now: number;
  31398. /**
  31399. * This method will return the name of the class used to create the instance of the given object.
  31400. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31401. * @param object the object to get the class name from
  31402. * @param isType defines if the object is actually a type
  31403. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31404. */
  31405. static GetClassName(object: any, isType?: boolean): string;
  31406. /**
  31407. * Gets the first element of an array satisfying a given predicate
  31408. * @param array defines the array to browse
  31409. * @param predicate defines the predicate to use
  31410. * @returns null if not found or the element
  31411. */
  31412. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31413. /**
  31414. * This method will return the name of the full name of the class, including its owning module (if any).
  31415. * 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).
  31416. * @param object the object to get the class name from
  31417. * @param isType defines if the object is actually a type
  31418. * @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.
  31419. * @ignorenaming
  31420. */
  31421. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31422. /**
  31423. * Returns a promise that resolves after the given amount of time.
  31424. * @param delay Number of milliseconds to delay
  31425. * @returns Promise that resolves after the given amount of time
  31426. */
  31427. static DelayAsync(delay: number): Promise<void>;
  31428. /**
  31429. * Gets the current gradient from an array of IValueGradient
  31430. * @param ratio defines the current ratio to get
  31431. * @param gradients defines the array of IValueGradient
  31432. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31433. */
  31434. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31435. }
  31436. /**
  31437. * This class is used to track a performance counter which is number based.
  31438. * The user has access to many properties which give statistics of different nature.
  31439. *
  31440. * The implementer can track two kinds of Performance Counter: time and count.
  31441. * 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.
  31442. * 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.
  31443. */
  31444. export class PerfCounter {
  31445. /**
  31446. * Gets or sets a global boolean to turn on and off all the counters
  31447. */
  31448. static Enabled: boolean;
  31449. /**
  31450. * Returns the smallest value ever
  31451. */
  31452. readonly min: number;
  31453. /**
  31454. * Returns the biggest value ever
  31455. */
  31456. readonly max: number;
  31457. /**
  31458. * Returns the average value since the performance counter is running
  31459. */
  31460. readonly average: number;
  31461. /**
  31462. * Returns the average value of the last second the counter was monitored
  31463. */
  31464. readonly lastSecAverage: number;
  31465. /**
  31466. * Returns the current value
  31467. */
  31468. readonly current: number;
  31469. /**
  31470. * Gets the accumulated total
  31471. */
  31472. readonly total: number;
  31473. /**
  31474. * Gets the total value count
  31475. */
  31476. readonly count: number;
  31477. /**
  31478. * Creates a new counter
  31479. */
  31480. constructor();
  31481. /**
  31482. * Call this method to start monitoring a new frame.
  31483. * 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.
  31484. */
  31485. fetchNewFrame(): void;
  31486. /**
  31487. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31488. * @param newCount the count value to add to the monitored count
  31489. * @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.
  31490. */
  31491. addCount(newCount: number, fetchResult: boolean): void;
  31492. /**
  31493. * Start monitoring this performance counter
  31494. */
  31495. beginMonitoring(): void;
  31496. /**
  31497. * Compute the time lapsed since the previous beginMonitoring() call.
  31498. * @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
  31499. */
  31500. endMonitoring(newFrame?: boolean): void;
  31501. private _fetchResult;
  31502. private _startMonitoringTime;
  31503. private _min;
  31504. private _max;
  31505. private _average;
  31506. private _current;
  31507. private _totalValueCount;
  31508. private _totalAccumulated;
  31509. private _lastSecAverage;
  31510. private _lastSecAccumulated;
  31511. private _lastSecTime;
  31512. private _lastSecValueCount;
  31513. }
  31514. /**
  31515. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31516. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31517. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31518. * @param name The name of the class, case should be preserved
  31519. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31520. */
  31521. export function className(name: string, module?: string): (target: Object) => void;
  31522. /**
  31523. * An implementation of a loop for asynchronous functions.
  31524. */
  31525. export class AsyncLoop {
  31526. /**
  31527. * Defines the number of iterations for the loop
  31528. */
  31529. iterations: number;
  31530. /**
  31531. * Defines the current index of the loop.
  31532. */
  31533. index: number;
  31534. private _done;
  31535. private _fn;
  31536. private _successCallback;
  31537. /**
  31538. * Constructor.
  31539. * @param iterations the number of iterations.
  31540. * @param func the function to run each iteration
  31541. * @param successCallback the callback that will be called upon succesful execution
  31542. * @param offset starting offset.
  31543. */
  31544. constructor(
  31545. /**
  31546. * Defines the number of iterations for the loop
  31547. */
  31548. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31549. /**
  31550. * Execute the next iteration. Must be called after the last iteration was finished.
  31551. */
  31552. executeNext(): void;
  31553. /**
  31554. * Break the loop and run the success callback.
  31555. */
  31556. breakLoop(): void;
  31557. /**
  31558. * Create and run an async loop.
  31559. * @param iterations the number of iterations.
  31560. * @param fn the function to run each iteration
  31561. * @param successCallback the callback that will be called upon succesful execution
  31562. * @param offset starting offset.
  31563. * @returns the created async loop object
  31564. */
  31565. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31566. /**
  31567. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31568. * @param iterations total number of iterations
  31569. * @param syncedIterations number of synchronous iterations in each async iteration.
  31570. * @param fn the function to call each iteration.
  31571. * @param callback a success call back that will be called when iterating stops.
  31572. * @param breakFunction a break condition (optional)
  31573. * @param timeout timeout settings for the setTimeout function. default - 0.
  31574. * @returns the created async loop object
  31575. */
  31576. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31577. }
  31578. }
  31579. declare module BABYLON {
  31580. /** @hidden */
  31581. export interface ICollisionCoordinator {
  31582. createCollider(): Collider;
  31583. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31584. init(scene: Scene): void;
  31585. }
  31586. /** @hidden */
  31587. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31588. private _scene;
  31589. private _scaledPosition;
  31590. private _scaledVelocity;
  31591. private _finalPosition;
  31592. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31593. createCollider(): Collider;
  31594. init(scene: Scene): void;
  31595. private _collideWithWorld;
  31596. }
  31597. }
  31598. declare module BABYLON {
  31599. /**
  31600. * Class used to manage all inputs for the scene.
  31601. */
  31602. export class InputManager {
  31603. /** The distance in pixel that you have to move to prevent some events */
  31604. static DragMovementThreshold: number;
  31605. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31606. static LongPressDelay: number;
  31607. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31608. static DoubleClickDelay: number;
  31609. /** If you need to check double click without raising a single click at first click, enable this flag */
  31610. static ExclusiveDoubleClickMode: boolean;
  31611. private _wheelEventName;
  31612. private _onPointerMove;
  31613. private _onPointerDown;
  31614. private _onPointerUp;
  31615. private _initClickEvent;
  31616. private _initActionManager;
  31617. private _delayedSimpleClick;
  31618. private _delayedSimpleClickTimeout;
  31619. private _previousDelayedSimpleClickTimeout;
  31620. private _meshPickProceed;
  31621. private _previousButtonPressed;
  31622. private _currentPickResult;
  31623. private _previousPickResult;
  31624. private _totalPointersPressed;
  31625. private _doubleClickOccured;
  31626. private _pointerOverMesh;
  31627. private _pickedDownMesh;
  31628. private _pickedUpMesh;
  31629. private _pointerX;
  31630. private _pointerY;
  31631. private _unTranslatedPointerX;
  31632. private _unTranslatedPointerY;
  31633. private _startingPointerPosition;
  31634. private _previousStartingPointerPosition;
  31635. private _startingPointerTime;
  31636. private _previousStartingPointerTime;
  31637. private _pointerCaptures;
  31638. private _onKeyDown;
  31639. private _onKeyUp;
  31640. private _onCanvasFocusObserver;
  31641. private _onCanvasBlurObserver;
  31642. private _scene;
  31643. /**
  31644. * Creates a new InputManager
  31645. * @param scene defines the hosting scene
  31646. */
  31647. constructor(scene: Scene);
  31648. /**
  31649. * Gets the mesh that is currently under the pointer
  31650. */
  31651. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31652. /**
  31653. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31654. */
  31655. readonly unTranslatedPointer: Vector2;
  31656. /**
  31657. * Gets or sets the current on-screen X position of the pointer
  31658. */
  31659. pointerX: number;
  31660. /**
  31661. * Gets or sets the current on-screen Y position of the pointer
  31662. */
  31663. pointerY: number;
  31664. private _updatePointerPosition;
  31665. private _processPointerMove;
  31666. private _setRayOnPointerInfo;
  31667. private _checkPrePointerObservable;
  31668. /**
  31669. * Use this method to simulate a pointer move on a mesh
  31670. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31671. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31672. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31673. */
  31674. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31675. /**
  31676. * Use this method to simulate a pointer down on a mesh
  31677. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31678. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31679. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31680. */
  31681. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31682. private _processPointerDown;
  31683. /** @hidden */
  31684. _isPointerSwiping(): boolean;
  31685. /**
  31686. * Use this method to simulate a pointer up on a mesh
  31687. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31688. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31689. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31690. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31691. */
  31692. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31693. private _processPointerUp;
  31694. /**
  31695. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31696. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31697. * @returns true if the pointer was captured
  31698. */
  31699. isPointerCaptured(pointerId?: number): boolean;
  31700. /**
  31701. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31702. * @param attachUp defines if you want to attach events to pointerup
  31703. * @param attachDown defines if you want to attach events to pointerdown
  31704. * @param attachMove defines if you want to attach events to pointermove
  31705. */
  31706. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31707. /**
  31708. * Detaches all event handlers
  31709. */
  31710. detachControl(): void;
  31711. /**
  31712. * Force the value of meshUnderPointer
  31713. * @param mesh defines the mesh to use
  31714. */
  31715. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31716. /**
  31717. * Gets the mesh under the pointer
  31718. * @returns a Mesh or null if no mesh is under the pointer
  31719. */
  31720. getPointerOverMesh(): Nullable<AbstractMesh>;
  31721. }
  31722. }
  31723. declare module BABYLON {
  31724. /**
  31725. * This class defines the direct association between an animation and a target
  31726. */
  31727. export class TargetedAnimation {
  31728. /**
  31729. * Animation to perform
  31730. */
  31731. animation: Animation;
  31732. /**
  31733. * Target to animate
  31734. */
  31735. target: any;
  31736. /**
  31737. * Serialize the object
  31738. * @returns the JSON object representing the current entity
  31739. */
  31740. serialize(): any;
  31741. }
  31742. /**
  31743. * Use this class to create coordinated animations on multiple targets
  31744. */
  31745. export class AnimationGroup implements IDisposable {
  31746. /** The name of the animation group */
  31747. name: string;
  31748. private _scene;
  31749. private _targetedAnimations;
  31750. private _animatables;
  31751. private _from;
  31752. private _to;
  31753. private _isStarted;
  31754. private _isPaused;
  31755. private _speedRatio;
  31756. private _loopAnimation;
  31757. /**
  31758. * Gets or sets the unique id of the node
  31759. */
  31760. uniqueId: number;
  31761. /**
  31762. * This observable will notify when one animation have ended
  31763. */
  31764. onAnimationEndObservable: Observable<TargetedAnimation>;
  31765. /**
  31766. * Observer raised when one animation loops
  31767. */
  31768. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31769. /**
  31770. * This observable will notify when all animations have ended.
  31771. */
  31772. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31773. /**
  31774. * This observable will notify when all animations have paused.
  31775. */
  31776. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31777. /**
  31778. * This observable will notify when all animations are playing.
  31779. */
  31780. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31781. /**
  31782. * Gets the first frame
  31783. */
  31784. readonly from: number;
  31785. /**
  31786. * Gets the last frame
  31787. */
  31788. readonly to: number;
  31789. /**
  31790. * Define if the animations are started
  31791. */
  31792. readonly isStarted: boolean;
  31793. /**
  31794. * Gets a value indicating that the current group is playing
  31795. */
  31796. readonly isPlaying: boolean;
  31797. /**
  31798. * Gets or sets the speed ratio to use for all animations
  31799. */
  31800. /**
  31801. * Gets or sets the speed ratio to use for all animations
  31802. */
  31803. speedRatio: number;
  31804. /**
  31805. * Gets or sets if all animations should loop or not
  31806. */
  31807. loopAnimation: boolean;
  31808. /**
  31809. * Gets the targeted animations for this animation group
  31810. */
  31811. readonly targetedAnimations: Array<TargetedAnimation>;
  31812. /**
  31813. * returning the list of animatables controlled by this animation group.
  31814. */
  31815. readonly animatables: Array<Animatable>;
  31816. /**
  31817. * Instantiates a new Animation Group.
  31818. * This helps managing several animations at once.
  31819. * @see http://doc.babylonjs.com/how_to/group
  31820. * @param name Defines the name of the group
  31821. * @param scene Defines the scene the group belongs to
  31822. */
  31823. constructor(
  31824. /** The name of the animation group */
  31825. name: string, scene?: Nullable<Scene>);
  31826. /**
  31827. * Add an animation (with its target) in the group
  31828. * @param animation defines the animation we want to add
  31829. * @param target defines the target of the animation
  31830. * @returns the TargetedAnimation object
  31831. */
  31832. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31833. /**
  31834. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31835. * It can add constant keys at begin or end
  31836. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31837. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31838. * @returns the animation group
  31839. */
  31840. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31841. /**
  31842. * Start all animations on given targets
  31843. * @param loop defines if animations must loop
  31844. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31845. * @param from defines the from key (optional)
  31846. * @param to defines the to key (optional)
  31847. * @returns the current animation group
  31848. */
  31849. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31850. /**
  31851. * Pause all animations
  31852. * @returns the animation group
  31853. */
  31854. pause(): AnimationGroup;
  31855. /**
  31856. * Play all animations to initial state
  31857. * This function will start() the animations if they were not started or will restart() them if they were paused
  31858. * @param loop defines if animations must loop
  31859. * @returns the animation group
  31860. */
  31861. play(loop?: boolean): AnimationGroup;
  31862. /**
  31863. * Reset all animations to initial state
  31864. * @returns the animation group
  31865. */
  31866. reset(): AnimationGroup;
  31867. /**
  31868. * Restart animations from key 0
  31869. * @returns the animation group
  31870. */
  31871. restart(): AnimationGroup;
  31872. /**
  31873. * Stop all animations
  31874. * @returns the animation group
  31875. */
  31876. stop(): AnimationGroup;
  31877. /**
  31878. * Set animation weight for all animatables
  31879. * @param weight defines the weight to use
  31880. * @return the animationGroup
  31881. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31882. */
  31883. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31884. /**
  31885. * Synchronize and normalize all animatables with a source animatable
  31886. * @param root defines the root animatable to synchronize with
  31887. * @return the animationGroup
  31888. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31889. */
  31890. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31891. /**
  31892. * Goes to a specific frame in this animation group
  31893. * @param frame the frame number to go to
  31894. * @return the animationGroup
  31895. */
  31896. goToFrame(frame: number): AnimationGroup;
  31897. /**
  31898. * Dispose all associated resources
  31899. */
  31900. dispose(): void;
  31901. private _checkAnimationGroupEnded;
  31902. /**
  31903. * Clone the current animation group and returns a copy
  31904. * @param newName defines the name of the new group
  31905. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31906. * @returns the new aniamtion group
  31907. */
  31908. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31909. /**
  31910. * Serializes the animationGroup to an object
  31911. * @returns Serialized object
  31912. */
  31913. serialize(): any;
  31914. /**
  31915. * Returns a new AnimationGroup object parsed from the source provided.
  31916. * @param parsedAnimationGroup defines the source
  31917. * @param scene defines the scene that will receive the animationGroup
  31918. * @returns a new AnimationGroup
  31919. */
  31920. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31921. /**
  31922. * Returns the string "AnimationGroup"
  31923. * @returns "AnimationGroup"
  31924. */
  31925. getClassName(): string;
  31926. /**
  31927. * Creates a detailled string about the object
  31928. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31929. * @returns a string representing the object
  31930. */
  31931. toString(fullDetails?: boolean): string;
  31932. }
  31933. }
  31934. declare module BABYLON {
  31935. /**
  31936. * Define an interface for all classes that will hold resources
  31937. */
  31938. export interface IDisposable {
  31939. /**
  31940. * Releases all held resources
  31941. */
  31942. dispose(): void;
  31943. }
  31944. /** Interface defining initialization parameters for Scene class */
  31945. export interface SceneOptions {
  31946. /**
  31947. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31948. * It will improve performance when the number of geometries becomes important.
  31949. */
  31950. useGeometryUniqueIdsMap?: boolean;
  31951. /**
  31952. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31953. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31954. */
  31955. useMaterialMeshMap?: boolean;
  31956. /**
  31957. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31958. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31959. */
  31960. useClonedMeshhMap?: boolean;
  31961. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  31962. virtual?: boolean;
  31963. }
  31964. /**
  31965. * Represents a scene to be rendered by the engine.
  31966. * @see http://doc.babylonjs.com/features/scene
  31967. */
  31968. export class Scene extends AbstractScene implements IAnimatable {
  31969. private static _uniqueIdCounter;
  31970. /** The fog is deactivated */
  31971. static readonly FOGMODE_NONE: number;
  31972. /** The fog density is following an exponential function */
  31973. static readonly FOGMODE_EXP: number;
  31974. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31975. static readonly FOGMODE_EXP2: number;
  31976. /** The fog density is following a linear function. */
  31977. static readonly FOGMODE_LINEAR: number;
  31978. /**
  31979. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31980. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31981. */
  31982. static MinDeltaTime: number;
  31983. /**
  31984. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31985. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31986. */
  31987. static MaxDeltaTime: number;
  31988. /**
  31989. * Factory used to create the default material.
  31990. * @param name The name of the material to create
  31991. * @param scene The scene to create the material for
  31992. * @returns The default material
  31993. */
  31994. static DefaultMaterialFactory(scene: Scene): Material;
  31995. /**
  31996. * Factory used to create the a collision coordinator.
  31997. * @returns The collision coordinator
  31998. */
  31999. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32000. /** @hidden */
  32001. _inputManager: InputManager;
  32002. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32003. cameraToUseForPointers: Nullable<Camera>;
  32004. /** @hidden */
  32005. readonly _isScene: boolean;
  32006. /**
  32007. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32008. */
  32009. autoClear: boolean;
  32010. /**
  32011. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32012. */
  32013. autoClearDepthAndStencil: boolean;
  32014. /**
  32015. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32016. */
  32017. clearColor: Color4;
  32018. /**
  32019. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32020. */
  32021. ambientColor: Color3;
  32022. /**
  32023. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32024. * It should only be one of the following (if not the default embedded one):
  32025. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32026. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32027. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32028. * The material properties need to be setup according to the type of texture in use.
  32029. */
  32030. environmentBRDFTexture: BaseTexture;
  32031. /** @hidden */
  32032. protected _environmentTexture: Nullable<BaseTexture>;
  32033. /**
  32034. * Texture used in all pbr material as the reflection texture.
  32035. * As in the majority of the scene they are the same (exception for multi room and so on),
  32036. * this is easier to reference from here than from all the materials.
  32037. */
  32038. /**
  32039. * Texture used in all pbr material as the reflection texture.
  32040. * As in the majority of the scene they are the same (exception for multi room and so on),
  32041. * this is easier to set here than in all the materials.
  32042. */
  32043. environmentTexture: Nullable<BaseTexture>;
  32044. /** @hidden */
  32045. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32046. /**
  32047. * Default image processing configuration used either in the rendering
  32048. * Forward main pass or through the imageProcessingPostProcess if present.
  32049. * As in the majority of the scene they are the same (exception for multi camera),
  32050. * this is easier to reference from here than from all the materials and post process.
  32051. *
  32052. * No setter as we it is a shared configuration, you can set the values instead.
  32053. */
  32054. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32055. private _forceWireframe;
  32056. /**
  32057. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32058. */
  32059. forceWireframe: boolean;
  32060. private _forcePointsCloud;
  32061. /**
  32062. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32063. */
  32064. forcePointsCloud: boolean;
  32065. /**
  32066. * Gets or sets the active clipplane 1
  32067. */
  32068. clipPlane: Nullable<Plane>;
  32069. /**
  32070. * Gets or sets the active clipplane 2
  32071. */
  32072. clipPlane2: Nullable<Plane>;
  32073. /**
  32074. * Gets or sets the active clipplane 3
  32075. */
  32076. clipPlane3: Nullable<Plane>;
  32077. /**
  32078. * Gets or sets the active clipplane 4
  32079. */
  32080. clipPlane4: Nullable<Plane>;
  32081. /**
  32082. * Gets or sets a boolean indicating if animations are enabled
  32083. */
  32084. animationsEnabled: boolean;
  32085. private _animationPropertiesOverride;
  32086. /**
  32087. * Gets or sets the animation properties override
  32088. */
  32089. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32090. /**
  32091. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32092. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32093. */
  32094. useConstantAnimationDeltaTime: boolean;
  32095. /**
  32096. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32097. * Please note that it requires to run a ray cast through the scene on every frame
  32098. */
  32099. constantlyUpdateMeshUnderPointer: boolean;
  32100. /**
  32101. * Defines the HTML cursor to use when hovering over interactive elements
  32102. */
  32103. hoverCursor: string;
  32104. /**
  32105. * Defines the HTML default cursor to use (empty by default)
  32106. */
  32107. defaultCursor: string;
  32108. /**
  32109. * This is used to call preventDefault() on pointer down
  32110. * in order to block unwanted artifacts like system double clicks
  32111. */
  32112. preventDefaultOnPointerDown: boolean;
  32113. /**
  32114. * This is used to call preventDefault() on pointer up
  32115. * in order to block unwanted artifacts like system double clicks
  32116. */
  32117. preventDefaultOnPointerUp: boolean;
  32118. /**
  32119. * Gets or sets user defined metadata
  32120. */
  32121. metadata: any;
  32122. /**
  32123. * For internal use only. Please do not use.
  32124. */
  32125. reservedDataStore: any;
  32126. /**
  32127. * Gets the name of the plugin used to load this scene (null by default)
  32128. */
  32129. loadingPluginName: string;
  32130. /**
  32131. * Use this array to add regular expressions used to disable offline support for specific urls
  32132. */
  32133. disableOfflineSupportExceptionRules: RegExp[];
  32134. /**
  32135. * An event triggered when the scene is disposed.
  32136. */
  32137. onDisposeObservable: Observable<Scene>;
  32138. private _onDisposeObserver;
  32139. /** Sets a function to be executed when this scene is disposed. */
  32140. onDispose: () => void;
  32141. /**
  32142. * An event triggered before rendering the scene (right after animations and physics)
  32143. */
  32144. onBeforeRenderObservable: Observable<Scene>;
  32145. private _onBeforeRenderObserver;
  32146. /** Sets a function to be executed before rendering this scene */
  32147. beforeRender: Nullable<() => void>;
  32148. /**
  32149. * An event triggered after rendering the scene
  32150. */
  32151. onAfterRenderObservable: Observable<Scene>;
  32152. private _onAfterRenderObserver;
  32153. /** Sets a function to be executed after rendering this scene */
  32154. afterRender: Nullable<() => void>;
  32155. /**
  32156. * An event triggered before animating the scene
  32157. */
  32158. onBeforeAnimationsObservable: Observable<Scene>;
  32159. /**
  32160. * An event triggered after animations processing
  32161. */
  32162. onAfterAnimationsObservable: Observable<Scene>;
  32163. /**
  32164. * An event triggered before draw calls are ready to be sent
  32165. */
  32166. onBeforeDrawPhaseObservable: Observable<Scene>;
  32167. /**
  32168. * An event triggered after draw calls have been sent
  32169. */
  32170. onAfterDrawPhaseObservable: Observable<Scene>;
  32171. /**
  32172. * An event triggered when the scene is ready
  32173. */
  32174. onReadyObservable: Observable<Scene>;
  32175. /**
  32176. * An event triggered before rendering a camera
  32177. */
  32178. onBeforeCameraRenderObservable: Observable<Camera>;
  32179. private _onBeforeCameraRenderObserver;
  32180. /** Sets a function to be executed before rendering a camera*/
  32181. beforeCameraRender: () => void;
  32182. /**
  32183. * An event triggered after rendering a camera
  32184. */
  32185. onAfterCameraRenderObservable: Observable<Camera>;
  32186. private _onAfterCameraRenderObserver;
  32187. /** Sets a function to be executed after rendering a camera*/
  32188. afterCameraRender: () => void;
  32189. /**
  32190. * An event triggered when active meshes evaluation is about to start
  32191. */
  32192. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32193. /**
  32194. * An event triggered when active meshes evaluation is done
  32195. */
  32196. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32197. /**
  32198. * An event triggered when particles rendering is about to start
  32199. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32200. */
  32201. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32202. /**
  32203. * An event triggered when particles rendering is done
  32204. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32205. */
  32206. onAfterParticlesRenderingObservable: Observable<Scene>;
  32207. /**
  32208. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32209. */
  32210. onDataLoadedObservable: Observable<Scene>;
  32211. /**
  32212. * An event triggered when a camera is created
  32213. */
  32214. onNewCameraAddedObservable: Observable<Camera>;
  32215. /**
  32216. * An event triggered when a camera is removed
  32217. */
  32218. onCameraRemovedObservable: Observable<Camera>;
  32219. /**
  32220. * An event triggered when a light is created
  32221. */
  32222. onNewLightAddedObservable: Observable<Light>;
  32223. /**
  32224. * An event triggered when a light is removed
  32225. */
  32226. onLightRemovedObservable: Observable<Light>;
  32227. /**
  32228. * An event triggered when a geometry is created
  32229. */
  32230. onNewGeometryAddedObservable: Observable<Geometry>;
  32231. /**
  32232. * An event triggered when a geometry is removed
  32233. */
  32234. onGeometryRemovedObservable: Observable<Geometry>;
  32235. /**
  32236. * An event triggered when a transform node is created
  32237. */
  32238. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32239. /**
  32240. * An event triggered when a transform node is removed
  32241. */
  32242. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32243. /**
  32244. * An event triggered when a mesh is created
  32245. */
  32246. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32247. /**
  32248. * An event triggered when a mesh is removed
  32249. */
  32250. onMeshRemovedObservable: Observable<AbstractMesh>;
  32251. /**
  32252. * An event triggered when a skeleton is created
  32253. */
  32254. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32255. /**
  32256. * An event triggered when a skeleton is removed
  32257. */
  32258. onSkeletonRemovedObservable: Observable<Skeleton>;
  32259. /**
  32260. * An event triggered when a material is created
  32261. */
  32262. onNewMaterialAddedObservable: Observable<Material>;
  32263. /**
  32264. * An event triggered when a material is removed
  32265. */
  32266. onMaterialRemovedObservable: Observable<Material>;
  32267. /**
  32268. * An event triggered when a texture is created
  32269. */
  32270. onNewTextureAddedObservable: Observable<BaseTexture>;
  32271. /**
  32272. * An event triggered when a texture is removed
  32273. */
  32274. onTextureRemovedObservable: Observable<BaseTexture>;
  32275. /**
  32276. * An event triggered when render targets are about to be rendered
  32277. * Can happen multiple times per frame.
  32278. */
  32279. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32280. /**
  32281. * An event triggered when render targets were rendered.
  32282. * Can happen multiple times per frame.
  32283. */
  32284. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32285. /**
  32286. * An event triggered before calculating deterministic simulation step
  32287. */
  32288. onBeforeStepObservable: Observable<Scene>;
  32289. /**
  32290. * An event triggered after calculating deterministic simulation step
  32291. */
  32292. onAfterStepObservable: Observable<Scene>;
  32293. /**
  32294. * An event triggered when the activeCamera property is updated
  32295. */
  32296. onActiveCameraChanged: Observable<Scene>;
  32297. /**
  32298. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32299. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32300. * 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)
  32301. */
  32302. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32303. /**
  32304. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32305. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32306. * 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)
  32307. */
  32308. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32309. /**
  32310. * This Observable will when a mesh has been imported into the scene.
  32311. */
  32312. onMeshImportedObservable: Observable<AbstractMesh>;
  32313. /**
  32314. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32315. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32316. */
  32317. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32318. /** @hidden */
  32319. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32320. /**
  32321. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32322. */
  32323. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32324. /**
  32325. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32326. */
  32327. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32328. /**
  32329. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32330. */
  32331. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32332. /** Callback called when a pointer move is detected */
  32333. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32334. /** Callback called when a pointer down is detected */
  32335. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32336. /** Callback called when a pointer up is detected */
  32337. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32338. /** Callback called when a pointer pick is detected */
  32339. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32340. /**
  32341. * 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).
  32342. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32343. */
  32344. onPrePointerObservable: Observable<PointerInfoPre>;
  32345. /**
  32346. * Observable event triggered each time an input event is received from the rendering canvas
  32347. */
  32348. onPointerObservable: Observable<PointerInfo>;
  32349. /**
  32350. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32351. */
  32352. readonly unTranslatedPointer: Vector2;
  32353. /**
  32354. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32355. */
  32356. static DragMovementThreshold: number;
  32357. /**
  32358. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32359. */
  32360. static LongPressDelay: number;
  32361. /**
  32362. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32363. */
  32364. static DoubleClickDelay: number;
  32365. /** If you need to check double click without raising a single click at first click, enable this flag */
  32366. static ExclusiveDoubleClickMode: boolean;
  32367. /** @hidden */
  32368. _mirroredCameraPosition: Nullable<Vector3>;
  32369. /**
  32370. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32371. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32372. */
  32373. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32374. /**
  32375. * Observable event triggered each time an keyboard event is received from the hosting window
  32376. */
  32377. onKeyboardObservable: Observable<KeyboardInfo>;
  32378. private _useRightHandedSystem;
  32379. /**
  32380. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32381. */
  32382. useRightHandedSystem: boolean;
  32383. private _timeAccumulator;
  32384. private _currentStepId;
  32385. private _currentInternalStep;
  32386. /**
  32387. * Sets the step Id used by deterministic lock step
  32388. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32389. * @param newStepId defines the step Id
  32390. */
  32391. setStepId(newStepId: number): void;
  32392. /**
  32393. * Gets the step Id used by deterministic lock step
  32394. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32395. * @returns the step Id
  32396. */
  32397. getStepId(): number;
  32398. /**
  32399. * Gets the internal step used by deterministic lock step
  32400. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32401. * @returns the internal step
  32402. */
  32403. getInternalStep(): number;
  32404. private _fogEnabled;
  32405. /**
  32406. * Gets or sets a boolean indicating if fog is enabled on this scene
  32407. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32408. * (Default is true)
  32409. */
  32410. fogEnabled: boolean;
  32411. private _fogMode;
  32412. /**
  32413. * Gets or sets the fog mode to use
  32414. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32415. * | mode | value |
  32416. * | --- | --- |
  32417. * | FOGMODE_NONE | 0 |
  32418. * | FOGMODE_EXP | 1 |
  32419. * | FOGMODE_EXP2 | 2 |
  32420. * | FOGMODE_LINEAR | 3 |
  32421. */
  32422. fogMode: number;
  32423. /**
  32424. * Gets or sets the fog color to use
  32425. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32426. * (Default is Color3(0.2, 0.2, 0.3))
  32427. */
  32428. fogColor: Color3;
  32429. /**
  32430. * Gets or sets the fog density to use
  32431. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32432. * (Default is 0.1)
  32433. */
  32434. fogDensity: number;
  32435. /**
  32436. * Gets or sets the fog start distance to use
  32437. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32438. * (Default is 0)
  32439. */
  32440. fogStart: number;
  32441. /**
  32442. * Gets or sets the fog end distance to use
  32443. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32444. * (Default is 1000)
  32445. */
  32446. fogEnd: number;
  32447. private _shadowsEnabled;
  32448. /**
  32449. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32450. */
  32451. shadowsEnabled: boolean;
  32452. private _lightsEnabled;
  32453. /**
  32454. * Gets or sets a boolean indicating if lights are enabled on this scene
  32455. */
  32456. lightsEnabled: boolean;
  32457. /** All of the active cameras added to this scene. */
  32458. activeCameras: Camera[];
  32459. /** @hidden */
  32460. _activeCamera: Nullable<Camera>;
  32461. /** Gets or sets the current active camera */
  32462. activeCamera: Nullable<Camera>;
  32463. private _defaultMaterial;
  32464. /** The default material used on meshes when no material is affected */
  32465. /** The default material used on meshes when no material is affected */
  32466. defaultMaterial: Material;
  32467. private _texturesEnabled;
  32468. /**
  32469. * Gets or sets a boolean indicating if textures are enabled on this scene
  32470. */
  32471. texturesEnabled: boolean;
  32472. /**
  32473. * Gets or sets a boolean indicating if particles are enabled on this scene
  32474. */
  32475. particlesEnabled: boolean;
  32476. /**
  32477. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32478. */
  32479. spritesEnabled: boolean;
  32480. private _skeletonsEnabled;
  32481. /**
  32482. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32483. */
  32484. skeletonsEnabled: boolean;
  32485. /**
  32486. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32487. */
  32488. lensFlaresEnabled: boolean;
  32489. /**
  32490. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32491. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32492. */
  32493. collisionsEnabled: boolean;
  32494. private _collisionCoordinator;
  32495. /** @hidden */
  32496. readonly collisionCoordinator: ICollisionCoordinator;
  32497. /**
  32498. * Defines the gravity applied to this scene (used only for collisions)
  32499. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32500. */
  32501. gravity: Vector3;
  32502. /**
  32503. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32504. */
  32505. postProcessesEnabled: boolean;
  32506. /**
  32507. * The list of postprocesses added to the scene
  32508. */
  32509. postProcesses: PostProcess[];
  32510. /**
  32511. * Gets the current postprocess manager
  32512. */
  32513. postProcessManager: PostProcessManager;
  32514. /**
  32515. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32516. */
  32517. renderTargetsEnabled: boolean;
  32518. /**
  32519. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32520. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32521. */
  32522. dumpNextRenderTargets: boolean;
  32523. /**
  32524. * The list of user defined render targets added to the scene
  32525. */
  32526. customRenderTargets: RenderTargetTexture[];
  32527. /**
  32528. * Defines if texture loading must be delayed
  32529. * If true, textures will only be loaded when they need to be rendered
  32530. */
  32531. useDelayedTextureLoading: boolean;
  32532. /**
  32533. * Gets the list of meshes imported to the scene through SceneLoader
  32534. */
  32535. importedMeshesFiles: String[];
  32536. /**
  32537. * Gets or sets a boolean indicating if probes are enabled on this scene
  32538. */
  32539. probesEnabled: boolean;
  32540. /**
  32541. * Gets or sets the current offline provider to use to store scene data
  32542. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32543. */
  32544. offlineProvider: IOfflineProvider;
  32545. /**
  32546. * Gets or sets the action manager associated with the scene
  32547. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32548. */
  32549. actionManager: AbstractActionManager;
  32550. private _meshesForIntersections;
  32551. /**
  32552. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32553. */
  32554. proceduralTexturesEnabled: boolean;
  32555. private _engine;
  32556. private _totalVertices;
  32557. /** @hidden */
  32558. _activeIndices: PerfCounter;
  32559. /** @hidden */
  32560. _activeParticles: PerfCounter;
  32561. /** @hidden */
  32562. _activeBones: PerfCounter;
  32563. private _animationRatio;
  32564. /** @hidden */
  32565. _animationTimeLast: number;
  32566. /** @hidden */
  32567. _animationTime: number;
  32568. /**
  32569. * Gets or sets a general scale for animation speed
  32570. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32571. */
  32572. animationTimeScale: number;
  32573. /** @hidden */
  32574. _cachedMaterial: Nullable<Material>;
  32575. /** @hidden */
  32576. _cachedEffect: Nullable<Effect>;
  32577. /** @hidden */
  32578. _cachedVisibility: Nullable<number>;
  32579. private _renderId;
  32580. private _frameId;
  32581. private _executeWhenReadyTimeoutId;
  32582. private _intermediateRendering;
  32583. private _viewUpdateFlag;
  32584. private _projectionUpdateFlag;
  32585. /** @hidden */
  32586. _toBeDisposed: Nullable<IDisposable>[];
  32587. private _activeRequests;
  32588. /** @hidden */
  32589. _pendingData: any[];
  32590. private _isDisposed;
  32591. /**
  32592. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32593. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32594. */
  32595. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32596. private _activeMeshes;
  32597. private _processedMaterials;
  32598. private _renderTargets;
  32599. /** @hidden */
  32600. _activeParticleSystems: SmartArray<IParticleSystem>;
  32601. private _activeSkeletons;
  32602. private _softwareSkinnedMeshes;
  32603. private _renderingManager;
  32604. /** @hidden */
  32605. _activeAnimatables: Animatable[];
  32606. private _transformMatrix;
  32607. private _sceneUbo;
  32608. /** @hidden */
  32609. _viewMatrix: Matrix;
  32610. private _projectionMatrix;
  32611. /** @hidden */
  32612. _forcedViewPosition: Nullable<Vector3>;
  32613. /** @hidden */
  32614. _frustumPlanes: Plane[];
  32615. /**
  32616. * Gets the list of frustum planes (built from the active camera)
  32617. */
  32618. readonly frustumPlanes: Plane[];
  32619. /**
  32620. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32621. * This is useful if there are more lights that the maximum simulteanous authorized
  32622. */
  32623. requireLightSorting: boolean;
  32624. /** @hidden */
  32625. readonly useMaterialMeshMap: boolean;
  32626. /** @hidden */
  32627. readonly useClonedMeshhMap: boolean;
  32628. private _externalData;
  32629. private _uid;
  32630. /**
  32631. * @hidden
  32632. * Backing store of defined scene components.
  32633. */
  32634. _components: ISceneComponent[];
  32635. /**
  32636. * @hidden
  32637. * Backing store of defined scene components.
  32638. */
  32639. _serializableComponents: ISceneSerializableComponent[];
  32640. /**
  32641. * List of components to register on the next registration step.
  32642. */
  32643. private _transientComponents;
  32644. /**
  32645. * Registers the transient components if needed.
  32646. */
  32647. private _registerTransientComponents;
  32648. /**
  32649. * @hidden
  32650. * Add a component to the scene.
  32651. * Note that the ccomponent could be registered on th next frame if this is called after
  32652. * the register component stage.
  32653. * @param component Defines the component to add to the scene
  32654. */
  32655. _addComponent(component: ISceneComponent): void;
  32656. /**
  32657. * @hidden
  32658. * Gets a component from the scene.
  32659. * @param name defines the name of the component to retrieve
  32660. * @returns the component or null if not present
  32661. */
  32662. _getComponent(name: string): Nullable<ISceneComponent>;
  32663. /**
  32664. * @hidden
  32665. * Defines the actions happening before camera updates.
  32666. */
  32667. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32668. /**
  32669. * @hidden
  32670. * Defines the actions happening before clear the canvas.
  32671. */
  32672. _beforeClearStage: Stage<SimpleStageAction>;
  32673. /**
  32674. * @hidden
  32675. * Defines the actions when collecting render targets for the frame.
  32676. */
  32677. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32678. /**
  32679. * @hidden
  32680. * Defines the actions happening for one camera in the frame.
  32681. */
  32682. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32683. /**
  32684. * @hidden
  32685. * Defines the actions happening during the per mesh ready checks.
  32686. */
  32687. _isReadyForMeshStage: Stage<MeshStageAction>;
  32688. /**
  32689. * @hidden
  32690. * Defines the actions happening before evaluate active mesh checks.
  32691. */
  32692. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32693. /**
  32694. * @hidden
  32695. * Defines the actions happening during the evaluate sub mesh checks.
  32696. */
  32697. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32698. /**
  32699. * @hidden
  32700. * Defines the actions happening during the active mesh stage.
  32701. */
  32702. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32703. /**
  32704. * @hidden
  32705. * Defines the actions happening during the per camera render target step.
  32706. */
  32707. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32708. /**
  32709. * @hidden
  32710. * Defines the actions happening just before the active camera is drawing.
  32711. */
  32712. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32713. /**
  32714. * @hidden
  32715. * Defines the actions happening just before a render target is drawing.
  32716. */
  32717. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32718. /**
  32719. * @hidden
  32720. * Defines the actions happening just before a rendering group is drawing.
  32721. */
  32722. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32723. /**
  32724. * @hidden
  32725. * Defines the actions happening just before a mesh is drawing.
  32726. */
  32727. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32728. /**
  32729. * @hidden
  32730. * Defines the actions happening just after a mesh has been drawn.
  32731. */
  32732. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32733. /**
  32734. * @hidden
  32735. * Defines the actions happening just after a rendering group has been drawn.
  32736. */
  32737. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32738. /**
  32739. * @hidden
  32740. * Defines the actions happening just after the active camera has been drawn.
  32741. */
  32742. _afterCameraDrawStage: Stage<CameraStageAction>;
  32743. /**
  32744. * @hidden
  32745. * Defines the actions happening just after a render target has been drawn.
  32746. */
  32747. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32748. /**
  32749. * @hidden
  32750. * Defines the actions happening just after rendering all cameras and computing intersections.
  32751. */
  32752. _afterRenderStage: Stage<SimpleStageAction>;
  32753. /**
  32754. * @hidden
  32755. * Defines the actions happening when a pointer move event happens.
  32756. */
  32757. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32758. /**
  32759. * @hidden
  32760. * Defines the actions happening when a pointer down event happens.
  32761. */
  32762. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32763. /**
  32764. * @hidden
  32765. * Defines the actions happening when a pointer up event happens.
  32766. */
  32767. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32768. /**
  32769. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32770. */
  32771. private geometriesByUniqueId;
  32772. /**
  32773. * Creates a new Scene
  32774. * @param engine defines the engine to use to render this scene
  32775. * @param options defines the scene options
  32776. */
  32777. constructor(engine: Engine, options?: SceneOptions);
  32778. /**
  32779. * Gets a string idenfifying the name of the class
  32780. * @returns "Scene" string
  32781. */
  32782. getClassName(): string;
  32783. private _defaultMeshCandidates;
  32784. /**
  32785. * @hidden
  32786. */
  32787. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32788. private _defaultSubMeshCandidates;
  32789. /**
  32790. * @hidden
  32791. */
  32792. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32793. /**
  32794. * Sets the default candidate providers for the scene.
  32795. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32796. * and getCollidingSubMeshCandidates to their default function
  32797. */
  32798. setDefaultCandidateProviders(): void;
  32799. /**
  32800. * Gets the mesh that is currently under the pointer
  32801. */
  32802. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32803. /**
  32804. * Gets or sets the current on-screen X position of the pointer
  32805. */
  32806. pointerX: number;
  32807. /**
  32808. * Gets or sets the current on-screen Y position of the pointer
  32809. */
  32810. pointerY: number;
  32811. /**
  32812. * Gets the cached material (ie. the latest rendered one)
  32813. * @returns the cached material
  32814. */
  32815. getCachedMaterial(): Nullable<Material>;
  32816. /**
  32817. * Gets the cached effect (ie. the latest rendered one)
  32818. * @returns the cached effect
  32819. */
  32820. getCachedEffect(): Nullable<Effect>;
  32821. /**
  32822. * Gets the cached visibility state (ie. the latest rendered one)
  32823. * @returns the cached visibility state
  32824. */
  32825. getCachedVisibility(): Nullable<number>;
  32826. /**
  32827. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32828. * @param material defines the current material
  32829. * @param effect defines the current effect
  32830. * @param visibility defines the current visibility state
  32831. * @returns true if one parameter is not cached
  32832. */
  32833. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32834. /**
  32835. * Gets the engine associated with the scene
  32836. * @returns an Engine
  32837. */
  32838. getEngine(): Engine;
  32839. /**
  32840. * Gets the total number of vertices rendered per frame
  32841. * @returns the total number of vertices rendered per frame
  32842. */
  32843. getTotalVertices(): number;
  32844. /**
  32845. * Gets the performance counter for total vertices
  32846. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32847. */
  32848. readonly totalVerticesPerfCounter: PerfCounter;
  32849. /**
  32850. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32851. * @returns the total number of active indices rendered per frame
  32852. */
  32853. getActiveIndices(): number;
  32854. /**
  32855. * Gets the performance counter for active indices
  32856. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32857. */
  32858. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32859. /**
  32860. * Gets the total number of active particles rendered per frame
  32861. * @returns the total number of active particles rendered per frame
  32862. */
  32863. getActiveParticles(): number;
  32864. /**
  32865. * Gets the performance counter for active particles
  32866. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32867. */
  32868. readonly activeParticlesPerfCounter: PerfCounter;
  32869. /**
  32870. * Gets the total number of active bones rendered per frame
  32871. * @returns the total number of active bones rendered per frame
  32872. */
  32873. getActiveBones(): number;
  32874. /**
  32875. * Gets the performance counter for active bones
  32876. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32877. */
  32878. readonly activeBonesPerfCounter: PerfCounter;
  32879. /**
  32880. * Gets the array of active meshes
  32881. * @returns an array of AbstractMesh
  32882. */
  32883. getActiveMeshes(): SmartArray<AbstractMesh>;
  32884. /**
  32885. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32886. * @returns a number
  32887. */
  32888. getAnimationRatio(): number;
  32889. /**
  32890. * Gets an unique Id for the current render phase
  32891. * @returns a number
  32892. */
  32893. getRenderId(): number;
  32894. /**
  32895. * Gets an unique Id for the current frame
  32896. * @returns a number
  32897. */
  32898. getFrameId(): number;
  32899. /** Call this function if you want to manually increment the render Id*/
  32900. incrementRenderId(): void;
  32901. private _createUbo;
  32902. /**
  32903. * Use this method to simulate a pointer move on a mesh
  32904. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32905. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32906. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32907. * @returns the current scene
  32908. */
  32909. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32910. /**
  32911. * Use this method to simulate a pointer down on a mesh
  32912. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32913. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32914. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32915. * @returns the current scene
  32916. */
  32917. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32918. /**
  32919. * Use this method to simulate a pointer up on a mesh
  32920. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32921. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32922. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32923. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32924. * @returns the current scene
  32925. */
  32926. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32927. /**
  32928. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32929. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32930. * @returns true if the pointer was captured
  32931. */
  32932. isPointerCaptured(pointerId?: number): boolean;
  32933. /**
  32934. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32935. * @param attachUp defines if you want to attach events to pointerup
  32936. * @param attachDown defines if you want to attach events to pointerdown
  32937. * @param attachMove defines if you want to attach events to pointermove
  32938. */
  32939. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32940. /** Detaches all event handlers*/
  32941. detachControl(): void;
  32942. /**
  32943. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32944. * Delay loaded resources are not taking in account
  32945. * @return true if all required resources are ready
  32946. */
  32947. isReady(): boolean;
  32948. /** Resets all cached information relative to material (including effect and visibility) */
  32949. resetCachedMaterial(): void;
  32950. /**
  32951. * Registers a function to be called before every frame render
  32952. * @param func defines the function to register
  32953. */
  32954. registerBeforeRender(func: () => void): void;
  32955. /**
  32956. * Unregisters a function called before every frame render
  32957. * @param func defines the function to unregister
  32958. */
  32959. unregisterBeforeRender(func: () => void): void;
  32960. /**
  32961. * Registers a function to be called after every frame render
  32962. * @param func defines the function to register
  32963. */
  32964. registerAfterRender(func: () => void): void;
  32965. /**
  32966. * Unregisters a function called after every frame render
  32967. * @param func defines the function to unregister
  32968. */
  32969. unregisterAfterRender(func: () => void): void;
  32970. private _executeOnceBeforeRender;
  32971. /**
  32972. * The provided function will run before render once and will be disposed afterwards.
  32973. * A timeout delay can be provided so that the function will be executed in N ms.
  32974. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32975. * @param func The function to be executed.
  32976. * @param timeout optional delay in ms
  32977. */
  32978. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32979. /** @hidden */
  32980. _addPendingData(data: any): void;
  32981. /** @hidden */
  32982. _removePendingData(data: any): void;
  32983. /**
  32984. * Returns the number of items waiting to be loaded
  32985. * @returns the number of items waiting to be loaded
  32986. */
  32987. getWaitingItemsCount(): number;
  32988. /**
  32989. * Returns a boolean indicating if the scene is still loading data
  32990. */
  32991. readonly isLoading: boolean;
  32992. /**
  32993. * Registers a function to be executed when the scene is ready
  32994. * @param {Function} func - the function to be executed
  32995. */
  32996. executeWhenReady(func: () => void): void;
  32997. /**
  32998. * Returns a promise that resolves when the scene is ready
  32999. * @returns A promise that resolves when the scene is ready
  33000. */
  33001. whenReadyAsync(): Promise<void>;
  33002. /** @hidden */
  33003. _checkIsReady(): void;
  33004. /**
  33005. * Gets all animatable attached to the scene
  33006. */
  33007. readonly animatables: Animatable[];
  33008. /**
  33009. * Resets the last animation time frame.
  33010. * Useful to override when animations start running when loading a scene for the first time.
  33011. */
  33012. resetLastAnimationTimeFrame(): void;
  33013. /**
  33014. * Gets the current view matrix
  33015. * @returns a Matrix
  33016. */
  33017. getViewMatrix(): Matrix;
  33018. /**
  33019. * Gets the current projection matrix
  33020. * @returns a Matrix
  33021. */
  33022. getProjectionMatrix(): Matrix;
  33023. /**
  33024. * Gets the current transform matrix
  33025. * @returns a Matrix made of View * Projection
  33026. */
  33027. getTransformMatrix(): Matrix;
  33028. /**
  33029. * Sets the current transform matrix
  33030. * @param viewL defines the View matrix to use
  33031. * @param projectionL defines the Projection matrix to use
  33032. * @param viewR defines the right View matrix to use (if provided)
  33033. * @param projectionR defines the right Projection matrix to use (if provided)
  33034. */
  33035. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33036. /**
  33037. * Gets the uniform buffer used to store scene data
  33038. * @returns a UniformBuffer
  33039. */
  33040. getSceneUniformBuffer(): UniformBuffer;
  33041. /**
  33042. * Gets an unique (relatively to the current scene) Id
  33043. * @returns an unique number for the scene
  33044. */
  33045. getUniqueId(): number;
  33046. /**
  33047. * Add a mesh to the list of scene's meshes
  33048. * @param newMesh defines the mesh to add
  33049. * @param recursive if all child meshes should also be added to the scene
  33050. */
  33051. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33052. /**
  33053. * Remove a mesh for the list of scene's meshes
  33054. * @param toRemove defines the mesh to remove
  33055. * @param recursive if all child meshes should also be removed from the scene
  33056. * @returns the index where the mesh was in the mesh list
  33057. */
  33058. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33059. /**
  33060. * Add a transform node to the list of scene's transform nodes
  33061. * @param newTransformNode defines the transform node to add
  33062. */
  33063. addTransformNode(newTransformNode: TransformNode): void;
  33064. /**
  33065. * Remove a transform node for the list of scene's transform nodes
  33066. * @param toRemove defines the transform node to remove
  33067. * @returns the index where the transform node was in the transform node list
  33068. */
  33069. removeTransformNode(toRemove: TransformNode): number;
  33070. /**
  33071. * Remove a skeleton for the list of scene's skeletons
  33072. * @param toRemove defines the skeleton to remove
  33073. * @returns the index where the skeleton was in the skeleton list
  33074. */
  33075. removeSkeleton(toRemove: Skeleton): number;
  33076. /**
  33077. * Remove a morph target for the list of scene's morph targets
  33078. * @param toRemove defines the morph target to remove
  33079. * @returns the index where the morph target was in the morph target list
  33080. */
  33081. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33082. /**
  33083. * Remove a light for the list of scene's lights
  33084. * @param toRemove defines the light to remove
  33085. * @returns the index where the light was in the light list
  33086. */
  33087. removeLight(toRemove: Light): number;
  33088. /**
  33089. * Remove a camera for the list of scene's cameras
  33090. * @param toRemove defines the camera to remove
  33091. * @returns the index where the camera was in the camera list
  33092. */
  33093. removeCamera(toRemove: Camera): number;
  33094. /**
  33095. * Remove a particle system for the list of scene's particle systems
  33096. * @param toRemove defines the particle system to remove
  33097. * @returns the index where the particle system was in the particle system list
  33098. */
  33099. removeParticleSystem(toRemove: IParticleSystem): number;
  33100. /**
  33101. * Remove a animation for the list of scene's animations
  33102. * @param toRemove defines the animation to remove
  33103. * @returns the index where the animation was in the animation list
  33104. */
  33105. removeAnimation(toRemove: Animation): number;
  33106. /**
  33107. * Will stop the animation of the given target
  33108. * @param target - the target
  33109. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33110. * @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)
  33111. */
  33112. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33113. /**
  33114. * Removes the given animation group from this scene.
  33115. * @param toRemove The animation group to remove
  33116. * @returns The index of the removed animation group
  33117. */
  33118. removeAnimationGroup(toRemove: AnimationGroup): number;
  33119. /**
  33120. * Removes the given multi-material from this scene.
  33121. * @param toRemove The multi-material to remove
  33122. * @returns The index of the removed multi-material
  33123. */
  33124. removeMultiMaterial(toRemove: MultiMaterial): number;
  33125. /**
  33126. * Removes the given material from this scene.
  33127. * @param toRemove The material to remove
  33128. * @returns The index of the removed material
  33129. */
  33130. removeMaterial(toRemove: Material): number;
  33131. /**
  33132. * Removes the given action manager from this scene.
  33133. * @param toRemove The action manager to remove
  33134. * @returns The index of the removed action manager
  33135. */
  33136. removeActionManager(toRemove: AbstractActionManager): number;
  33137. /**
  33138. * Removes the given texture from this scene.
  33139. * @param toRemove The texture to remove
  33140. * @returns The index of the removed texture
  33141. */
  33142. removeTexture(toRemove: BaseTexture): number;
  33143. /**
  33144. * Adds the given light to this scene
  33145. * @param newLight The light to add
  33146. */
  33147. addLight(newLight: Light): void;
  33148. /**
  33149. * Sorts the list list based on light priorities
  33150. */
  33151. sortLightsByPriority(): void;
  33152. /**
  33153. * Adds the given camera to this scene
  33154. * @param newCamera The camera to add
  33155. */
  33156. addCamera(newCamera: Camera): void;
  33157. /**
  33158. * Adds the given skeleton to this scene
  33159. * @param newSkeleton The skeleton to add
  33160. */
  33161. addSkeleton(newSkeleton: Skeleton): void;
  33162. /**
  33163. * Adds the given particle system to this scene
  33164. * @param newParticleSystem The particle system to add
  33165. */
  33166. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33167. /**
  33168. * Adds the given animation to this scene
  33169. * @param newAnimation The animation to add
  33170. */
  33171. addAnimation(newAnimation: Animation): void;
  33172. /**
  33173. * Adds the given animation group to this scene.
  33174. * @param newAnimationGroup The animation group to add
  33175. */
  33176. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33177. /**
  33178. * Adds the given multi-material to this scene
  33179. * @param newMultiMaterial The multi-material to add
  33180. */
  33181. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33182. /**
  33183. * Adds the given material to this scene
  33184. * @param newMaterial The material to add
  33185. */
  33186. addMaterial(newMaterial: Material): void;
  33187. /**
  33188. * Adds the given morph target to this scene
  33189. * @param newMorphTargetManager The morph target to add
  33190. */
  33191. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33192. /**
  33193. * Adds the given geometry to this scene
  33194. * @param newGeometry The geometry to add
  33195. */
  33196. addGeometry(newGeometry: Geometry): void;
  33197. /**
  33198. * Adds the given action manager to this scene
  33199. * @param newActionManager The action manager to add
  33200. */
  33201. addActionManager(newActionManager: AbstractActionManager): void;
  33202. /**
  33203. * Adds the given texture to this scene.
  33204. * @param newTexture The texture to add
  33205. */
  33206. addTexture(newTexture: BaseTexture): void;
  33207. /**
  33208. * Switch active camera
  33209. * @param newCamera defines the new active camera
  33210. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33211. */
  33212. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33213. /**
  33214. * sets the active camera of the scene using its ID
  33215. * @param id defines the camera's ID
  33216. * @return the new active camera or null if none found.
  33217. */
  33218. setActiveCameraByID(id: string): Nullable<Camera>;
  33219. /**
  33220. * sets the active camera of the scene using its name
  33221. * @param name defines the camera's name
  33222. * @returns the new active camera or null if none found.
  33223. */
  33224. setActiveCameraByName(name: string): Nullable<Camera>;
  33225. /**
  33226. * get an animation group using its name
  33227. * @param name defines the material's name
  33228. * @return the animation group or null if none found.
  33229. */
  33230. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33231. /**
  33232. * Get a material using its unique id
  33233. * @param uniqueId defines the material's unique id
  33234. * @return the material or null if none found.
  33235. */
  33236. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33237. /**
  33238. * get a material using its id
  33239. * @param id defines the material's ID
  33240. * @return the material or null if none found.
  33241. */
  33242. getMaterialByID(id: string): Nullable<Material>;
  33243. /**
  33244. * Gets a material using its name
  33245. * @param name defines the material's name
  33246. * @return the material or null if none found.
  33247. */
  33248. getMaterialByName(name: string): Nullable<Material>;
  33249. /**
  33250. * Gets a camera using its id
  33251. * @param id defines the id to look for
  33252. * @returns the camera or null if not found
  33253. */
  33254. getCameraByID(id: string): Nullable<Camera>;
  33255. /**
  33256. * Gets a camera using its unique id
  33257. * @param uniqueId defines the unique id to look for
  33258. * @returns the camera or null if not found
  33259. */
  33260. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33261. /**
  33262. * Gets a camera using its name
  33263. * @param name defines the camera's name
  33264. * @return the camera or null if none found.
  33265. */
  33266. getCameraByName(name: string): Nullable<Camera>;
  33267. /**
  33268. * Gets a bone using its id
  33269. * @param id defines the bone's id
  33270. * @return the bone or null if not found
  33271. */
  33272. getBoneByID(id: string): Nullable<Bone>;
  33273. /**
  33274. * Gets a bone using its id
  33275. * @param name defines the bone's name
  33276. * @return the bone or null if not found
  33277. */
  33278. getBoneByName(name: string): Nullable<Bone>;
  33279. /**
  33280. * Gets a light node using its name
  33281. * @param name defines the the light's name
  33282. * @return the light or null if none found.
  33283. */
  33284. getLightByName(name: string): Nullable<Light>;
  33285. /**
  33286. * Gets a light node using its id
  33287. * @param id defines the light's id
  33288. * @return the light or null if none found.
  33289. */
  33290. getLightByID(id: string): Nullable<Light>;
  33291. /**
  33292. * Gets a light node using its scene-generated unique ID
  33293. * @param uniqueId defines the light's unique id
  33294. * @return the light or null if none found.
  33295. */
  33296. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33297. /**
  33298. * Gets a particle system by id
  33299. * @param id defines the particle system id
  33300. * @return the corresponding system or null if none found
  33301. */
  33302. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33303. /**
  33304. * Gets a geometry using its ID
  33305. * @param id defines the geometry's id
  33306. * @return the geometry or null if none found.
  33307. */
  33308. getGeometryByID(id: string): Nullable<Geometry>;
  33309. private _getGeometryByUniqueID;
  33310. /**
  33311. * Add a new geometry to this scene
  33312. * @param geometry defines the geometry to be added to the scene.
  33313. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33314. * @return a boolean defining if the geometry was added or not
  33315. */
  33316. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33317. /**
  33318. * Removes an existing geometry
  33319. * @param geometry defines the geometry to be removed from the scene
  33320. * @return a boolean defining if the geometry was removed or not
  33321. */
  33322. removeGeometry(geometry: Geometry): boolean;
  33323. /**
  33324. * Gets the list of geometries attached to the scene
  33325. * @returns an array of Geometry
  33326. */
  33327. getGeometries(): Geometry[];
  33328. /**
  33329. * Gets the first added mesh found of a given ID
  33330. * @param id defines the id to search for
  33331. * @return the mesh found or null if not found at all
  33332. */
  33333. getMeshByID(id: string): Nullable<AbstractMesh>;
  33334. /**
  33335. * Gets a list of meshes using their id
  33336. * @param id defines the id to search for
  33337. * @returns a list of meshes
  33338. */
  33339. getMeshesByID(id: string): Array<AbstractMesh>;
  33340. /**
  33341. * Gets the first added transform node found of a given ID
  33342. * @param id defines the id to search for
  33343. * @return the found transform node or null if not found at all.
  33344. */
  33345. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33346. /**
  33347. * Gets a transform node with its auto-generated unique id
  33348. * @param uniqueId efines the unique id to search for
  33349. * @return the found transform node or null if not found at all.
  33350. */
  33351. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33352. /**
  33353. * Gets a list of transform nodes using their id
  33354. * @param id defines the id to search for
  33355. * @returns a list of transform nodes
  33356. */
  33357. getTransformNodesByID(id: string): Array<TransformNode>;
  33358. /**
  33359. * Gets a mesh with its auto-generated unique id
  33360. * @param uniqueId defines the unique id to search for
  33361. * @return the found mesh or null if not found at all.
  33362. */
  33363. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33364. /**
  33365. * Gets a the last added mesh using a given id
  33366. * @param id defines the id to search for
  33367. * @return the found mesh or null if not found at all.
  33368. */
  33369. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33370. /**
  33371. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33372. * @param id defines the id to search for
  33373. * @return the found node or null if not found at all
  33374. */
  33375. getLastEntryByID(id: string): Nullable<Node>;
  33376. /**
  33377. * Gets a node (Mesh, Camera, Light) using a given id
  33378. * @param id defines the id to search for
  33379. * @return the found node or null if not found at all
  33380. */
  33381. getNodeByID(id: string): Nullable<Node>;
  33382. /**
  33383. * Gets a node (Mesh, Camera, Light) using a given name
  33384. * @param name defines the name to search for
  33385. * @return the found node or null if not found at all.
  33386. */
  33387. getNodeByName(name: string): Nullable<Node>;
  33388. /**
  33389. * Gets a mesh using a given name
  33390. * @param name defines the name to search for
  33391. * @return the found mesh or null if not found at all.
  33392. */
  33393. getMeshByName(name: string): Nullable<AbstractMesh>;
  33394. /**
  33395. * Gets a transform node using a given name
  33396. * @param name defines the name to search for
  33397. * @return the found transform node or null if not found at all.
  33398. */
  33399. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33400. /**
  33401. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33402. * @param id defines the id to search for
  33403. * @return the found skeleton or null if not found at all.
  33404. */
  33405. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33406. /**
  33407. * Gets a skeleton using a given auto generated unique id
  33408. * @param uniqueId defines the unique id to search for
  33409. * @return the found skeleton or null if not found at all.
  33410. */
  33411. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33412. /**
  33413. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33414. * @param id defines the id to search for
  33415. * @return the found skeleton or null if not found at all.
  33416. */
  33417. getSkeletonById(id: string): Nullable<Skeleton>;
  33418. /**
  33419. * Gets a skeleton using a given name
  33420. * @param name defines the name to search for
  33421. * @return the found skeleton or null if not found at all.
  33422. */
  33423. getSkeletonByName(name: string): Nullable<Skeleton>;
  33424. /**
  33425. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33426. * @param id defines the id to search for
  33427. * @return the found morph target manager or null if not found at all.
  33428. */
  33429. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33430. /**
  33431. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33432. * @param id defines the id to search for
  33433. * @return the found morph target or null if not found at all.
  33434. */
  33435. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33436. /**
  33437. * Gets a boolean indicating if the given mesh is active
  33438. * @param mesh defines the mesh to look for
  33439. * @returns true if the mesh is in the active list
  33440. */
  33441. isActiveMesh(mesh: AbstractMesh): boolean;
  33442. /**
  33443. * Return a unique id as a string which can serve as an identifier for the scene
  33444. */
  33445. readonly uid: string;
  33446. /**
  33447. * Add an externaly attached data from its key.
  33448. * This method call will fail and return false, if such key already exists.
  33449. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33450. * @param key the unique key that identifies the data
  33451. * @param data the data object to associate to the key for this Engine instance
  33452. * @return true if no such key were already present and the data was added successfully, false otherwise
  33453. */
  33454. addExternalData<T>(key: string, data: T): boolean;
  33455. /**
  33456. * Get an externaly attached data from its key
  33457. * @param key the unique key that identifies the data
  33458. * @return the associated data, if present (can be null), or undefined if not present
  33459. */
  33460. getExternalData<T>(key: string): Nullable<T>;
  33461. /**
  33462. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33463. * @param key the unique key that identifies the data
  33464. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33465. * @return the associated data, can be null if the factory returned null.
  33466. */
  33467. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33468. /**
  33469. * Remove an externaly attached data from the Engine instance
  33470. * @param key the unique key that identifies the data
  33471. * @return true if the data was successfully removed, false if it doesn't exist
  33472. */
  33473. removeExternalData(key: string): boolean;
  33474. private _evaluateSubMesh;
  33475. /**
  33476. * Clear the processed materials smart array preventing retention point in material dispose.
  33477. */
  33478. freeProcessedMaterials(): void;
  33479. private _preventFreeActiveMeshesAndRenderingGroups;
  33480. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33481. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33482. * when disposing several meshes in a row or a hierarchy of meshes.
  33483. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33484. */
  33485. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33486. /**
  33487. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33488. */
  33489. freeActiveMeshes(): void;
  33490. /**
  33491. * Clear the info related to rendering groups preventing retention points during dispose.
  33492. */
  33493. freeRenderingGroups(): void;
  33494. /** @hidden */
  33495. _isInIntermediateRendering(): boolean;
  33496. /**
  33497. * Lambda returning the list of potentially active meshes.
  33498. */
  33499. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33500. /**
  33501. * Lambda returning the list of potentially active sub meshes.
  33502. */
  33503. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33504. /**
  33505. * Lambda returning the list of potentially intersecting sub meshes.
  33506. */
  33507. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33508. /**
  33509. * Lambda returning the list of potentially colliding sub meshes.
  33510. */
  33511. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33512. private _activeMeshesFrozen;
  33513. /**
  33514. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33515. * @returns the current scene
  33516. */
  33517. freezeActiveMeshes(): Scene;
  33518. /**
  33519. * Use this function to restart evaluating active meshes on every frame
  33520. * @returns the current scene
  33521. */
  33522. unfreezeActiveMeshes(): Scene;
  33523. private _evaluateActiveMeshes;
  33524. private _activeMesh;
  33525. /**
  33526. * Update the transform matrix to update from the current active camera
  33527. * @param force defines a boolean used to force the update even if cache is up to date
  33528. */
  33529. updateTransformMatrix(force?: boolean): void;
  33530. private _bindFrameBuffer;
  33531. /** @hidden */
  33532. _allowPostProcessClearColor: boolean;
  33533. /** @hidden */
  33534. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33535. private _processSubCameras;
  33536. private _checkIntersections;
  33537. /** @hidden */
  33538. _advancePhysicsEngineStep(step: number): void;
  33539. /**
  33540. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33541. */
  33542. getDeterministicFrameTime: () => number;
  33543. /** @hidden */
  33544. _animate(): void;
  33545. /** Execute all animations (for a frame) */
  33546. animate(): void;
  33547. /**
  33548. * Render the scene
  33549. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33550. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33551. */
  33552. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33553. /**
  33554. * Freeze all materials
  33555. * A frozen material will not be updatable but should be faster to render
  33556. */
  33557. freezeMaterials(): void;
  33558. /**
  33559. * Unfreeze all materials
  33560. * A frozen material will not be updatable but should be faster to render
  33561. */
  33562. unfreezeMaterials(): void;
  33563. /**
  33564. * Releases all held ressources
  33565. */
  33566. dispose(): void;
  33567. /**
  33568. * Gets if the scene is already disposed
  33569. */
  33570. readonly isDisposed: boolean;
  33571. /**
  33572. * Call this function to reduce memory footprint of the scene.
  33573. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33574. */
  33575. clearCachedVertexData(): void;
  33576. /**
  33577. * This function will remove the local cached buffer data from texture.
  33578. * It will save memory but will prevent the texture from being rebuilt
  33579. */
  33580. cleanCachedTextureBuffer(): void;
  33581. /**
  33582. * Get the world extend vectors with an optional filter
  33583. *
  33584. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33585. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33586. */
  33587. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33588. min: Vector3;
  33589. max: Vector3;
  33590. };
  33591. /**
  33592. * Creates a ray that can be used to pick in the scene
  33593. * @param x defines the x coordinate of the origin (on-screen)
  33594. * @param y defines the y coordinate of the origin (on-screen)
  33595. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33596. * @param camera defines the camera to use for the picking
  33597. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33598. * @returns a Ray
  33599. */
  33600. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33601. /**
  33602. * Creates a ray that can be used to pick in the scene
  33603. * @param x defines the x coordinate of the origin (on-screen)
  33604. * @param y defines the y coordinate of the origin (on-screen)
  33605. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33606. * @param result defines the ray where to store the picking ray
  33607. * @param camera defines the camera to use for the picking
  33608. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33609. * @returns the current scene
  33610. */
  33611. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33612. /**
  33613. * Creates a ray that can be used to pick in the scene
  33614. * @param x defines the x coordinate of the origin (on-screen)
  33615. * @param y defines the y coordinate of the origin (on-screen)
  33616. * @param camera defines the camera to use for the picking
  33617. * @returns a Ray
  33618. */
  33619. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33620. /**
  33621. * Creates a ray that can be used to pick in the scene
  33622. * @param x defines the x coordinate of the origin (on-screen)
  33623. * @param y defines the y coordinate of the origin (on-screen)
  33624. * @param result defines the ray where to store the picking ray
  33625. * @param camera defines the camera to use for the picking
  33626. * @returns the current scene
  33627. */
  33628. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33629. /** Launch a ray to try to pick a mesh in the scene
  33630. * @param x position on screen
  33631. * @param y position on screen
  33632. * @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
  33633. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33634. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33635. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33636. * @returns a PickingInfo
  33637. */
  33638. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33639. /** Use the given ray to pick a mesh in the scene
  33640. * @param ray The ray to use to pick meshes
  33641. * @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
  33642. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33643. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33644. * @returns a PickingInfo
  33645. */
  33646. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33647. /**
  33648. * Launch a ray to try to pick a mesh in the scene
  33649. * @param x X position on screen
  33650. * @param y Y position on screen
  33651. * @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
  33652. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33653. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33654. * @returns an array of PickingInfo
  33655. */
  33656. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33657. /**
  33658. * Launch a ray to try to pick a mesh in the scene
  33659. * @param ray Ray to use
  33660. * @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
  33661. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33662. * @returns an array of PickingInfo
  33663. */
  33664. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33665. /**
  33666. * Force the value of meshUnderPointer
  33667. * @param mesh defines the mesh to use
  33668. */
  33669. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33670. /**
  33671. * Gets the mesh under the pointer
  33672. * @returns a Mesh or null if no mesh is under the pointer
  33673. */
  33674. getPointerOverMesh(): Nullable<AbstractMesh>;
  33675. /** @hidden */
  33676. _rebuildGeometries(): void;
  33677. /** @hidden */
  33678. _rebuildTextures(): void;
  33679. private _getByTags;
  33680. /**
  33681. * Get a list of meshes by tags
  33682. * @param tagsQuery defines the tags query to use
  33683. * @param forEach defines a predicate used to filter results
  33684. * @returns an array of Mesh
  33685. */
  33686. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33687. /**
  33688. * Get a list of cameras by tags
  33689. * @param tagsQuery defines the tags query to use
  33690. * @param forEach defines a predicate used to filter results
  33691. * @returns an array of Camera
  33692. */
  33693. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33694. /**
  33695. * Get a list of lights by tags
  33696. * @param tagsQuery defines the tags query to use
  33697. * @param forEach defines a predicate used to filter results
  33698. * @returns an array of Light
  33699. */
  33700. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33701. /**
  33702. * Get a list of materials by tags
  33703. * @param tagsQuery defines the tags query to use
  33704. * @param forEach defines a predicate used to filter results
  33705. * @returns an array of Material
  33706. */
  33707. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33708. /**
  33709. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33710. * This allowed control for front to back rendering or reversly depending of the special needs.
  33711. *
  33712. * @param renderingGroupId The rendering group id corresponding to its index
  33713. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33714. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33715. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33716. */
  33717. 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;
  33718. /**
  33719. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33720. *
  33721. * @param renderingGroupId The rendering group id corresponding to its index
  33722. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33723. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33724. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33725. */
  33726. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33727. /**
  33728. * Gets the current auto clear configuration for one rendering group of the rendering
  33729. * manager.
  33730. * @param index the rendering group index to get the information for
  33731. * @returns The auto clear setup for the requested rendering group
  33732. */
  33733. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33734. private _blockMaterialDirtyMechanism;
  33735. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33736. blockMaterialDirtyMechanism: boolean;
  33737. /**
  33738. * Will flag all materials as dirty to trigger new shader compilation
  33739. * @param flag defines the flag used to specify which material part must be marked as dirty
  33740. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33741. */
  33742. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33743. /** @hidden */
  33744. _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;
  33745. /** @hidden */
  33746. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33747. }
  33748. }
  33749. declare module BABYLON {
  33750. /**
  33751. * Set of assets to keep when moving a scene into an asset container.
  33752. */
  33753. export class KeepAssets extends AbstractScene {
  33754. }
  33755. /**
  33756. * Container with a set of assets that can be added or removed from a scene.
  33757. */
  33758. export class AssetContainer extends AbstractScene {
  33759. /**
  33760. * The scene the AssetContainer belongs to.
  33761. */
  33762. scene: Scene;
  33763. /**
  33764. * Instantiates an AssetContainer.
  33765. * @param scene The scene the AssetContainer belongs to.
  33766. */
  33767. constructor(scene: Scene);
  33768. /**
  33769. * Adds all the assets from the container to the scene.
  33770. */
  33771. addAllToScene(): void;
  33772. /**
  33773. * Removes all the assets in the container from the scene
  33774. */
  33775. removeAllFromScene(): void;
  33776. /**
  33777. * Disposes all the assets in the container
  33778. */
  33779. dispose(): void;
  33780. private _moveAssets;
  33781. /**
  33782. * Removes all the assets contained in the scene and adds them to the container.
  33783. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33784. */
  33785. moveAllFromScene(keepAssets?: KeepAssets): void;
  33786. /**
  33787. * 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.
  33788. * @returns the root mesh
  33789. */
  33790. createRootMesh(): Mesh;
  33791. }
  33792. }
  33793. declare module BABYLON {
  33794. /**
  33795. * Defines how the parser contract is defined.
  33796. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33797. */
  33798. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33799. /**
  33800. * Defines how the individual parser contract is defined.
  33801. * These parser can parse an individual asset
  33802. */
  33803. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33804. /**
  33805. * Base class of the scene acting as a container for the different elements composing a scene.
  33806. * This class is dynamically extended by the different components of the scene increasing
  33807. * flexibility and reducing coupling
  33808. */
  33809. export abstract class AbstractScene {
  33810. /**
  33811. * Stores the list of available parsers in the application.
  33812. */
  33813. private static _BabylonFileParsers;
  33814. /**
  33815. * Stores the list of available individual parsers in the application.
  33816. */
  33817. private static _IndividualBabylonFileParsers;
  33818. /**
  33819. * Adds a parser in the list of available ones
  33820. * @param name Defines the name of the parser
  33821. * @param parser Defines the parser to add
  33822. */
  33823. static AddParser(name: string, parser: BabylonFileParser): void;
  33824. /**
  33825. * Gets a general parser from the list of avaialble ones
  33826. * @param name Defines the name of the parser
  33827. * @returns the requested parser or null
  33828. */
  33829. static GetParser(name: string): Nullable<BabylonFileParser>;
  33830. /**
  33831. * Adds n individual parser in the list of available ones
  33832. * @param name Defines the name of the parser
  33833. * @param parser Defines the parser to add
  33834. */
  33835. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33836. /**
  33837. * Gets an individual parser from the list of avaialble ones
  33838. * @param name Defines the name of the parser
  33839. * @returns the requested parser or null
  33840. */
  33841. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33842. /**
  33843. * Parser json data and populate both a scene and its associated container object
  33844. * @param jsonData Defines the data to parse
  33845. * @param scene Defines the scene to parse the data for
  33846. * @param container Defines the container attached to the parsing sequence
  33847. * @param rootUrl Defines the root url of the data
  33848. */
  33849. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33850. /**
  33851. * Gets the list of root nodes (ie. nodes with no parent)
  33852. */
  33853. rootNodes: Node[];
  33854. /** All of the cameras added to this scene
  33855. * @see http://doc.babylonjs.com/babylon101/cameras
  33856. */
  33857. cameras: Camera[];
  33858. /**
  33859. * All of the lights added to this scene
  33860. * @see http://doc.babylonjs.com/babylon101/lights
  33861. */
  33862. lights: Light[];
  33863. /**
  33864. * All of the (abstract) meshes added to this scene
  33865. */
  33866. meshes: AbstractMesh[];
  33867. /**
  33868. * The list of skeletons added to the scene
  33869. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33870. */
  33871. skeletons: Skeleton[];
  33872. /**
  33873. * All of the particle systems added to this scene
  33874. * @see http://doc.babylonjs.com/babylon101/particles
  33875. */
  33876. particleSystems: IParticleSystem[];
  33877. /**
  33878. * Gets a list of Animations associated with the scene
  33879. */
  33880. animations: Animation[];
  33881. /**
  33882. * All of the animation groups added to this scene
  33883. * @see http://doc.babylonjs.com/how_to/group
  33884. */
  33885. animationGroups: AnimationGroup[];
  33886. /**
  33887. * All of the multi-materials added to this scene
  33888. * @see http://doc.babylonjs.com/how_to/multi_materials
  33889. */
  33890. multiMaterials: MultiMaterial[];
  33891. /**
  33892. * All of the materials added to this scene
  33893. * In the context of a Scene, it is not supposed to be modified manually.
  33894. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33895. * Note also that the order of the Material wihin the array is not significant and might change.
  33896. * @see http://doc.babylonjs.com/babylon101/materials
  33897. */
  33898. materials: Material[];
  33899. /**
  33900. * The list of morph target managers added to the scene
  33901. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33902. */
  33903. morphTargetManagers: MorphTargetManager[];
  33904. /**
  33905. * The list of geometries used in the scene.
  33906. */
  33907. geometries: Geometry[];
  33908. /**
  33909. * All of the tranform nodes added to this scene
  33910. * In the context of a Scene, it is not supposed to be modified manually.
  33911. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33912. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33913. * @see http://doc.babylonjs.com/how_to/transformnode
  33914. */
  33915. transformNodes: TransformNode[];
  33916. /**
  33917. * ActionManagers available on the scene.
  33918. */
  33919. actionManagers: AbstractActionManager[];
  33920. /**
  33921. * Textures to keep.
  33922. */
  33923. textures: BaseTexture[];
  33924. /**
  33925. * Environment texture for the scene
  33926. */
  33927. environmentTexture: Nullable<BaseTexture>;
  33928. }
  33929. }
  33930. declare module BABYLON {
  33931. /**
  33932. * Defines a sound that can be played in the application.
  33933. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33934. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33935. */
  33936. export class Sound {
  33937. /**
  33938. * The name of the sound in the scene.
  33939. */
  33940. name: string;
  33941. /**
  33942. * Does the sound autoplay once loaded.
  33943. */
  33944. autoplay: boolean;
  33945. /**
  33946. * Does the sound loop after it finishes playing once.
  33947. */
  33948. loop: boolean;
  33949. /**
  33950. * Does the sound use a custom attenuation curve to simulate the falloff
  33951. * happening when the source gets further away from the camera.
  33952. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33953. */
  33954. useCustomAttenuation: boolean;
  33955. /**
  33956. * The sound track id this sound belongs to.
  33957. */
  33958. soundTrackId: number;
  33959. /**
  33960. * Is this sound currently played.
  33961. */
  33962. isPlaying: boolean;
  33963. /**
  33964. * Is this sound currently paused.
  33965. */
  33966. isPaused: boolean;
  33967. /**
  33968. * Does this sound enables spatial sound.
  33969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33970. */
  33971. spatialSound: boolean;
  33972. /**
  33973. * Define the reference distance the sound should be heard perfectly.
  33974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33975. */
  33976. refDistance: number;
  33977. /**
  33978. * Define the roll off factor of spatial sounds.
  33979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33980. */
  33981. rolloffFactor: number;
  33982. /**
  33983. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33984. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33985. */
  33986. maxDistance: number;
  33987. /**
  33988. * Define the distance attenuation model the sound will follow.
  33989. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33990. */
  33991. distanceModel: string;
  33992. /**
  33993. * @hidden
  33994. * Back Compat
  33995. **/
  33996. onended: () => any;
  33997. /**
  33998. * Observable event when the current playing sound finishes.
  33999. */
  34000. onEndedObservable: Observable<Sound>;
  34001. private _panningModel;
  34002. private _playbackRate;
  34003. private _streaming;
  34004. private _startTime;
  34005. private _startOffset;
  34006. private _position;
  34007. /** @hidden */
  34008. _positionInEmitterSpace: boolean;
  34009. private _localDirection;
  34010. private _volume;
  34011. private _isReadyToPlay;
  34012. private _isDirectional;
  34013. private _readyToPlayCallback;
  34014. private _audioBuffer;
  34015. private _soundSource;
  34016. private _streamingSource;
  34017. private _soundPanner;
  34018. private _soundGain;
  34019. private _inputAudioNode;
  34020. private _outputAudioNode;
  34021. private _coneInnerAngle;
  34022. private _coneOuterAngle;
  34023. private _coneOuterGain;
  34024. private _scene;
  34025. private _connectedTransformNode;
  34026. private _customAttenuationFunction;
  34027. private _registerFunc;
  34028. private _isOutputConnected;
  34029. private _htmlAudioElement;
  34030. private _urlType;
  34031. /** @hidden */
  34032. static _SceneComponentInitialization: (scene: Scene) => void;
  34033. /**
  34034. * Create a sound and attach it to a scene
  34035. * @param name Name of your sound
  34036. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34037. * @param scene defines the scene the sound belongs to
  34038. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34039. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34040. */
  34041. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34042. /**
  34043. * Release the sound and its associated resources
  34044. */
  34045. dispose(): void;
  34046. /**
  34047. * Gets if the sounds is ready to be played or not.
  34048. * @returns true if ready, otherwise false
  34049. */
  34050. isReady(): boolean;
  34051. private _soundLoaded;
  34052. /**
  34053. * Sets the data of the sound from an audiobuffer
  34054. * @param audioBuffer The audioBuffer containing the data
  34055. */
  34056. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34057. /**
  34058. * Updates the current sounds options such as maxdistance, loop...
  34059. * @param options A JSON object containing values named as the object properties
  34060. */
  34061. updateOptions(options: any): void;
  34062. private _createSpatialParameters;
  34063. private _updateSpatialParameters;
  34064. /**
  34065. * Switch the panning model to HRTF:
  34066. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34067. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34068. */
  34069. switchPanningModelToHRTF(): void;
  34070. /**
  34071. * Switch the panning model to Equal Power:
  34072. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34073. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34074. */
  34075. switchPanningModelToEqualPower(): void;
  34076. private _switchPanningModel;
  34077. /**
  34078. * Connect this sound to a sound track audio node like gain...
  34079. * @param soundTrackAudioNode the sound track audio node to connect to
  34080. */
  34081. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34082. /**
  34083. * Transform this sound into a directional source
  34084. * @param coneInnerAngle Size of the inner cone in degree
  34085. * @param coneOuterAngle Size of the outer cone in degree
  34086. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34087. */
  34088. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34089. /**
  34090. * Gets or sets the inner angle for the directional cone.
  34091. */
  34092. /**
  34093. * Gets or sets the inner angle for the directional cone.
  34094. */
  34095. directionalConeInnerAngle: number;
  34096. /**
  34097. * Gets or sets the outer angle for the directional cone.
  34098. */
  34099. /**
  34100. * Gets or sets the outer angle for the directional cone.
  34101. */
  34102. directionalConeOuterAngle: number;
  34103. /**
  34104. * Sets the position of the emitter if spatial sound is enabled
  34105. * @param newPosition Defines the new posisiton
  34106. */
  34107. setPosition(newPosition: Vector3): void;
  34108. /**
  34109. * Sets the local direction of the emitter if spatial sound is enabled
  34110. * @param newLocalDirection Defines the new local direction
  34111. */
  34112. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34113. private _updateDirection;
  34114. /** @hidden */
  34115. updateDistanceFromListener(): void;
  34116. /**
  34117. * Sets a new custom attenuation function for the sound.
  34118. * @param callback Defines the function used for the attenuation
  34119. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34120. */
  34121. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34122. /**
  34123. * Play the sound
  34124. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34125. * @param offset (optional) Start the sound setting it at a specific time
  34126. */
  34127. play(time?: number, offset?: number): void;
  34128. private _onended;
  34129. /**
  34130. * Stop the sound
  34131. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34132. */
  34133. stop(time?: number): void;
  34134. /**
  34135. * Put the sound in pause
  34136. */
  34137. pause(): void;
  34138. /**
  34139. * Sets a dedicated volume for this sounds
  34140. * @param newVolume Define the new volume of the sound
  34141. * @param time Define in how long the sound should be at this value
  34142. */
  34143. setVolume(newVolume: number, time?: number): void;
  34144. /**
  34145. * Set the sound play back rate
  34146. * @param newPlaybackRate Define the playback rate the sound should be played at
  34147. */
  34148. setPlaybackRate(newPlaybackRate: number): void;
  34149. /**
  34150. * Gets the volume of the sound.
  34151. * @returns the volume of the sound
  34152. */
  34153. getVolume(): number;
  34154. /**
  34155. * Attach the sound to a dedicated mesh
  34156. * @param transformNode The transform node to connect the sound with
  34157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34158. */
  34159. attachToMesh(transformNode: TransformNode): void;
  34160. /**
  34161. * Detach the sound from the previously attached mesh
  34162. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34163. */
  34164. detachFromMesh(): void;
  34165. private _onRegisterAfterWorldMatrixUpdate;
  34166. /**
  34167. * Clone the current sound in the scene.
  34168. * @returns the new sound clone
  34169. */
  34170. clone(): Nullable<Sound>;
  34171. /**
  34172. * Gets the current underlying audio buffer containing the data
  34173. * @returns the audio buffer
  34174. */
  34175. getAudioBuffer(): Nullable<AudioBuffer>;
  34176. /**
  34177. * Serializes the Sound in a JSON representation
  34178. * @returns the JSON representation of the sound
  34179. */
  34180. serialize(): any;
  34181. /**
  34182. * Parse a JSON representation of a sound to innstantiate in a given scene
  34183. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34184. * @param scene Define the scene the new parsed sound should be created in
  34185. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34186. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34187. * @returns the newly parsed sound
  34188. */
  34189. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34190. }
  34191. }
  34192. declare module BABYLON {
  34193. /**
  34194. * This defines an action helpful to play a defined sound on a triggered action.
  34195. */
  34196. export class PlaySoundAction extends Action {
  34197. private _sound;
  34198. /**
  34199. * Instantiate the action
  34200. * @param triggerOptions defines the trigger options
  34201. * @param sound defines the sound to play
  34202. * @param condition defines the trigger related conditions
  34203. */
  34204. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34205. /** @hidden */
  34206. _prepare(): void;
  34207. /**
  34208. * Execute the action and play the sound.
  34209. */
  34210. execute(): void;
  34211. /**
  34212. * Serializes the actions and its related information.
  34213. * @param parent defines the object to serialize in
  34214. * @returns the serialized object
  34215. */
  34216. serialize(parent: any): any;
  34217. }
  34218. /**
  34219. * This defines an action helpful to stop a defined sound on a triggered action.
  34220. */
  34221. export class StopSoundAction extends Action {
  34222. private _sound;
  34223. /**
  34224. * Instantiate the action
  34225. * @param triggerOptions defines the trigger options
  34226. * @param sound defines the sound to stop
  34227. * @param condition defines the trigger related conditions
  34228. */
  34229. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34230. /** @hidden */
  34231. _prepare(): void;
  34232. /**
  34233. * Execute the action and stop the sound.
  34234. */
  34235. execute(): void;
  34236. /**
  34237. * Serializes the actions and its related information.
  34238. * @param parent defines the object to serialize in
  34239. * @returns the serialized object
  34240. */
  34241. serialize(parent: any): any;
  34242. }
  34243. }
  34244. declare module BABYLON {
  34245. /**
  34246. * This defines an action responsible to change the value of a property
  34247. * by interpolating between its current value and the newly set one once triggered.
  34248. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34249. */
  34250. export class InterpolateValueAction extends Action {
  34251. /**
  34252. * Defines the path of the property where the value should be interpolated
  34253. */
  34254. propertyPath: string;
  34255. /**
  34256. * Defines the target value at the end of the interpolation.
  34257. */
  34258. value: any;
  34259. /**
  34260. * Defines the time it will take for the property to interpolate to the value.
  34261. */
  34262. duration: number;
  34263. /**
  34264. * Defines if the other scene animations should be stopped when the action has been triggered
  34265. */
  34266. stopOtherAnimations?: boolean;
  34267. /**
  34268. * Defines a callback raised once the interpolation animation has been done.
  34269. */
  34270. onInterpolationDone?: () => void;
  34271. /**
  34272. * Observable triggered once the interpolation animation has been done.
  34273. */
  34274. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34275. private _target;
  34276. private _effectiveTarget;
  34277. private _property;
  34278. /**
  34279. * Instantiate the action
  34280. * @param triggerOptions defines the trigger options
  34281. * @param target defines the object containing the value to interpolate
  34282. * @param propertyPath defines the path to the property in the target object
  34283. * @param value defines the target value at the end of the interpolation
  34284. * @param duration deines the time it will take for the property to interpolate to the value.
  34285. * @param condition defines the trigger related conditions
  34286. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34287. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34288. */
  34289. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34290. /** @hidden */
  34291. _prepare(): void;
  34292. /**
  34293. * Execute the action starts the value interpolation.
  34294. */
  34295. execute(): void;
  34296. /**
  34297. * Serializes the actions and its related information.
  34298. * @param parent defines the object to serialize in
  34299. * @returns the serialized object
  34300. */
  34301. serialize(parent: any): any;
  34302. }
  34303. }
  34304. declare module BABYLON {
  34305. /**
  34306. * Options allowed during the creation of a sound track.
  34307. */
  34308. export interface ISoundTrackOptions {
  34309. /**
  34310. * The volume the sound track should take during creation
  34311. */
  34312. volume?: number;
  34313. /**
  34314. * Define if the sound track is the main sound track of the scene
  34315. */
  34316. mainTrack?: boolean;
  34317. }
  34318. /**
  34319. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34320. * It will be also used in a future release to apply effects on a specific track.
  34321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34322. */
  34323. export class SoundTrack {
  34324. /**
  34325. * The unique identifier of the sound track in the scene.
  34326. */
  34327. id: number;
  34328. /**
  34329. * The list of sounds included in the sound track.
  34330. */
  34331. soundCollection: Array<Sound>;
  34332. private _outputAudioNode;
  34333. private _scene;
  34334. private _isMainTrack;
  34335. private _connectedAnalyser;
  34336. private _options;
  34337. private _isInitialized;
  34338. /**
  34339. * Creates a new sound track.
  34340. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34341. * @param scene Define the scene the sound track belongs to
  34342. * @param options
  34343. */
  34344. constructor(scene: Scene, options?: ISoundTrackOptions);
  34345. private _initializeSoundTrackAudioGraph;
  34346. /**
  34347. * Release the sound track and its associated resources
  34348. */
  34349. dispose(): void;
  34350. /**
  34351. * Adds a sound to this sound track
  34352. * @param sound define the cound to add
  34353. * @ignoreNaming
  34354. */
  34355. AddSound(sound: Sound): void;
  34356. /**
  34357. * Removes a sound to this sound track
  34358. * @param sound define the cound to remove
  34359. * @ignoreNaming
  34360. */
  34361. RemoveSound(sound: Sound): void;
  34362. /**
  34363. * Set a global volume for the full sound track.
  34364. * @param newVolume Define the new volume of the sound track
  34365. */
  34366. setVolume(newVolume: number): void;
  34367. /**
  34368. * Switch the panning model to HRTF:
  34369. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34370. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34371. */
  34372. switchPanningModelToHRTF(): void;
  34373. /**
  34374. * Switch the panning model to Equal Power:
  34375. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34376. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34377. */
  34378. switchPanningModelToEqualPower(): void;
  34379. /**
  34380. * Connect the sound track to an audio analyser allowing some amazing
  34381. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34382. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34383. * @param analyser The analyser to connect to the engine
  34384. */
  34385. connectToAnalyser(analyser: Analyser): void;
  34386. }
  34387. }
  34388. declare module BABYLON {
  34389. interface AbstractScene {
  34390. /**
  34391. * The list of sounds used in the scene.
  34392. */
  34393. sounds: Nullable<Array<Sound>>;
  34394. }
  34395. interface Scene {
  34396. /**
  34397. * @hidden
  34398. * Backing field
  34399. */
  34400. _mainSoundTrack: SoundTrack;
  34401. /**
  34402. * The main sound track played by the scene.
  34403. * It cotains your primary collection of sounds.
  34404. */
  34405. mainSoundTrack: SoundTrack;
  34406. /**
  34407. * The list of sound tracks added to the scene
  34408. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34409. */
  34410. soundTracks: Nullable<Array<SoundTrack>>;
  34411. /**
  34412. * Gets a sound using a given name
  34413. * @param name defines the name to search for
  34414. * @return the found sound or null if not found at all.
  34415. */
  34416. getSoundByName(name: string): Nullable<Sound>;
  34417. /**
  34418. * Gets or sets if audio support is enabled
  34419. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34420. */
  34421. audioEnabled: boolean;
  34422. /**
  34423. * Gets or sets if audio will be output to headphones
  34424. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34425. */
  34426. headphone: boolean;
  34427. }
  34428. /**
  34429. * Defines the sound scene component responsible to manage any sounds
  34430. * in a given scene.
  34431. */
  34432. export class AudioSceneComponent implements ISceneSerializableComponent {
  34433. /**
  34434. * The component name helpfull to identify the component in the list of scene components.
  34435. */
  34436. readonly name: string;
  34437. /**
  34438. * The scene the component belongs to.
  34439. */
  34440. scene: Scene;
  34441. private _audioEnabled;
  34442. /**
  34443. * Gets whether audio is enabled or not.
  34444. * Please use related enable/disable method to switch state.
  34445. */
  34446. readonly audioEnabled: boolean;
  34447. private _headphone;
  34448. /**
  34449. * Gets whether audio is outputing to headphone or not.
  34450. * Please use the according Switch methods to change output.
  34451. */
  34452. readonly headphone: boolean;
  34453. /**
  34454. * Creates a new instance of the component for the given scene
  34455. * @param scene Defines the scene to register the component in
  34456. */
  34457. constructor(scene: Scene);
  34458. /**
  34459. * Registers the component in a given scene
  34460. */
  34461. register(): void;
  34462. /**
  34463. * Rebuilds the elements related to this component in case of
  34464. * context lost for instance.
  34465. */
  34466. rebuild(): void;
  34467. /**
  34468. * Serializes the component data to the specified json object
  34469. * @param serializationObject The object to serialize to
  34470. */
  34471. serialize(serializationObject: any): void;
  34472. /**
  34473. * Adds all the elements from the container to the scene
  34474. * @param container the container holding the elements
  34475. */
  34476. addFromContainer(container: AbstractScene): void;
  34477. /**
  34478. * Removes all the elements in the container from the scene
  34479. * @param container contains the elements to remove
  34480. * @param dispose if the removed element should be disposed (default: false)
  34481. */
  34482. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34483. /**
  34484. * Disposes the component and the associated ressources.
  34485. */
  34486. dispose(): void;
  34487. /**
  34488. * Disables audio in the associated scene.
  34489. */
  34490. disableAudio(): void;
  34491. /**
  34492. * Enables audio in the associated scene.
  34493. */
  34494. enableAudio(): void;
  34495. /**
  34496. * Switch audio to headphone output.
  34497. */
  34498. switchAudioModeForHeadphones(): void;
  34499. /**
  34500. * Switch audio to normal speakers.
  34501. */
  34502. switchAudioModeForNormalSpeakers(): void;
  34503. private _afterRender;
  34504. }
  34505. }
  34506. declare module BABYLON {
  34507. /**
  34508. * Wraps one or more Sound objects and selects one with random weight for playback.
  34509. */
  34510. export class WeightedSound {
  34511. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34512. loop: boolean;
  34513. private _coneInnerAngle;
  34514. private _coneOuterAngle;
  34515. private _volume;
  34516. /** A Sound is currently playing. */
  34517. isPlaying: boolean;
  34518. /** A Sound is currently paused. */
  34519. isPaused: boolean;
  34520. private _sounds;
  34521. private _weights;
  34522. private _currentIndex?;
  34523. /**
  34524. * Creates a new WeightedSound from the list of sounds given.
  34525. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34526. * @param sounds Array of Sounds that will be selected from.
  34527. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34528. */
  34529. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34530. /**
  34531. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34532. */
  34533. /**
  34534. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34535. */
  34536. directionalConeInnerAngle: number;
  34537. /**
  34538. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34539. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34540. */
  34541. /**
  34542. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34543. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34544. */
  34545. directionalConeOuterAngle: number;
  34546. /**
  34547. * Playback volume.
  34548. */
  34549. /**
  34550. * Playback volume.
  34551. */
  34552. volume: number;
  34553. private _onended;
  34554. /**
  34555. * Suspend playback
  34556. */
  34557. pause(): void;
  34558. /**
  34559. * Stop playback
  34560. */
  34561. stop(): void;
  34562. /**
  34563. * Start playback.
  34564. * @param startOffset Position the clip head at a specific time in seconds.
  34565. */
  34566. play(startOffset?: number): void;
  34567. }
  34568. }
  34569. declare module BABYLON {
  34570. /**
  34571. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34572. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34573. */
  34574. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34575. /**
  34576. * Gets the name of the behavior.
  34577. */
  34578. readonly name: string;
  34579. /**
  34580. * The easing function used by animations
  34581. */
  34582. static EasingFunction: BackEase;
  34583. /**
  34584. * The easing mode used by animations
  34585. */
  34586. static EasingMode: number;
  34587. /**
  34588. * The duration of the animation, in milliseconds
  34589. */
  34590. transitionDuration: number;
  34591. /**
  34592. * Length of the distance animated by the transition when lower radius is reached
  34593. */
  34594. lowerRadiusTransitionRange: number;
  34595. /**
  34596. * Length of the distance animated by the transition when upper radius is reached
  34597. */
  34598. upperRadiusTransitionRange: number;
  34599. private _autoTransitionRange;
  34600. /**
  34601. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34602. */
  34603. /**
  34604. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34605. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34606. */
  34607. autoTransitionRange: boolean;
  34608. private _attachedCamera;
  34609. private _onAfterCheckInputsObserver;
  34610. private _onMeshTargetChangedObserver;
  34611. /**
  34612. * Initializes the behavior.
  34613. */
  34614. init(): void;
  34615. /**
  34616. * Attaches the behavior to its arc rotate camera.
  34617. * @param camera Defines the camera to attach the behavior to
  34618. */
  34619. attach(camera: ArcRotateCamera): void;
  34620. /**
  34621. * Detaches the behavior from its current arc rotate camera.
  34622. */
  34623. detach(): void;
  34624. private _radiusIsAnimating;
  34625. private _radiusBounceTransition;
  34626. private _animatables;
  34627. private _cachedWheelPrecision;
  34628. /**
  34629. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34630. * @param radiusLimit The limit to check against.
  34631. * @return Bool to indicate if at limit.
  34632. */
  34633. private _isRadiusAtLimit;
  34634. /**
  34635. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34636. * @param radiusDelta The delta by which to animate to. Can be negative.
  34637. */
  34638. private _applyBoundRadiusAnimation;
  34639. /**
  34640. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34641. */
  34642. protected _clearAnimationLocks(): void;
  34643. /**
  34644. * Stops and removes all animations that have been applied to the camera
  34645. */
  34646. stopAllAnimations(): void;
  34647. }
  34648. }
  34649. declare module BABYLON {
  34650. /**
  34651. * 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.
  34652. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34653. */
  34654. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34655. /**
  34656. * Gets the name of the behavior.
  34657. */
  34658. readonly name: string;
  34659. private _mode;
  34660. private _radiusScale;
  34661. private _positionScale;
  34662. private _defaultElevation;
  34663. private _elevationReturnTime;
  34664. private _elevationReturnWaitTime;
  34665. private _zoomStopsAnimation;
  34666. private _framingTime;
  34667. /**
  34668. * The easing function used by animations
  34669. */
  34670. static EasingFunction: ExponentialEase;
  34671. /**
  34672. * The easing mode used by animations
  34673. */
  34674. static EasingMode: number;
  34675. /**
  34676. * Sets the current mode used by the behavior
  34677. */
  34678. /**
  34679. * Gets current mode used by the behavior.
  34680. */
  34681. mode: number;
  34682. /**
  34683. * Sets the scale applied to the radius (1 by default)
  34684. */
  34685. /**
  34686. * Gets the scale applied to the radius
  34687. */
  34688. radiusScale: number;
  34689. /**
  34690. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34691. */
  34692. /**
  34693. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34694. */
  34695. positionScale: number;
  34696. /**
  34697. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34698. * behaviour is triggered, in radians.
  34699. */
  34700. /**
  34701. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34702. * behaviour is triggered, in radians.
  34703. */
  34704. defaultElevation: number;
  34705. /**
  34706. * Sets the time (in milliseconds) taken to return to the default beta position.
  34707. * Negative value indicates camera should not return to default.
  34708. */
  34709. /**
  34710. * Gets the time (in milliseconds) taken to return to the default beta position.
  34711. * Negative value indicates camera should not return to default.
  34712. */
  34713. elevationReturnTime: number;
  34714. /**
  34715. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34716. */
  34717. /**
  34718. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34719. */
  34720. elevationReturnWaitTime: number;
  34721. /**
  34722. * Sets the flag that indicates if user zooming should stop animation.
  34723. */
  34724. /**
  34725. * Gets the flag that indicates if user zooming should stop animation.
  34726. */
  34727. zoomStopsAnimation: boolean;
  34728. /**
  34729. * Sets the transition time when framing the mesh, in milliseconds
  34730. */
  34731. /**
  34732. * Gets the transition time when framing the mesh, in milliseconds
  34733. */
  34734. framingTime: number;
  34735. /**
  34736. * Define if the behavior should automatically change the configured
  34737. * camera limits and sensibilities.
  34738. */
  34739. autoCorrectCameraLimitsAndSensibility: boolean;
  34740. private _onPrePointerObservableObserver;
  34741. private _onAfterCheckInputsObserver;
  34742. private _onMeshTargetChangedObserver;
  34743. private _attachedCamera;
  34744. private _isPointerDown;
  34745. private _lastInteractionTime;
  34746. /**
  34747. * Initializes the behavior.
  34748. */
  34749. init(): void;
  34750. /**
  34751. * Attaches the behavior to its arc rotate camera.
  34752. * @param camera Defines the camera to attach the behavior to
  34753. */
  34754. attach(camera: ArcRotateCamera): void;
  34755. /**
  34756. * Detaches the behavior from its current arc rotate camera.
  34757. */
  34758. detach(): void;
  34759. private _animatables;
  34760. private _betaIsAnimating;
  34761. private _betaTransition;
  34762. private _radiusTransition;
  34763. private _vectorTransition;
  34764. /**
  34765. * Targets the given mesh and updates zoom level accordingly.
  34766. * @param mesh The mesh to target.
  34767. * @param radius Optional. If a cached radius position already exists, overrides default.
  34768. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34769. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34770. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34771. */
  34772. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34773. /**
  34774. * Targets the given mesh with its children and updates zoom level accordingly.
  34775. * @param mesh The mesh to target.
  34776. * @param radius Optional. If a cached radius position already exists, overrides default.
  34777. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34778. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34779. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34780. */
  34781. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34782. /**
  34783. * Targets the given meshes with their children and updates zoom level accordingly.
  34784. * @param meshes The mesh to target.
  34785. * @param radius Optional. If a cached radius position already exists, overrides default.
  34786. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34787. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34788. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34789. */
  34790. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34791. /**
  34792. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34793. * @param minimumWorld Determines the smaller position of the bounding box extend
  34794. * @param maximumWorld Determines the bigger position of the bounding box extend
  34795. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34796. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34797. */
  34798. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34799. /**
  34800. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34801. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34802. * frustum width.
  34803. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34804. * to fully enclose the mesh in the viewing frustum.
  34805. */
  34806. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34807. /**
  34808. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34809. * is automatically returned to its default position (expected to be above ground plane).
  34810. */
  34811. private _maintainCameraAboveGround;
  34812. /**
  34813. * Returns the frustum slope based on the canvas ratio and camera FOV
  34814. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34815. */
  34816. private _getFrustumSlope;
  34817. /**
  34818. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34819. */
  34820. private _clearAnimationLocks;
  34821. /**
  34822. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34823. */
  34824. private _applyUserInteraction;
  34825. /**
  34826. * Stops and removes all animations that have been applied to the camera
  34827. */
  34828. stopAllAnimations(): void;
  34829. /**
  34830. * Gets a value indicating if the user is moving the camera
  34831. */
  34832. readonly isUserIsMoving: boolean;
  34833. /**
  34834. * The camera can move all the way towards the mesh.
  34835. */
  34836. static IgnoreBoundsSizeMode: number;
  34837. /**
  34838. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34839. */
  34840. static FitFrustumSidesMode: number;
  34841. }
  34842. }
  34843. declare module BABYLON {
  34844. /**
  34845. * Base class for Camera Pointer Inputs.
  34846. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34847. * for example usage.
  34848. */
  34849. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34850. /**
  34851. * Defines the camera the input is attached to.
  34852. */
  34853. abstract camera: Camera;
  34854. /**
  34855. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34856. */
  34857. protected _altKey: boolean;
  34858. protected _ctrlKey: boolean;
  34859. protected _metaKey: boolean;
  34860. protected _shiftKey: boolean;
  34861. /**
  34862. * Which mouse buttons were pressed at time of last mouse event.
  34863. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34864. */
  34865. protected _buttonsPressed: number;
  34866. /**
  34867. * Defines the buttons associated with the input to handle camera move.
  34868. */
  34869. buttons: number[];
  34870. /**
  34871. * Attach the input controls to a specific dom element to get the input from.
  34872. * @param element Defines the element the controls should be listened from
  34873. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34874. */
  34875. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34876. /**
  34877. * Detach the current controls from the specified dom element.
  34878. * @param element Defines the element to stop listening the inputs from
  34879. */
  34880. detachControl(element: Nullable<HTMLElement>): void;
  34881. /**
  34882. * Gets the class name of the current input.
  34883. * @returns the class name
  34884. */
  34885. getClassName(): string;
  34886. /**
  34887. * Get the friendly name associated with the input class.
  34888. * @returns the input friendly name
  34889. */
  34890. getSimpleName(): string;
  34891. /**
  34892. * Called on pointer POINTERDOUBLETAP event.
  34893. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34894. */
  34895. protected onDoubleTap(type: string): void;
  34896. /**
  34897. * Called on pointer POINTERMOVE event if only a single touch is active.
  34898. * Override this method to provide functionality.
  34899. */
  34900. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34901. /**
  34902. * Called on pointer POINTERMOVE event if multiple touches are active.
  34903. * Override this method to provide functionality.
  34904. */
  34905. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34906. /**
  34907. * Called on JS contextmenu event.
  34908. * Override this method to provide functionality.
  34909. */
  34910. protected onContextMenu(evt: PointerEvent): void;
  34911. /**
  34912. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34913. * press.
  34914. * Override this method to provide functionality.
  34915. */
  34916. protected onButtonDown(evt: PointerEvent): void;
  34917. /**
  34918. * Called each time a new POINTERUP event occurs. Ie, for each button
  34919. * release.
  34920. * Override this method to provide functionality.
  34921. */
  34922. protected onButtonUp(evt: PointerEvent): void;
  34923. /**
  34924. * Called when window becomes inactive.
  34925. * Override this method to provide functionality.
  34926. */
  34927. protected onLostFocus(): void;
  34928. private _pointerInput;
  34929. private _observer;
  34930. private _onLostFocus;
  34931. private pointA;
  34932. private pointB;
  34933. }
  34934. }
  34935. declare module BABYLON {
  34936. /**
  34937. * Manage the pointers inputs to control an arc rotate camera.
  34938. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34939. */
  34940. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34941. /**
  34942. * Defines the camera the input is attached to.
  34943. */
  34944. camera: ArcRotateCamera;
  34945. /**
  34946. * Gets the class name of the current input.
  34947. * @returns the class name
  34948. */
  34949. getClassName(): string;
  34950. /**
  34951. * Defines the buttons associated with the input to handle camera move.
  34952. */
  34953. buttons: number[];
  34954. /**
  34955. * Defines the pointer angular sensibility along the X axis or how fast is
  34956. * the camera rotating.
  34957. */
  34958. angularSensibilityX: number;
  34959. /**
  34960. * Defines the pointer angular sensibility along the Y axis or how fast is
  34961. * the camera rotating.
  34962. */
  34963. angularSensibilityY: number;
  34964. /**
  34965. * Defines the pointer pinch precision or how fast is the camera zooming.
  34966. */
  34967. pinchPrecision: number;
  34968. /**
  34969. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34970. * from 0.
  34971. * It defines the percentage of current camera.radius to use as delta when
  34972. * pinch zoom is used.
  34973. */
  34974. pinchDeltaPercentage: number;
  34975. /**
  34976. * Defines the pointer panning sensibility or how fast is the camera moving.
  34977. */
  34978. panningSensibility: number;
  34979. /**
  34980. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34981. */
  34982. multiTouchPanning: boolean;
  34983. /**
  34984. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34985. * zoom (pinch) through multitouch.
  34986. */
  34987. multiTouchPanAndZoom: boolean;
  34988. /**
  34989. * Revers pinch action direction.
  34990. */
  34991. pinchInwards: boolean;
  34992. private _isPanClick;
  34993. private _twoFingerActivityCount;
  34994. private _isPinching;
  34995. /**
  34996. * Called on pointer POINTERMOVE event if only a single touch is active.
  34997. */
  34998. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34999. /**
  35000. * Called on pointer POINTERDOUBLETAP event.
  35001. */
  35002. protected onDoubleTap(type: string): void;
  35003. /**
  35004. * Called on pointer POINTERMOVE event if multiple touches are active.
  35005. */
  35006. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35007. /**
  35008. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35009. * press.
  35010. */
  35011. protected onButtonDown(evt: PointerEvent): void;
  35012. /**
  35013. * Called each time a new POINTERUP event occurs. Ie, for each button
  35014. * release.
  35015. */
  35016. protected onButtonUp(evt: PointerEvent): void;
  35017. /**
  35018. * Called when window becomes inactive.
  35019. */
  35020. protected onLostFocus(): void;
  35021. }
  35022. }
  35023. declare module BABYLON {
  35024. /**
  35025. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35026. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35027. */
  35028. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35029. /**
  35030. * Defines the camera the input is attached to.
  35031. */
  35032. camera: ArcRotateCamera;
  35033. /**
  35034. * Defines the list of key codes associated with the up action (increase alpha)
  35035. */
  35036. keysUp: number[];
  35037. /**
  35038. * Defines the list of key codes associated with the down action (decrease alpha)
  35039. */
  35040. keysDown: number[];
  35041. /**
  35042. * Defines the list of key codes associated with the left action (increase beta)
  35043. */
  35044. keysLeft: number[];
  35045. /**
  35046. * Defines the list of key codes associated with the right action (decrease beta)
  35047. */
  35048. keysRight: number[];
  35049. /**
  35050. * Defines the list of key codes associated with the reset action.
  35051. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35052. */
  35053. keysReset: number[];
  35054. /**
  35055. * Defines the panning sensibility of the inputs.
  35056. * (How fast is the camera paning)
  35057. */
  35058. panningSensibility: number;
  35059. /**
  35060. * Defines the zooming sensibility of the inputs.
  35061. * (How fast is the camera zooming)
  35062. */
  35063. zoomingSensibility: number;
  35064. /**
  35065. * Defines wether maintaining the alt key down switch the movement mode from
  35066. * orientation to zoom.
  35067. */
  35068. useAltToZoom: boolean;
  35069. /**
  35070. * Rotation speed of the camera
  35071. */
  35072. angularSpeed: number;
  35073. private _keys;
  35074. private _ctrlPressed;
  35075. private _altPressed;
  35076. private _onCanvasBlurObserver;
  35077. private _onKeyboardObserver;
  35078. private _engine;
  35079. private _scene;
  35080. /**
  35081. * Attach the input controls to a specific dom element to get the input from.
  35082. * @param element Defines the element the controls should be listened from
  35083. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35084. */
  35085. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35086. /**
  35087. * Detach the current controls from the specified dom element.
  35088. * @param element Defines the element to stop listening the inputs from
  35089. */
  35090. detachControl(element: Nullable<HTMLElement>): void;
  35091. /**
  35092. * Update the current camera state depending on the inputs that have been used this frame.
  35093. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35094. */
  35095. checkInputs(): void;
  35096. /**
  35097. * Gets the class name of the current intput.
  35098. * @returns the class name
  35099. */
  35100. getClassName(): string;
  35101. /**
  35102. * Get the friendly name associated with the input class.
  35103. * @returns the input friendly name
  35104. */
  35105. getSimpleName(): string;
  35106. }
  35107. }
  35108. declare module BABYLON {
  35109. /**
  35110. * Manage the mouse wheel inputs to control an arc rotate camera.
  35111. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35112. */
  35113. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35114. /**
  35115. * Defines the camera the input is attached to.
  35116. */
  35117. camera: ArcRotateCamera;
  35118. /**
  35119. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35120. */
  35121. wheelPrecision: number;
  35122. /**
  35123. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35124. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35125. */
  35126. wheelDeltaPercentage: number;
  35127. private _wheel;
  35128. private _observer;
  35129. private computeDeltaFromMouseWheelLegacyEvent;
  35130. /**
  35131. * Attach the input controls to a specific dom element to get the input from.
  35132. * @param element Defines the element the controls should be listened from
  35133. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35134. */
  35135. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35136. /**
  35137. * Detach the current controls from the specified dom element.
  35138. * @param element Defines the element to stop listening the inputs from
  35139. */
  35140. detachControl(element: Nullable<HTMLElement>): void;
  35141. /**
  35142. * Gets the class name of the current intput.
  35143. * @returns the class name
  35144. */
  35145. getClassName(): string;
  35146. /**
  35147. * Get the friendly name associated with the input class.
  35148. * @returns the input friendly name
  35149. */
  35150. getSimpleName(): string;
  35151. }
  35152. }
  35153. declare module BABYLON {
  35154. /**
  35155. * Default Inputs manager for the ArcRotateCamera.
  35156. * It groups all the default supported inputs for ease of use.
  35157. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35158. */
  35159. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35160. /**
  35161. * Instantiates a new ArcRotateCameraInputsManager.
  35162. * @param camera Defines the camera the inputs belong to
  35163. */
  35164. constructor(camera: ArcRotateCamera);
  35165. /**
  35166. * Add mouse wheel input support to the input manager.
  35167. * @returns the current input manager
  35168. */
  35169. addMouseWheel(): ArcRotateCameraInputsManager;
  35170. /**
  35171. * Add pointers input support to the input manager.
  35172. * @returns the current input manager
  35173. */
  35174. addPointers(): ArcRotateCameraInputsManager;
  35175. /**
  35176. * Add keyboard input support to the input manager.
  35177. * @returns the current input manager
  35178. */
  35179. addKeyboard(): ArcRotateCameraInputsManager;
  35180. }
  35181. }
  35182. declare module BABYLON {
  35183. /**
  35184. * This represents an orbital type of camera.
  35185. *
  35186. * 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.
  35187. * 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.
  35188. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35189. */
  35190. export class ArcRotateCamera extends TargetCamera {
  35191. /**
  35192. * Defines the rotation angle of the camera along the longitudinal axis.
  35193. */
  35194. alpha: number;
  35195. /**
  35196. * Defines the rotation angle of the camera along the latitudinal axis.
  35197. */
  35198. beta: number;
  35199. /**
  35200. * Defines the radius of the camera from it s target point.
  35201. */
  35202. radius: number;
  35203. protected _target: Vector3;
  35204. protected _targetHost: Nullable<AbstractMesh>;
  35205. /**
  35206. * Defines the target point of the camera.
  35207. * The camera looks towards it form the radius distance.
  35208. */
  35209. target: Vector3;
  35210. /**
  35211. * Define the current local position of the camera in the scene
  35212. */
  35213. position: Vector3;
  35214. protected _upVector: Vector3;
  35215. protected _upToYMatrix: Matrix;
  35216. protected _YToUpMatrix: Matrix;
  35217. /**
  35218. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35219. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35220. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35221. */
  35222. upVector: Vector3;
  35223. /**
  35224. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35225. */
  35226. setMatUp(): void;
  35227. /**
  35228. * Current inertia value on the longitudinal axis.
  35229. * The bigger this number the longer it will take for the camera to stop.
  35230. */
  35231. inertialAlphaOffset: number;
  35232. /**
  35233. * Current inertia value on the latitudinal axis.
  35234. * The bigger this number the longer it will take for the camera to stop.
  35235. */
  35236. inertialBetaOffset: number;
  35237. /**
  35238. * Current inertia value on the radius axis.
  35239. * The bigger this number the longer it will take for the camera to stop.
  35240. */
  35241. inertialRadiusOffset: number;
  35242. /**
  35243. * Minimum allowed angle on the longitudinal axis.
  35244. * This can help limiting how the Camera is able to move in the scene.
  35245. */
  35246. lowerAlphaLimit: Nullable<number>;
  35247. /**
  35248. * Maximum allowed angle on the longitudinal axis.
  35249. * This can help limiting how the Camera is able to move in the scene.
  35250. */
  35251. upperAlphaLimit: Nullable<number>;
  35252. /**
  35253. * Minimum allowed angle on the latitudinal axis.
  35254. * This can help limiting how the Camera is able to move in the scene.
  35255. */
  35256. lowerBetaLimit: number;
  35257. /**
  35258. * Maximum allowed angle on the latitudinal axis.
  35259. * This can help limiting how the Camera is able to move in the scene.
  35260. */
  35261. upperBetaLimit: number;
  35262. /**
  35263. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35264. * This can help limiting how the Camera is able to move in the scene.
  35265. */
  35266. lowerRadiusLimit: Nullable<number>;
  35267. /**
  35268. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35269. * This can help limiting how the Camera is able to move in the scene.
  35270. */
  35271. upperRadiusLimit: Nullable<number>;
  35272. /**
  35273. * Defines the current inertia value used during panning of the camera along the X axis.
  35274. */
  35275. inertialPanningX: number;
  35276. /**
  35277. * Defines the current inertia value used during panning of the camera along the Y axis.
  35278. */
  35279. inertialPanningY: number;
  35280. /**
  35281. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35282. * Basically if your fingers moves away from more than this distance you will be considered
  35283. * in pinch mode.
  35284. */
  35285. pinchToPanMaxDistance: number;
  35286. /**
  35287. * Defines the maximum distance the camera can pan.
  35288. * This could help keeping the cammera always in your scene.
  35289. */
  35290. panningDistanceLimit: Nullable<number>;
  35291. /**
  35292. * Defines the target of the camera before paning.
  35293. */
  35294. panningOriginTarget: Vector3;
  35295. /**
  35296. * Defines the value of the inertia used during panning.
  35297. * 0 would mean stop inertia and one would mean no decelleration at all.
  35298. */
  35299. panningInertia: number;
  35300. /**
  35301. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35302. */
  35303. angularSensibilityX: number;
  35304. /**
  35305. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35306. */
  35307. angularSensibilityY: number;
  35308. /**
  35309. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35310. */
  35311. pinchPrecision: number;
  35312. /**
  35313. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35314. * It will be used instead of pinchDeltaPrecision if different from 0.
  35315. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35316. */
  35317. pinchDeltaPercentage: number;
  35318. /**
  35319. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35320. */
  35321. panningSensibility: number;
  35322. /**
  35323. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35324. */
  35325. keysUp: number[];
  35326. /**
  35327. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35328. */
  35329. keysDown: number[];
  35330. /**
  35331. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35332. */
  35333. keysLeft: number[];
  35334. /**
  35335. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35336. */
  35337. keysRight: number[];
  35338. /**
  35339. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35340. */
  35341. wheelPrecision: number;
  35342. /**
  35343. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35344. * It will be used instead of pinchDeltaPrecision if different from 0.
  35345. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35346. */
  35347. wheelDeltaPercentage: number;
  35348. /**
  35349. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35350. */
  35351. zoomOnFactor: number;
  35352. /**
  35353. * Defines a screen offset for the camera position.
  35354. */
  35355. targetScreenOffset: Vector2;
  35356. /**
  35357. * Allows the camera to be completely reversed.
  35358. * If false the camera can not arrive upside down.
  35359. */
  35360. allowUpsideDown: boolean;
  35361. /**
  35362. * Define if double tap/click is used to restore the previously saved state of the camera.
  35363. */
  35364. useInputToRestoreState: boolean;
  35365. /** @hidden */
  35366. _viewMatrix: Matrix;
  35367. /** @hidden */
  35368. _useCtrlForPanning: boolean;
  35369. /** @hidden */
  35370. _panningMouseButton: number;
  35371. /**
  35372. * Defines the input associated to the camera.
  35373. */
  35374. inputs: ArcRotateCameraInputsManager;
  35375. /** @hidden */
  35376. _reset: () => void;
  35377. /**
  35378. * Defines the allowed panning axis.
  35379. */
  35380. panningAxis: Vector3;
  35381. protected _localDirection: Vector3;
  35382. protected _transformedDirection: Vector3;
  35383. private _bouncingBehavior;
  35384. /**
  35385. * Gets the bouncing behavior of the camera if it has been enabled.
  35386. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35387. */
  35388. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35389. /**
  35390. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35391. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35392. */
  35393. useBouncingBehavior: boolean;
  35394. private _framingBehavior;
  35395. /**
  35396. * Gets the framing behavior of the camera if it has been enabled.
  35397. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35398. */
  35399. readonly framingBehavior: Nullable<FramingBehavior>;
  35400. /**
  35401. * Defines if the framing behavior of the camera is enabled on the camera.
  35402. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35403. */
  35404. useFramingBehavior: boolean;
  35405. private _autoRotationBehavior;
  35406. /**
  35407. * Gets the auto rotation behavior of the camera if it has been enabled.
  35408. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35409. */
  35410. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35411. /**
  35412. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35413. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35414. */
  35415. useAutoRotationBehavior: boolean;
  35416. /**
  35417. * Observable triggered when the mesh target has been changed on the camera.
  35418. */
  35419. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35420. /**
  35421. * Event raised when the camera is colliding with a mesh.
  35422. */
  35423. onCollide: (collidedMesh: AbstractMesh) => void;
  35424. /**
  35425. * Defines whether the camera should check collision with the objects oh the scene.
  35426. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35427. */
  35428. checkCollisions: boolean;
  35429. /**
  35430. * Defines the collision radius of the camera.
  35431. * This simulates a sphere around the camera.
  35432. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35433. */
  35434. collisionRadius: Vector3;
  35435. protected _collider: Collider;
  35436. protected _previousPosition: Vector3;
  35437. protected _collisionVelocity: Vector3;
  35438. protected _newPosition: Vector3;
  35439. protected _previousAlpha: number;
  35440. protected _previousBeta: number;
  35441. protected _previousRadius: number;
  35442. protected _collisionTriggered: boolean;
  35443. protected _targetBoundingCenter: Nullable<Vector3>;
  35444. private _computationVector;
  35445. /**
  35446. * Instantiates a new ArcRotateCamera in a given scene
  35447. * @param name Defines the name of the camera
  35448. * @param alpha Defines the camera rotation along the logitudinal axis
  35449. * @param beta Defines the camera rotation along the latitudinal axis
  35450. * @param radius Defines the camera distance from its target
  35451. * @param target Defines the camera target
  35452. * @param scene Defines the scene the camera belongs to
  35453. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35454. */
  35455. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35456. /** @hidden */
  35457. _initCache(): void;
  35458. /** @hidden */
  35459. _updateCache(ignoreParentClass?: boolean): void;
  35460. protected _getTargetPosition(): Vector3;
  35461. private _storedAlpha;
  35462. private _storedBeta;
  35463. private _storedRadius;
  35464. private _storedTarget;
  35465. /**
  35466. * Stores the current state of the camera (alpha, beta, radius and target)
  35467. * @returns the camera itself
  35468. */
  35469. storeState(): Camera;
  35470. /**
  35471. * @hidden
  35472. * Restored camera state. You must call storeState() first
  35473. */
  35474. _restoreStateValues(): boolean;
  35475. /** @hidden */
  35476. _isSynchronizedViewMatrix(): boolean;
  35477. /**
  35478. * Attached controls to the current camera.
  35479. * @param element Defines the element the controls should be listened from
  35480. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35481. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35482. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35483. */
  35484. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35485. /**
  35486. * Detach the current controls from the camera.
  35487. * The camera will stop reacting to inputs.
  35488. * @param element Defines the element to stop listening the inputs from
  35489. */
  35490. detachControl(element: HTMLElement): void;
  35491. /** @hidden */
  35492. _checkInputs(): void;
  35493. protected _checkLimits(): void;
  35494. /**
  35495. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35496. */
  35497. rebuildAnglesAndRadius(): void;
  35498. /**
  35499. * Use a position to define the current camera related information like aplha, beta and radius
  35500. * @param position Defines the position to set the camera at
  35501. */
  35502. setPosition(position: Vector3): void;
  35503. /**
  35504. * Defines the target the camera should look at.
  35505. * This will automatically adapt alpha beta and radius to fit within the new target.
  35506. * @param target Defines the new target as a Vector or a mesh
  35507. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35508. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35509. */
  35510. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35511. /** @hidden */
  35512. _getViewMatrix(): Matrix;
  35513. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35514. /**
  35515. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35516. * @param meshes Defines the mesh to zoom on
  35517. * @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)
  35518. */
  35519. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35520. /**
  35521. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35522. * The target will be changed but the radius
  35523. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35524. * @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)
  35525. */
  35526. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35527. min: Vector3;
  35528. max: Vector3;
  35529. distance: number;
  35530. }, doNotUpdateMaxZ?: boolean): void;
  35531. /**
  35532. * @override
  35533. * Override Camera.createRigCamera
  35534. */
  35535. createRigCamera(name: string, cameraIndex: number): Camera;
  35536. /**
  35537. * @hidden
  35538. * @override
  35539. * Override Camera._updateRigCameras
  35540. */
  35541. _updateRigCameras(): void;
  35542. /**
  35543. * Destroy the camera and release the current resources hold by it.
  35544. */
  35545. dispose(): void;
  35546. /**
  35547. * Gets the current object class name.
  35548. * @return the class name
  35549. */
  35550. getClassName(): string;
  35551. }
  35552. }
  35553. declare module BABYLON {
  35554. /**
  35555. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35556. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35557. */
  35558. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35559. /**
  35560. * Gets the name of the behavior.
  35561. */
  35562. readonly name: string;
  35563. private _zoomStopsAnimation;
  35564. private _idleRotationSpeed;
  35565. private _idleRotationWaitTime;
  35566. private _idleRotationSpinupTime;
  35567. /**
  35568. * Sets the flag that indicates if user zooming should stop animation.
  35569. */
  35570. /**
  35571. * Gets the flag that indicates if user zooming should stop animation.
  35572. */
  35573. zoomStopsAnimation: boolean;
  35574. /**
  35575. * Sets the default speed at which the camera rotates around the model.
  35576. */
  35577. /**
  35578. * Gets the default speed at which the camera rotates around the model.
  35579. */
  35580. idleRotationSpeed: number;
  35581. /**
  35582. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35583. */
  35584. /**
  35585. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35586. */
  35587. idleRotationWaitTime: number;
  35588. /**
  35589. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35590. */
  35591. /**
  35592. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35593. */
  35594. idleRotationSpinupTime: number;
  35595. /**
  35596. * Gets a value indicating if the camera is currently rotating because of this behavior
  35597. */
  35598. readonly rotationInProgress: boolean;
  35599. private _onPrePointerObservableObserver;
  35600. private _onAfterCheckInputsObserver;
  35601. private _attachedCamera;
  35602. private _isPointerDown;
  35603. private _lastFrameTime;
  35604. private _lastInteractionTime;
  35605. private _cameraRotationSpeed;
  35606. /**
  35607. * Initializes the behavior.
  35608. */
  35609. init(): void;
  35610. /**
  35611. * Attaches the behavior to its arc rotate camera.
  35612. * @param camera Defines the camera to attach the behavior to
  35613. */
  35614. attach(camera: ArcRotateCamera): void;
  35615. /**
  35616. * Detaches the behavior from its current arc rotate camera.
  35617. */
  35618. detach(): void;
  35619. /**
  35620. * Returns true if user is scrolling.
  35621. * @return true if user is scrolling.
  35622. */
  35623. private _userIsZooming;
  35624. private _lastFrameRadius;
  35625. private _shouldAnimationStopForInteraction;
  35626. /**
  35627. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35628. */
  35629. private _applyUserInteraction;
  35630. private _userIsMoving;
  35631. }
  35632. }
  35633. declare module BABYLON {
  35634. /**
  35635. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35636. */
  35637. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35638. private ui;
  35639. /**
  35640. * The name of the behavior
  35641. */
  35642. name: string;
  35643. /**
  35644. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35645. */
  35646. distanceAwayFromFace: number;
  35647. /**
  35648. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35649. */
  35650. distanceAwayFromBottomOfFace: number;
  35651. private _faceVectors;
  35652. private _target;
  35653. private _scene;
  35654. private _onRenderObserver;
  35655. private _tmpMatrix;
  35656. private _tmpVector;
  35657. /**
  35658. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35659. * @param ui The transform node that should be attched to the mesh
  35660. */
  35661. constructor(ui: TransformNode);
  35662. /**
  35663. * Initializes the behavior
  35664. */
  35665. init(): void;
  35666. private _closestFace;
  35667. private _zeroVector;
  35668. private _lookAtTmpMatrix;
  35669. private _lookAtToRef;
  35670. /**
  35671. * Attaches the AttachToBoxBehavior to the passed in mesh
  35672. * @param target The mesh that the specified node will be attached to
  35673. */
  35674. attach(target: Mesh): void;
  35675. /**
  35676. * Detaches the behavior from the mesh
  35677. */
  35678. detach(): void;
  35679. }
  35680. }
  35681. declare module BABYLON {
  35682. /**
  35683. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35684. */
  35685. export class FadeInOutBehavior implements Behavior<Mesh> {
  35686. /**
  35687. * Time in milliseconds to delay before fading in (Default: 0)
  35688. */
  35689. delay: number;
  35690. /**
  35691. * Time in milliseconds for the mesh to fade in (Default: 300)
  35692. */
  35693. fadeInTime: number;
  35694. private _millisecondsPerFrame;
  35695. private _hovered;
  35696. private _hoverValue;
  35697. private _ownerNode;
  35698. /**
  35699. * Instatiates the FadeInOutBehavior
  35700. */
  35701. constructor();
  35702. /**
  35703. * The name of the behavior
  35704. */
  35705. readonly name: string;
  35706. /**
  35707. * Initializes the behavior
  35708. */
  35709. init(): void;
  35710. /**
  35711. * Attaches the fade behavior on the passed in mesh
  35712. * @param ownerNode The mesh that will be faded in/out once attached
  35713. */
  35714. attach(ownerNode: Mesh): void;
  35715. /**
  35716. * Detaches the behavior from the mesh
  35717. */
  35718. detach(): void;
  35719. /**
  35720. * Triggers the mesh to begin fading in or out
  35721. * @param value if the object should fade in or out (true to fade in)
  35722. */
  35723. fadeIn(value: boolean): void;
  35724. private _update;
  35725. private _setAllVisibility;
  35726. }
  35727. }
  35728. declare module BABYLON {
  35729. /**
  35730. * Class containing a set of static utilities functions for managing Pivots
  35731. * @hidden
  35732. */
  35733. export class PivotTools {
  35734. private static _PivotCached;
  35735. private static _OldPivotPoint;
  35736. private static _PivotTranslation;
  35737. private static _PivotTmpVector;
  35738. /** @hidden */
  35739. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35740. /** @hidden */
  35741. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35742. }
  35743. }
  35744. declare module BABYLON {
  35745. /**
  35746. * Class containing static functions to help procedurally build meshes
  35747. */
  35748. export class PlaneBuilder {
  35749. /**
  35750. * Creates a plane mesh
  35751. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35752. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35753. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35755. * * 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
  35756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35757. * @param name defines the name of the mesh
  35758. * @param options defines the options used to create the mesh
  35759. * @param scene defines the hosting scene
  35760. * @returns the plane mesh
  35761. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35762. */
  35763. static CreatePlane(name: string, options: {
  35764. size?: number;
  35765. width?: number;
  35766. height?: number;
  35767. sideOrientation?: number;
  35768. frontUVs?: Vector4;
  35769. backUVs?: Vector4;
  35770. updatable?: boolean;
  35771. sourcePlane?: Plane;
  35772. }, scene?: Nullable<Scene>): Mesh;
  35773. }
  35774. }
  35775. declare module BABYLON {
  35776. /**
  35777. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35778. */
  35779. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35780. private static _AnyMouseID;
  35781. /**
  35782. * Abstract mesh the behavior is set on
  35783. */
  35784. attachedNode: AbstractMesh;
  35785. private _dragPlane;
  35786. private _scene;
  35787. private _pointerObserver;
  35788. private _beforeRenderObserver;
  35789. private static _planeScene;
  35790. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35791. /**
  35792. * 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)
  35793. */
  35794. maxDragAngle: number;
  35795. /**
  35796. * @hidden
  35797. */
  35798. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35799. /**
  35800. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35801. */
  35802. currentDraggingPointerID: number;
  35803. /**
  35804. * The last position where the pointer hit the drag plane in world space
  35805. */
  35806. lastDragPosition: Vector3;
  35807. /**
  35808. * If the behavior is currently in a dragging state
  35809. */
  35810. dragging: boolean;
  35811. /**
  35812. * 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)
  35813. */
  35814. dragDeltaRatio: number;
  35815. /**
  35816. * If the drag plane orientation should be updated during the dragging (Default: true)
  35817. */
  35818. updateDragPlane: boolean;
  35819. private _debugMode;
  35820. private _moving;
  35821. /**
  35822. * Fires each time the attached mesh is dragged with the pointer
  35823. * * delta between last drag position and current drag position in world space
  35824. * * dragDistance along the drag axis
  35825. * * dragPlaneNormal normal of the current drag plane used during the drag
  35826. * * dragPlanePoint in world space where the drag intersects the drag plane
  35827. */
  35828. onDragObservable: Observable<{
  35829. delta: Vector3;
  35830. dragPlanePoint: Vector3;
  35831. dragPlaneNormal: Vector3;
  35832. dragDistance: number;
  35833. pointerId: number;
  35834. }>;
  35835. /**
  35836. * Fires each time a drag begins (eg. mouse down on mesh)
  35837. */
  35838. onDragStartObservable: Observable<{
  35839. dragPlanePoint: Vector3;
  35840. pointerId: number;
  35841. }>;
  35842. /**
  35843. * Fires each time a drag ends (eg. mouse release after drag)
  35844. */
  35845. onDragEndObservable: Observable<{
  35846. dragPlanePoint: Vector3;
  35847. pointerId: number;
  35848. }>;
  35849. /**
  35850. * If the attached mesh should be moved when dragged
  35851. */
  35852. moveAttached: boolean;
  35853. /**
  35854. * If the drag behavior will react to drag events (Default: true)
  35855. */
  35856. enabled: boolean;
  35857. /**
  35858. * If camera controls should be detached during the drag
  35859. */
  35860. detachCameraControls: boolean;
  35861. /**
  35862. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35863. */
  35864. useObjectOrienationForDragging: boolean;
  35865. private _options;
  35866. /**
  35867. * Creates a pointer drag behavior that can be attached to a mesh
  35868. * @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)
  35869. */
  35870. constructor(options?: {
  35871. dragAxis?: Vector3;
  35872. dragPlaneNormal?: Vector3;
  35873. });
  35874. /**
  35875. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35876. */
  35877. validateDrag: (targetPosition: Vector3) => boolean;
  35878. /**
  35879. * The name of the behavior
  35880. */
  35881. readonly name: string;
  35882. /**
  35883. * Initializes the behavior
  35884. */
  35885. init(): void;
  35886. private _tmpVector;
  35887. private _alternatePickedPoint;
  35888. private _worldDragAxis;
  35889. private _targetPosition;
  35890. private _attachedElement;
  35891. /**
  35892. * Attaches the drag behavior the passed in mesh
  35893. * @param ownerNode The mesh that will be dragged around once attached
  35894. */
  35895. attach(ownerNode: AbstractMesh): void;
  35896. /**
  35897. * Force relase the drag action by code.
  35898. */
  35899. releaseDrag(): void;
  35900. private _startDragRay;
  35901. private _lastPointerRay;
  35902. /**
  35903. * Simulates the start of a pointer drag event on the behavior
  35904. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35905. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35906. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35907. */
  35908. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35909. private _startDrag;
  35910. private _dragDelta;
  35911. private _moveDrag;
  35912. private _pickWithRayOnDragPlane;
  35913. private _pointA;
  35914. private _pointB;
  35915. private _pointC;
  35916. private _lineA;
  35917. private _lineB;
  35918. private _localAxis;
  35919. private _lookAt;
  35920. private _updateDragPlanePosition;
  35921. /**
  35922. * Detaches the behavior from the mesh
  35923. */
  35924. detach(): void;
  35925. }
  35926. }
  35927. declare module BABYLON {
  35928. /**
  35929. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35930. */
  35931. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35932. private _dragBehaviorA;
  35933. private _dragBehaviorB;
  35934. private _startDistance;
  35935. private _initialScale;
  35936. private _targetScale;
  35937. private _ownerNode;
  35938. private _sceneRenderObserver;
  35939. /**
  35940. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35941. */
  35942. constructor();
  35943. /**
  35944. * The name of the behavior
  35945. */
  35946. readonly name: string;
  35947. /**
  35948. * Initializes the behavior
  35949. */
  35950. init(): void;
  35951. private _getCurrentDistance;
  35952. /**
  35953. * Attaches the scale behavior the passed in mesh
  35954. * @param ownerNode The mesh that will be scaled around once attached
  35955. */
  35956. attach(ownerNode: Mesh): void;
  35957. /**
  35958. * Detaches the behavior from the mesh
  35959. */
  35960. detach(): void;
  35961. }
  35962. }
  35963. declare module BABYLON {
  35964. /**
  35965. * 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
  35966. */
  35967. export class SixDofDragBehavior implements Behavior<Mesh> {
  35968. private static _virtualScene;
  35969. private _ownerNode;
  35970. private _sceneRenderObserver;
  35971. private _scene;
  35972. private _targetPosition;
  35973. private _virtualOriginMesh;
  35974. private _virtualDragMesh;
  35975. private _pointerObserver;
  35976. private _moving;
  35977. private _startingOrientation;
  35978. /**
  35979. * 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)
  35980. */
  35981. private zDragFactor;
  35982. /**
  35983. * If the object should rotate to face the drag origin
  35984. */
  35985. rotateDraggedObject: boolean;
  35986. /**
  35987. * If the behavior is currently in a dragging state
  35988. */
  35989. dragging: boolean;
  35990. /**
  35991. * 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)
  35992. */
  35993. dragDeltaRatio: number;
  35994. /**
  35995. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35996. */
  35997. currentDraggingPointerID: number;
  35998. /**
  35999. * If camera controls should be detached during the drag
  36000. */
  36001. detachCameraControls: boolean;
  36002. /**
  36003. * Fires each time a drag starts
  36004. */
  36005. onDragStartObservable: Observable<{}>;
  36006. /**
  36007. * Fires each time a drag ends (eg. mouse release after drag)
  36008. */
  36009. onDragEndObservable: Observable<{}>;
  36010. /**
  36011. * 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
  36012. */
  36013. constructor();
  36014. /**
  36015. * The name of the behavior
  36016. */
  36017. readonly name: string;
  36018. /**
  36019. * Initializes the behavior
  36020. */
  36021. init(): void;
  36022. /**
  36023. * Attaches the scale behavior the passed in mesh
  36024. * @param ownerNode The mesh that will be scaled around once attached
  36025. */
  36026. attach(ownerNode: Mesh): void;
  36027. /**
  36028. * Detaches the behavior from the mesh
  36029. */
  36030. detach(): void;
  36031. }
  36032. }
  36033. declare module BABYLON {
  36034. /**
  36035. * Class used to apply inverse kinematics to bones
  36036. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36037. */
  36038. export class BoneIKController {
  36039. private static _tmpVecs;
  36040. private static _tmpQuat;
  36041. private static _tmpMats;
  36042. /**
  36043. * Gets or sets the target mesh
  36044. */
  36045. targetMesh: AbstractMesh;
  36046. /** Gets or sets the mesh used as pole */
  36047. poleTargetMesh: AbstractMesh;
  36048. /**
  36049. * Gets or sets the bone used as pole
  36050. */
  36051. poleTargetBone: Nullable<Bone>;
  36052. /**
  36053. * Gets or sets the target position
  36054. */
  36055. targetPosition: Vector3;
  36056. /**
  36057. * Gets or sets the pole target position
  36058. */
  36059. poleTargetPosition: Vector3;
  36060. /**
  36061. * Gets or sets the pole target local offset
  36062. */
  36063. poleTargetLocalOffset: Vector3;
  36064. /**
  36065. * Gets or sets the pole angle
  36066. */
  36067. poleAngle: number;
  36068. /**
  36069. * Gets or sets the mesh associated with the controller
  36070. */
  36071. mesh: AbstractMesh;
  36072. /**
  36073. * 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)
  36074. */
  36075. slerpAmount: number;
  36076. private _bone1Quat;
  36077. private _bone1Mat;
  36078. private _bone2Ang;
  36079. private _bone1;
  36080. private _bone2;
  36081. private _bone1Length;
  36082. private _bone2Length;
  36083. private _maxAngle;
  36084. private _maxReach;
  36085. private _rightHandedSystem;
  36086. private _bendAxis;
  36087. private _slerping;
  36088. private _adjustRoll;
  36089. /**
  36090. * Gets or sets maximum allowed angle
  36091. */
  36092. maxAngle: number;
  36093. /**
  36094. * Creates a new BoneIKController
  36095. * @param mesh defines the mesh to control
  36096. * @param bone defines the bone to control
  36097. * @param options defines options to set up the controller
  36098. */
  36099. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36100. targetMesh?: AbstractMesh;
  36101. poleTargetMesh?: AbstractMesh;
  36102. poleTargetBone?: Bone;
  36103. poleTargetLocalOffset?: Vector3;
  36104. poleAngle?: number;
  36105. bendAxis?: Vector3;
  36106. maxAngle?: number;
  36107. slerpAmount?: number;
  36108. });
  36109. private _setMaxAngle;
  36110. /**
  36111. * Force the controller to update the bones
  36112. */
  36113. update(): void;
  36114. }
  36115. }
  36116. declare module BABYLON {
  36117. /**
  36118. * Class used to make a bone look toward a point in space
  36119. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36120. */
  36121. export class BoneLookController {
  36122. private static _tmpVecs;
  36123. private static _tmpQuat;
  36124. private static _tmpMats;
  36125. /**
  36126. * The target Vector3 that the bone will look at
  36127. */
  36128. target: Vector3;
  36129. /**
  36130. * The mesh that the bone is attached to
  36131. */
  36132. mesh: AbstractMesh;
  36133. /**
  36134. * The bone that will be looking to the target
  36135. */
  36136. bone: Bone;
  36137. /**
  36138. * The up axis of the coordinate system that is used when the bone is rotated
  36139. */
  36140. upAxis: Vector3;
  36141. /**
  36142. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36143. */
  36144. upAxisSpace: Space;
  36145. /**
  36146. * Used to make an adjustment to the yaw of the bone
  36147. */
  36148. adjustYaw: number;
  36149. /**
  36150. * Used to make an adjustment to the pitch of the bone
  36151. */
  36152. adjustPitch: number;
  36153. /**
  36154. * Used to make an adjustment to the roll of the bone
  36155. */
  36156. adjustRoll: number;
  36157. /**
  36158. * 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)
  36159. */
  36160. slerpAmount: number;
  36161. private _minYaw;
  36162. private _maxYaw;
  36163. private _minPitch;
  36164. private _maxPitch;
  36165. private _minYawSin;
  36166. private _minYawCos;
  36167. private _maxYawSin;
  36168. private _maxYawCos;
  36169. private _midYawConstraint;
  36170. private _minPitchTan;
  36171. private _maxPitchTan;
  36172. private _boneQuat;
  36173. private _slerping;
  36174. private _transformYawPitch;
  36175. private _transformYawPitchInv;
  36176. private _firstFrameSkipped;
  36177. private _yawRange;
  36178. private _fowardAxis;
  36179. /**
  36180. * Gets or sets the minimum yaw angle that the bone can look to
  36181. */
  36182. minYaw: number;
  36183. /**
  36184. * Gets or sets the maximum yaw angle that the bone can look to
  36185. */
  36186. maxYaw: number;
  36187. /**
  36188. * Gets or sets the minimum pitch angle that the bone can look to
  36189. */
  36190. minPitch: number;
  36191. /**
  36192. * Gets or sets the maximum pitch angle that the bone can look to
  36193. */
  36194. maxPitch: number;
  36195. /**
  36196. * Create a BoneLookController
  36197. * @param mesh the mesh that the bone belongs to
  36198. * @param bone the bone that will be looking to the target
  36199. * @param target the target Vector3 to look at
  36200. * @param options optional settings:
  36201. * * maxYaw: the maximum angle the bone will yaw to
  36202. * * minYaw: the minimum angle the bone will yaw to
  36203. * * maxPitch: the maximum angle the bone will pitch to
  36204. * * minPitch: the minimum angle the bone will yaw to
  36205. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36206. * * upAxis: the up axis of the coordinate system
  36207. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36208. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36209. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36210. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36211. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36212. * * adjustRoll: used to make an adjustment to the roll of the bone
  36213. **/
  36214. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36215. maxYaw?: number;
  36216. minYaw?: number;
  36217. maxPitch?: number;
  36218. minPitch?: number;
  36219. slerpAmount?: number;
  36220. upAxis?: Vector3;
  36221. upAxisSpace?: Space;
  36222. yawAxis?: Vector3;
  36223. pitchAxis?: Vector3;
  36224. adjustYaw?: number;
  36225. adjustPitch?: number;
  36226. adjustRoll?: number;
  36227. });
  36228. /**
  36229. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36230. */
  36231. update(): void;
  36232. private _getAngleDiff;
  36233. private _getAngleBetween;
  36234. private _isAngleBetween;
  36235. }
  36236. }
  36237. declare module BABYLON {
  36238. /**
  36239. * Manage the gamepad inputs to control an arc rotate camera.
  36240. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36241. */
  36242. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36243. /**
  36244. * Defines the camera the input is attached to.
  36245. */
  36246. camera: ArcRotateCamera;
  36247. /**
  36248. * Defines the gamepad the input is gathering event from.
  36249. */
  36250. gamepad: Nullable<Gamepad>;
  36251. /**
  36252. * Defines the gamepad rotation sensiblity.
  36253. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36254. */
  36255. gamepadRotationSensibility: number;
  36256. /**
  36257. * Defines the gamepad move sensiblity.
  36258. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36259. */
  36260. gamepadMoveSensibility: number;
  36261. private _onGamepadConnectedObserver;
  36262. private _onGamepadDisconnectedObserver;
  36263. /**
  36264. * Attach the input controls to a specific dom element to get the input from.
  36265. * @param element Defines the element the controls should be listened from
  36266. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36267. */
  36268. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36269. /**
  36270. * Detach the current controls from the specified dom element.
  36271. * @param element Defines the element to stop listening the inputs from
  36272. */
  36273. detachControl(element: Nullable<HTMLElement>): void;
  36274. /**
  36275. * Update the current camera state depending on the inputs that have been used this frame.
  36276. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36277. */
  36278. checkInputs(): void;
  36279. /**
  36280. * Gets the class name of the current intput.
  36281. * @returns the class name
  36282. */
  36283. getClassName(): string;
  36284. /**
  36285. * Get the friendly name associated with the input class.
  36286. * @returns the input friendly name
  36287. */
  36288. getSimpleName(): string;
  36289. }
  36290. }
  36291. declare module BABYLON {
  36292. interface ArcRotateCameraInputsManager {
  36293. /**
  36294. * Add orientation input support to the input manager.
  36295. * @returns the current input manager
  36296. */
  36297. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36298. }
  36299. /**
  36300. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36301. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36302. */
  36303. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36304. /**
  36305. * Defines the camera the input is attached to.
  36306. */
  36307. camera: ArcRotateCamera;
  36308. /**
  36309. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36310. */
  36311. alphaCorrection: number;
  36312. /**
  36313. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36314. */
  36315. gammaCorrection: number;
  36316. private _alpha;
  36317. private _gamma;
  36318. private _dirty;
  36319. private _deviceOrientationHandler;
  36320. /**
  36321. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36322. */
  36323. constructor();
  36324. /**
  36325. * Attach the input controls to a specific dom element to get the input from.
  36326. * @param element Defines the element the controls should be listened from
  36327. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36328. */
  36329. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36330. /** @hidden */
  36331. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36332. /**
  36333. * Update the current camera state depending on the inputs that have been used this frame.
  36334. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36335. */
  36336. checkInputs(): void;
  36337. /**
  36338. * Detach the current controls from the specified dom element.
  36339. * @param element Defines the element to stop listening the inputs from
  36340. */
  36341. detachControl(element: Nullable<HTMLElement>): void;
  36342. /**
  36343. * Gets the class name of the current intput.
  36344. * @returns the class name
  36345. */
  36346. getClassName(): string;
  36347. /**
  36348. * Get the friendly name associated with the input class.
  36349. * @returns the input friendly name
  36350. */
  36351. getSimpleName(): string;
  36352. }
  36353. }
  36354. declare module BABYLON {
  36355. /**
  36356. * Listen to mouse events to control the camera.
  36357. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36358. */
  36359. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36360. /**
  36361. * Defines the camera the input is attached to.
  36362. */
  36363. camera: FlyCamera;
  36364. /**
  36365. * Defines if touch is enabled. (Default is true.)
  36366. */
  36367. touchEnabled: boolean;
  36368. /**
  36369. * Defines the buttons associated with the input to handle camera rotation.
  36370. */
  36371. buttons: number[];
  36372. /**
  36373. * Assign buttons for Yaw control.
  36374. */
  36375. buttonsYaw: number[];
  36376. /**
  36377. * Assign buttons for Pitch control.
  36378. */
  36379. buttonsPitch: number[];
  36380. /**
  36381. * Assign buttons for Roll control.
  36382. */
  36383. buttonsRoll: number[];
  36384. /**
  36385. * Detect if any button is being pressed while mouse is moved.
  36386. * -1 = Mouse locked.
  36387. * 0 = Left button.
  36388. * 1 = Middle Button.
  36389. * 2 = Right Button.
  36390. */
  36391. activeButton: number;
  36392. /**
  36393. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36394. * Higher values reduce its sensitivity.
  36395. */
  36396. angularSensibility: number;
  36397. private _mousemoveCallback;
  36398. private _observer;
  36399. private _rollObserver;
  36400. private previousPosition;
  36401. private noPreventDefault;
  36402. private element;
  36403. /**
  36404. * Listen to mouse events to control the camera.
  36405. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36406. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36407. */
  36408. constructor(touchEnabled?: boolean);
  36409. /**
  36410. * Attach the mouse control to the HTML DOM element.
  36411. * @param element Defines the element that listens to the input events.
  36412. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36413. */
  36414. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36415. /**
  36416. * Detach the current controls from the specified dom element.
  36417. * @param element Defines the element to stop listening the inputs from
  36418. */
  36419. detachControl(element: Nullable<HTMLElement>): void;
  36420. /**
  36421. * Gets the class name of the current input.
  36422. * @returns the class name.
  36423. */
  36424. getClassName(): string;
  36425. /**
  36426. * Get the friendly name associated with the input class.
  36427. * @returns the input's friendly name.
  36428. */
  36429. getSimpleName(): string;
  36430. private _pointerInput;
  36431. private _onMouseMove;
  36432. /**
  36433. * Rotate camera by mouse offset.
  36434. */
  36435. private rotateCamera;
  36436. }
  36437. }
  36438. declare module BABYLON {
  36439. /**
  36440. * Default Inputs manager for the FlyCamera.
  36441. * It groups all the default supported inputs for ease of use.
  36442. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36443. */
  36444. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36445. /**
  36446. * Instantiates a new FlyCameraInputsManager.
  36447. * @param camera Defines the camera the inputs belong to.
  36448. */
  36449. constructor(camera: FlyCamera);
  36450. /**
  36451. * Add keyboard input support to the input manager.
  36452. * @returns the new FlyCameraKeyboardMoveInput().
  36453. */
  36454. addKeyboard(): FlyCameraInputsManager;
  36455. /**
  36456. * Add mouse input support to the input manager.
  36457. * @param touchEnabled Enable touch screen support.
  36458. * @returns the new FlyCameraMouseInput().
  36459. */
  36460. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36461. }
  36462. }
  36463. declare module BABYLON {
  36464. /**
  36465. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36466. * such as in a 3D Space Shooter or a Flight Simulator.
  36467. */
  36468. export class FlyCamera extends TargetCamera {
  36469. /**
  36470. * Define the collision ellipsoid of the camera.
  36471. * This is helpful for simulating a camera body, like a player's body.
  36472. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36473. */
  36474. ellipsoid: Vector3;
  36475. /**
  36476. * Define an offset for the position of the ellipsoid around the camera.
  36477. * This can be helpful if the camera is attached away from the player's body center,
  36478. * such as at its head.
  36479. */
  36480. ellipsoidOffset: Vector3;
  36481. /**
  36482. * Enable or disable collisions of the camera with the rest of the scene objects.
  36483. */
  36484. checkCollisions: boolean;
  36485. /**
  36486. * Enable or disable gravity on the camera.
  36487. */
  36488. applyGravity: boolean;
  36489. /**
  36490. * Define the current direction the camera is moving to.
  36491. */
  36492. cameraDirection: Vector3;
  36493. /**
  36494. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36495. * This overrides and empties cameraRotation.
  36496. */
  36497. rotationQuaternion: Quaternion;
  36498. /**
  36499. * Track Roll to maintain the wanted Rolling when looking around.
  36500. */
  36501. _trackRoll: number;
  36502. /**
  36503. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36504. */
  36505. rollCorrect: number;
  36506. /**
  36507. * Mimic a banked turn, Rolling the camera when Yawing.
  36508. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36509. */
  36510. bankedTurn: boolean;
  36511. /**
  36512. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36513. */
  36514. bankedTurnLimit: number;
  36515. /**
  36516. * Value of 0 disables the banked Roll.
  36517. * Value of 1 is equal to the Yaw angle in radians.
  36518. */
  36519. bankedTurnMultiplier: number;
  36520. /**
  36521. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36522. */
  36523. inputs: FlyCameraInputsManager;
  36524. /**
  36525. * Gets the input sensibility for mouse input.
  36526. * Higher values reduce sensitivity.
  36527. */
  36528. /**
  36529. * Sets the input sensibility for a mouse input.
  36530. * Higher values reduce sensitivity.
  36531. */
  36532. angularSensibility: number;
  36533. /**
  36534. * Get the keys for camera movement forward.
  36535. */
  36536. /**
  36537. * Set the keys for camera movement forward.
  36538. */
  36539. keysForward: number[];
  36540. /**
  36541. * Get the keys for camera movement backward.
  36542. */
  36543. keysBackward: number[];
  36544. /**
  36545. * Get the keys for camera movement up.
  36546. */
  36547. /**
  36548. * Set the keys for camera movement up.
  36549. */
  36550. keysUp: number[];
  36551. /**
  36552. * Get the keys for camera movement down.
  36553. */
  36554. /**
  36555. * Set the keys for camera movement down.
  36556. */
  36557. keysDown: number[];
  36558. /**
  36559. * Get the keys for camera movement left.
  36560. */
  36561. /**
  36562. * Set the keys for camera movement left.
  36563. */
  36564. keysLeft: number[];
  36565. /**
  36566. * Set the keys for camera movement right.
  36567. */
  36568. /**
  36569. * Set the keys for camera movement right.
  36570. */
  36571. keysRight: number[];
  36572. /**
  36573. * Event raised when the camera collides with a mesh in the scene.
  36574. */
  36575. onCollide: (collidedMesh: AbstractMesh) => void;
  36576. private _collider;
  36577. private _needMoveForGravity;
  36578. private _oldPosition;
  36579. private _diffPosition;
  36580. private _newPosition;
  36581. /** @hidden */
  36582. _localDirection: Vector3;
  36583. /** @hidden */
  36584. _transformedDirection: Vector3;
  36585. /**
  36586. * Instantiates a FlyCamera.
  36587. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36588. * such as in a 3D Space Shooter or a Flight Simulator.
  36589. * @param name Define the name of the camera in the scene.
  36590. * @param position Define the starting position of the camera in the scene.
  36591. * @param scene Define the scene the camera belongs to.
  36592. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36593. */
  36594. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36595. /**
  36596. * Attach a control to the HTML DOM element.
  36597. * @param element Defines the element that listens to the input events.
  36598. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36599. */
  36600. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36601. /**
  36602. * Detach a control from the HTML DOM element.
  36603. * The camera will stop reacting to that input.
  36604. * @param element Defines the element that listens to the input events.
  36605. */
  36606. detachControl(element: HTMLElement): void;
  36607. private _collisionMask;
  36608. /**
  36609. * Get the mask that the camera ignores in collision events.
  36610. */
  36611. /**
  36612. * Set the mask that the camera ignores in collision events.
  36613. */
  36614. collisionMask: number;
  36615. /** @hidden */
  36616. _collideWithWorld(displacement: Vector3): void;
  36617. /** @hidden */
  36618. private _onCollisionPositionChange;
  36619. /** @hidden */
  36620. _checkInputs(): void;
  36621. /** @hidden */
  36622. _decideIfNeedsToMove(): boolean;
  36623. /** @hidden */
  36624. _updatePosition(): void;
  36625. /**
  36626. * Restore the Roll to its target value at the rate specified.
  36627. * @param rate - Higher means slower restoring.
  36628. * @hidden
  36629. */
  36630. restoreRoll(rate: number): void;
  36631. /**
  36632. * Destroy the camera and release the current resources held by it.
  36633. */
  36634. dispose(): void;
  36635. /**
  36636. * Get the current object class name.
  36637. * @returns the class name.
  36638. */
  36639. getClassName(): string;
  36640. }
  36641. }
  36642. declare module BABYLON {
  36643. /**
  36644. * Listen to keyboard events to control the camera.
  36645. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36646. */
  36647. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36648. /**
  36649. * Defines the camera the input is attached to.
  36650. */
  36651. camera: FlyCamera;
  36652. /**
  36653. * The list of keyboard keys used to control the forward move of the camera.
  36654. */
  36655. keysForward: number[];
  36656. /**
  36657. * The list of keyboard keys used to control the backward move of the camera.
  36658. */
  36659. keysBackward: number[];
  36660. /**
  36661. * The list of keyboard keys used to control the forward move of the camera.
  36662. */
  36663. keysUp: number[];
  36664. /**
  36665. * The list of keyboard keys used to control the backward move of the camera.
  36666. */
  36667. keysDown: number[];
  36668. /**
  36669. * The list of keyboard keys used to control the right strafe move of the camera.
  36670. */
  36671. keysRight: number[];
  36672. /**
  36673. * The list of keyboard keys used to control the left strafe move of the camera.
  36674. */
  36675. keysLeft: number[];
  36676. private _keys;
  36677. private _onCanvasBlurObserver;
  36678. private _onKeyboardObserver;
  36679. private _engine;
  36680. private _scene;
  36681. /**
  36682. * Attach the input controls to a specific dom element to get the input from.
  36683. * @param element Defines the element the controls should be listened from
  36684. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36685. */
  36686. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36687. /**
  36688. * Detach the current controls from the specified dom element.
  36689. * @param element Defines the element to stop listening the inputs from
  36690. */
  36691. detachControl(element: Nullable<HTMLElement>): void;
  36692. /**
  36693. * Gets the class name of the current intput.
  36694. * @returns the class name
  36695. */
  36696. getClassName(): string;
  36697. /** @hidden */
  36698. _onLostFocus(e: FocusEvent): void;
  36699. /**
  36700. * Get the friendly name associated with the input class.
  36701. * @returns the input friendly name
  36702. */
  36703. getSimpleName(): string;
  36704. /**
  36705. * Update the current camera state depending on the inputs that have been used this frame.
  36706. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36707. */
  36708. checkInputs(): void;
  36709. }
  36710. }
  36711. declare module BABYLON {
  36712. /**
  36713. * Manage the mouse wheel inputs to control a follow camera.
  36714. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36715. */
  36716. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36717. /**
  36718. * Defines the camera the input is attached to.
  36719. */
  36720. camera: FollowCamera;
  36721. /**
  36722. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36723. */
  36724. axisControlRadius: boolean;
  36725. /**
  36726. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36727. */
  36728. axisControlHeight: boolean;
  36729. /**
  36730. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36731. */
  36732. axisControlRotation: boolean;
  36733. /**
  36734. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36735. * relation to mouseWheel events.
  36736. */
  36737. wheelPrecision: number;
  36738. /**
  36739. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36740. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36741. */
  36742. wheelDeltaPercentage: number;
  36743. private _wheel;
  36744. private _observer;
  36745. /**
  36746. * Attach the input controls to a specific dom element to get the input from.
  36747. * @param element Defines the element the controls should be listened from
  36748. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36749. */
  36750. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36751. /**
  36752. * Detach the current controls from the specified dom element.
  36753. * @param element Defines the element to stop listening the inputs from
  36754. */
  36755. detachControl(element: Nullable<HTMLElement>): void;
  36756. /**
  36757. * Gets the class name of the current intput.
  36758. * @returns the class name
  36759. */
  36760. getClassName(): string;
  36761. /**
  36762. * Get the friendly name associated with the input class.
  36763. * @returns the input friendly name
  36764. */
  36765. getSimpleName(): string;
  36766. }
  36767. }
  36768. declare module BABYLON {
  36769. /**
  36770. * Manage the pointers inputs to control an follow camera.
  36771. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36772. */
  36773. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36774. /**
  36775. * Defines the camera the input is attached to.
  36776. */
  36777. camera: FollowCamera;
  36778. /**
  36779. * Gets the class name of the current input.
  36780. * @returns the class name
  36781. */
  36782. getClassName(): string;
  36783. /**
  36784. * Defines the pointer angular sensibility along the X axis or how fast is
  36785. * the camera rotating.
  36786. * A negative number will reverse the axis direction.
  36787. */
  36788. angularSensibilityX: number;
  36789. /**
  36790. * Defines the pointer angular sensibility along the Y axis or how fast is
  36791. * the camera rotating.
  36792. * A negative number will reverse the axis direction.
  36793. */
  36794. angularSensibilityY: number;
  36795. /**
  36796. * Defines the pointer pinch precision or how fast is the camera zooming.
  36797. * A negative number will reverse the axis direction.
  36798. */
  36799. pinchPrecision: number;
  36800. /**
  36801. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36802. * from 0.
  36803. * It defines the percentage of current camera.radius to use as delta when
  36804. * pinch zoom is used.
  36805. */
  36806. pinchDeltaPercentage: number;
  36807. /**
  36808. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36809. */
  36810. axisXControlRadius: boolean;
  36811. /**
  36812. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36813. */
  36814. axisXControlHeight: boolean;
  36815. /**
  36816. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36817. */
  36818. axisXControlRotation: boolean;
  36819. /**
  36820. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36821. */
  36822. axisYControlRadius: boolean;
  36823. /**
  36824. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36825. */
  36826. axisYControlHeight: boolean;
  36827. /**
  36828. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36829. */
  36830. axisYControlRotation: boolean;
  36831. /**
  36832. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36833. */
  36834. axisPinchControlRadius: boolean;
  36835. /**
  36836. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36837. */
  36838. axisPinchControlHeight: boolean;
  36839. /**
  36840. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36841. */
  36842. axisPinchControlRotation: boolean;
  36843. /**
  36844. * Log error messages if basic misconfiguration has occurred.
  36845. */
  36846. warningEnable: boolean;
  36847. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36848. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36849. private _warningCounter;
  36850. private _warning;
  36851. }
  36852. }
  36853. declare module BABYLON {
  36854. /**
  36855. * Default Inputs manager for the FollowCamera.
  36856. * It groups all the default supported inputs for ease of use.
  36857. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36858. */
  36859. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36860. /**
  36861. * Instantiates a new FollowCameraInputsManager.
  36862. * @param camera Defines the camera the inputs belong to
  36863. */
  36864. constructor(camera: FollowCamera);
  36865. /**
  36866. * Add keyboard input support to the input manager.
  36867. * @returns the current input manager
  36868. */
  36869. addKeyboard(): FollowCameraInputsManager;
  36870. /**
  36871. * Add mouse wheel input support to the input manager.
  36872. * @returns the current input manager
  36873. */
  36874. addMouseWheel(): FollowCameraInputsManager;
  36875. /**
  36876. * Add pointers input support to the input manager.
  36877. * @returns the current input manager
  36878. */
  36879. addPointers(): FollowCameraInputsManager;
  36880. /**
  36881. * Add orientation input support to the input manager.
  36882. * @returns the current input manager
  36883. */
  36884. addVRDeviceOrientation(): FollowCameraInputsManager;
  36885. }
  36886. }
  36887. declare module BABYLON {
  36888. /**
  36889. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36890. * an arc rotate version arcFollowCamera are available.
  36891. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36892. */
  36893. export class FollowCamera extends TargetCamera {
  36894. /**
  36895. * Distance the follow camera should follow an object at
  36896. */
  36897. radius: number;
  36898. /**
  36899. * Minimum allowed distance of the camera to the axis of rotation
  36900. * (The camera can not get closer).
  36901. * This can help limiting how the Camera is able to move in the scene.
  36902. */
  36903. lowerRadiusLimit: Nullable<number>;
  36904. /**
  36905. * Maximum allowed distance of the camera to the axis of rotation
  36906. * (The camera can not get further).
  36907. * This can help limiting how the Camera is able to move in the scene.
  36908. */
  36909. upperRadiusLimit: Nullable<number>;
  36910. /**
  36911. * Define a rotation offset between the camera and the object it follows
  36912. */
  36913. rotationOffset: number;
  36914. /**
  36915. * Minimum allowed angle to camera position relative to target object.
  36916. * This can help limiting how the Camera is able to move in the scene.
  36917. */
  36918. lowerRotationOffsetLimit: Nullable<number>;
  36919. /**
  36920. * Maximum allowed angle to camera position relative to target object.
  36921. * This can help limiting how the Camera is able to move in the scene.
  36922. */
  36923. upperRotationOffsetLimit: Nullable<number>;
  36924. /**
  36925. * Define a height offset between the camera and the object it follows.
  36926. * It can help following an object from the top (like a car chaing a plane)
  36927. */
  36928. heightOffset: number;
  36929. /**
  36930. * Minimum allowed height of camera position relative to target object.
  36931. * This can help limiting how the Camera is able to move in the scene.
  36932. */
  36933. lowerHeightOffsetLimit: Nullable<number>;
  36934. /**
  36935. * Maximum allowed height of camera position relative to target object.
  36936. * This can help limiting how the Camera is able to move in the scene.
  36937. */
  36938. upperHeightOffsetLimit: Nullable<number>;
  36939. /**
  36940. * Define how fast the camera can accelerate to follow it s target.
  36941. */
  36942. cameraAcceleration: number;
  36943. /**
  36944. * Define the speed limit of the camera following an object.
  36945. */
  36946. maxCameraSpeed: number;
  36947. /**
  36948. * Define the target of the camera.
  36949. */
  36950. lockedTarget: Nullable<AbstractMesh>;
  36951. /**
  36952. * Defines the input associated with the camera.
  36953. */
  36954. inputs: FollowCameraInputsManager;
  36955. /**
  36956. * Instantiates the follow camera.
  36957. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36958. * @param name Define the name of the camera in the scene
  36959. * @param position Define the position of the camera
  36960. * @param scene Define the scene the camera belong to
  36961. * @param lockedTarget Define the target of the camera
  36962. */
  36963. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36964. private _follow;
  36965. /**
  36966. * Attached controls to the current camera.
  36967. * @param element Defines the element the controls should be listened from
  36968. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36969. */
  36970. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36971. /**
  36972. * Detach the current controls from the camera.
  36973. * The camera will stop reacting to inputs.
  36974. * @param element Defines the element to stop listening the inputs from
  36975. */
  36976. detachControl(element: HTMLElement): void;
  36977. /** @hidden */
  36978. _checkInputs(): void;
  36979. private _checkLimits;
  36980. /**
  36981. * Gets the camera class name.
  36982. * @returns the class name
  36983. */
  36984. getClassName(): string;
  36985. }
  36986. /**
  36987. * Arc Rotate version of the follow camera.
  36988. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36989. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36990. */
  36991. export class ArcFollowCamera extends TargetCamera {
  36992. /** The longitudinal angle of the camera */
  36993. alpha: number;
  36994. /** The latitudinal angle of the camera */
  36995. beta: number;
  36996. /** The radius of the camera from its target */
  36997. radius: number;
  36998. /** Define the camera target (the messh it should follow) */
  36999. target: Nullable<AbstractMesh>;
  37000. private _cartesianCoordinates;
  37001. /**
  37002. * Instantiates a new ArcFollowCamera
  37003. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37004. * @param name Define the name of the camera
  37005. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37006. * @param beta Define the rotation angle of the camera around the elevation axis
  37007. * @param radius Define the radius of the camera from its target point
  37008. * @param target Define the target of the camera
  37009. * @param scene Define the scene the camera belongs to
  37010. */
  37011. constructor(name: string,
  37012. /** The longitudinal angle of the camera */
  37013. alpha: number,
  37014. /** The latitudinal angle of the camera */
  37015. beta: number,
  37016. /** The radius of the camera from its target */
  37017. radius: number,
  37018. /** Define the camera target (the messh it should follow) */
  37019. target: Nullable<AbstractMesh>, scene: Scene);
  37020. private _follow;
  37021. /** @hidden */
  37022. _checkInputs(): void;
  37023. /**
  37024. * Returns the class name of the object.
  37025. * It is mostly used internally for serialization purposes.
  37026. */
  37027. getClassName(): string;
  37028. }
  37029. }
  37030. declare module BABYLON {
  37031. /**
  37032. * Manage the keyboard inputs to control the movement of a follow camera.
  37033. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37034. */
  37035. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37036. /**
  37037. * Defines the camera the input is attached to.
  37038. */
  37039. camera: FollowCamera;
  37040. /**
  37041. * Defines the list of key codes associated with the up action (increase heightOffset)
  37042. */
  37043. keysHeightOffsetIncr: number[];
  37044. /**
  37045. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37046. */
  37047. keysHeightOffsetDecr: number[];
  37048. /**
  37049. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37050. */
  37051. keysHeightOffsetModifierAlt: boolean;
  37052. /**
  37053. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37054. */
  37055. keysHeightOffsetModifierCtrl: boolean;
  37056. /**
  37057. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37058. */
  37059. keysHeightOffsetModifierShift: boolean;
  37060. /**
  37061. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37062. */
  37063. keysRotationOffsetIncr: number[];
  37064. /**
  37065. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37066. */
  37067. keysRotationOffsetDecr: number[];
  37068. /**
  37069. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37070. */
  37071. keysRotationOffsetModifierAlt: boolean;
  37072. /**
  37073. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37074. */
  37075. keysRotationOffsetModifierCtrl: boolean;
  37076. /**
  37077. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37078. */
  37079. keysRotationOffsetModifierShift: boolean;
  37080. /**
  37081. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37082. */
  37083. keysRadiusIncr: number[];
  37084. /**
  37085. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37086. */
  37087. keysRadiusDecr: number[];
  37088. /**
  37089. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37090. */
  37091. keysRadiusModifierAlt: boolean;
  37092. /**
  37093. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37094. */
  37095. keysRadiusModifierCtrl: boolean;
  37096. /**
  37097. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37098. */
  37099. keysRadiusModifierShift: boolean;
  37100. /**
  37101. * Defines the rate of change of heightOffset.
  37102. */
  37103. heightSensibility: number;
  37104. /**
  37105. * Defines the rate of change of rotationOffset.
  37106. */
  37107. rotationSensibility: number;
  37108. /**
  37109. * Defines the rate of change of radius.
  37110. */
  37111. radiusSensibility: number;
  37112. private _keys;
  37113. private _ctrlPressed;
  37114. private _altPressed;
  37115. private _shiftPressed;
  37116. private _onCanvasBlurObserver;
  37117. private _onKeyboardObserver;
  37118. private _engine;
  37119. private _scene;
  37120. /**
  37121. * Attach the input controls to a specific dom element to get the input from.
  37122. * @param element Defines the element the controls should be listened from
  37123. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37124. */
  37125. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37126. /**
  37127. * Detach the current controls from the specified dom element.
  37128. * @param element Defines the element to stop listening the inputs from
  37129. */
  37130. detachControl(element: Nullable<HTMLElement>): void;
  37131. /**
  37132. * Update the current camera state depending on the inputs that have been used this frame.
  37133. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37134. */
  37135. checkInputs(): void;
  37136. /**
  37137. * Gets the class name of the current input.
  37138. * @returns the class name
  37139. */
  37140. getClassName(): string;
  37141. /**
  37142. * Get the friendly name associated with the input class.
  37143. * @returns the input friendly name
  37144. */
  37145. getSimpleName(): string;
  37146. /**
  37147. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37148. * allow modification of the heightOffset value.
  37149. */
  37150. private _modifierHeightOffset;
  37151. /**
  37152. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37153. * allow modification of the rotationOffset value.
  37154. */
  37155. private _modifierRotationOffset;
  37156. /**
  37157. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37158. * allow modification of the radius value.
  37159. */
  37160. private _modifierRadius;
  37161. }
  37162. }
  37163. declare module BABYLON {
  37164. interface FreeCameraInputsManager {
  37165. /**
  37166. * @hidden
  37167. */
  37168. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37169. /**
  37170. * Add orientation input support to the input manager.
  37171. * @returns the current input manager
  37172. */
  37173. addDeviceOrientation(): FreeCameraInputsManager;
  37174. }
  37175. /**
  37176. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37177. * Screen rotation is taken into account.
  37178. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37179. */
  37180. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37181. private _camera;
  37182. private _screenOrientationAngle;
  37183. private _constantTranform;
  37184. private _screenQuaternion;
  37185. private _alpha;
  37186. private _beta;
  37187. private _gamma;
  37188. /**
  37189. * @hidden
  37190. */
  37191. _onDeviceOrientationChangedObservable: Observable<void>;
  37192. /**
  37193. * Instantiates a new input
  37194. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37195. */
  37196. constructor();
  37197. /**
  37198. * Define the camera controlled by the input.
  37199. */
  37200. camera: FreeCamera;
  37201. /**
  37202. * Attach the input controls to a specific dom element to get the input from.
  37203. * @param element Defines the element the controls should be listened from
  37204. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37205. */
  37206. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37207. private _orientationChanged;
  37208. private _deviceOrientation;
  37209. /**
  37210. * Detach the current controls from the specified dom element.
  37211. * @param element Defines the element to stop listening the inputs from
  37212. */
  37213. detachControl(element: Nullable<HTMLElement>): void;
  37214. /**
  37215. * Update the current camera state depending on the inputs that have been used this frame.
  37216. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37217. */
  37218. checkInputs(): void;
  37219. /**
  37220. * Gets the class name of the current intput.
  37221. * @returns the class name
  37222. */
  37223. getClassName(): string;
  37224. /**
  37225. * Get the friendly name associated with the input class.
  37226. * @returns the input friendly name
  37227. */
  37228. getSimpleName(): string;
  37229. }
  37230. }
  37231. declare module BABYLON {
  37232. /**
  37233. * Manage the gamepad inputs to control a free camera.
  37234. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37235. */
  37236. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37237. /**
  37238. * Define the camera the input is attached to.
  37239. */
  37240. camera: FreeCamera;
  37241. /**
  37242. * Define the Gamepad controlling the input
  37243. */
  37244. gamepad: Nullable<Gamepad>;
  37245. /**
  37246. * Defines the gamepad rotation sensiblity.
  37247. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37248. */
  37249. gamepadAngularSensibility: number;
  37250. /**
  37251. * Defines the gamepad move sensiblity.
  37252. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37253. */
  37254. gamepadMoveSensibility: number;
  37255. private _onGamepadConnectedObserver;
  37256. private _onGamepadDisconnectedObserver;
  37257. private _cameraTransform;
  37258. private _deltaTransform;
  37259. private _vector3;
  37260. private _vector2;
  37261. /**
  37262. * Attach the input controls to a specific dom element to get the input from.
  37263. * @param element Defines the element the controls should be listened from
  37264. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37265. */
  37266. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37267. /**
  37268. * Detach the current controls from the specified dom element.
  37269. * @param element Defines the element to stop listening the inputs from
  37270. */
  37271. detachControl(element: Nullable<HTMLElement>): void;
  37272. /**
  37273. * Update the current camera state depending on the inputs that have been used this frame.
  37274. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37275. */
  37276. checkInputs(): void;
  37277. /**
  37278. * Gets the class name of the current intput.
  37279. * @returns the class name
  37280. */
  37281. getClassName(): string;
  37282. /**
  37283. * Get the friendly name associated with the input class.
  37284. * @returns the input friendly name
  37285. */
  37286. getSimpleName(): string;
  37287. }
  37288. }
  37289. declare module BABYLON {
  37290. /**
  37291. * Defines the potential axis of a Joystick
  37292. */
  37293. export enum JoystickAxis {
  37294. /** X axis */
  37295. X = 0,
  37296. /** Y axis */
  37297. Y = 1,
  37298. /** Z axis */
  37299. Z = 2
  37300. }
  37301. /**
  37302. * Class used to define virtual joystick (used in touch mode)
  37303. */
  37304. export class VirtualJoystick {
  37305. /**
  37306. * Gets or sets a boolean indicating that left and right values must be inverted
  37307. */
  37308. reverseLeftRight: boolean;
  37309. /**
  37310. * Gets or sets a boolean indicating that up and down values must be inverted
  37311. */
  37312. reverseUpDown: boolean;
  37313. /**
  37314. * Gets the offset value for the position (ie. the change of the position value)
  37315. */
  37316. deltaPosition: Vector3;
  37317. /**
  37318. * Gets a boolean indicating if the virtual joystick was pressed
  37319. */
  37320. pressed: boolean;
  37321. /**
  37322. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37323. */
  37324. static Canvas: Nullable<HTMLCanvasElement>;
  37325. private static _globalJoystickIndex;
  37326. private static vjCanvasContext;
  37327. private static vjCanvasWidth;
  37328. private static vjCanvasHeight;
  37329. private static halfWidth;
  37330. private _action;
  37331. private _axisTargetedByLeftAndRight;
  37332. private _axisTargetedByUpAndDown;
  37333. private _joystickSensibility;
  37334. private _inversedSensibility;
  37335. private _joystickPointerID;
  37336. private _joystickColor;
  37337. private _joystickPointerPos;
  37338. private _joystickPreviousPointerPos;
  37339. private _joystickPointerStartPos;
  37340. private _deltaJoystickVector;
  37341. private _leftJoystick;
  37342. private _touches;
  37343. private _onPointerDownHandlerRef;
  37344. private _onPointerMoveHandlerRef;
  37345. private _onPointerUpHandlerRef;
  37346. private _onResize;
  37347. /**
  37348. * Creates a new virtual joystick
  37349. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37350. */
  37351. constructor(leftJoystick?: boolean);
  37352. /**
  37353. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37354. * @param newJoystickSensibility defines the new sensibility
  37355. */
  37356. setJoystickSensibility(newJoystickSensibility: number): void;
  37357. private _onPointerDown;
  37358. private _onPointerMove;
  37359. private _onPointerUp;
  37360. /**
  37361. * Change the color of the virtual joystick
  37362. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37363. */
  37364. setJoystickColor(newColor: string): void;
  37365. /**
  37366. * Defines a callback to call when the joystick is touched
  37367. * @param action defines the callback
  37368. */
  37369. setActionOnTouch(action: () => any): void;
  37370. /**
  37371. * Defines which axis you'd like to control for left & right
  37372. * @param axis defines the axis to use
  37373. */
  37374. setAxisForLeftRight(axis: JoystickAxis): void;
  37375. /**
  37376. * Defines which axis you'd like to control for up & down
  37377. * @param axis defines the axis to use
  37378. */
  37379. setAxisForUpDown(axis: JoystickAxis): void;
  37380. private _drawVirtualJoystick;
  37381. /**
  37382. * Release internal HTML canvas
  37383. */
  37384. releaseCanvas(): void;
  37385. }
  37386. }
  37387. declare module BABYLON {
  37388. interface FreeCameraInputsManager {
  37389. /**
  37390. * Add virtual joystick input support to the input manager.
  37391. * @returns the current input manager
  37392. */
  37393. addVirtualJoystick(): FreeCameraInputsManager;
  37394. }
  37395. /**
  37396. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37397. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37398. */
  37399. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37400. /**
  37401. * Defines the camera the input is attached to.
  37402. */
  37403. camera: FreeCamera;
  37404. private _leftjoystick;
  37405. private _rightjoystick;
  37406. /**
  37407. * Gets the left stick of the virtual joystick.
  37408. * @returns The virtual Joystick
  37409. */
  37410. getLeftJoystick(): VirtualJoystick;
  37411. /**
  37412. * Gets the right stick of the virtual joystick.
  37413. * @returns The virtual Joystick
  37414. */
  37415. getRightJoystick(): VirtualJoystick;
  37416. /**
  37417. * Update the current camera state depending on the inputs that have been used this frame.
  37418. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37419. */
  37420. checkInputs(): void;
  37421. /**
  37422. * Attach the input controls to a specific dom element to get the input from.
  37423. * @param element Defines the element the controls should be listened from
  37424. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37425. */
  37426. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37427. /**
  37428. * Detach the current controls from the specified dom element.
  37429. * @param element Defines the element to stop listening the inputs from
  37430. */
  37431. detachControl(element: Nullable<HTMLElement>): void;
  37432. /**
  37433. * Gets the class name of the current intput.
  37434. * @returns the class name
  37435. */
  37436. getClassName(): string;
  37437. /**
  37438. * Get the friendly name associated with the input class.
  37439. * @returns the input friendly name
  37440. */
  37441. getSimpleName(): string;
  37442. }
  37443. }
  37444. declare module BABYLON {
  37445. /**
  37446. * This represents a FPS type of camera controlled by touch.
  37447. * This is like a universal camera minus the Gamepad controls.
  37448. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37449. */
  37450. export class TouchCamera extends FreeCamera {
  37451. /**
  37452. * Defines the touch sensibility for rotation.
  37453. * The higher the faster.
  37454. */
  37455. touchAngularSensibility: number;
  37456. /**
  37457. * Defines the touch sensibility for move.
  37458. * The higher the faster.
  37459. */
  37460. touchMoveSensibility: number;
  37461. /**
  37462. * Instantiates a new touch camera.
  37463. * This represents a FPS type of camera controlled by touch.
  37464. * This is like a universal camera minus the Gamepad controls.
  37465. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37466. * @param name Define the name of the camera in the scene
  37467. * @param position Define the start position of the camera in the scene
  37468. * @param scene Define the scene the camera belongs to
  37469. */
  37470. constructor(name: string, position: Vector3, scene: Scene);
  37471. /**
  37472. * Gets the current object class name.
  37473. * @return the class name
  37474. */
  37475. getClassName(): string;
  37476. /** @hidden */
  37477. _setupInputs(): void;
  37478. }
  37479. }
  37480. declare module BABYLON {
  37481. /**
  37482. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37483. * being tilted forward or back and left or right.
  37484. */
  37485. export class DeviceOrientationCamera extends FreeCamera {
  37486. private _initialQuaternion;
  37487. private _quaternionCache;
  37488. private _tmpDragQuaternion;
  37489. /**
  37490. * Creates a new device orientation camera
  37491. * @param name The name of the camera
  37492. * @param position The start position camera
  37493. * @param scene The scene the camera belongs to
  37494. */
  37495. constructor(name: string, position: Vector3, scene: Scene);
  37496. /**
  37497. * @hidden
  37498. * Disabled pointer input on first orientation sensor update (Default: true)
  37499. */
  37500. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  37501. private _dragFactor;
  37502. /**
  37503. * Enabled turning on the y axis when the orientation sensor is active
  37504. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37505. */
  37506. enableHorizontalDragging(dragFactor?: number): void;
  37507. /**
  37508. * Gets the current instance class name ("DeviceOrientationCamera").
  37509. * This helps avoiding instanceof at run time.
  37510. * @returns the class name
  37511. */
  37512. getClassName(): string;
  37513. /**
  37514. * @hidden
  37515. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37516. */
  37517. _checkInputs(): void;
  37518. /**
  37519. * Reset the camera to its default orientation on the specified axis only.
  37520. * @param axis The axis to reset
  37521. */
  37522. resetToCurrentRotation(axis?: Axis): void;
  37523. }
  37524. }
  37525. declare module BABYLON {
  37526. /**
  37527. * Defines supported buttons for XBox360 compatible gamepads
  37528. */
  37529. export enum Xbox360Button {
  37530. /** A */
  37531. A = 0,
  37532. /** B */
  37533. B = 1,
  37534. /** X */
  37535. X = 2,
  37536. /** Y */
  37537. Y = 3,
  37538. /** Start */
  37539. Start = 4,
  37540. /** Back */
  37541. Back = 5,
  37542. /** Left button */
  37543. LB = 6,
  37544. /** Right button */
  37545. RB = 7,
  37546. /** Left stick */
  37547. LeftStick = 8,
  37548. /** Right stick */
  37549. RightStick = 9
  37550. }
  37551. /** Defines values for XBox360 DPad */
  37552. export enum Xbox360Dpad {
  37553. /** Up */
  37554. Up = 0,
  37555. /** Down */
  37556. Down = 1,
  37557. /** Left */
  37558. Left = 2,
  37559. /** Right */
  37560. Right = 3
  37561. }
  37562. /**
  37563. * Defines a XBox360 gamepad
  37564. */
  37565. export class Xbox360Pad extends Gamepad {
  37566. private _leftTrigger;
  37567. private _rightTrigger;
  37568. private _onlefttriggerchanged;
  37569. private _onrighttriggerchanged;
  37570. private _onbuttondown;
  37571. private _onbuttonup;
  37572. private _ondpaddown;
  37573. private _ondpadup;
  37574. /** Observable raised when a button is pressed */
  37575. onButtonDownObservable: Observable<Xbox360Button>;
  37576. /** Observable raised when a button is released */
  37577. onButtonUpObservable: Observable<Xbox360Button>;
  37578. /** Observable raised when a pad is pressed */
  37579. onPadDownObservable: Observable<Xbox360Dpad>;
  37580. /** Observable raised when a pad is released */
  37581. onPadUpObservable: Observable<Xbox360Dpad>;
  37582. private _buttonA;
  37583. private _buttonB;
  37584. private _buttonX;
  37585. private _buttonY;
  37586. private _buttonBack;
  37587. private _buttonStart;
  37588. private _buttonLB;
  37589. private _buttonRB;
  37590. private _buttonLeftStick;
  37591. private _buttonRightStick;
  37592. private _dPadUp;
  37593. private _dPadDown;
  37594. private _dPadLeft;
  37595. private _dPadRight;
  37596. private _isXboxOnePad;
  37597. /**
  37598. * Creates a new XBox360 gamepad object
  37599. * @param id defines the id of this gamepad
  37600. * @param index defines its index
  37601. * @param gamepad defines the internal HTML gamepad object
  37602. * @param xboxOne defines if it is a XBox One gamepad
  37603. */
  37604. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37605. /**
  37606. * Defines the callback to call when left trigger is pressed
  37607. * @param callback defines the callback to use
  37608. */
  37609. onlefttriggerchanged(callback: (value: number) => void): void;
  37610. /**
  37611. * Defines the callback to call when right trigger is pressed
  37612. * @param callback defines the callback to use
  37613. */
  37614. onrighttriggerchanged(callback: (value: number) => void): void;
  37615. /**
  37616. * Gets the left trigger value
  37617. */
  37618. /**
  37619. * Sets the left trigger value
  37620. */
  37621. leftTrigger: number;
  37622. /**
  37623. * Gets the right trigger value
  37624. */
  37625. /**
  37626. * Sets the right trigger value
  37627. */
  37628. rightTrigger: number;
  37629. /**
  37630. * Defines the callback to call when a button is pressed
  37631. * @param callback defines the callback to use
  37632. */
  37633. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37634. /**
  37635. * Defines the callback to call when a button is released
  37636. * @param callback defines the callback to use
  37637. */
  37638. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37639. /**
  37640. * Defines the callback to call when a pad is pressed
  37641. * @param callback defines the callback to use
  37642. */
  37643. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37644. /**
  37645. * Defines the callback to call when a pad is released
  37646. * @param callback defines the callback to use
  37647. */
  37648. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37649. private _setButtonValue;
  37650. private _setDPadValue;
  37651. /**
  37652. * Gets the value of the `A` button
  37653. */
  37654. /**
  37655. * Sets the value of the `A` button
  37656. */
  37657. buttonA: number;
  37658. /**
  37659. * Gets the value of the `B` button
  37660. */
  37661. /**
  37662. * Sets the value of the `B` button
  37663. */
  37664. buttonB: number;
  37665. /**
  37666. * Gets the value of the `X` button
  37667. */
  37668. /**
  37669. * Sets the value of the `X` button
  37670. */
  37671. buttonX: number;
  37672. /**
  37673. * Gets the value of the `Y` button
  37674. */
  37675. /**
  37676. * Sets the value of the `Y` button
  37677. */
  37678. buttonY: number;
  37679. /**
  37680. * Gets the value of the `Start` button
  37681. */
  37682. /**
  37683. * Sets the value of the `Start` button
  37684. */
  37685. buttonStart: number;
  37686. /**
  37687. * Gets the value of the `Back` button
  37688. */
  37689. /**
  37690. * Sets the value of the `Back` button
  37691. */
  37692. buttonBack: number;
  37693. /**
  37694. * Gets the value of the `Left` button
  37695. */
  37696. /**
  37697. * Sets the value of the `Left` button
  37698. */
  37699. buttonLB: number;
  37700. /**
  37701. * Gets the value of the `Right` button
  37702. */
  37703. /**
  37704. * Sets the value of the `Right` button
  37705. */
  37706. buttonRB: number;
  37707. /**
  37708. * Gets the value of the Left joystick
  37709. */
  37710. /**
  37711. * Sets the value of the Left joystick
  37712. */
  37713. buttonLeftStick: number;
  37714. /**
  37715. * Gets the value of the Right joystick
  37716. */
  37717. /**
  37718. * Sets the value of the Right joystick
  37719. */
  37720. buttonRightStick: number;
  37721. /**
  37722. * Gets the value of D-pad up
  37723. */
  37724. /**
  37725. * Sets the value of D-pad up
  37726. */
  37727. dPadUp: number;
  37728. /**
  37729. * Gets the value of D-pad down
  37730. */
  37731. /**
  37732. * Sets the value of D-pad down
  37733. */
  37734. dPadDown: number;
  37735. /**
  37736. * Gets the value of D-pad left
  37737. */
  37738. /**
  37739. * Sets the value of D-pad left
  37740. */
  37741. dPadLeft: number;
  37742. /**
  37743. * Gets the value of D-pad right
  37744. */
  37745. /**
  37746. * Sets the value of D-pad right
  37747. */
  37748. dPadRight: number;
  37749. /**
  37750. * Force the gamepad to synchronize with device values
  37751. */
  37752. update(): void;
  37753. /**
  37754. * Disposes the gamepad
  37755. */
  37756. dispose(): void;
  37757. }
  37758. }
  37759. declare module BABYLON {
  37760. /**
  37761. * Manager for handling gamepads
  37762. */
  37763. export class GamepadManager {
  37764. private _scene?;
  37765. private _babylonGamepads;
  37766. private _oneGamepadConnected;
  37767. /** @hidden */
  37768. _isMonitoring: boolean;
  37769. private _gamepadEventSupported;
  37770. private _gamepadSupport;
  37771. /**
  37772. * observable to be triggered when the gamepad controller has been connected
  37773. */
  37774. onGamepadConnectedObservable: Observable<Gamepad>;
  37775. /**
  37776. * observable to be triggered when the gamepad controller has been disconnected
  37777. */
  37778. onGamepadDisconnectedObservable: Observable<Gamepad>;
  37779. private _onGamepadConnectedEvent;
  37780. private _onGamepadDisconnectedEvent;
  37781. /**
  37782. * Initializes the gamepad manager
  37783. * @param _scene BabylonJS scene
  37784. */
  37785. constructor(_scene?: Scene | undefined);
  37786. /**
  37787. * The gamepads in the game pad manager
  37788. */
  37789. readonly gamepads: Gamepad[];
  37790. /**
  37791. * Get the gamepad controllers based on type
  37792. * @param type The type of gamepad controller
  37793. * @returns Nullable gamepad
  37794. */
  37795. getGamepadByType(type?: number): Nullable<Gamepad>;
  37796. /**
  37797. * Disposes the gamepad manager
  37798. */
  37799. dispose(): void;
  37800. private _addNewGamepad;
  37801. private _startMonitoringGamepads;
  37802. private _stopMonitoringGamepads;
  37803. /** @hidden */
  37804. _checkGamepadsStatus(): void;
  37805. private _updateGamepadObjects;
  37806. }
  37807. }
  37808. declare module BABYLON {
  37809. interface Scene {
  37810. /** @hidden */
  37811. _gamepadManager: Nullable<GamepadManager>;
  37812. /**
  37813. * Gets the gamepad manager associated with the scene
  37814. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  37815. */
  37816. gamepadManager: GamepadManager;
  37817. }
  37818. /**
  37819. * Interface representing a free camera inputs manager
  37820. */
  37821. interface FreeCameraInputsManager {
  37822. /**
  37823. * Adds gamepad input support to the FreeCameraInputsManager.
  37824. * @returns the FreeCameraInputsManager
  37825. */
  37826. addGamepad(): FreeCameraInputsManager;
  37827. }
  37828. /**
  37829. * Interface representing an arc rotate camera inputs manager
  37830. */
  37831. interface ArcRotateCameraInputsManager {
  37832. /**
  37833. * Adds gamepad input support to the ArcRotateCamera InputManager.
  37834. * @returns the camera inputs manager
  37835. */
  37836. addGamepad(): ArcRotateCameraInputsManager;
  37837. }
  37838. /**
  37839. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  37840. */
  37841. export class GamepadSystemSceneComponent implements ISceneComponent {
  37842. /**
  37843. * The component name helpfull to identify the component in the list of scene components.
  37844. */
  37845. readonly name: string;
  37846. /**
  37847. * The scene the component belongs to.
  37848. */
  37849. scene: Scene;
  37850. /**
  37851. * Creates a new instance of the component for the given scene
  37852. * @param scene Defines the scene to register the component in
  37853. */
  37854. constructor(scene: Scene);
  37855. /**
  37856. * Registers the component in a given scene
  37857. */
  37858. register(): void;
  37859. /**
  37860. * Rebuilds the elements related to this component in case of
  37861. * context lost for instance.
  37862. */
  37863. rebuild(): void;
  37864. /**
  37865. * Disposes the component and the associated ressources
  37866. */
  37867. dispose(): void;
  37868. private _beforeCameraUpdate;
  37869. }
  37870. }
  37871. declare module BABYLON {
  37872. /**
  37873. * 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,
  37874. * which still works and will still be found in many Playgrounds.
  37875. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37876. */
  37877. export class UniversalCamera extends TouchCamera {
  37878. /**
  37879. * Defines the gamepad rotation sensiblity.
  37880. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37881. */
  37882. gamepadAngularSensibility: number;
  37883. /**
  37884. * Defines the gamepad move sensiblity.
  37885. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37886. */
  37887. gamepadMoveSensibility: number;
  37888. /**
  37889. * 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,
  37890. * which still works and will still be found in many Playgrounds.
  37891. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37892. * @param name Define the name of the camera in the scene
  37893. * @param position Define the start position of the camera in the scene
  37894. * @param scene Define the scene the camera belongs to
  37895. */
  37896. constructor(name: string, position: Vector3, scene: Scene);
  37897. /**
  37898. * Gets the current object class name.
  37899. * @return the class name
  37900. */
  37901. getClassName(): string;
  37902. }
  37903. }
  37904. declare module BABYLON {
  37905. /**
  37906. * This represents a FPS type of camera. This is only here for back compat purpose.
  37907. * Please use the UniversalCamera instead as both are identical.
  37908. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37909. */
  37910. export class GamepadCamera extends UniversalCamera {
  37911. /**
  37912. * Instantiates a new Gamepad Camera
  37913. * This represents a FPS type of camera. This is only here for back compat purpose.
  37914. * Please use the UniversalCamera instead as both are identical.
  37915. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37916. * @param name Define the name of the camera in the scene
  37917. * @param position Define the start position of the camera in the scene
  37918. * @param scene Define the scene the camera belongs to
  37919. */
  37920. constructor(name: string, position: Vector3, scene: Scene);
  37921. /**
  37922. * Gets the current object class name.
  37923. * @return the class name
  37924. */
  37925. getClassName(): string;
  37926. }
  37927. }
  37928. declare module BABYLON {
  37929. /** @hidden */
  37930. export var passPixelShader: {
  37931. name: string;
  37932. shader: string;
  37933. };
  37934. }
  37935. declare module BABYLON {
  37936. /** @hidden */
  37937. export var passCubePixelShader: {
  37938. name: string;
  37939. shader: string;
  37940. };
  37941. }
  37942. declare module BABYLON {
  37943. /**
  37944. * PassPostProcess which produces an output the same as it's input
  37945. */
  37946. export class PassPostProcess extends PostProcess {
  37947. /**
  37948. * Creates the PassPostProcess
  37949. * @param name The name of the effect.
  37950. * @param options The required width/height ratio to downsize to before computing the render pass.
  37951. * @param camera The camera to apply the render pass to.
  37952. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37953. * @param engine The engine which the post process will be applied. (default: current engine)
  37954. * @param reusable If the post process can be reused on the same frame. (default: false)
  37955. * @param textureType The type of texture to be used when performing the post processing.
  37956. * @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)
  37957. */
  37958. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37959. }
  37960. /**
  37961. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37962. */
  37963. export class PassCubePostProcess extends PostProcess {
  37964. private _face;
  37965. /**
  37966. * Gets or sets the cube face to display.
  37967. * * 0 is +X
  37968. * * 1 is -X
  37969. * * 2 is +Y
  37970. * * 3 is -Y
  37971. * * 4 is +Z
  37972. * * 5 is -Z
  37973. */
  37974. face: number;
  37975. /**
  37976. * Creates the PassCubePostProcess
  37977. * @param name The name of the effect.
  37978. * @param options The required width/height ratio to downsize to before computing the render pass.
  37979. * @param camera The camera to apply the render pass to.
  37980. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37981. * @param engine The engine which the post process will be applied. (default: current engine)
  37982. * @param reusable If the post process can be reused on the same frame. (default: false)
  37983. * @param textureType The type of texture to be used when performing the post processing.
  37984. * @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)
  37985. */
  37986. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37987. }
  37988. }
  37989. declare module BABYLON {
  37990. /** @hidden */
  37991. export var anaglyphPixelShader: {
  37992. name: string;
  37993. shader: string;
  37994. };
  37995. }
  37996. declare module BABYLON {
  37997. /**
  37998. * Postprocess used to generate anaglyphic rendering
  37999. */
  38000. export class AnaglyphPostProcess extends PostProcess {
  38001. private _passedProcess;
  38002. /**
  38003. * Creates a new AnaglyphPostProcess
  38004. * @param name defines postprocess name
  38005. * @param options defines creation options or target ratio scale
  38006. * @param rigCameras defines cameras using this postprocess
  38007. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38008. * @param engine defines hosting engine
  38009. * @param reusable defines if the postprocess will be reused multiple times per frame
  38010. */
  38011. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38012. }
  38013. }
  38014. declare module BABYLON {
  38015. /**
  38016. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38017. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38018. */
  38019. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38020. /**
  38021. * Creates a new AnaglyphArcRotateCamera
  38022. * @param name defines camera name
  38023. * @param alpha defines alpha angle (in radians)
  38024. * @param beta defines beta angle (in radians)
  38025. * @param radius defines radius
  38026. * @param target defines camera target
  38027. * @param interaxialDistance defines distance between each color axis
  38028. * @param scene defines the hosting scene
  38029. */
  38030. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38031. /**
  38032. * Gets camera class name
  38033. * @returns AnaglyphArcRotateCamera
  38034. */
  38035. getClassName(): string;
  38036. }
  38037. }
  38038. declare module BABYLON {
  38039. /**
  38040. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38041. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38042. */
  38043. export class AnaglyphFreeCamera extends FreeCamera {
  38044. /**
  38045. * Creates a new AnaglyphFreeCamera
  38046. * @param name defines camera name
  38047. * @param position defines initial position
  38048. * @param interaxialDistance defines distance between each color axis
  38049. * @param scene defines the hosting scene
  38050. */
  38051. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38052. /**
  38053. * Gets camera class name
  38054. * @returns AnaglyphFreeCamera
  38055. */
  38056. getClassName(): string;
  38057. }
  38058. }
  38059. declare module BABYLON {
  38060. /**
  38061. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38062. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38063. */
  38064. export class AnaglyphGamepadCamera extends GamepadCamera {
  38065. /**
  38066. * Creates a new AnaglyphGamepadCamera
  38067. * @param name defines camera name
  38068. * @param position defines initial position
  38069. * @param interaxialDistance defines distance between each color axis
  38070. * @param scene defines the hosting scene
  38071. */
  38072. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38073. /**
  38074. * Gets camera class name
  38075. * @returns AnaglyphGamepadCamera
  38076. */
  38077. getClassName(): string;
  38078. }
  38079. }
  38080. declare module BABYLON {
  38081. /**
  38082. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38083. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38084. */
  38085. export class AnaglyphUniversalCamera extends UniversalCamera {
  38086. /**
  38087. * Creates a new AnaglyphUniversalCamera
  38088. * @param name defines camera name
  38089. * @param position defines initial position
  38090. * @param interaxialDistance defines distance between each color axis
  38091. * @param scene defines the hosting scene
  38092. */
  38093. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38094. /**
  38095. * Gets camera class name
  38096. * @returns AnaglyphUniversalCamera
  38097. */
  38098. getClassName(): string;
  38099. }
  38100. }
  38101. declare module BABYLON {
  38102. /** @hidden */
  38103. export var stereoscopicInterlacePixelShader: {
  38104. name: string;
  38105. shader: string;
  38106. };
  38107. }
  38108. declare module BABYLON {
  38109. /**
  38110. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38111. */
  38112. export class StereoscopicInterlacePostProcess extends PostProcess {
  38113. private _stepSize;
  38114. private _passedProcess;
  38115. /**
  38116. * Initializes a StereoscopicInterlacePostProcess
  38117. * @param name The name of the effect.
  38118. * @param rigCameras The rig cameras to be appled to the post process
  38119. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38120. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38121. * @param engine The engine which the post process will be applied. (default: current engine)
  38122. * @param reusable If the post process can be reused on the same frame. (default: false)
  38123. */
  38124. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38125. }
  38126. }
  38127. declare module BABYLON {
  38128. /**
  38129. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38130. * @see http://doc.babylonjs.com/features/cameras
  38131. */
  38132. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38133. /**
  38134. * Creates a new StereoscopicArcRotateCamera
  38135. * @param name defines camera name
  38136. * @param alpha defines alpha angle (in radians)
  38137. * @param beta defines beta angle (in radians)
  38138. * @param radius defines radius
  38139. * @param target defines camera target
  38140. * @param interaxialDistance defines distance between each color axis
  38141. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38142. * @param scene defines the hosting scene
  38143. */
  38144. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38145. /**
  38146. * Gets camera class name
  38147. * @returns StereoscopicArcRotateCamera
  38148. */
  38149. getClassName(): string;
  38150. }
  38151. }
  38152. declare module BABYLON {
  38153. /**
  38154. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38155. * @see http://doc.babylonjs.com/features/cameras
  38156. */
  38157. export class StereoscopicFreeCamera extends FreeCamera {
  38158. /**
  38159. * Creates a new StereoscopicFreeCamera
  38160. * @param name defines camera name
  38161. * @param position defines initial position
  38162. * @param interaxialDistance defines distance between each color axis
  38163. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38164. * @param scene defines the hosting scene
  38165. */
  38166. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38167. /**
  38168. * Gets camera class name
  38169. * @returns StereoscopicFreeCamera
  38170. */
  38171. getClassName(): string;
  38172. }
  38173. }
  38174. declare module BABYLON {
  38175. /**
  38176. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38177. * @see http://doc.babylonjs.com/features/cameras
  38178. */
  38179. export class StereoscopicGamepadCamera extends GamepadCamera {
  38180. /**
  38181. * Creates a new StereoscopicGamepadCamera
  38182. * @param name defines camera name
  38183. * @param position defines initial position
  38184. * @param interaxialDistance defines distance between each color axis
  38185. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38186. * @param scene defines the hosting scene
  38187. */
  38188. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38189. /**
  38190. * Gets camera class name
  38191. * @returns StereoscopicGamepadCamera
  38192. */
  38193. getClassName(): string;
  38194. }
  38195. }
  38196. declare module BABYLON {
  38197. /**
  38198. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38199. * @see http://doc.babylonjs.com/features/cameras
  38200. */
  38201. export class StereoscopicUniversalCamera extends UniversalCamera {
  38202. /**
  38203. * Creates a new StereoscopicUniversalCamera
  38204. * @param name defines camera name
  38205. * @param position defines initial position
  38206. * @param interaxialDistance defines distance between each color axis
  38207. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38208. * @param scene defines the hosting scene
  38209. */
  38210. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38211. /**
  38212. * Gets camera class name
  38213. * @returns StereoscopicUniversalCamera
  38214. */
  38215. getClassName(): string;
  38216. }
  38217. }
  38218. declare module BABYLON {
  38219. /**
  38220. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38221. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38222. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38223. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38224. */
  38225. export class VirtualJoysticksCamera extends FreeCamera {
  38226. /**
  38227. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38228. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38229. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38230. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38231. * @param name Define the name of the camera in the scene
  38232. * @param position Define the start position of the camera in the scene
  38233. * @param scene Define the scene the camera belongs to
  38234. */
  38235. constructor(name: string, position: Vector3, scene: Scene);
  38236. /**
  38237. * Gets the current object class name.
  38238. * @return the class name
  38239. */
  38240. getClassName(): string;
  38241. }
  38242. }
  38243. declare module BABYLON {
  38244. /**
  38245. * This represents all the required metrics to create a VR camera.
  38246. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38247. */
  38248. export class VRCameraMetrics {
  38249. /**
  38250. * Define the horizontal resolution off the screen.
  38251. */
  38252. hResolution: number;
  38253. /**
  38254. * Define the vertical resolution off the screen.
  38255. */
  38256. vResolution: number;
  38257. /**
  38258. * Define the horizontal screen size.
  38259. */
  38260. hScreenSize: number;
  38261. /**
  38262. * Define the vertical screen size.
  38263. */
  38264. vScreenSize: number;
  38265. /**
  38266. * Define the vertical screen center position.
  38267. */
  38268. vScreenCenter: number;
  38269. /**
  38270. * Define the distance of the eyes to the screen.
  38271. */
  38272. eyeToScreenDistance: number;
  38273. /**
  38274. * Define the distance between both lenses
  38275. */
  38276. lensSeparationDistance: number;
  38277. /**
  38278. * Define the distance between both viewer's eyes.
  38279. */
  38280. interpupillaryDistance: number;
  38281. /**
  38282. * Define the distortion factor of the VR postprocess.
  38283. * Please, touch with care.
  38284. */
  38285. distortionK: number[];
  38286. /**
  38287. * Define the chromatic aberration correction factors for the VR post process.
  38288. */
  38289. chromaAbCorrection: number[];
  38290. /**
  38291. * Define the scale factor of the post process.
  38292. * The smaller the better but the slower.
  38293. */
  38294. postProcessScaleFactor: number;
  38295. /**
  38296. * Define an offset for the lens center.
  38297. */
  38298. lensCenterOffset: number;
  38299. /**
  38300. * Define if the current vr camera should compensate the distortion of the lense or not.
  38301. */
  38302. compensateDistortion: boolean;
  38303. /**
  38304. * Defines if multiview should be enabled when rendering (Default: false)
  38305. */
  38306. multiviewEnabled: boolean;
  38307. /**
  38308. * Gets the rendering aspect ratio based on the provided resolutions.
  38309. */
  38310. readonly aspectRatio: number;
  38311. /**
  38312. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38313. */
  38314. readonly aspectRatioFov: number;
  38315. /**
  38316. * @hidden
  38317. */
  38318. readonly leftHMatrix: Matrix;
  38319. /**
  38320. * @hidden
  38321. */
  38322. readonly rightHMatrix: Matrix;
  38323. /**
  38324. * @hidden
  38325. */
  38326. readonly leftPreViewMatrix: Matrix;
  38327. /**
  38328. * @hidden
  38329. */
  38330. readonly rightPreViewMatrix: Matrix;
  38331. /**
  38332. * Get the default VRMetrics based on the most generic setup.
  38333. * @returns the default vr metrics
  38334. */
  38335. static GetDefault(): VRCameraMetrics;
  38336. }
  38337. }
  38338. declare module BABYLON {
  38339. /** @hidden */
  38340. export var vrDistortionCorrectionPixelShader: {
  38341. name: string;
  38342. shader: string;
  38343. };
  38344. }
  38345. declare module BABYLON {
  38346. /**
  38347. * VRDistortionCorrectionPostProcess used for mobile VR
  38348. */
  38349. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38350. private _isRightEye;
  38351. private _distortionFactors;
  38352. private _postProcessScaleFactor;
  38353. private _lensCenterOffset;
  38354. private _scaleIn;
  38355. private _scaleFactor;
  38356. private _lensCenter;
  38357. /**
  38358. * Initializes the VRDistortionCorrectionPostProcess
  38359. * @param name The name of the effect.
  38360. * @param camera The camera to apply the render pass to.
  38361. * @param isRightEye If this is for the right eye distortion
  38362. * @param vrMetrics All the required metrics for the VR camera
  38363. */
  38364. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38365. }
  38366. }
  38367. declare module BABYLON {
  38368. /**
  38369. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38370. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38371. */
  38372. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38373. /**
  38374. * Creates a new VRDeviceOrientationArcRotateCamera
  38375. * @param name defines camera name
  38376. * @param alpha defines the camera rotation along the logitudinal axis
  38377. * @param beta defines the camera rotation along the latitudinal axis
  38378. * @param radius defines the camera distance from its target
  38379. * @param target defines the camera target
  38380. * @param scene defines the scene the camera belongs to
  38381. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38382. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38383. */
  38384. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38385. /**
  38386. * Gets camera class name
  38387. * @returns VRDeviceOrientationArcRotateCamera
  38388. */
  38389. getClassName(): string;
  38390. }
  38391. }
  38392. declare module BABYLON {
  38393. /**
  38394. * Camera used to simulate VR rendering (based on FreeCamera)
  38395. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38396. */
  38397. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38398. /**
  38399. * Creates a new VRDeviceOrientationFreeCamera
  38400. * @param name defines camera name
  38401. * @param position defines the start position of the camera
  38402. * @param scene defines the scene the camera belongs to
  38403. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38404. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38405. */
  38406. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38407. /**
  38408. * Gets camera class name
  38409. * @returns VRDeviceOrientationFreeCamera
  38410. */
  38411. getClassName(): string;
  38412. }
  38413. }
  38414. declare module BABYLON {
  38415. /**
  38416. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38417. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38418. */
  38419. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38420. /**
  38421. * Creates a new VRDeviceOrientationGamepadCamera
  38422. * @param name defines camera name
  38423. * @param position defines the start position of the camera
  38424. * @param scene defines the scene the camera belongs to
  38425. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38426. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38427. */
  38428. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38429. /**
  38430. * Gets camera class name
  38431. * @returns VRDeviceOrientationGamepadCamera
  38432. */
  38433. getClassName(): string;
  38434. }
  38435. }
  38436. declare module BABYLON {
  38437. /**
  38438. * Base class of materials working in push mode in babylon JS
  38439. * @hidden
  38440. */
  38441. export class PushMaterial extends Material {
  38442. protected _activeEffect: Effect;
  38443. protected _normalMatrix: Matrix;
  38444. /**
  38445. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38446. * This means that the material can keep using a previous shader while a new one is being compiled.
  38447. * This is mostly used when shader parallel compilation is supported (true by default)
  38448. */
  38449. allowShaderHotSwapping: boolean;
  38450. constructor(name: string, scene: Scene);
  38451. getEffect(): Effect;
  38452. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38453. /**
  38454. * Binds the given world matrix to the active effect
  38455. *
  38456. * @param world the matrix to bind
  38457. */
  38458. bindOnlyWorldMatrix(world: Matrix): void;
  38459. /**
  38460. * Binds the given normal matrix to the active effect
  38461. *
  38462. * @param normalMatrix the matrix to bind
  38463. */
  38464. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38465. bind(world: Matrix, mesh?: Mesh): void;
  38466. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38467. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38468. }
  38469. }
  38470. declare module BABYLON {
  38471. /**
  38472. * This groups all the flags used to control the materials channel.
  38473. */
  38474. export class MaterialFlags {
  38475. private static _DiffuseTextureEnabled;
  38476. /**
  38477. * Are diffuse textures enabled in the application.
  38478. */
  38479. static DiffuseTextureEnabled: boolean;
  38480. private static _AmbientTextureEnabled;
  38481. /**
  38482. * Are ambient textures enabled in the application.
  38483. */
  38484. static AmbientTextureEnabled: boolean;
  38485. private static _OpacityTextureEnabled;
  38486. /**
  38487. * Are opacity textures enabled in the application.
  38488. */
  38489. static OpacityTextureEnabled: boolean;
  38490. private static _ReflectionTextureEnabled;
  38491. /**
  38492. * Are reflection textures enabled in the application.
  38493. */
  38494. static ReflectionTextureEnabled: boolean;
  38495. private static _EmissiveTextureEnabled;
  38496. /**
  38497. * Are emissive textures enabled in the application.
  38498. */
  38499. static EmissiveTextureEnabled: boolean;
  38500. private static _SpecularTextureEnabled;
  38501. /**
  38502. * Are specular textures enabled in the application.
  38503. */
  38504. static SpecularTextureEnabled: boolean;
  38505. private static _BumpTextureEnabled;
  38506. /**
  38507. * Are bump textures enabled in the application.
  38508. */
  38509. static BumpTextureEnabled: boolean;
  38510. private static _LightmapTextureEnabled;
  38511. /**
  38512. * Are lightmap textures enabled in the application.
  38513. */
  38514. static LightmapTextureEnabled: boolean;
  38515. private static _RefractionTextureEnabled;
  38516. /**
  38517. * Are refraction textures enabled in the application.
  38518. */
  38519. static RefractionTextureEnabled: boolean;
  38520. private static _ColorGradingTextureEnabled;
  38521. /**
  38522. * Are color grading textures enabled in the application.
  38523. */
  38524. static ColorGradingTextureEnabled: boolean;
  38525. private static _FresnelEnabled;
  38526. /**
  38527. * Are fresnels enabled in the application.
  38528. */
  38529. static FresnelEnabled: boolean;
  38530. private static _ClearCoatTextureEnabled;
  38531. /**
  38532. * Are clear coat textures enabled in the application.
  38533. */
  38534. static ClearCoatTextureEnabled: boolean;
  38535. private static _ClearCoatBumpTextureEnabled;
  38536. /**
  38537. * Are clear coat bump textures enabled in the application.
  38538. */
  38539. static ClearCoatBumpTextureEnabled: boolean;
  38540. private static _ClearCoatTintTextureEnabled;
  38541. /**
  38542. * Are clear coat tint textures enabled in the application.
  38543. */
  38544. static ClearCoatTintTextureEnabled: boolean;
  38545. private static _SheenTextureEnabled;
  38546. /**
  38547. * Are sheen textures enabled in the application.
  38548. */
  38549. static SheenTextureEnabled: boolean;
  38550. private static _AnisotropicTextureEnabled;
  38551. /**
  38552. * Are anisotropic textures enabled in the application.
  38553. */
  38554. static AnisotropicTextureEnabled: boolean;
  38555. private static _ThicknessTextureEnabled;
  38556. /**
  38557. * Are thickness textures enabled in the application.
  38558. */
  38559. static ThicknessTextureEnabled: boolean;
  38560. }
  38561. }
  38562. declare module BABYLON {
  38563. /** @hidden */
  38564. export var defaultFragmentDeclaration: {
  38565. name: string;
  38566. shader: string;
  38567. };
  38568. }
  38569. declare module BABYLON {
  38570. /** @hidden */
  38571. export var defaultUboDeclaration: {
  38572. name: string;
  38573. shader: string;
  38574. };
  38575. }
  38576. declare module BABYLON {
  38577. /** @hidden */
  38578. export var lightFragmentDeclaration: {
  38579. name: string;
  38580. shader: string;
  38581. };
  38582. }
  38583. declare module BABYLON {
  38584. /** @hidden */
  38585. export var lightUboDeclaration: {
  38586. name: string;
  38587. shader: string;
  38588. };
  38589. }
  38590. declare module BABYLON {
  38591. /** @hidden */
  38592. export var lightsFragmentFunctions: {
  38593. name: string;
  38594. shader: string;
  38595. };
  38596. }
  38597. declare module BABYLON {
  38598. /** @hidden */
  38599. export var shadowsFragmentFunctions: {
  38600. name: string;
  38601. shader: string;
  38602. };
  38603. }
  38604. declare module BABYLON {
  38605. /** @hidden */
  38606. export var fresnelFunction: {
  38607. name: string;
  38608. shader: string;
  38609. };
  38610. }
  38611. declare module BABYLON {
  38612. /** @hidden */
  38613. export var reflectionFunction: {
  38614. name: string;
  38615. shader: string;
  38616. };
  38617. }
  38618. declare module BABYLON {
  38619. /** @hidden */
  38620. export var bumpFragmentFunctions: {
  38621. name: string;
  38622. shader: string;
  38623. };
  38624. }
  38625. declare module BABYLON {
  38626. /** @hidden */
  38627. export var logDepthDeclaration: {
  38628. name: string;
  38629. shader: string;
  38630. };
  38631. }
  38632. declare module BABYLON {
  38633. /** @hidden */
  38634. export var bumpFragment: {
  38635. name: string;
  38636. shader: string;
  38637. };
  38638. }
  38639. declare module BABYLON {
  38640. /** @hidden */
  38641. export var depthPrePass: {
  38642. name: string;
  38643. shader: string;
  38644. };
  38645. }
  38646. declare module BABYLON {
  38647. /** @hidden */
  38648. export var lightFragment: {
  38649. name: string;
  38650. shader: string;
  38651. };
  38652. }
  38653. declare module BABYLON {
  38654. /** @hidden */
  38655. export var logDepthFragment: {
  38656. name: string;
  38657. shader: string;
  38658. };
  38659. }
  38660. declare module BABYLON {
  38661. /** @hidden */
  38662. export var defaultPixelShader: {
  38663. name: string;
  38664. shader: string;
  38665. };
  38666. }
  38667. declare module BABYLON {
  38668. /** @hidden */
  38669. export var defaultVertexDeclaration: {
  38670. name: string;
  38671. shader: string;
  38672. };
  38673. }
  38674. declare module BABYLON {
  38675. /** @hidden */
  38676. export var bumpVertexDeclaration: {
  38677. name: string;
  38678. shader: string;
  38679. };
  38680. }
  38681. declare module BABYLON {
  38682. /** @hidden */
  38683. export var bumpVertex: {
  38684. name: string;
  38685. shader: string;
  38686. };
  38687. }
  38688. declare module BABYLON {
  38689. /** @hidden */
  38690. export var fogVertex: {
  38691. name: string;
  38692. shader: string;
  38693. };
  38694. }
  38695. declare module BABYLON {
  38696. /** @hidden */
  38697. export var shadowsVertex: {
  38698. name: string;
  38699. shader: string;
  38700. };
  38701. }
  38702. declare module BABYLON {
  38703. /** @hidden */
  38704. export var pointCloudVertex: {
  38705. name: string;
  38706. shader: string;
  38707. };
  38708. }
  38709. declare module BABYLON {
  38710. /** @hidden */
  38711. export var logDepthVertex: {
  38712. name: string;
  38713. shader: string;
  38714. };
  38715. }
  38716. declare module BABYLON {
  38717. /** @hidden */
  38718. export var defaultVertexShader: {
  38719. name: string;
  38720. shader: string;
  38721. };
  38722. }
  38723. declare module BABYLON {
  38724. /** @hidden */
  38725. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38726. MAINUV1: boolean;
  38727. MAINUV2: boolean;
  38728. DIFFUSE: boolean;
  38729. DIFFUSEDIRECTUV: number;
  38730. AMBIENT: boolean;
  38731. AMBIENTDIRECTUV: number;
  38732. OPACITY: boolean;
  38733. OPACITYDIRECTUV: number;
  38734. OPACITYRGB: boolean;
  38735. REFLECTION: boolean;
  38736. EMISSIVE: boolean;
  38737. EMISSIVEDIRECTUV: number;
  38738. SPECULAR: boolean;
  38739. SPECULARDIRECTUV: number;
  38740. BUMP: boolean;
  38741. BUMPDIRECTUV: number;
  38742. PARALLAX: boolean;
  38743. PARALLAXOCCLUSION: boolean;
  38744. SPECULAROVERALPHA: boolean;
  38745. CLIPPLANE: boolean;
  38746. CLIPPLANE2: boolean;
  38747. CLIPPLANE3: boolean;
  38748. CLIPPLANE4: boolean;
  38749. ALPHATEST: boolean;
  38750. DEPTHPREPASS: boolean;
  38751. ALPHAFROMDIFFUSE: boolean;
  38752. POINTSIZE: boolean;
  38753. FOG: boolean;
  38754. SPECULARTERM: boolean;
  38755. DIFFUSEFRESNEL: boolean;
  38756. OPACITYFRESNEL: boolean;
  38757. REFLECTIONFRESNEL: boolean;
  38758. REFRACTIONFRESNEL: boolean;
  38759. EMISSIVEFRESNEL: boolean;
  38760. FRESNEL: boolean;
  38761. NORMAL: boolean;
  38762. UV1: boolean;
  38763. UV2: boolean;
  38764. VERTEXCOLOR: boolean;
  38765. VERTEXALPHA: boolean;
  38766. NUM_BONE_INFLUENCERS: number;
  38767. BonesPerMesh: number;
  38768. BONETEXTURE: boolean;
  38769. INSTANCES: boolean;
  38770. GLOSSINESS: boolean;
  38771. ROUGHNESS: boolean;
  38772. EMISSIVEASILLUMINATION: boolean;
  38773. LINKEMISSIVEWITHDIFFUSE: boolean;
  38774. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38775. LIGHTMAP: boolean;
  38776. LIGHTMAPDIRECTUV: number;
  38777. OBJECTSPACE_NORMALMAP: boolean;
  38778. USELIGHTMAPASSHADOWMAP: boolean;
  38779. REFLECTIONMAP_3D: boolean;
  38780. REFLECTIONMAP_SPHERICAL: boolean;
  38781. REFLECTIONMAP_PLANAR: boolean;
  38782. REFLECTIONMAP_CUBIC: boolean;
  38783. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38784. REFLECTIONMAP_PROJECTION: boolean;
  38785. REFLECTIONMAP_SKYBOX: boolean;
  38786. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38787. REFLECTIONMAP_EXPLICIT: boolean;
  38788. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38789. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38790. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38791. INVERTCUBICMAP: boolean;
  38792. LOGARITHMICDEPTH: boolean;
  38793. REFRACTION: boolean;
  38794. REFRACTIONMAP_3D: boolean;
  38795. REFLECTIONOVERALPHA: boolean;
  38796. TWOSIDEDLIGHTING: boolean;
  38797. SHADOWFLOAT: boolean;
  38798. MORPHTARGETS: boolean;
  38799. MORPHTARGETS_NORMAL: boolean;
  38800. MORPHTARGETS_TANGENT: boolean;
  38801. NUM_MORPH_INFLUENCERS: number;
  38802. NONUNIFORMSCALING: boolean;
  38803. PREMULTIPLYALPHA: boolean;
  38804. IMAGEPROCESSING: boolean;
  38805. VIGNETTE: boolean;
  38806. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38807. VIGNETTEBLENDMODEOPAQUE: boolean;
  38808. TONEMAPPING: boolean;
  38809. TONEMAPPING_ACES: boolean;
  38810. CONTRAST: boolean;
  38811. COLORCURVES: boolean;
  38812. COLORGRADING: boolean;
  38813. COLORGRADING3D: boolean;
  38814. SAMPLER3DGREENDEPTH: boolean;
  38815. SAMPLER3DBGRMAP: boolean;
  38816. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38817. MULTIVIEW: boolean;
  38818. /**
  38819. * If the reflection texture on this material is in linear color space
  38820. * @hidden
  38821. */
  38822. IS_REFLECTION_LINEAR: boolean;
  38823. /**
  38824. * If the refraction texture on this material is in linear color space
  38825. * @hidden
  38826. */
  38827. IS_REFRACTION_LINEAR: boolean;
  38828. EXPOSURE: boolean;
  38829. constructor();
  38830. setReflectionMode(modeToEnable: string): void;
  38831. }
  38832. /**
  38833. * This is the default material used in Babylon. It is the best trade off between quality
  38834. * and performances.
  38835. * @see http://doc.babylonjs.com/babylon101/materials
  38836. */
  38837. export class StandardMaterial extends PushMaterial {
  38838. private _diffuseTexture;
  38839. /**
  38840. * The basic texture of the material as viewed under a light.
  38841. */
  38842. diffuseTexture: Nullable<BaseTexture>;
  38843. private _ambientTexture;
  38844. /**
  38845. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38846. */
  38847. ambientTexture: Nullable<BaseTexture>;
  38848. private _opacityTexture;
  38849. /**
  38850. * Define the transparency of the material from a texture.
  38851. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38852. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38853. */
  38854. opacityTexture: Nullable<BaseTexture>;
  38855. private _reflectionTexture;
  38856. /**
  38857. * Define the texture used to display the reflection.
  38858. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38859. */
  38860. reflectionTexture: Nullable<BaseTexture>;
  38861. private _emissiveTexture;
  38862. /**
  38863. * Define texture of the material as if self lit.
  38864. * This will be mixed in the final result even in the absence of light.
  38865. */
  38866. emissiveTexture: Nullable<BaseTexture>;
  38867. private _specularTexture;
  38868. /**
  38869. * Define how the color and intensity of the highlight given by the light in the material.
  38870. */
  38871. specularTexture: Nullable<BaseTexture>;
  38872. private _bumpTexture;
  38873. /**
  38874. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38875. * 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.
  38876. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38877. */
  38878. bumpTexture: Nullable<BaseTexture>;
  38879. private _lightmapTexture;
  38880. /**
  38881. * Complex lighting can be computationally expensive to compute at runtime.
  38882. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38883. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38884. */
  38885. lightmapTexture: Nullable<BaseTexture>;
  38886. private _refractionTexture;
  38887. /**
  38888. * Define the texture used to display the refraction.
  38889. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38890. */
  38891. refractionTexture: Nullable<BaseTexture>;
  38892. /**
  38893. * The color of the material lit by the environmental background lighting.
  38894. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38895. */
  38896. ambientColor: Color3;
  38897. /**
  38898. * The basic color of the material as viewed under a light.
  38899. */
  38900. diffuseColor: Color3;
  38901. /**
  38902. * Define how the color and intensity of the highlight given by the light in the material.
  38903. */
  38904. specularColor: Color3;
  38905. /**
  38906. * Define the color of the material as if self lit.
  38907. * This will be mixed in the final result even in the absence of light.
  38908. */
  38909. emissiveColor: Color3;
  38910. /**
  38911. * Defines how sharp are the highlights in the material.
  38912. * The bigger the value the sharper giving a more glossy feeling to the result.
  38913. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38914. */
  38915. specularPower: number;
  38916. private _useAlphaFromDiffuseTexture;
  38917. /**
  38918. * Does the transparency come from the diffuse texture alpha channel.
  38919. */
  38920. useAlphaFromDiffuseTexture: boolean;
  38921. private _useEmissiveAsIllumination;
  38922. /**
  38923. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38924. */
  38925. useEmissiveAsIllumination: boolean;
  38926. private _linkEmissiveWithDiffuse;
  38927. /**
  38928. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38929. * the emissive level when the final color is close to one.
  38930. */
  38931. linkEmissiveWithDiffuse: boolean;
  38932. private _useSpecularOverAlpha;
  38933. /**
  38934. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38935. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38936. */
  38937. useSpecularOverAlpha: boolean;
  38938. private _useReflectionOverAlpha;
  38939. /**
  38940. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38941. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38942. */
  38943. useReflectionOverAlpha: boolean;
  38944. private _disableLighting;
  38945. /**
  38946. * Does lights from the scene impacts this material.
  38947. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38948. */
  38949. disableLighting: boolean;
  38950. private _useObjectSpaceNormalMap;
  38951. /**
  38952. * Allows using an object space normal map (instead of tangent space).
  38953. */
  38954. useObjectSpaceNormalMap: boolean;
  38955. private _useParallax;
  38956. /**
  38957. * Is parallax enabled or not.
  38958. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38959. */
  38960. useParallax: boolean;
  38961. private _useParallaxOcclusion;
  38962. /**
  38963. * Is parallax occlusion enabled or not.
  38964. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38965. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38966. */
  38967. useParallaxOcclusion: boolean;
  38968. /**
  38969. * 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.
  38970. */
  38971. parallaxScaleBias: number;
  38972. private _roughness;
  38973. /**
  38974. * Helps to define how blurry the reflections should appears in the material.
  38975. */
  38976. roughness: number;
  38977. /**
  38978. * In case of refraction, define the value of the indice of refraction.
  38979. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38980. */
  38981. indexOfRefraction: number;
  38982. /**
  38983. * Invert the refraction texture alongside the y axis.
  38984. * It can be useful with procedural textures or probe for instance.
  38985. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38986. */
  38987. invertRefractionY: boolean;
  38988. /**
  38989. * Defines the alpha limits in alpha test mode.
  38990. */
  38991. alphaCutOff: number;
  38992. private _useLightmapAsShadowmap;
  38993. /**
  38994. * In case of light mapping, define whether the map contains light or shadow informations.
  38995. */
  38996. useLightmapAsShadowmap: boolean;
  38997. private _diffuseFresnelParameters;
  38998. /**
  38999. * Define the diffuse fresnel parameters of the material.
  39000. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39001. */
  39002. diffuseFresnelParameters: FresnelParameters;
  39003. private _opacityFresnelParameters;
  39004. /**
  39005. * Define the opacity fresnel parameters of the material.
  39006. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39007. */
  39008. opacityFresnelParameters: FresnelParameters;
  39009. private _reflectionFresnelParameters;
  39010. /**
  39011. * Define the reflection fresnel parameters of the material.
  39012. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39013. */
  39014. reflectionFresnelParameters: FresnelParameters;
  39015. private _refractionFresnelParameters;
  39016. /**
  39017. * Define the refraction fresnel parameters of the material.
  39018. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39019. */
  39020. refractionFresnelParameters: FresnelParameters;
  39021. private _emissiveFresnelParameters;
  39022. /**
  39023. * Define the emissive fresnel parameters of the material.
  39024. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39025. */
  39026. emissiveFresnelParameters: FresnelParameters;
  39027. private _useReflectionFresnelFromSpecular;
  39028. /**
  39029. * If true automatically deducts the fresnels values from the material specularity.
  39030. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39031. */
  39032. useReflectionFresnelFromSpecular: boolean;
  39033. private _useGlossinessFromSpecularMapAlpha;
  39034. /**
  39035. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39036. */
  39037. useGlossinessFromSpecularMapAlpha: boolean;
  39038. private _maxSimultaneousLights;
  39039. /**
  39040. * Defines the maximum number of lights that can be used in the material
  39041. */
  39042. maxSimultaneousLights: number;
  39043. private _invertNormalMapX;
  39044. /**
  39045. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39046. */
  39047. invertNormalMapX: boolean;
  39048. private _invertNormalMapY;
  39049. /**
  39050. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39051. */
  39052. invertNormalMapY: boolean;
  39053. private _twoSidedLighting;
  39054. /**
  39055. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39056. */
  39057. twoSidedLighting: boolean;
  39058. /**
  39059. * Default configuration related to image processing available in the standard Material.
  39060. */
  39061. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39062. /**
  39063. * Gets the image processing configuration used either in this material.
  39064. */
  39065. /**
  39066. * Sets the Default image processing configuration used either in the this material.
  39067. *
  39068. * If sets to null, the scene one is in use.
  39069. */
  39070. imageProcessingConfiguration: ImageProcessingConfiguration;
  39071. /**
  39072. * Keep track of the image processing observer to allow dispose and replace.
  39073. */
  39074. private _imageProcessingObserver;
  39075. /**
  39076. * Attaches a new image processing configuration to the Standard Material.
  39077. * @param configuration
  39078. */
  39079. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39080. /**
  39081. * Gets wether the color curves effect is enabled.
  39082. */
  39083. /**
  39084. * Sets wether the color curves effect is enabled.
  39085. */
  39086. cameraColorCurvesEnabled: boolean;
  39087. /**
  39088. * Gets wether the color grading effect is enabled.
  39089. */
  39090. /**
  39091. * Gets wether the color grading effect is enabled.
  39092. */
  39093. cameraColorGradingEnabled: boolean;
  39094. /**
  39095. * Gets wether tonemapping is enabled or not.
  39096. */
  39097. /**
  39098. * Sets wether tonemapping is enabled or not
  39099. */
  39100. cameraToneMappingEnabled: boolean;
  39101. /**
  39102. * The camera exposure used on this material.
  39103. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39104. * This corresponds to a photographic exposure.
  39105. */
  39106. /**
  39107. * The camera exposure used on this material.
  39108. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39109. * This corresponds to a photographic exposure.
  39110. */
  39111. cameraExposure: number;
  39112. /**
  39113. * Gets The camera contrast used on this material.
  39114. */
  39115. /**
  39116. * Sets The camera contrast used on this material.
  39117. */
  39118. cameraContrast: number;
  39119. /**
  39120. * Gets the Color Grading 2D Lookup Texture.
  39121. */
  39122. /**
  39123. * Sets the Color Grading 2D Lookup Texture.
  39124. */
  39125. cameraColorGradingTexture: Nullable<BaseTexture>;
  39126. /**
  39127. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39128. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39129. * 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;
  39130. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39131. */
  39132. /**
  39133. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39134. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39135. * 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;
  39136. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39137. */
  39138. cameraColorCurves: Nullable<ColorCurves>;
  39139. /**
  39140. * Custom callback helping to override the default shader used in the material.
  39141. */
  39142. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39143. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39144. protected _worldViewProjectionMatrix: Matrix;
  39145. protected _globalAmbientColor: Color3;
  39146. protected _useLogarithmicDepth: boolean;
  39147. /**
  39148. * Instantiates a new standard material.
  39149. * This is the default material used in Babylon. It is the best trade off between quality
  39150. * and performances.
  39151. * @see http://doc.babylonjs.com/babylon101/materials
  39152. * @param name Define the name of the material in the scene
  39153. * @param scene Define the scene the material belong to
  39154. */
  39155. constructor(name: string, scene: Scene);
  39156. /**
  39157. * Gets a boolean indicating that current material needs to register RTT
  39158. */
  39159. readonly hasRenderTargetTextures: boolean;
  39160. /**
  39161. * Gets the current class name of the material e.g. "StandardMaterial"
  39162. * Mainly use in serialization.
  39163. * @returns the class name
  39164. */
  39165. getClassName(): string;
  39166. /**
  39167. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39168. * You can try switching to logarithmic depth.
  39169. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39170. */
  39171. useLogarithmicDepth: boolean;
  39172. /**
  39173. * Specifies if the material will require alpha blending
  39174. * @returns a boolean specifying if alpha blending is needed
  39175. */
  39176. needAlphaBlending(): boolean;
  39177. /**
  39178. * Specifies if this material should be rendered in alpha test mode
  39179. * @returns a boolean specifying if an alpha test is needed.
  39180. */
  39181. needAlphaTesting(): boolean;
  39182. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39183. /**
  39184. * Get the texture used for alpha test purpose.
  39185. * @returns the diffuse texture in case of the standard material.
  39186. */
  39187. getAlphaTestTexture(): Nullable<BaseTexture>;
  39188. /**
  39189. * Get if the submesh is ready to be used and all its information available.
  39190. * Child classes can use it to update shaders
  39191. * @param mesh defines the mesh to check
  39192. * @param subMesh defines which submesh to check
  39193. * @param useInstances specifies that instances should be used
  39194. * @returns a boolean indicating that the submesh is ready or not
  39195. */
  39196. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39197. /**
  39198. * Builds the material UBO layouts.
  39199. * Used internally during the effect preparation.
  39200. */
  39201. buildUniformLayout(): void;
  39202. /**
  39203. * Unbinds the material from the mesh
  39204. */
  39205. unbind(): void;
  39206. /**
  39207. * Binds the submesh to this material by preparing the effect and shader to draw
  39208. * @param world defines the world transformation matrix
  39209. * @param mesh defines the mesh containing the submesh
  39210. * @param subMesh defines the submesh to bind the material to
  39211. */
  39212. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39213. /**
  39214. * Get the list of animatables in the material.
  39215. * @returns the list of animatables object used in the material
  39216. */
  39217. getAnimatables(): IAnimatable[];
  39218. /**
  39219. * Gets the active textures from the material
  39220. * @returns an array of textures
  39221. */
  39222. getActiveTextures(): BaseTexture[];
  39223. /**
  39224. * Specifies if the material uses a texture
  39225. * @param texture defines the texture to check against the material
  39226. * @returns a boolean specifying if the material uses the texture
  39227. */
  39228. hasTexture(texture: BaseTexture): boolean;
  39229. /**
  39230. * Disposes the material
  39231. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39232. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39233. */
  39234. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39235. /**
  39236. * Makes a duplicate of the material, and gives it a new name
  39237. * @param name defines the new name for the duplicated material
  39238. * @returns the cloned material
  39239. */
  39240. clone(name: string): StandardMaterial;
  39241. /**
  39242. * Serializes this material in a JSON representation
  39243. * @returns the serialized material object
  39244. */
  39245. serialize(): any;
  39246. /**
  39247. * Creates a standard material from parsed material data
  39248. * @param source defines the JSON representation of the material
  39249. * @param scene defines the hosting scene
  39250. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39251. * @returns a new standard material
  39252. */
  39253. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39254. /**
  39255. * Are diffuse textures enabled in the application.
  39256. */
  39257. static DiffuseTextureEnabled: boolean;
  39258. /**
  39259. * Are ambient textures enabled in the application.
  39260. */
  39261. static AmbientTextureEnabled: boolean;
  39262. /**
  39263. * Are opacity textures enabled in the application.
  39264. */
  39265. static OpacityTextureEnabled: boolean;
  39266. /**
  39267. * Are reflection textures enabled in the application.
  39268. */
  39269. static ReflectionTextureEnabled: boolean;
  39270. /**
  39271. * Are emissive textures enabled in the application.
  39272. */
  39273. static EmissiveTextureEnabled: boolean;
  39274. /**
  39275. * Are specular textures enabled in the application.
  39276. */
  39277. static SpecularTextureEnabled: boolean;
  39278. /**
  39279. * Are bump textures enabled in the application.
  39280. */
  39281. static BumpTextureEnabled: boolean;
  39282. /**
  39283. * Are lightmap textures enabled in the application.
  39284. */
  39285. static LightmapTextureEnabled: boolean;
  39286. /**
  39287. * Are refraction textures enabled in the application.
  39288. */
  39289. static RefractionTextureEnabled: boolean;
  39290. /**
  39291. * Are color grading textures enabled in the application.
  39292. */
  39293. static ColorGradingTextureEnabled: boolean;
  39294. /**
  39295. * Are fresnels enabled in the application.
  39296. */
  39297. static FresnelEnabled: boolean;
  39298. }
  39299. }
  39300. declare module BABYLON {
  39301. /**
  39302. * A class extending Texture allowing drawing on a texture
  39303. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39304. */
  39305. export class DynamicTexture extends Texture {
  39306. private _generateMipMaps;
  39307. private _canvas;
  39308. private _context;
  39309. private _engine;
  39310. /**
  39311. * Creates a DynamicTexture
  39312. * @param name defines the name of the texture
  39313. * @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
  39314. * @param scene defines the scene where you want the texture
  39315. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39316. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39317. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39318. */
  39319. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39320. /**
  39321. * Get the current class name of the texture useful for serialization or dynamic coding.
  39322. * @returns "DynamicTexture"
  39323. */
  39324. getClassName(): string;
  39325. /**
  39326. * Gets the current state of canRescale
  39327. */
  39328. readonly canRescale: boolean;
  39329. private _recreate;
  39330. /**
  39331. * Scales the texture
  39332. * @param ratio the scale factor to apply to both width and height
  39333. */
  39334. scale(ratio: number): void;
  39335. /**
  39336. * Resizes the texture
  39337. * @param width the new width
  39338. * @param height the new height
  39339. */
  39340. scaleTo(width: number, height: number): void;
  39341. /**
  39342. * Gets the context of the canvas used by the texture
  39343. * @returns the canvas context of the dynamic texture
  39344. */
  39345. getContext(): CanvasRenderingContext2D;
  39346. /**
  39347. * Clears the texture
  39348. */
  39349. clear(): void;
  39350. /**
  39351. * Updates the texture
  39352. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39353. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39354. */
  39355. update(invertY?: boolean, premulAlpha?: boolean): void;
  39356. /**
  39357. * Draws text onto the texture
  39358. * @param text defines the text to be drawn
  39359. * @param x defines the placement of the text from the left
  39360. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39361. * @param font defines the font to be used with font-style, font-size, font-name
  39362. * @param color defines the color used for the text
  39363. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39364. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39365. * @param update defines whether texture is immediately update (default is true)
  39366. */
  39367. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39368. /**
  39369. * Clones the texture
  39370. * @returns the clone of the texture.
  39371. */
  39372. clone(): DynamicTexture;
  39373. /**
  39374. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39375. * @returns a serialized dynamic texture object
  39376. */
  39377. serialize(): any;
  39378. /** @hidden */
  39379. _rebuild(): void;
  39380. }
  39381. }
  39382. declare module BABYLON {
  39383. /** @hidden */
  39384. export var imageProcessingPixelShader: {
  39385. name: string;
  39386. shader: string;
  39387. };
  39388. }
  39389. declare module BABYLON {
  39390. /**
  39391. * ImageProcessingPostProcess
  39392. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39393. */
  39394. export class ImageProcessingPostProcess extends PostProcess {
  39395. /**
  39396. * Default configuration related to image processing available in the PBR Material.
  39397. */
  39398. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39399. /**
  39400. * Gets the image processing configuration used either in this material.
  39401. */
  39402. /**
  39403. * Sets the Default image processing configuration used either in the this material.
  39404. *
  39405. * If sets to null, the scene one is in use.
  39406. */
  39407. imageProcessingConfiguration: ImageProcessingConfiguration;
  39408. /**
  39409. * Keep track of the image processing observer to allow dispose and replace.
  39410. */
  39411. private _imageProcessingObserver;
  39412. /**
  39413. * Attaches a new image processing configuration to the PBR Material.
  39414. * @param configuration
  39415. */
  39416. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39417. /**
  39418. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39419. */
  39420. /**
  39421. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39422. */
  39423. colorCurves: Nullable<ColorCurves>;
  39424. /**
  39425. * Gets wether the color curves effect is enabled.
  39426. */
  39427. /**
  39428. * Sets wether the color curves effect is enabled.
  39429. */
  39430. colorCurvesEnabled: boolean;
  39431. /**
  39432. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39433. */
  39434. /**
  39435. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39436. */
  39437. colorGradingTexture: Nullable<BaseTexture>;
  39438. /**
  39439. * Gets wether the color grading effect is enabled.
  39440. */
  39441. /**
  39442. * Gets wether the color grading effect is enabled.
  39443. */
  39444. colorGradingEnabled: boolean;
  39445. /**
  39446. * Gets exposure used in the effect.
  39447. */
  39448. /**
  39449. * Sets exposure used in the effect.
  39450. */
  39451. exposure: number;
  39452. /**
  39453. * Gets wether tonemapping is enabled or not.
  39454. */
  39455. /**
  39456. * Sets wether tonemapping is enabled or not
  39457. */
  39458. toneMappingEnabled: boolean;
  39459. /**
  39460. * Gets the type of tone mapping effect.
  39461. */
  39462. /**
  39463. * Sets the type of tone mapping effect.
  39464. */
  39465. toneMappingType: number;
  39466. /**
  39467. * Gets contrast used in the effect.
  39468. */
  39469. /**
  39470. * Sets contrast used in the effect.
  39471. */
  39472. contrast: number;
  39473. /**
  39474. * Gets Vignette stretch size.
  39475. */
  39476. /**
  39477. * Sets Vignette stretch size.
  39478. */
  39479. vignetteStretch: number;
  39480. /**
  39481. * Gets Vignette centre X Offset.
  39482. */
  39483. /**
  39484. * Sets Vignette centre X Offset.
  39485. */
  39486. vignetteCentreX: number;
  39487. /**
  39488. * Gets Vignette centre Y Offset.
  39489. */
  39490. /**
  39491. * Sets Vignette centre Y Offset.
  39492. */
  39493. vignetteCentreY: number;
  39494. /**
  39495. * Gets Vignette weight or intensity of the vignette effect.
  39496. */
  39497. /**
  39498. * Sets Vignette weight or intensity of the vignette effect.
  39499. */
  39500. vignetteWeight: number;
  39501. /**
  39502. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39503. * if vignetteEnabled is set to true.
  39504. */
  39505. /**
  39506. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39507. * if vignetteEnabled is set to true.
  39508. */
  39509. vignetteColor: Color4;
  39510. /**
  39511. * Gets Camera field of view used by the Vignette effect.
  39512. */
  39513. /**
  39514. * Sets Camera field of view used by the Vignette effect.
  39515. */
  39516. vignetteCameraFov: number;
  39517. /**
  39518. * Gets the vignette blend mode allowing different kind of effect.
  39519. */
  39520. /**
  39521. * Sets the vignette blend mode allowing different kind of effect.
  39522. */
  39523. vignetteBlendMode: number;
  39524. /**
  39525. * Gets wether the vignette effect is enabled.
  39526. */
  39527. /**
  39528. * Sets wether the vignette effect is enabled.
  39529. */
  39530. vignetteEnabled: boolean;
  39531. private _fromLinearSpace;
  39532. /**
  39533. * Gets wether the input of the processing is in Gamma or Linear Space.
  39534. */
  39535. /**
  39536. * Sets wether the input of the processing is in Gamma or Linear Space.
  39537. */
  39538. fromLinearSpace: boolean;
  39539. /**
  39540. * Defines cache preventing GC.
  39541. */
  39542. private _defines;
  39543. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39544. /**
  39545. * "ImageProcessingPostProcess"
  39546. * @returns "ImageProcessingPostProcess"
  39547. */
  39548. getClassName(): string;
  39549. protected _updateParameters(): void;
  39550. dispose(camera?: Camera): void;
  39551. }
  39552. }
  39553. declare module BABYLON {
  39554. /**
  39555. * Class containing static functions to help procedurally build meshes
  39556. */
  39557. export class GroundBuilder {
  39558. /**
  39559. * Creates a ground mesh
  39560. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39561. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39563. * @param name defines the name of the mesh
  39564. * @param options defines the options used to create the mesh
  39565. * @param scene defines the hosting scene
  39566. * @returns the ground mesh
  39567. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39568. */
  39569. static CreateGround(name: string, options: {
  39570. width?: number;
  39571. height?: number;
  39572. subdivisions?: number;
  39573. subdivisionsX?: number;
  39574. subdivisionsY?: number;
  39575. updatable?: boolean;
  39576. }, scene: any): Mesh;
  39577. /**
  39578. * Creates a tiled ground mesh
  39579. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39580. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39581. * * 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
  39582. * * 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
  39583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39584. * @param name defines the name of the mesh
  39585. * @param options defines the options used to create the mesh
  39586. * @param scene defines the hosting scene
  39587. * @returns the tiled ground mesh
  39588. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39589. */
  39590. static CreateTiledGround(name: string, options: {
  39591. xmin: number;
  39592. zmin: number;
  39593. xmax: number;
  39594. zmax: number;
  39595. subdivisions?: {
  39596. w: number;
  39597. h: number;
  39598. };
  39599. precision?: {
  39600. w: number;
  39601. h: number;
  39602. };
  39603. updatable?: boolean;
  39604. }, scene?: Nullable<Scene>): Mesh;
  39605. /**
  39606. * Creates a ground mesh from a height map
  39607. * * The parameter `url` sets the URL of the height map image resource.
  39608. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39609. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39610. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39611. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39612. * * 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.
  39613. * * 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).
  39614. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39616. * @param name defines the name of the mesh
  39617. * @param url defines the url to the height map
  39618. * @param options defines the options used to create the mesh
  39619. * @param scene defines the hosting scene
  39620. * @returns the ground mesh
  39621. * @see https://doc.babylonjs.com/babylon101/height_map
  39622. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39623. */
  39624. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39625. width?: number;
  39626. height?: number;
  39627. subdivisions?: number;
  39628. minHeight?: number;
  39629. maxHeight?: number;
  39630. colorFilter?: Color3;
  39631. alphaFilter?: number;
  39632. updatable?: boolean;
  39633. onReady?: (mesh: GroundMesh) => void;
  39634. }, scene?: Nullable<Scene>): GroundMesh;
  39635. }
  39636. }
  39637. declare module BABYLON {
  39638. /**
  39639. * Class containing static functions to help procedurally build meshes
  39640. */
  39641. export class TorusBuilder {
  39642. /**
  39643. * Creates a torus mesh
  39644. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39645. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39646. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39647. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39648. * * 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
  39649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39650. * @param name defines the name of the mesh
  39651. * @param options defines the options used to create the mesh
  39652. * @param scene defines the hosting scene
  39653. * @returns the torus mesh
  39654. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39655. */
  39656. static CreateTorus(name: string, options: {
  39657. diameter?: number;
  39658. thickness?: number;
  39659. tessellation?: number;
  39660. updatable?: boolean;
  39661. sideOrientation?: number;
  39662. frontUVs?: Vector4;
  39663. backUVs?: Vector4;
  39664. }, scene: any): Mesh;
  39665. }
  39666. }
  39667. declare module BABYLON {
  39668. /**
  39669. * Class containing static functions to help procedurally build meshes
  39670. */
  39671. export class CylinderBuilder {
  39672. /**
  39673. * Creates a cylinder or a cone mesh
  39674. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39675. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39676. * * 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.
  39677. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39678. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39679. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39680. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39681. * * 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).
  39682. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39683. * * 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).
  39684. * * 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
  39685. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39686. * * 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
  39687. * * 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.
  39688. * * If `enclose` is false, a ring surface is one element.
  39689. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39690. * * 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
  39691. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39692. * * 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
  39693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39694. * @param name defines the name of the mesh
  39695. * @param options defines the options used to create the mesh
  39696. * @param scene defines the hosting scene
  39697. * @returns the cylinder mesh
  39698. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39699. */
  39700. static CreateCylinder(name: string, options: {
  39701. height?: number;
  39702. diameterTop?: number;
  39703. diameterBottom?: number;
  39704. diameter?: number;
  39705. tessellation?: number;
  39706. subdivisions?: number;
  39707. arc?: number;
  39708. faceColors?: Color4[];
  39709. faceUV?: Vector4[];
  39710. updatable?: boolean;
  39711. hasRings?: boolean;
  39712. enclose?: boolean;
  39713. cap?: number;
  39714. sideOrientation?: number;
  39715. frontUVs?: Vector4;
  39716. backUVs?: Vector4;
  39717. }, scene: any): Mesh;
  39718. }
  39719. }
  39720. declare module BABYLON {
  39721. /**
  39722. * Options to modify the vr teleportation behavior.
  39723. */
  39724. export interface VRTeleportationOptions {
  39725. /**
  39726. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39727. */
  39728. floorMeshName?: string;
  39729. /**
  39730. * A list of meshes to be used as the teleportation floor. (default: empty)
  39731. */
  39732. floorMeshes?: Mesh[];
  39733. }
  39734. /**
  39735. * Options to modify the vr experience helper's behavior.
  39736. */
  39737. export interface VRExperienceHelperOptions extends WebVROptions {
  39738. /**
  39739. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39740. */
  39741. createDeviceOrientationCamera?: boolean;
  39742. /**
  39743. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39744. */
  39745. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39746. /**
  39747. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39748. */
  39749. laserToggle?: boolean;
  39750. /**
  39751. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39752. */
  39753. floorMeshes?: Mesh[];
  39754. /**
  39755. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39756. */
  39757. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39758. }
  39759. /**
  39760. * Event containing information after VR has been entered
  39761. */
  39762. export class OnAfterEnteringVRObservableEvent {
  39763. /**
  39764. * If entering vr was successful
  39765. */
  39766. success: boolean;
  39767. }
  39768. /**
  39769. * Helps to quickly add VR support to an existing scene.
  39770. * See http://doc.babylonjs.com/how_to/webvr_helper
  39771. */
  39772. export class VRExperienceHelper {
  39773. /** Options to modify the vr experience helper's behavior. */
  39774. webVROptions: VRExperienceHelperOptions;
  39775. private _scene;
  39776. private _position;
  39777. private _btnVR;
  39778. private _btnVRDisplayed;
  39779. private _webVRsupported;
  39780. private _webVRready;
  39781. private _webVRrequesting;
  39782. private _webVRpresenting;
  39783. private _hasEnteredVR;
  39784. private _fullscreenVRpresenting;
  39785. private _canvas;
  39786. private _webVRCamera;
  39787. private _vrDeviceOrientationCamera;
  39788. private _deviceOrientationCamera;
  39789. private _existingCamera;
  39790. private _onKeyDown;
  39791. private _onVrDisplayPresentChange;
  39792. private _onVRDisplayChanged;
  39793. private _onVRRequestPresentStart;
  39794. private _onVRRequestPresentComplete;
  39795. /**
  39796. * Observable raised right before entering VR.
  39797. */
  39798. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39799. /**
  39800. * Observable raised when entering VR has completed.
  39801. */
  39802. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39803. /**
  39804. * Observable raised when exiting VR.
  39805. */
  39806. onExitingVRObservable: Observable<VRExperienceHelper>;
  39807. /**
  39808. * Observable raised when controller mesh is loaded.
  39809. */
  39810. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39811. /** Return this.onEnteringVRObservable
  39812. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39813. */
  39814. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39815. /** Return this.onExitingVRObservable
  39816. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39817. */
  39818. readonly onExitingVR: Observable<VRExperienceHelper>;
  39819. /** Return this.onControllerMeshLoadedObservable
  39820. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39821. */
  39822. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39823. private _rayLength;
  39824. private _useCustomVRButton;
  39825. private _teleportationRequested;
  39826. private _teleportActive;
  39827. private _floorMeshName;
  39828. private _floorMeshesCollection;
  39829. private _rotationAllowed;
  39830. private _teleportBackwardsVector;
  39831. private _teleportationTarget;
  39832. private _isDefaultTeleportationTarget;
  39833. private _postProcessMove;
  39834. private _teleportationFillColor;
  39835. private _teleportationBorderColor;
  39836. private _rotationAngle;
  39837. private _haloCenter;
  39838. private _cameraGazer;
  39839. private _padSensibilityUp;
  39840. private _padSensibilityDown;
  39841. private _leftController;
  39842. private _rightController;
  39843. /**
  39844. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39845. */
  39846. onNewMeshSelected: Observable<AbstractMesh>;
  39847. /**
  39848. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39849. */
  39850. onNewMeshPicked: Observable<PickingInfo>;
  39851. private _circleEase;
  39852. /**
  39853. * Observable raised before camera teleportation
  39854. */
  39855. onBeforeCameraTeleport: Observable<Vector3>;
  39856. /**
  39857. * Observable raised after camera teleportation
  39858. */
  39859. onAfterCameraTeleport: Observable<Vector3>;
  39860. /**
  39861. * Observable raised when current selected mesh gets unselected
  39862. */
  39863. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39864. private _raySelectionPredicate;
  39865. /**
  39866. * To be optionaly changed by user to define custom ray selection
  39867. */
  39868. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39869. /**
  39870. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39871. */
  39872. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39873. /**
  39874. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39875. */
  39876. teleportationEnabled: boolean;
  39877. private _defaultHeight;
  39878. private _teleportationInitialized;
  39879. private _interactionsEnabled;
  39880. private _interactionsRequested;
  39881. private _displayGaze;
  39882. private _displayLaserPointer;
  39883. /**
  39884. * The mesh used to display where the user is going to teleport.
  39885. */
  39886. /**
  39887. * Sets the mesh to be used to display where the user is going to teleport.
  39888. */
  39889. teleportationTarget: Mesh;
  39890. /**
  39891. * 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
  39892. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39893. * See http://doc.babylonjs.com/resources/baking_transformations
  39894. */
  39895. gazeTrackerMesh: Mesh;
  39896. /**
  39897. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39898. */
  39899. updateGazeTrackerScale: boolean;
  39900. /**
  39901. * If the gaze trackers color should be updated when selecting meshes
  39902. */
  39903. updateGazeTrackerColor: boolean;
  39904. /**
  39905. * The gaze tracking mesh corresponding to the left controller
  39906. */
  39907. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39908. /**
  39909. * The gaze tracking mesh corresponding to the right controller
  39910. */
  39911. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39912. /**
  39913. * If the ray of the gaze should be displayed.
  39914. */
  39915. /**
  39916. * Sets if the ray of the gaze should be displayed.
  39917. */
  39918. displayGaze: boolean;
  39919. /**
  39920. * If the ray of the LaserPointer should be displayed.
  39921. */
  39922. /**
  39923. * Sets if the ray of the LaserPointer should be displayed.
  39924. */
  39925. displayLaserPointer: boolean;
  39926. /**
  39927. * The deviceOrientationCamera used as the camera when not in VR.
  39928. */
  39929. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39930. /**
  39931. * Based on the current WebVR support, returns the current VR camera used.
  39932. */
  39933. readonly currentVRCamera: Nullable<Camera>;
  39934. /**
  39935. * The webVRCamera which is used when in VR.
  39936. */
  39937. readonly webVRCamera: WebVRFreeCamera;
  39938. /**
  39939. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39940. */
  39941. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39942. private readonly _teleportationRequestInitiated;
  39943. /**
  39944. * Defines wether or not Pointer lock should be requested when switching to
  39945. * full screen.
  39946. */
  39947. requestPointerLockOnFullScreen: boolean;
  39948. /**
  39949. * Instantiates a VRExperienceHelper.
  39950. * Helps to quickly add VR support to an existing scene.
  39951. * @param scene The scene the VRExperienceHelper belongs to.
  39952. * @param webVROptions Options to modify the vr experience helper's behavior.
  39953. */
  39954. constructor(scene: Scene,
  39955. /** Options to modify the vr experience helper's behavior. */
  39956. webVROptions?: VRExperienceHelperOptions);
  39957. private _onDefaultMeshLoaded;
  39958. private _onResize;
  39959. private _onFullscreenChange;
  39960. /**
  39961. * Gets a value indicating if we are currently in VR mode.
  39962. */
  39963. readonly isInVRMode: boolean;
  39964. private onVrDisplayPresentChange;
  39965. private onVRDisplayChanged;
  39966. private moveButtonToBottomRight;
  39967. private displayVRButton;
  39968. private updateButtonVisibility;
  39969. private _cachedAngularSensibility;
  39970. /**
  39971. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39972. * Otherwise, will use the fullscreen API.
  39973. */
  39974. enterVR(): void;
  39975. /**
  39976. * Attempt to exit VR, or fullscreen.
  39977. */
  39978. exitVR(): void;
  39979. /**
  39980. * The position of the vr experience helper.
  39981. */
  39982. /**
  39983. * Sets the position of the vr experience helper.
  39984. */
  39985. position: Vector3;
  39986. /**
  39987. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39988. */
  39989. enableInteractions(): void;
  39990. private readonly _noControllerIsActive;
  39991. private beforeRender;
  39992. private _isTeleportationFloor;
  39993. /**
  39994. * Adds a floor mesh to be used for teleportation.
  39995. * @param floorMesh the mesh to be used for teleportation.
  39996. */
  39997. addFloorMesh(floorMesh: Mesh): void;
  39998. /**
  39999. * Removes a floor mesh from being used for teleportation.
  40000. * @param floorMesh the mesh to be removed.
  40001. */
  40002. removeFloorMesh(floorMesh: Mesh): void;
  40003. /**
  40004. * Enables interactions and teleportation using the VR controllers and gaze.
  40005. * @param vrTeleportationOptions options to modify teleportation behavior.
  40006. */
  40007. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40008. private _onNewGamepadConnected;
  40009. private _tryEnableInteractionOnController;
  40010. private _onNewGamepadDisconnected;
  40011. private _enableInteractionOnController;
  40012. private _checkTeleportWithRay;
  40013. private _checkRotate;
  40014. private _checkTeleportBackwards;
  40015. private _enableTeleportationOnController;
  40016. private _createTeleportationCircles;
  40017. private _displayTeleportationTarget;
  40018. private _hideTeleportationTarget;
  40019. private _rotateCamera;
  40020. private _moveTeleportationSelectorTo;
  40021. private _workingVector;
  40022. private _workingQuaternion;
  40023. private _workingMatrix;
  40024. /**
  40025. * Teleports the users feet to the desired location
  40026. * @param location The location where the user's feet should be placed
  40027. */
  40028. teleportCamera(location: Vector3): void;
  40029. private _convertNormalToDirectionOfRay;
  40030. private _castRayAndSelectObject;
  40031. private _notifySelectedMeshUnselected;
  40032. /**
  40033. * Sets the color of the laser ray from the vr controllers.
  40034. * @param color new color for the ray.
  40035. */
  40036. changeLaserColor(color: Color3): void;
  40037. /**
  40038. * Sets the color of the ray from the vr headsets gaze.
  40039. * @param color new color for the ray.
  40040. */
  40041. changeGazeColor(color: Color3): void;
  40042. /**
  40043. * Exits VR and disposes of the vr experience helper
  40044. */
  40045. dispose(): void;
  40046. /**
  40047. * Gets the name of the VRExperienceHelper class
  40048. * @returns "VRExperienceHelper"
  40049. */
  40050. getClassName(): string;
  40051. }
  40052. }
  40053. declare module BABYLON {
  40054. /**
  40055. * Manages an XRSession
  40056. * @see https://doc.babylonjs.com/how_to/webxr
  40057. */
  40058. export class WebXRSessionManager implements IDisposable {
  40059. private scene;
  40060. /**
  40061. * Fires every time a new xrFrame arrives which can be used to update the camera
  40062. */
  40063. onXRFrameObservable: Observable<any>;
  40064. /**
  40065. * Fires when the xr session is ended either by the device or manually done
  40066. */
  40067. onXRSessionEnded: Observable<any>;
  40068. /** @hidden */
  40069. _xrSession: XRSession;
  40070. /** @hidden */
  40071. _frameOfReference: XRFrameOfReference;
  40072. /** @hidden */
  40073. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40074. /** @hidden */
  40075. _currentXRFrame: Nullable<XRFrame>;
  40076. private _xrNavigator;
  40077. private _xrDevice;
  40078. private _tmpMatrix;
  40079. /**
  40080. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40081. * @param scene The scene which the session should be created for
  40082. */
  40083. constructor(scene: Scene);
  40084. /**
  40085. * Initializes the manager
  40086. * After initialization enterXR can be called to start an XR session
  40087. * @returns Promise which resolves after it is initialized
  40088. */
  40089. initializeAsync(): Promise<void>;
  40090. /**
  40091. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40092. * @param sessionCreationOptions xr options to create the session with
  40093. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40094. * @returns Promise which resolves after it enters XR
  40095. */
  40096. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40097. /**
  40098. * Stops the xrSession and restores the renderloop
  40099. * @returns Promise which resolves after it exits XR
  40100. */
  40101. exitXRAsync(): Promise<void>;
  40102. /**
  40103. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40104. * @param ray ray to cast into the environment
  40105. * @returns Promise which resolves with a collision point in the environment if it exists
  40106. */
  40107. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40108. /**
  40109. * Checks if a session would be supported for the creation options specified
  40110. * @param options creation options to check if they are supported
  40111. * @returns true if supported
  40112. */
  40113. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40114. /**
  40115. * @hidden
  40116. * Converts the render layer of xrSession to a render target
  40117. * @param session session to create render target for
  40118. * @param scene scene the new render target should be created for
  40119. */
  40120. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40121. /**
  40122. * Disposes of the session manager
  40123. */
  40124. dispose(): void;
  40125. }
  40126. }
  40127. declare module BABYLON {
  40128. /**
  40129. * WebXR Camera which holds the views for the xrSession
  40130. * @see https://doc.babylonjs.com/how_to/webxr
  40131. */
  40132. export class WebXRCamera extends FreeCamera {
  40133. private static _TmpMatrix;
  40134. /**
  40135. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40136. * @param name the name of the camera
  40137. * @param scene the scene to add the camera to
  40138. */
  40139. constructor(name: string, scene: Scene);
  40140. private _updateNumberOfRigCameras;
  40141. /** @hidden */
  40142. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40143. /**
  40144. * Updates the cameras position from the current pose information of the XR session
  40145. * @param xrSessionManager the session containing pose information
  40146. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40147. */
  40148. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40149. }
  40150. }
  40151. declare module BABYLON {
  40152. /**
  40153. * States of the webXR experience
  40154. */
  40155. export enum WebXRState {
  40156. /**
  40157. * Transitioning to being in XR mode
  40158. */
  40159. ENTERING_XR = 0,
  40160. /**
  40161. * Transitioning to non XR mode
  40162. */
  40163. EXITING_XR = 1,
  40164. /**
  40165. * In XR mode and presenting
  40166. */
  40167. IN_XR = 2,
  40168. /**
  40169. * Not entered XR mode
  40170. */
  40171. NOT_IN_XR = 3
  40172. }
  40173. /**
  40174. * Helper class used to enable XR
  40175. * @see https://doc.babylonjs.com/how_to/webxr
  40176. */
  40177. export class WebXRExperienceHelper implements IDisposable {
  40178. private scene;
  40179. /**
  40180. * 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
  40181. */
  40182. container: AbstractMesh;
  40183. /**
  40184. * Camera used to render xr content
  40185. */
  40186. camera: WebXRCamera;
  40187. /**
  40188. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40189. */
  40190. state: WebXRState;
  40191. private _setState;
  40192. private static _TmpVector;
  40193. /**
  40194. * Fires when the state of the experience helper has changed
  40195. */
  40196. onStateChangedObservable: Observable<WebXRState>;
  40197. /** @hidden */
  40198. _sessionManager: WebXRSessionManager;
  40199. private _nonVRCamera;
  40200. private _originalSceneAutoClear;
  40201. private _supported;
  40202. /**
  40203. * Creates the experience helper
  40204. * @param scene the scene to attach the experience helper to
  40205. * @returns a promise for the experience helper
  40206. */
  40207. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40208. /**
  40209. * Creates a WebXRExperienceHelper
  40210. * @param scene The scene the helper should be created in
  40211. */
  40212. private constructor();
  40213. /**
  40214. * Exits XR mode and returns the scene to its original state
  40215. * @returns promise that resolves after xr mode has exited
  40216. */
  40217. exitXRAsync(): Promise<void>;
  40218. /**
  40219. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40220. * @param sessionCreationOptions options for the XR session
  40221. * @param frameOfReference frame of reference of the XR session
  40222. * @returns promise that resolves after xr mode has entered
  40223. */
  40224. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40225. /**
  40226. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40227. * @param ray ray to cast into the environment
  40228. * @returns Promise which resolves with a collision point in the environment if it exists
  40229. */
  40230. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40231. /**
  40232. * Updates the global position of the camera by moving the camera's container
  40233. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40234. * @param position The desired global position of the camera
  40235. */
  40236. setPositionOfCameraUsingContainer(position: Vector3): void;
  40237. /**
  40238. * Rotates the xr camera by rotating the camera's container around the camera's position
  40239. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40240. * @param rotation the desired quaternion rotation to apply to the camera
  40241. */
  40242. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40243. /**
  40244. * Checks if the creation options are supported by the xr session
  40245. * @param options creation options
  40246. * @returns true if supported
  40247. */
  40248. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40249. /**
  40250. * Disposes of the experience helper
  40251. */
  40252. dispose(): void;
  40253. }
  40254. }
  40255. declare module BABYLON {
  40256. /**
  40257. * Button which can be used to enter a different mode of XR
  40258. */
  40259. export class WebXREnterExitUIButton {
  40260. /** button element */
  40261. element: HTMLElement;
  40262. /** XR initialization options for the button */
  40263. initializationOptions: XRSessionCreationOptions;
  40264. /**
  40265. * Creates a WebXREnterExitUIButton
  40266. * @param element button element
  40267. * @param initializationOptions XR initialization options for the button
  40268. */
  40269. constructor(
  40270. /** button element */
  40271. element: HTMLElement,
  40272. /** XR initialization options for the button */
  40273. initializationOptions: XRSessionCreationOptions);
  40274. /**
  40275. * Overwritable function which can be used to update the button's visuals when the state changes
  40276. * @param activeButton the current active button in the UI
  40277. */
  40278. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40279. }
  40280. /**
  40281. * Options to create the webXR UI
  40282. */
  40283. export class WebXREnterExitUIOptions {
  40284. /**
  40285. * Context to enter xr with
  40286. */
  40287. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40288. /**
  40289. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40290. */
  40291. customButtons?: Array<WebXREnterExitUIButton>;
  40292. }
  40293. /**
  40294. * UI to allow the user to enter/exit XR mode
  40295. */
  40296. export class WebXREnterExitUI implements IDisposable {
  40297. private scene;
  40298. private _overlay;
  40299. private _buttons;
  40300. private _activeButton;
  40301. /**
  40302. * Fired every time the active button is changed.
  40303. *
  40304. * When xr is entered via a button that launches xr that button will be the callback parameter
  40305. *
  40306. * When exiting xr the callback parameter will be null)
  40307. */
  40308. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40309. /**
  40310. * Creates UI to allow the user to enter/exit XR mode
  40311. * @param scene the scene to add the ui to
  40312. * @param helper the xr experience helper to enter/exit xr with
  40313. * @param options options to configure the UI
  40314. * @returns the created ui
  40315. */
  40316. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40317. private constructor();
  40318. private _updateButtons;
  40319. /**
  40320. * Disposes of the object
  40321. */
  40322. dispose(): void;
  40323. }
  40324. }
  40325. declare module BABYLON {
  40326. /**
  40327. * Represents an XR input
  40328. */
  40329. export class WebXRController {
  40330. /**
  40331. * 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
  40332. */
  40333. grip?: AbstractMesh;
  40334. /**
  40335. * Pointer which can be used to select objects or attach a visible laser to
  40336. */
  40337. pointer: AbstractMesh;
  40338. /**
  40339. * Creates the controller
  40340. * @see https://doc.babylonjs.com/how_to/webxr
  40341. * @param scene the scene which the controller should be associated to
  40342. */
  40343. constructor(scene: Scene);
  40344. /**
  40345. * Disposes of the object
  40346. */
  40347. dispose(): void;
  40348. }
  40349. /**
  40350. * XR input used to track XR inputs such as controllers/rays
  40351. */
  40352. export class WebXRInput implements IDisposable {
  40353. private helper;
  40354. /**
  40355. * XR controllers being tracked
  40356. */
  40357. controllers: Array<WebXRController>;
  40358. private _tmpMatrix;
  40359. private _frameObserver;
  40360. /**
  40361. * Initializes the WebXRInput
  40362. * @param helper experience helper which the input should be created for
  40363. */
  40364. constructor(helper: WebXRExperienceHelper);
  40365. /**
  40366. * Disposes of the object
  40367. */
  40368. dispose(): void;
  40369. }
  40370. }
  40371. declare module BABYLON {
  40372. /**
  40373. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40374. */
  40375. export class WebXRManagedOutputCanvas implements IDisposable {
  40376. private _canvas;
  40377. /**
  40378. * xrpresent context of the canvas which can be used to display/mirror xr content
  40379. */
  40380. canvasContext: Nullable<WebGLRenderingContext>;
  40381. /**
  40382. * Initializes the canvas to be added/removed upon entering/exiting xr
  40383. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40384. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40385. */
  40386. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40387. /**
  40388. * Disposes of the object
  40389. */
  40390. dispose(): void;
  40391. private _setManagedOutputCanvas;
  40392. private _addCanvas;
  40393. private _removeCanvas;
  40394. }
  40395. }
  40396. declare module BABYLON {
  40397. /**
  40398. * Contains an array of blocks representing the octree
  40399. */
  40400. export interface IOctreeContainer<T> {
  40401. /**
  40402. * Blocks within the octree
  40403. */
  40404. blocks: Array<OctreeBlock<T>>;
  40405. }
  40406. /**
  40407. * Class used to store a cell in an octree
  40408. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40409. */
  40410. export class OctreeBlock<T> {
  40411. /**
  40412. * Gets the content of the current block
  40413. */
  40414. entries: T[];
  40415. /**
  40416. * Gets the list of block children
  40417. */
  40418. blocks: Array<OctreeBlock<T>>;
  40419. private _depth;
  40420. private _maxDepth;
  40421. private _capacity;
  40422. private _minPoint;
  40423. private _maxPoint;
  40424. private _boundingVectors;
  40425. private _creationFunc;
  40426. /**
  40427. * Creates a new block
  40428. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40429. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40430. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40431. * @param depth defines the current depth of this block in the octree
  40432. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40433. * @param creationFunc defines a callback to call when an element is added to the block
  40434. */
  40435. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40436. /**
  40437. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40438. */
  40439. readonly capacity: number;
  40440. /**
  40441. * Gets the minimum vector (in world space) of the block's bounding box
  40442. */
  40443. readonly minPoint: Vector3;
  40444. /**
  40445. * Gets the maximum vector (in world space) of the block's bounding box
  40446. */
  40447. readonly maxPoint: Vector3;
  40448. /**
  40449. * Add a new element to this block
  40450. * @param entry defines the element to add
  40451. */
  40452. addEntry(entry: T): void;
  40453. /**
  40454. * Remove an element from this block
  40455. * @param entry defines the element to remove
  40456. */
  40457. removeEntry(entry: T): void;
  40458. /**
  40459. * Add an array of elements to this block
  40460. * @param entries defines the array of elements to add
  40461. */
  40462. addEntries(entries: T[]): void;
  40463. /**
  40464. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40465. * @param frustumPlanes defines the frustum planes to test
  40466. * @param selection defines the array to store current content if selection is positive
  40467. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40468. */
  40469. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40470. /**
  40471. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40472. * @param sphereCenter defines the bounding sphere center
  40473. * @param sphereRadius defines the bounding sphere radius
  40474. * @param selection defines the array to store current content if selection is positive
  40475. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40476. */
  40477. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40478. /**
  40479. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40480. * @param ray defines the ray to test with
  40481. * @param selection defines the array to store current content if selection is positive
  40482. */
  40483. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40484. /**
  40485. * Subdivide the content into child blocks (this block will then be empty)
  40486. */
  40487. createInnerBlocks(): void;
  40488. /**
  40489. * @hidden
  40490. */
  40491. 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;
  40492. }
  40493. }
  40494. declare module BABYLON {
  40495. /**
  40496. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40497. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40498. */
  40499. export class Octree<T> {
  40500. /** 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.) */
  40501. maxDepth: number;
  40502. /**
  40503. * Blocks within the octree containing objects
  40504. */
  40505. blocks: Array<OctreeBlock<T>>;
  40506. /**
  40507. * Content stored in the octree
  40508. */
  40509. dynamicContent: T[];
  40510. private _maxBlockCapacity;
  40511. private _selectionContent;
  40512. private _creationFunc;
  40513. /**
  40514. * Creates a octree
  40515. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40516. * @param creationFunc function to be used to instatiate the octree
  40517. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40518. * @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.)
  40519. */
  40520. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40521. /** 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.) */
  40522. maxDepth?: number);
  40523. /**
  40524. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40525. * @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);
  40526. * @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);
  40527. * @param entries meshes to be added to the octree blocks
  40528. */
  40529. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40530. /**
  40531. * Adds a mesh to the octree
  40532. * @param entry Mesh to add to the octree
  40533. */
  40534. addMesh(entry: T): void;
  40535. /**
  40536. * Remove an element from the octree
  40537. * @param entry defines the element to remove
  40538. */
  40539. removeMesh(entry: T): void;
  40540. /**
  40541. * Selects an array of meshes within the frustum
  40542. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40543. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40544. * @returns array of meshes within the frustum
  40545. */
  40546. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40547. /**
  40548. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40549. * @param sphereCenter defines the bounding sphere center
  40550. * @param sphereRadius defines the bounding sphere radius
  40551. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40552. * @returns an array of objects that intersect the sphere
  40553. */
  40554. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40555. /**
  40556. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40557. * @param ray defines the ray to test with
  40558. * @returns array of intersected objects
  40559. */
  40560. intersectsRay(ray: Ray): SmartArray<T>;
  40561. /**
  40562. * Adds a mesh into the octree block if it intersects the block
  40563. */
  40564. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40565. /**
  40566. * Adds a submesh into the octree block if it intersects the block
  40567. */
  40568. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40569. }
  40570. }
  40571. declare module BABYLON {
  40572. interface Scene {
  40573. /**
  40574. * @hidden
  40575. * Backing Filed
  40576. */
  40577. _selectionOctree: Octree<AbstractMesh>;
  40578. /**
  40579. * Gets the octree used to boost mesh selection (picking)
  40580. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40581. */
  40582. selectionOctree: Octree<AbstractMesh>;
  40583. /**
  40584. * Creates or updates the octree used to boost selection (picking)
  40585. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40586. * @param maxCapacity defines the maximum capacity per leaf
  40587. * @param maxDepth defines the maximum depth of the octree
  40588. * @returns an octree of AbstractMesh
  40589. */
  40590. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40591. }
  40592. interface AbstractMesh {
  40593. /**
  40594. * @hidden
  40595. * Backing Field
  40596. */
  40597. _submeshesOctree: Octree<SubMesh>;
  40598. /**
  40599. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40600. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40601. * @param maxCapacity defines the maximum size of each block (64 by default)
  40602. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40603. * @returns the new octree
  40604. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40605. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40606. */
  40607. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40608. }
  40609. /**
  40610. * Defines the octree scene component responsible to manage any octrees
  40611. * in a given scene.
  40612. */
  40613. export class OctreeSceneComponent {
  40614. /**
  40615. * The component name help to identify the component in the list of scene components.
  40616. */
  40617. readonly name: string;
  40618. /**
  40619. * The scene the component belongs to.
  40620. */
  40621. scene: Scene;
  40622. /**
  40623. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40624. */
  40625. readonly checksIsEnabled: boolean;
  40626. /**
  40627. * Creates a new instance of the component for the given scene
  40628. * @param scene Defines the scene to register the component in
  40629. */
  40630. constructor(scene: Scene);
  40631. /**
  40632. * Registers the component in a given scene
  40633. */
  40634. register(): void;
  40635. /**
  40636. * Return the list of active meshes
  40637. * @returns the list of active meshes
  40638. */
  40639. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40640. /**
  40641. * Return the list of active sub meshes
  40642. * @param mesh The mesh to get the candidates sub meshes from
  40643. * @returns the list of active sub meshes
  40644. */
  40645. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40646. private _tempRay;
  40647. /**
  40648. * Return the list of sub meshes intersecting with a given local ray
  40649. * @param mesh defines the mesh to find the submesh for
  40650. * @param localRay defines the ray in local space
  40651. * @returns the list of intersecting sub meshes
  40652. */
  40653. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40654. /**
  40655. * Return the list of sub meshes colliding with a collider
  40656. * @param mesh defines the mesh to find the submesh for
  40657. * @param collider defines the collider to evaluate the collision against
  40658. * @returns the list of colliding sub meshes
  40659. */
  40660. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40661. /**
  40662. * Rebuilds the elements related to this component in case of
  40663. * context lost for instance.
  40664. */
  40665. rebuild(): void;
  40666. /**
  40667. * Disposes the component and the associated ressources.
  40668. */
  40669. dispose(): void;
  40670. }
  40671. }
  40672. declare module BABYLON {
  40673. /**
  40674. * Renders a layer on top of an existing scene
  40675. */
  40676. export class UtilityLayerRenderer implements IDisposable {
  40677. /** the original scene that will be rendered on top of */
  40678. originalScene: Scene;
  40679. private _pointerCaptures;
  40680. private _lastPointerEvents;
  40681. private static _DefaultUtilityLayer;
  40682. private static _DefaultKeepDepthUtilityLayer;
  40683. private _sharedGizmoLight;
  40684. /**
  40685. * @hidden
  40686. * Light which used by gizmos to get light shading
  40687. */
  40688. _getSharedGizmoLight(): HemisphericLight;
  40689. /**
  40690. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40691. */
  40692. pickUtilitySceneFirst: boolean;
  40693. /**
  40694. * 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)
  40695. */
  40696. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40697. /**
  40698. * 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)
  40699. */
  40700. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40701. /**
  40702. * The scene that is rendered on top of the original scene
  40703. */
  40704. utilityLayerScene: Scene;
  40705. /**
  40706. * If the utility layer should automatically be rendered on top of existing scene
  40707. */
  40708. shouldRender: boolean;
  40709. /**
  40710. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40711. */
  40712. onlyCheckPointerDownEvents: boolean;
  40713. /**
  40714. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40715. */
  40716. processAllEvents: boolean;
  40717. /**
  40718. * Observable raised when the pointer move from the utility layer scene to the main scene
  40719. */
  40720. onPointerOutObservable: Observable<number>;
  40721. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40722. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40723. private _afterRenderObserver;
  40724. private _sceneDisposeObserver;
  40725. private _originalPointerObserver;
  40726. /**
  40727. * Instantiates a UtilityLayerRenderer
  40728. * @param originalScene the original scene that will be rendered on top of
  40729. * @param handleEvents boolean indicating if the utility layer should handle events
  40730. */
  40731. constructor(
  40732. /** the original scene that will be rendered on top of */
  40733. originalScene: Scene, handleEvents?: boolean);
  40734. private _notifyObservers;
  40735. /**
  40736. * Renders the utility layers scene on top of the original scene
  40737. */
  40738. render(): void;
  40739. /**
  40740. * Disposes of the renderer
  40741. */
  40742. dispose(): void;
  40743. private _updateCamera;
  40744. }
  40745. }
  40746. declare module BABYLON {
  40747. /**
  40748. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40749. */
  40750. export class Gizmo implements IDisposable {
  40751. /** The utility layer the gizmo will be added to */
  40752. gizmoLayer: UtilityLayerRenderer;
  40753. /**
  40754. * The root mesh of the gizmo
  40755. */
  40756. _rootMesh: Mesh;
  40757. private _attachedMesh;
  40758. /**
  40759. * Ratio for the scale of the gizmo (Default: 1)
  40760. */
  40761. scaleRatio: number;
  40762. /**
  40763. * If a custom mesh has been set (Default: false)
  40764. */
  40765. protected _customMeshSet: boolean;
  40766. /**
  40767. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40768. * * When set, interactions will be enabled
  40769. */
  40770. attachedMesh: Nullable<AbstractMesh>;
  40771. /**
  40772. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40773. * @param mesh The mesh to replace the default mesh of the gizmo
  40774. */
  40775. setCustomMesh(mesh: Mesh): void;
  40776. /**
  40777. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40778. */
  40779. updateGizmoRotationToMatchAttachedMesh: boolean;
  40780. /**
  40781. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40782. */
  40783. updateGizmoPositionToMatchAttachedMesh: boolean;
  40784. /**
  40785. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40786. */
  40787. protected _updateScale: boolean;
  40788. protected _interactionsEnabled: boolean;
  40789. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40790. private _beforeRenderObserver;
  40791. private _tempVector;
  40792. /**
  40793. * Creates a gizmo
  40794. * @param gizmoLayer The utility layer the gizmo will be added to
  40795. */
  40796. constructor(
  40797. /** The utility layer the gizmo will be added to */
  40798. gizmoLayer?: UtilityLayerRenderer);
  40799. /**
  40800. * Updates the gizmo to match the attached mesh's position/rotation
  40801. */
  40802. protected _update(): void;
  40803. /**
  40804. * Disposes of the gizmo
  40805. */
  40806. dispose(): void;
  40807. }
  40808. }
  40809. declare module BABYLON {
  40810. /**
  40811. * Single axis drag gizmo
  40812. */
  40813. export class AxisDragGizmo extends Gizmo {
  40814. /**
  40815. * Drag behavior responsible for the gizmos dragging interactions
  40816. */
  40817. dragBehavior: PointerDragBehavior;
  40818. private _pointerObserver;
  40819. /**
  40820. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40821. */
  40822. snapDistance: number;
  40823. /**
  40824. * Event that fires each time the gizmo snaps to a new location.
  40825. * * snapDistance is the the change in distance
  40826. */
  40827. onSnapObservable: Observable<{
  40828. snapDistance: number;
  40829. }>;
  40830. /** @hidden */
  40831. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40832. /** @hidden */
  40833. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40834. /**
  40835. * Creates an AxisDragGizmo
  40836. * @param gizmoLayer The utility layer the gizmo will be added to
  40837. * @param dragAxis The axis which the gizmo will be able to drag on
  40838. * @param color The color of the gizmo
  40839. */
  40840. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40841. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40842. /**
  40843. * Disposes of the gizmo
  40844. */
  40845. dispose(): void;
  40846. }
  40847. }
  40848. declare module BABYLON.Debug {
  40849. /**
  40850. * The Axes viewer will show 3 axes in a specific point in space
  40851. */
  40852. export class AxesViewer {
  40853. private _xAxis;
  40854. private _yAxis;
  40855. private _zAxis;
  40856. private _scaleLinesFactor;
  40857. private _instanced;
  40858. /**
  40859. * Gets the hosting scene
  40860. */
  40861. scene: Scene;
  40862. /**
  40863. * Gets or sets a number used to scale line length
  40864. */
  40865. scaleLines: number;
  40866. /** Gets the node hierarchy used to render x-axis */
  40867. readonly xAxis: TransformNode;
  40868. /** Gets the node hierarchy used to render y-axis */
  40869. readonly yAxis: TransformNode;
  40870. /** Gets the node hierarchy used to render z-axis */
  40871. readonly zAxis: TransformNode;
  40872. /**
  40873. * Creates a new AxesViewer
  40874. * @param scene defines the hosting scene
  40875. * @param scaleLines defines a number used to scale line length (1 by default)
  40876. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40877. * @param xAxis defines the node hierarchy used to render the x-axis
  40878. * @param yAxis defines the node hierarchy used to render the y-axis
  40879. * @param zAxis defines the node hierarchy used to render the z-axis
  40880. */
  40881. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40882. /**
  40883. * Force the viewer to update
  40884. * @param position defines the position of the viewer
  40885. * @param xaxis defines the x axis of the viewer
  40886. * @param yaxis defines the y axis of the viewer
  40887. * @param zaxis defines the z axis of the viewer
  40888. */
  40889. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40890. /**
  40891. * Creates an instance of this axes viewer.
  40892. * @returns a new axes viewer with instanced meshes
  40893. */
  40894. createInstance(): AxesViewer;
  40895. /** Releases resources */
  40896. dispose(): void;
  40897. private static _SetRenderingGroupId;
  40898. }
  40899. }
  40900. declare module BABYLON.Debug {
  40901. /**
  40902. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40903. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40904. */
  40905. export class BoneAxesViewer extends AxesViewer {
  40906. /**
  40907. * Gets or sets the target mesh where to display the axes viewer
  40908. */
  40909. mesh: Nullable<Mesh>;
  40910. /**
  40911. * Gets or sets the target bone where to display the axes viewer
  40912. */
  40913. bone: Nullable<Bone>;
  40914. /** Gets current position */
  40915. pos: Vector3;
  40916. /** Gets direction of X axis */
  40917. xaxis: Vector3;
  40918. /** Gets direction of Y axis */
  40919. yaxis: Vector3;
  40920. /** Gets direction of Z axis */
  40921. zaxis: Vector3;
  40922. /**
  40923. * Creates a new BoneAxesViewer
  40924. * @param scene defines the hosting scene
  40925. * @param bone defines the target bone
  40926. * @param mesh defines the target mesh
  40927. * @param scaleLines defines a scaling factor for line length (1 by default)
  40928. */
  40929. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40930. /**
  40931. * Force the viewer to update
  40932. */
  40933. update(): void;
  40934. /** Releases resources */
  40935. dispose(): void;
  40936. }
  40937. }
  40938. declare module BABYLON {
  40939. /**
  40940. * Interface used to define scene explorer extensibility option
  40941. */
  40942. export interface IExplorerExtensibilityOption {
  40943. /**
  40944. * Define the option label
  40945. */
  40946. label: string;
  40947. /**
  40948. * Defines the action to execute on click
  40949. */
  40950. action: (entity: any) => void;
  40951. }
  40952. /**
  40953. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40954. */
  40955. export interface IExplorerExtensibilityGroup {
  40956. /**
  40957. * Defines a predicate to test if a given type mut be extended
  40958. */
  40959. predicate: (entity: any) => boolean;
  40960. /**
  40961. * Gets the list of options added to a type
  40962. */
  40963. entries: IExplorerExtensibilityOption[];
  40964. }
  40965. /**
  40966. * Interface used to define the options to use to create the Inspector
  40967. */
  40968. export interface IInspectorOptions {
  40969. /**
  40970. * Display in overlay mode (default: false)
  40971. */
  40972. overlay?: boolean;
  40973. /**
  40974. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40975. */
  40976. globalRoot?: HTMLElement;
  40977. /**
  40978. * Display the Scene explorer
  40979. */
  40980. showExplorer?: boolean;
  40981. /**
  40982. * Display the property inspector
  40983. */
  40984. showInspector?: boolean;
  40985. /**
  40986. * Display in embed mode (both panes on the right)
  40987. */
  40988. embedMode?: boolean;
  40989. /**
  40990. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40991. */
  40992. handleResize?: boolean;
  40993. /**
  40994. * Allow the panes to popup (default: true)
  40995. */
  40996. enablePopup?: boolean;
  40997. /**
  40998. * Allow the panes to be closed by users (default: true)
  40999. */
  41000. enableClose?: boolean;
  41001. /**
  41002. * Optional list of extensibility entries
  41003. */
  41004. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41005. /**
  41006. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41007. */
  41008. inspectorURL?: string;
  41009. }
  41010. interface Scene {
  41011. /**
  41012. * @hidden
  41013. * Backing field
  41014. */
  41015. _debugLayer: DebugLayer;
  41016. /**
  41017. * Gets the debug layer (aka Inspector) associated with the scene
  41018. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41019. */
  41020. debugLayer: DebugLayer;
  41021. }
  41022. /**
  41023. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41024. * what is happening in your scene
  41025. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41026. */
  41027. export class DebugLayer {
  41028. /**
  41029. * Define the url to get the inspector script from.
  41030. * By default it uses the babylonjs CDN.
  41031. * @ignoreNaming
  41032. */
  41033. static InspectorURL: string;
  41034. private _scene;
  41035. private BJSINSPECTOR;
  41036. /**
  41037. * Observable triggered when a property is changed through the inspector.
  41038. */
  41039. onPropertyChangedObservable: Observable<{
  41040. object: any;
  41041. property: string;
  41042. value: any;
  41043. initialValue: any;
  41044. }>;
  41045. /**
  41046. * Instantiates a new debug layer.
  41047. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41048. * what is happening in your scene
  41049. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41050. * @param scene Defines the scene to inspect
  41051. */
  41052. constructor(scene: Scene);
  41053. /** Creates the inspector window. */
  41054. private _createInspector;
  41055. /**
  41056. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41057. * @param entity defines the entity to select
  41058. * @param lineContainerTitle defines the specific block to highlight
  41059. */
  41060. select(entity: any, lineContainerTitle?: string): void;
  41061. /** Get the inspector from bundle or global */
  41062. private _getGlobalInspector;
  41063. /**
  41064. * Get if the inspector is visible or not.
  41065. * @returns true if visible otherwise, false
  41066. */
  41067. isVisible(): boolean;
  41068. /**
  41069. * Hide the inspector and close its window.
  41070. */
  41071. hide(): void;
  41072. /**
  41073. * Launch the debugLayer.
  41074. * @param config Define the configuration of the inspector
  41075. * @return a promise fulfilled when the debug layer is visible
  41076. */
  41077. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41078. }
  41079. }
  41080. declare module BABYLON {
  41081. /**
  41082. * Class containing static functions to help procedurally build meshes
  41083. */
  41084. export class BoxBuilder {
  41085. /**
  41086. * Creates a box mesh
  41087. * * The parameter `size` sets the size (float) of each box side (default 1)
  41088. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41089. * * 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)
  41090. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41092. * * 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
  41093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41094. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41095. * @param name defines the name of the mesh
  41096. * @param options defines the options used to create the mesh
  41097. * @param scene defines the hosting scene
  41098. * @returns the box mesh
  41099. */
  41100. static CreateBox(name: string, options: {
  41101. size?: number;
  41102. width?: number;
  41103. height?: number;
  41104. depth?: number;
  41105. faceUV?: Vector4[];
  41106. faceColors?: Color4[];
  41107. sideOrientation?: number;
  41108. frontUVs?: Vector4;
  41109. backUVs?: Vector4;
  41110. wrap?: boolean;
  41111. topBaseAt?: number;
  41112. bottomBaseAt?: number;
  41113. updatable?: boolean;
  41114. }, scene?: Nullable<Scene>): Mesh;
  41115. }
  41116. }
  41117. declare module BABYLON {
  41118. /**
  41119. * Class containing static functions to help procedurally build meshes
  41120. */
  41121. export class SphereBuilder {
  41122. /**
  41123. * Creates a sphere mesh
  41124. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41125. * * 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`)
  41126. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41127. * * 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
  41128. * * 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)
  41129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41130. * * 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
  41131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41132. * @param name defines the name of the mesh
  41133. * @param options defines the options used to create the mesh
  41134. * @param scene defines the hosting scene
  41135. * @returns the sphere mesh
  41136. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41137. */
  41138. static CreateSphere(name: string, options: {
  41139. segments?: number;
  41140. diameter?: number;
  41141. diameterX?: number;
  41142. diameterY?: number;
  41143. diameterZ?: number;
  41144. arc?: number;
  41145. slice?: number;
  41146. sideOrientation?: number;
  41147. frontUVs?: Vector4;
  41148. backUVs?: Vector4;
  41149. updatable?: boolean;
  41150. }, scene: any): Mesh;
  41151. }
  41152. }
  41153. declare module BABYLON.Debug {
  41154. /**
  41155. * Used to show the physics impostor around the specific mesh
  41156. */
  41157. export class PhysicsViewer {
  41158. /** @hidden */
  41159. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41160. /** @hidden */
  41161. protected _meshes: Array<Nullable<AbstractMesh>>;
  41162. /** @hidden */
  41163. protected _scene: Nullable<Scene>;
  41164. /** @hidden */
  41165. protected _numMeshes: number;
  41166. /** @hidden */
  41167. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41168. private _renderFunction;
  41169. private _utilityLayer;
  41170. private _debugBoxMesh;
  41171. private _debugSphereMesh;
  41172. private _debugCylinderMesh;
  41173. private _debugMaterial;
  41174. private _debugMeshMeshes;
  41175. /**
  41176. * Creates a new PhysicsViewer
  41177. * @param scene defines the hosting scene
  41178. */
  41179. constructor(scene: Scene);
  41180. /** @hidden */
  41181. protected _updateDebugMeshes(): void;
  41182. /**
  41183. * Renders a specified physic impostor
  41184. * @param impostor defines the impostor to render
  41185. * @param targetMesh defines the mesh represented by the impostor
  41186. * @returns the new debug mesh used to render the impostor
  41187. */
  41188. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  41189. /**
  41190. * Hides a specified physic impostor
  41191. * @param impostor defines the impostor to hide
  41192. */
  41193. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41194. private _getDebugMaterial;
  41195. private _getDebugBoxMesh;
  41196. private _getDebugSphereMesh;
  41197. private _getDebugCylinderMesh;
  41198. private _getDebugMeshMesh;
  41199. private _getDebugMesh;
  41200. /** Releases all resources */
  41201. dispose(): void;
  41202. }
  41203. }
  41204. declare module BABYLON {
  41205. /**
  41206. * Class containing static functions to help procedurally build meshes
  41207. */
  41208. export class LinesBuilder {
  41209. /**
  41210. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41211. * * 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
  41212. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41213. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41214. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41215. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41216. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41217. * * 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
  41218. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41220. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41221. * @param name defines the name of the new line system
  41222. * @param options defines the options used to create the line system
  41223. * @param scene defines the hosting scene
  41224. * @returns a new line system mesh
  41225. */
  41226. static CreateLineSystem(name: string, options: {
  41227. lines: Vector3[][];
  41228. updatable?: boolean;
  41229. instance?: Nullable<LinesMesh>;
  41230. colors?: Nullable<Color4[][]>;
  41231. useVertexAlpha?: boolean;
  41232. }, scene: Nullable<Scene>): LinesMesh;
  41233. /**
  41234. * Creates a line mesh
  41235. * 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
  41236. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41237. * * The parameter `points` is an array successive Vector3
  41238. * * 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
  41239. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41240. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41241. * * When updating an instance, remember that only point positions can change, not the number of points
  41242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41243. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41244. * @param name defines the name of the new line system
  41245. * @param options defines the options used to create the line system
  41246. * @param scene defines the hosting scene
  41247. * @returns a new line mesh
  41248. */
  41249. static CreateLines(name: string, options: {
  41250. points: Vector3[];
  41251. updatable?: boolean;
  41252. instance?: Nullable<LinesMesh>;
  41253. colors?: Color4[];
  41254. useVertexAlpha?: boolean;
  41255. }, scene?: Nullable<Scene>): LinesMesh;
  41256. /**
  41257. * Creates a dashed line mesh
  41258. * * 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
  41259. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41260. * * The parameter `points` is an array successive Vector3
  41261. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41262. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41263. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41264. * * 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
  41265. * * When updating an instance, remember that only point positions can change, not the number of points
  41266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41267. * @param name defines the name of the mesh
  41268. * @param options defines the options used to create the mesh
  41269. * @param scene defines the hosting scene
  41270. * @returns the dashed line mesh
  41271. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41272. */
  41273. static CreateDashedLines(name: string, options: {
  41274. points: Vector3[];
  41275. dashSize?: number;
  41276. gapSize?: number;
  41277. dashNb?: number;
  41278. updatable?: boolean;
  41279. instance?: LinesMesh;
  41280. }, scene?: Nullable<Scene>): LinesMesh;
  41281. }
  41282. }
  41283. declare module BABYLON {
  41284. /**
  41285. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41286. * in order to better appreciate the issue one might have.
  41287. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41288. */
  41289. export class RayHelper {
  41290. /**
  41291. * Defines the ray we are currently tryin to visualize.
  41292. */
  41293. ray: Nullable<Ray>;
  41294. private _renderPoints;
  41295. private _renderLine;
  41296. private _renderFunction;
  41297. private _scene;
  41298. private _updateToMeshFunction;
  41299. private _attachedToMesh;
  41300. private _meshSpaceDirection;
  41301. private _meshSpaceOrigin;
  41302. /**
  41303. * Helper function to create a colored helper in a scene in one line.
  41304. * @param ray Defines the ray we are currently tryin to visualize
  41305. * @param scene Defines the scene the ray is used in
  41306. * @param color Defines the color we want to see the ray in
  41307. * @returns The newly created ray helper.
  41308. */
  41309. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41310. /**
  41311. * Instantiate a new ray helper.
  41312. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41313. * in order to better appreciate the issue one might have.
  41314. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41315. * @param ray Defines the ray we are currently tryin to visualize
  41316. */
  41317. constructor(ray: Ray);
  41318. /**
  41319. * Shows the ray we are willing to debug.
  41320. * @param scene Defines the scene the ray needs to be rendered in
  41321. * @param color Defines the color the ray needs to be rendered in
  41322. */
  41323. show(scene: Scene, color?: Color3): void;
  41324. /**
  41325. * Hides the ray we are debugging.
  41326. */
  41327. hide(): void;
  41328. private _render;
  41329. /**
  41330. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41331. * @param mesh Defines the mesh we want the helper attached to
  41332. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41333. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41334. * @param length Defines the length of the ray
  41335. */
  41336. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41337. /**
  41338. * Detach the ray helper from the mesh it has previously been attached to.
  41339. */
  41340. detachFromMesh(): void;
  41341. private _updateToMesh;
  41342. /**
  41343. * Dispose the helper and release its associated resources.
  41344. */
  41345. dispose(): void;
  41346. }
  41347. }
  41348. declare module BABYLON.Debug {
  41349. /**
  41350. * Class used to render a debug view of a given skeleton
  41351. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41352. */
  41353. export class SkeletonViewer {
  41354. /** defines the skeleton to render */
  41355. skeleton: Skeleton;
  41356. /** defines the mesh attached to the skeleton */
  41357. mesh: AbstractMesh;
  41358. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41359. autoUpdateBonesMatrices: boolean;
  41360. /** defines the rendering group id to use with the viewer */
  41361. renderingGroupId: number;
  41362. /** Gets or sets the color used to render the skeleton */
  41363. color: Color3;
  41364. private _scene;
  41365. private _debugLines;
  41366. private _debugMesh;
  41367. private _isEnabled;
  41368. private _renderFunction;
  41369. private _utilityLayer;
  41370. /**
  41371. * Returns the mesh used to render the bones
  41372. */
  41373. readonly debugMesh: Nullable<LinesMesh>;
  41374. /**
  41375. * Creates a new SkeletonViewer
  41376. * @param skeleton defines the skeleton to render
  41377. * @param mesh defines the mesh attached to the skeleton
  41378. * @param scene defines the hosting scene
  41379. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41380. * @param renderingGroupId defines the rendering group id to use with the viewer
  41381. */
  41382. constructor(
  41383. /** defines the skeleton to render */
  41384. skeleton: Skeleton,
  41385. /** defines the mesh attached to the skeleton */
  41386. mesh: AbstractMesh, scene: Scene,
  41387. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41388. autoUpdateBonesMatrices?: boolean,
  41389. /** defines the rendering group id to use with the viewer */
  41390. renderingGroupId?: number);
  41391. /** Gets or sets a boolean indicating if the viewer is enabled */
  41392. isEnabled: boolean;
  41393. private _getBonePosition;
  41394. private _getLinesForBonesWithLength;
  41395. private _getLinesForBonesNoLength;
  41396. /** Update the viewer to sync with current skeleton state */
  41397. update(): void;
  41398. /** Release associated resources */
  41399. dispose(): void;
  41400. }
  41401. }
  41402. declare module BABYLON {
  41403. /**
  41404. * Options to create the null engine
  41405. */
  41406. export class NullEngineOptions {
  41407. /**
  41408. * Render width (Default: 512)
  41409. */
  41410. renderWidth: number;
  41411. /**
  41412. * Render height (Default: 256)
  41413. */
  41414. renderHeight: number;
  41415. /**
  41416. * Texture size (Default: 512)
  41417. */
  41418. textureSize: number;
  41419. /**
  41420. * If delta time between frames should be constant
  41421. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41422. */
  41423. deterministicLockstep: boolean;
  41424. /**
  41425. * Maximum about of steps between frames (Default: 4)
  41426. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41427. */
  41428. lockstepMaxSteps: number;
  41429. }
  41430. /**
  41431. * The null engine class provides support for headless version of babylon.js.
  41432. * This can be used in server side scenario or for testing purposes
  41433. */
  41434. export class NullEngine extends Engine {
  41435. private _options;
  41436. /**
  41437. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41438. */
  41439. isDeterministicLockStep(): boolean;
  41440. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41441. getLockstepMaxSteps(): number;
  41442. /**
  41443. * Sets hardware scaling, used to save performance if needed
  41444. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41445. */
  41446. getHardwareScalingLevel(): number;
  41447. constructor(options?: NullEngineOptions);
  41448. createVertexBuffer(vertices: FloatArray): DataBuffer;
  41449. createIndexBuffer(indices: IndicesArray): DataBuffer;
  41450. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41451. getRenderWidth(useScreen?: boolean): number;
  41452. getRenderHeight(useScreen?: boolean): number;
  41453. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41454. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41455. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41456. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41457. bindSamplers(effect: Effect): void;
  41458. enableEffect(effect: Effect): void;
  41459. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41460. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41461. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41462. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41463. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41464. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41465. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41466. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41467. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41468. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41469. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41470. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41471. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41472. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41473. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41474. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41475. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41476. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41477. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41478. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41479. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41480. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41481. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41482. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41483. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41484. bindBuffers(vertexBuffers: {
  41485. [key: string]: VertexBuffer;
  41486. }, indexBuffer: DataBuffer, effect: Effect): void;
  41487. wipeCaches(bruteForce?: boolean): void;
  41488. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41489. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41490. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41491. /** @hidden */
  41492. _createTexture(): WebGLTexture;
  41493. /** @hidden */
  41494. _releaseTexture(texture: InternalTexture): void;
  41495. 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;
  41496. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41497. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41498. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41499. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41500. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  41501. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41502. areAllEffectsReady(): boolean;
  41503. /**
  41504. * @hidden
  41505. * Get the current error code of the webGL context
  41506. * @returns the error code
  41507. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41508. */
  41509. getError(): number;
  41510. /** @hidden */
  41511. _getUnpackAlignement(): number;
  41512. /** @hidden */
  41513. _unpackFlipY(value: boolean): void;
  41514. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41515. /**
  41516. * Updates a dynamic vertex buffer.
  41517. * @param vertexBuffer the vertex buffer to update
  41518. * @param data the data used to update the vertex buffer
  41519. * @param byteOffset the byte offset of the data (optional)
  41520. * @param byteLength the byte length of the data (optional)
  41521. */
  41522. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41523. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41524. /** @hidden */
  41525. _bindTexture(channel: number, texture: InternalTexture): void;
  41526. /** @hidden */
  41527. _releaseBuffer(buffer: DataBuffer): boolean;
  41528. releaseEffects(): void;
  41529. displayLoadingUI(): void;
  41530. hideLoadingUI(): void;
  41531. /** @hidden */
  41532. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41533. /** @hidden */
  41534. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41535. /** @hidden */
  41536. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41537. /** @hidden */
  41538. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41539. }
  41540. }
  41541. declare module BABYLON {
  41542. /** @hidden */
  41543. export class _OcclusionDataStorage {
  41544. /** @hidden */
  41545. occlusionInternalRetryCounter: number;
  41546. /** @hidden */
  41547. isOcclusionQueryInProgress: boolean;
  41548. /** @hidden */
  41549. isOccluded: boolean;
  41550. /** @hidden */
  41551. occlusionRetryCount: number;
  41552. /** @hidden */
  41553. occlusionType: number;
  41554. /** @hidden */
  41555. occlusionQueryAlgorithmType: number;
  41556. }
  41557. interface Engine {
  41558. /**
  41559. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41560. * @return the new query
  41561. */
  41562. createQuery(): WebGLQuery;
  41563. /**
  41564. * Delete and release a webGL query
  41565. * @param query defines the query to delete
  41566. * @return the current engine
  41567. */
  41568. deleteQuery(query: WebGLQuery): Engine;
  41569. /**
  41570. * Check if a given query has resolved and got its value
  41571. * @param query defines the query to check
  41572. * @returns true if the query got its value
  41573. */
  41574. isQueryResultAvailable(query: WebGLQuery): boolean;
  41575. /**
  41576. * Gets the value of a given query
  41577. * @param query defines the query to check
  41578. * @returns the value of the query
  41579. */
  41580. getQueryResult(query: WebGLQuery): number;
  41581. /**
  41582. * Initiates an occlusion query
  41583. * @param algorithmType defines the algorithm to use
  41584. * @param query defines the query to use
  41585. * @returns the current engine
  41586. * @see http://doc.babylonjs.com/features/occlusionquery
  41587. */
  41588. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41589. /**
  41590. * Ends an occlusion query
  41591. * @see http://doc.babylonjs.com/features/occlusionquery
  41592. * @param algorithmType defines the algorithm to use
  41593. * @returns the current engine
  41594. */
  41595. endOcclusionQuery(algorithmType: number): Engine;
  41596. /**
  41597. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41598. * Please note that only one query can be issued at a time
  41599. * @returns a time token used to track the time span
  41600. */
  41601. startTimeQuery(): Nullable<_TimeToken>;
  41602. /**
  41603. * Ends a time query
  41604. * @param token defines the token used to measure the time span
  41605. * @returns the time spent (in ns)
  41606. */
  41607. endTimeQuery(token: _TimeToken): int;
  41608. /** @hidden */
  41609. _currentNonTimestampToken: Nullable<_TimeToken>;
  41610. /** @hidden */
  41611. _createTimeQuery(): WebGLQuery;
  41612. /** @hidden */
  41613. _deleteTimeQuery(query: WebGLQuery): void;
  41614. /** @hidden */
  41615. _getGlAlgorithmType(algorithmType: number): number;
  41616. /** @hidden */
  41617. _getTimeQueryResult(query: WebGLQuery): any;
  41618. /** @hidden */
  41619. _getTimeQueryAvailability(query: WebGLQuery): any;
  41620. }
  41621. interface AbstractMesh {
  41622. /**
  41623. * Backing filed
  41624. * @hidden
  41625. */
  41626. __occlusionDataStorage: _OcclusionDataStorage;
  41627. /**
  41628. * Access property
  41629. * @hidden
  41630. */
  41631. _occlusionDataStorage: _OcclusionDataStorage;
  41632. /**
  41633. * 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.
  41634. * The default value is -1 which means don't break the query and wait till the result
  41635. * @see http://doc.babylonjs.com/features/occlusionquery
  41636. */
  41637. occlusionRetryCount: number;
  41638. /**
  41639. * 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:
  41640. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41641. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41642. * * 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.
  41643. * @see http://doc.babylonjs.com/features/occlusionquery
  41644. */
  41645. occlusionType: number;
  41646. /**
  41647. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41648. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41649. * * 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.
  41650. * @see http://doc.babylonjs.com/features/occlusionquery
  41651. */
  41652. occlusionQueryAlgorithmType: number;
  41653. /**
  41654. * 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
  41655. * @see http://doc.babylonjs.com/features/occlusionquery
  41656. */
  41657. isOccluded: boolean;
  41658. /**
  41659. * Flag to check the progress status of the query
  41660. * @see http://doc.babylonjs.com/features/occlusionquery
  41661. */
  41662. isOcclusionQueryInProgress: boolean;
  41663. }
  41664. }
  41665. declare module BABYLON {
  41666. /** @hidden */
  41667. export var _forceTransformFeedbackToBundle: boolean;
  41668. interface Engine {
  41669. /**
  41670. * Creates a webGL transform feedback object
  41671. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41672. * @returns the webGL transform feedback object
  41673. */
  41674. createTransformFeedback(): WebGLTransformFeedback;
  41675. /**
  41676. * Delete a webGL transform feedback object
  41677. * @param value defines the webGL transform feedback object to delete
  41678. */
  41679. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41680. /**
  41681. * Bind a webGL transform feedback object to the webgl context
  41682. * @param value defines the webGL transform feedback object to bind
  41683. */
  41684. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41685. /**
  41686. * Begins a transform feedback operation
  41687. * @param usePoints defines if points or triangles must be used
  41688. */
  41689. beginTransformFeedback(usePoints: boolean): void;
  41690. /**
  41691. * Ends a transform feedback operation
  41692. */
  41693. endTransformFeedback(): void;
  41694. /**
  41695. * Specify the varyings to use with transform feedback
  41696. * @param program defines the associated webGL program
  41697. * @param value defines the list of strings representing the varying names
  41698. */
  41699. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41700. /**
  41701. * Bind a webGL buffer for a transform feedback operation
  41702. * @param value defines the webGL buffer to bind
  41703. */
  41704. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  41705. }
  41706. }
  41707. declare module BABYLON {
  41708. /**
  41709. * Creation options of the multi render target texture.
  41710. */
  41711. export interface IMultiRenderTargetOptions {
  41712. /**
  41713. * Define if the texture needs to create mip maps after render.
  41714. */
  41715. generateMipMaps?: boolean;
  41716. /**
  41717. * Define the types of all the draw buffers we want to create
  41718. */
  41719. types?: number[];
  41720. /**
  41721. * Define the sampling modes of all the draw buffers we want to create
  41722. */
  41723. samplingModes?: number[];
  41724. /**
  41725. * Define if a depth buffer is required
  41726. */
  41727. generateDepthBuffer?: boolean;
  41728. /**
  41729. * Define if a stencil buffer is required
  41730. */
  41731. generateStencilBuffer?: boolean;
  41732. /**
  41733. * Define if a depth texture is required instead of a depth buffer
  41734. */
  41735. generateDepthTexture?: boolean;
  41736. /**
  41737. * Define the number of desired draw buffers
  41738. */
  41739. textureCount?: number;
  41740. /**
  41741. * Define if aspect ratio should be adapted to the texture or stay the scene one
  41742. */
  41743. doNotChangeAspectRatio?: boolean;
  41744. /**
  41745. * Define the default type of the buffers we are creating
  41746. */
  41747. defaultType?: number;
  41748. }
  41749. /**
  41750. * A multi render target, like a render target provides the ability to render to a texture.
  41751. * Unlike the render target, it can render to several draw buffers in one draw.
  41752. * This is specially interesting in deferred rendering or for any effects requiring more than
  41753. * just one color from a single pass.
  41754. */
  41755. export class MultiRenderTarget extends RenderTargetTexture {
  41756. private _internalTextures;
  41757. private _textures;
  41758. private _multiRenderTargetOptions;
  41759. /**
  41760. * Get if draw buffers are currently supported by the used hardware and browser.
  41761. */
  41762. readonly isSupported: boolean;
  41763. /**
  41764. * Get the list of textures generated by the multi render target.
  41765. */
  41766. readonly textures: Texture[];
  41767. /**
  41768. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  41769. */
  41770. readonly depthTexture: Texture;
  41771. /**
  41772. * Set the wrapping mode on U of all the textures we are rendering to.
  41773. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41774. */
  41775. wrapU: number;
  41776. /**
  41777. * Set the wrapping mode on V of all the textures we are rendering to.
  41778. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41779. */
  41780. wrapV: number;
  41781. /**
  41782. * Instantiate a new multi render target texture.
  41783. * A multi render target, like a render target provides the ability to render to a texture.
  41784. * Unlike the render target, it can render to several draw buffers in one draw.
  41785. * This is specially interesting in deferred rendering or for any effects requiring more than
  41786. * just one color from a single pass.
  41787. * @param name Define the name of the texture
  41788. * @param size Define the size of the buffers to render to
  41789. * @param count Define the number of target we are rendering into
  41790. * @param scene Define the scene the texture belongs to
  41791. * @param options Define the options used to create the multi render target
  41792. */
  41793. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  41794. /** @hidden */
  41795. _rebuild(): void;
  41796. private _createInternalTextures;
  41797. private _createTextures;
  41798. /**
  41799. * Define the number of samples used if MSAA is enabled.
  41800. */
  41801. samples: number;
  41802. /**
  41803. * Resize all the textures in the multi render target.
  41804. * Be carrefull as it will recreate all the data in the new texture.
  41805. * @param size Define the new size
  41806. */
  41807. resize(size: any): void;
  41808. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  41809. /**
  41810. * Dispose the render targets and their associated resources
  41811. */
  41812. dispose(): void;
  41813. /**
  41814. * Release all the underlying texture used as draw buffers.
  41815. */
  41816. releaseInternalTextures(): void;
  41817. }
  41818. }
  41819. declare module BABYLON {
  41820. interface Engine {
  41821. /**
  41822. * Unbind a list of render target textures from the webGL context
  41823. * This is used only when drawBuffer extension or webGL2 are active
  41824. * @param textures defines the render target textures to unbind
  41825. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  41826. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  41827. */
  41828. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  41829. /**
  41830. * Create a multi render target texture
  41831. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  41832. * @param size defines the size of the texture
  41833. * @param options defines the creation options
  41834. * @returns the cube texture as an InternalTexture
  41835. */
  41836. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  41837. /**
  41838. * Update the sample count for a given multiple render target texture
  41839. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41840. * @param textures defines the textures to update
  41841. * @param samples defines the sample count to set
  41842. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41843. */
  41844. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  41845. }
  41846. }
  41847. declare module BABYLON {
  41848. /**
  41849. * Gather the list of clipboard event types as constants.
  41850. */
  41851. export class ClipboardEventTypes {
  41852. /**
  41853. * The clipboard event is fired when a copy command is active (pressed).
  41854. */
  41855. static readonly COPY: number;
  41856. /**
  41857. * The clipboard event is fired when a cut command is active (pressed).
  41858. */
  41859. static readonly CUT: number;
  41860. /**
  41861. * The clipboard event is fired when a paste command is active (pressed).
  41862. */
  41863. static readonly PASTE: number;
  41864. }
  41865. /**
  41866. * This class is used to store clipboard related info for the onClipboardObservable event.
  41867. */
  41868. export class ClipboardInfo {
  41869. /**
  41870. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41871. */
  41872. type: number;
  41873. /**
  41874. * Defines the related dom event
  41875. */
  41876. event: ClipboardEvent;
  41877. /**
  41878. *Creates an instance of ClipboardInfo.
  41879. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41880. * @param event Defines the related dom event
  41881. */
  41882. constructor(
  41883. /**
  41884. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41885. */
  41886. type: number,
  41887. /**
  41888. * Defines the related dom event
  41889. */
  41890. event: ClipboardEvent);
  41891. /**
  41892. * Get the clipboard event's type from the keycode.
  41893. * @param keyCode Defines the keyCode for the current keyboard event.
  41894. * @return {number}
  41895. */
  41896. static GetTypeFromCharacter(keyCode: number): number;
  41897. }
  41898. }
  41899. declare module BABYLON {
  41900. /**
  41901. * Class used to represent data loading progression
  41902. */
  41903. export class SceneLoaderProgressEvent {
  41904. /** defines if data length to load can be evaluated */
  41905. readonly lengthComputable: boolean;
  41906. /** defines the loaded data length */
  41907. readonly loaded: number;
  41908. /** defines the data length to load */
  41909. readonly total: number;
  41910. /**
  41911. * Create a new progress event
  41912. * @param lengthComputable defines if data length to load can be evaluated
  41913. * @param loaded defines the loaded data length
  41914. * @param total defines the data length to load
  41915. */
  41916. constructor(
  41917. /** defines if data length to load can be evaluated */
  41918. lengthComputable: boolean,
  41919. /** defines the loaded data length */
  41920. loaded: number,
  41921. /** defines the data length to load */
  41922. total: number);
  41923. /**
  41924. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41925. * @param event defines the source event
  41926. * @returns a new SceneLoaderProgressEvent
  41927. */
  41928. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41929. }
  41930. /**
  41931. * Interface used by SceneLoader plugins to define supported file extensions
  41932. */
  41933. export interface ISceneLoaderPluginExtensions {
  41934. /**
  41935. * Defines the list of supported extensions
  41936. */
  41937. [extension: string]: {
  41938. isBinary: boolean;
  41939. };
  41940. }
  41941. /**
  41942. * Interface used by SceneLoader plugin factory
  41943. */
  41944. export interface ISceneLoaderPluginFactory {
  41945. /**
  41946. * Defines the name of the factory
  41947. */
  41948. name: string;
  41949. /**
  41950. * Function called to create a new plugin
  41951. * @return the new plugin
  41952. */
  41953. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41954. /**
  41955. * Boolean indicating if the plugin can direct load specific data
  41956. */
  41957. canDirectLoad?: (data: string) => boolean;
  41958. }
  41959. /**
  41960. * Interface used to define a SceneLoader plugin
  41961. */
  41962. export interface ISceneLoaderPlugin {
  41963. /**
  41964. * The friendly name of this plugin.
  41965. */
  41966. name: string;
  41967. /**
  41968. * The file extensions supported by this plugin.
  41969. */
  41970. extensions: string | ISceneLoaderPluginExtensions;
  41971. /**
  41972. * Import meshes into a scene.
  41973. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41974. * @param scene The scene to import into
  41975. * @param data The data to import
  41976. * @param rootUrl The root url for scene and resources
  41977. * @param meshes The meshes array to import into
  41978. * @param particleSystems The particle systems array to import into
  41979. * @param skeletons The skeletons array to import into
  41980. * @param onError The callback when import fails
  41981. * @returns True if successful or false otherwise
  41982. */
  41983. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41984. /**
  41985. * Load into a scene.
  41986. * @param scene The scene to load into
  41987. * @param data The data to import
  41988. * @param rootUrl The root url for scene and resources
  41989. * @param onError The callback when import fails
  41990. * @returns true if successful or false otherwise
  41991. */
  41992. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41993. /**
  41994. * The callback that returns true if the data can be directly loaded.
  41995. */
  41996. canDirectLoad?: (data: string) => boolean;
  41997. /**
  41998. * The callback that allows custom handling of the root url based on the response url.
  41999. */
  42000. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42001. /**
  42002. * Load into an asset container.
  42003. * @param scene The scene to load into
  42004. * @param data The data to import
  42005. * @param rootUrl The root url for scene and resources
  42006. * @param onError The callback when import fails
  42007. * @returns The loaded asset container
  42008. */
  42009. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42010. }
  42011. /**
  42012. * Interface used to define an async SceneLoader plugin
  42013. */
  42014. export interface ISceneLoaderPluginAsync {
  42015. /**
  42016. * The friendly name of this plugin.
  42017. */
  42018. name: string;
  42019. /**
  42020. * The file extensions supported by this plugin.
  42021. */
  42022. extensions: string | ISceneLoaderPluginExtensions;
  42023. /**
  42024. * Import meshes into a scene.
  42025. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42026. * @param scene The scene to import into
  42027. * @param data The data to import
  42028. * @param rootUrl The root url for scene and resources
  42029. * @param onProgress The callback when the load progresses
  42030. * @param fileName Defines the name of the file to load
  42031. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42032. */
  42033. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42034. meshes: AbstractMesh[];
  42035. particleSystems: IParticleSystem[];
  42036. skeletons: Skeleton[];
  42037. animationGroups: AnimationGroup[];
  42038. }>;
  42039. /**
  42040. * Load into a scene.
  42041. * @param scene The scene to load into
  42042. * @param data The data to import
  42043. * @param rootUrl The root url for scene and resources
  42044. * @param onProgress The callback when the load progresses
  42045. * @param fileName Defines the name of the file to load
  42046. * @returns Nothing
  42047. */
  42048. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42049. /**
  42050. * The callback that returns true if the data can be directly loaded.
  42051. */
  42052. canDirectLoad?: (data: string) => boolean;
  42053. /**
  42054. * The callback that allows custom handling of the root url based on the response url.
  42055. */
  42056. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42057. /**
  42058. * Load into an asset container.
  42059. * @param scene The scene to load into
  42060. * @param data The data to import
  42061. * @param rootUrl The root url for scene and resources
  42062. * @param onProgress The callback when the load progresses
  42063. * @param fileName Defines the name of the file to load
  42064. * @returns The loaded asset container
  42065. */
  42066. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42067. }
  42068. /**
  42069. * Class used to load scene from various file formats using registered plugins
  42070. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42071. */
  42072. export class SceneLoader {
  42073. /**
  42074. * No logging while loading
  42075. */
  42076. static readonly NO_LOGGING: number;
  42077. /**
  42078. * Minimal logging while loading
  42079. */
  42080. static readonly MINIMAL_LOGGING: number;
  42081. /**
  42082. * Summary logging while loading
  42083. */
  42084. static readonly SUMMARY_LOGGING: number;
  42085. /**
  42086. * Detailled logging while loading
  42087. */
  42088. static readonly DETAILED_LOGGING: number;
  42089. /**
  42090. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42091. */
  42092. static ForceFullSceneLoadingForIncremental: boolean;
  42093. /**
  42094. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42095. */
  42096. static ShowLoadingScreen: boolean;
  42097. /**
  42098. * Defines the current logging level (while loading the scene)
  42099. * @ignorenaming
  42100. */
  42101. static loggingLevel: number;
  42102. /**
  42103. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42104. */
  42105. static CleanBoneMatrixWeights: boolean;
  42106. /**
  42107. * Event raised when a plugin is used to load a scene
  42108. */
  42109. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42110. private static _registeredPlugins;
  42111. private static _getDefaultPlugin;
  42112. private static _getPluginForExtension;
  42113. private static _getPluginForDirectLoad;
  42114. private static _getPluginForFilename;
  42115. private static _getDirectLoad;
  42116. private static _loadData;
  42117. private static _getFileInfo;
  42118. /**
  42119. * Gets a plugin that can load the given extension
  42120. * @param extension defines the extension to load
  42121. * @returns a plugin or null if none works
  42122. */
  42123. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42124. /**
  42125. * Gets a boolean indicating that the given extension can be loaded
  42126. * @param extension defines the extension to load
  42127. * @returns true if the extension is supported
  42128. */
  42129. static IsPluginForExtensionAvailable(extension: string): boolean;
  42130. /**
  42131. * Adds a new plugin to the list of registered plugins
  42132. * @param plugin defines the plugin to add
  42133. */
  42134. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42135. /**
  42136. * Import meshes into a scene
  42137. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42138. * @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)
  42139. * @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)
  42140. * @param scene the instance of BABYLON.Scene to append to
  42141. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42142. * @param onProgress a callback with a progress event for each file being loaded
  42143. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42144. * @param pluginExtension the extension used to determine the plugin
  42145. * @returns The loaded plugin
  42146. */
  42147. 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>;
  42148. /**
  42149. * Import meshes into a scene
  42150. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42151. * @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)
  42152. * @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)
  42153. * @param scene the instance of BABYLON.Scene to append to
  42154. * @param onProgress a callback with a progress event for each file being loaded
  42155. * @param pluginExtension the extension used to determine the plugin
  42156. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42157. */
  42158. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42159. meshes: AbstractMesh[];
  42160. particleSystems: IParticleSystem[];
  42161. skeletons: Skeleton[];
  42162. animationGroups: AnimationGroup[];
  42163. }>;
  42164. /**
  42165. * Load a scene
  42166. * @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)
  42167. * @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)
  42168. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42169. * @param onSuccess a callback with the scene when import succeeds
  42170. * @param onProgress a callback with a progress event for each file being loaded
  42171. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42172. * @param pluginExtension the extension used to determine the plugin
  42173. * @returns The loaded plugin
  42174. */
  42175. 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>;
  42176. /**
  42177. * Load a scene
  42178. * @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)
  42179. * @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)
  42180. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42181. * @param onProgress a callback with a progress event for each file being loaded
  42182. * @param pluginExtension the extension used to determine the plugin
  42183. * @returns The loaded scene
  42184. */
  42185. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42186. /**
  42187. * Append a scene
  42188. * @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)
  42189. * @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)
  42190. * @param scene is the instance of BABYLON.Scene to append to
  42191. * @param onSuccess a callback with the scene when import succeeds
  42192. * @param onProgress a callback with a progress event for each file being loaded
  42193. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42194. * @param pluginExtension the extension used to determine the plugin
  42195. * @returns The loaded plugin
  42196. */
  42197. 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>;
  42198. /**
  42199. * Append a scene
  42200. * @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)
  42201. * @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)
  42202. * @param scene is the instance of BABYLON.Scene to append to
  42203. * @param onProgress a callback with a progress event for each file being loaded
  42204. * @param pluginExtension the extension used to determine the plugin
  42205. * @returns The given scene
  42206. */
  42207. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42208. /**
  42209. * Load a scene into an asset container
  42210. * @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)
  42211. * @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)
  42212. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42213. * @param onSuccess a callback with the scene when import succeeds
  42214. * @param onProgress a callback with a progress event for each file being loaded
  42215. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42216. * @param pluginExtension the extension used to determine the plugin
  42217. * @returns The loaded plugin
  42218. */
  42219. 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>;
  42220. /**
  42221. * Load a scene into an asset container
  42222. * @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)
  42223. * @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)
  42224. * @param scene is the instance of Scene to append to
  42225. * @param onProgress a callback with a progress event for each file being loaded
  42226. * @param pluginExtension the extension used to determine the plugin
  42227. * @returns The loaded asset container
  42228. */
  42229. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42230. }
  42231. }
  42232. declare module BABYLON {
  42233. /**
  42234. * Google Daydream controller
  42235. */
  42236. export class DaydreamController extends WebVRController {
  42237. /**
  42238. * Base Url for the controller model.
  42239. */
  42240. static MODEL_BASE_URL: string;
  42241. /**
  42242. * File name for the controller model.
  42243. */
  42244. static MODEL_FILENAME: string;
  42245. /**
  42246. * Gamepad Id prefix used to identify Daydream Controller.
  42247. */
  42248. static readonly GAMEPAD_ID_PREFIX: string;
  42249. /**
  42250. * Creates a new DaydreamController from a gamepad
  42251. * @param vrGamepad the gamepad that the controller should be created from
  42252. */
  42253. constructor(vrGamepad: any);
  42254. /**
  42255. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42256. * @param scene scene in which to add meshes
  42257. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42258. */
  42259. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42260. /**
  42261. * Called once for each button that changed state since the last frame
  42262. * @param buttonIdx Which button index changed
  42263. * @param state New state of the button
  42264. * @param changes Which properties on the state changed since last frame
  42265. */
  42266. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42267. }
  42268. }
  42269. declare module BABYLON {
  42270. /**
  42271. * Gear VR Controller
  42272. */
  42273. export class GearVRController extends WebVRController {
  42274. /**
  42275. * Base Url for the controller model.
  42276. */
  42277. static MODEL_BASE_URL: string;
  42278. /**
  42279. * File name for the controller model.
  42280. */
  42281. static MODEL_FILENAME: string;
  42282. /**
  42283. * Gamepad Id prefix used to identify this controller.
  42284. */
  42285. static readonly GAMEPAD_ID_PREFIX: string;
  42286. private readonly _buttonIndexToObservableNameMap;
  42287. /**
  42288. * Creates a new GearVRController from a gamepad
  42289. * @param vrGamepad the gamepad that the controller should be created from
  42290. */
  42291. constructor(vrGamepad: any);
  42292. /**
  42293. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42294. * @param scene scene in which to add meshes
  42295. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42296. */
  42297. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42298. /**
  42299. * Called once for each button that changed state since the last frame
  42300. * @param buttonIdx Which button index changed
  42301. * @param state New state of the button
  42302. * @param changes Which properties on the state changed since last frame
  42303. */
  42304. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42305. }
  42306. }
  42307. declare module BABYLON {
  42308. /**
  42309. * Generic Controller
  42310. */
  42311. export class GenericController extends WebVRController {
  42312. /**
  42313. * Base Url for the controller model.
  42314. */
  42315. static readonly MODEL_BASE_URL: string;
  42316. /**
  42317. * File name for the controller model.
  42318. */
  42319. static readonly MODEL_FILENAME: string;
  42320. /**
  42321. * Creates a new GenericController from a gamepad
  42322. * @param vrGamepad the gamepad that the controller should be created from
  42323. */
  42324. constructor(vrGamepad: any);
  42325. /**
  42326. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42327. * @param scene scene in which to add meshes
  42328. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42329. */
  42330. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42331. /**
  42332. * Called once for each button that changed state since the last frame
  42333. * @param buttonIdx Which button index changed
  42334. * @param state New state of the button
  42335. * @param changes Which properties on the state changed since last frame
  42336. */
  42337. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42338. }
  42339. }
  42340. declare module BABYLON {
  42341. /**
  42342. * Oculus Touch Controller
  42343. */
  42344. export class OculusTouchController extends WebVRController {
  42345. /**
  42346. * Base Url for the controller model.
  42347. */
  42348. static MODEL_BASE_URL: string;
  42349. /**
  42350. * File name for the left controller model.
  42351. */
  42352. static MODEL_LEFT_FILENAME: string;
  42353. /**
  42354. * File name for the right controller model.
  42355. */
  42356. static MODEL_RIGHT_FILENAME: string;
  42357. /**
  42358. * Fired when the secondary trigger on this controller is modified
  42359. */
  42360. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42361. /**
  42362. * Fired when the thumb rest on this controller is modified
  42363. */
  42364. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42365. /**
  42366. * Creates a new OculusTouchController from a gamepad
  42367. * @param vrGamepad the gamepad that the controller should be created from
  42368. */
  42369. constructor(vrGamepad: any);
  42370. /**
  42371. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42372. * @param scene scene in which to add meshes
  42373. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42374. */
  42375. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42376. /**
  42377. * Fired when the A button on this controller is modified
  42378. */
  42379. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42380. /**
  42381. * Fired when the B button on this controller is modified
  42382. */
  42383. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42384. /**
  42385. * Fired when the X button on this controller is modified
  42386. */
  42387. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42388. /**
  42389. * Fired when the Y button on this controller is modified
  42390. */
  42391. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42392. /**
  42393. * Called once for each button that changed state since the last frame
  42394. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42395. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42396. * 2) secondary trigger (same)
  42397. * 3) A (right) X (left), touch, pressed = value
  42398. * 4) B / Y
  42399. * 5) thumb rest
  42400. * @param buttonIdx Which button index changed
  42401. * @param state New state of the button
  42402. * @param changes Which properties on the state changed since last frame
  42403. */
  42404. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42405. }
  42406. }
  42407. declare module BABYLON {
  42408. /**
  42409. * Vive Controller
  42410. */
  42411. export class ViveController extends WebVRController {
  42412. /**
  42413. * Base Url for the controller model.
  42414. */
  42415. static MODEL_BASE_URL: string;
  42416. /**
  42417. * File name for the controller model.
  42418. */
  42419. static MODEL_FILENAME: string;
  42420. /**
  42421. * Creates a new ViveController from a gamepad
  42422. * @param vrGamepad the gamepad that the controller should be created from
  42423. */
  42424. constructor(vrGamepad: any);
  42425. /**
  42426. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42427. * @param scene scene in which to add meshes
  42428. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42429. */
  42430. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42431. /**
  42432. * Fired when the left button on this controller is modified
  42433. */
  42434. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42435. /**
  42436. * Fired when the right button on this controller is modified
  42437. */
  42438. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42439. /**
  42440. * Fired when the menu button on this controller is modified
  42441. */
  42442. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42443. /**
  42444. * Called once for each button that changed state since the last frame
  42445. * Vive mapping:
  42446. * 0: touchpad
  42447. * 1: trigger
  42448. * 2: left AND right buttons
  42449. * 3: menu button
  42450. * @param buttonIdx Which button index changed
  42451. * @param state New state of the button
  42452. * @param changes Which properties on the state changed since last frame
  42453. */
  42454. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42455. }
  42456. }
  42457. declare module BABYLON {
  42458. /**
  42459. * Defines the WindowsMotionController object that the state of the windows motion controller
  42460. */
  42461. export class WindowsMotionController extends WebVRController {
  42462. /**
  42463. * The base url used to load the left and right controller models
  42464. */
  42465. static MODEL_BASE_URL: string;
  42466. /**
  42467. * The name of the left controller model file
  42468. */
  42469. static MODEL_LEFT_FILENAME: string;
  42470. /**
  42471. * The name of the right controller model file
  42472. */
  42473. static MODEL_RIGHT_FILENAME: string;
  42474. /**
  42475. * The controller name prefix for this controller type
  42476. */
  42477. static readonly GAMEPAD_ID_PREFIX: string;
  42478. /**
  42479. * The controller id pattern for this controller type
  42480. */
  42481. private static readonly GAMEPAD_ID_PATTERN;
  42482. private _loadedMeshInfo;
  42483. private readonly _mapping;
  42484. /**
  42485. * Fired when the trackpad on this controller is clicked
  42486. */
  42487. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42488. /**
  42489. * Fired when the trackpad on this controller is modified
  42490. */
  42491. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42492. /**
  42493. * The current x and y values of this controller's trackpad
  42494. */
  42495. trackpad: StickValues;
  42496. /**
  42497. * Creates a new WindowsMotionController from a gamepad
  42498. * @param vrGamepad the gamepad that the controller should be created from
  42499. */
  42500. constructor(vrGamepad: any);
  42501. /**
  42502. * Fired when the trigger on this controller is modified
  42503. */
  42504. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42505. /**
  42506. * Fired when the menu button on this controller is modified
  42507. */
  42508. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42509. /**
  42510. * Fired when the grip button on this controller is modified
  42511. */
  42512. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42513. /**
  42514. * Fired when the thumbstick button on this controller is modified
  42515. */
  42516. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42517. /**
  42518. * Fired when the touchpad button on this controller is modified
  42519. */
  42520. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42521. /**
  42522. * Fired when the touchpad values on this controller are modified
  42523. */
  42524. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42525. private _updateTrackpad;
  42526. /**
  42527. * Called once per frame by the engine.
  42528. */
  42529. update(): void;
  42530. /**
  42531. * Called once for each button that changed state since the last frame
  42532. * @param buttonIdx Which button index changed
  42533. * @param state New state of the button
  42534. * @param changes Which properties on the state changed since last frame
  42535. */
  42536. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42537. /**
  42538. * Moves the buttons on the controller mesh based on their current state
  42539. * @param buttonName the name of the button to move
  42540. * @param buttonValue the value of the button which determines the buttons new position
  42541. */
  42542. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42543. /**
  42544. * Moves the axis on the controller mesh based on its current state
  42545. * @param axis the index of the axis
  42546. * @param axisValue the value of the axis which determines the meshes new position
  42547. * @hidden
  42548. */
  42549. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42550. /**
  42551. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42552. * @param scene scene in which to add meshes
  42553. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42554. */
  42555. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42556. /**
  42557. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42558. * can be transformed by button presses and axes values, based on this._mapping.
  42559. *
  42560. * @param scene scene in which the meshes exist
  42561. * @param meshes list of meshes that make up the controller model to process
  42562. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42563. */
  42564. private processModel;
  42565. private createMeshInfo;
  42566. /**
  42567. * Gets the ray of the controller in the direction the controller is pointing
  42568. * @param length the length the resulting ray should be
  42569. * @returns a ray in the direction the controller is pointing
  42570. */
  42571. getForwardRay(length?: number): Ray;
  42572. /**
  42573. * Disposes of the controller
  42574. */
  42575. dispose(): void;
  42576. }
  42577. }
  42578. declare module BABYLON {
  42579. /**
  42580. * Single axis scale gizmo
  42581. */
  42582. export class AxisScaleGizmo extends Gizmo {
  42583. private _coloredMaterial;
  42584. /**
  42585. * Drag behavior responsible for the gizmos dragging interactions
  42586. */
  42587. dragBehavior: PointerDragBehavior;
  42588. private _pointerObserver;
  42589. /**
  42590. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42591. */
  42592. snapDistance: number;
  42593. /**
  42594. * Event that fires each time the gizmo snaps to a new location.
  42595. * * snapDistance is the the change in distance
  42596. */
  42597. onSnapObservable: Observable<{
  42598. snapDistance: number;
  42599. }>;
  42600. /**
  42601. * If the scaling operation should be done on all axis (default: false)
  42602. */
  42603. uniformScaling: boolean;
  42604. /**
  42605. * Creates an AxisScaleGizmo
  42606. * @param gizmoLayer The utility layer the gizmo will be added to
  42607. * @param dragAxis The axis which the gizmo will be able to scale on
  42608. * @param color The color of the gizmo
  42609. */
  42610. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42611. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42612. /**
  42613. * Disposes of the gizmo
  42614. */
  42615. dispose(): void;
  42616. /**
  42617. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42618. * @param mesh The mesh to replace the default mesh of the gizmo
  42619. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42620. */
  42621. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42622. }
  42623. }
  42624. declare module BABYLON {
  42625. /**
  42626. * Bounding box gizmo
  42627. */
  42628. export class BoundingBoxGizmo extends Gizmo {
  42629. private _lineBoundingBox;
  42630. private _rotateSpheresParent;
  42631. private _scaleBoxesParent;
  42632. private _boundingDimensions;
  42633. private _renderObserver;
  42634. private _pointerObserver;
  42635. private _scaleDragSpeed;
  42636. private _tmpQuaternion;
  42637. private _tmpVector;
  42638. private _tmpRotationMatrix;
  42639. /**
  42640. * 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)
  42641. */
  42642. ignoreChildren: boolean;
  42643. /**
  42644. * 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)
  42645. */
  42646. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42647. /**
  42648. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42649. */
  42650. rotationSphereSize: number;
  42651. /**
  42652. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42653. */
  42654. scaleBoxSize: number;
  42655. /**
  42656. * 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)
  42657. */
  42658. fixedDragMeshScreenSize: boolean;
  42659. /**
  42660. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42661. */
  42662. fixedDragMeshScreenSizeDistanceFactor: number;
  42663. /**
  42664. * Fired when a rotation sphere or scale box is dragged
  42665. */
  42666. onDragStartObservable: Observable<{}>;
  42667. /**
  42668. * Fired when a scale box is dragged
  42669. */
  42670. onScaleBoxDragObservable: Observable<{}>;
  42671. /**
  42672. * Fired when a scale box drag is ended
  42673. */
  42674. onScaleBoxDragEndObservable: Observable<{}>;
  42675. /**
  42676. * Fired when a rotation sphere is dragged
  42677. */
  42678. onRotationSphereDragObservable: Observable<{}>;
  42679. /**
  42680. * Fired when a rotation sphere drag is ended
  42681. */
  42682. onRotationSphereDragEndObservable: Observable<{}>;
  42683. /**
  42684. * 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)
  42685. */
  42686. scalePivot: Nullable<Vector3>;
  42687. /**
  42688. * Mesh used as a pivot to rotate the attached mesh
  42689. */
  42690. private _anchorMesh;
  42691. private _existingMeshScale;
  42692. private _dragMesh;
  42693. private pointerDragBehavior;
  42694. private coloredMaterial;
  42695. private hoverColoredMaterial;
  42696. /**
  42697. * Sets the color of the bounding box gizmo
  42698. * @param color the color to set
  42699. */
  42700. setColor(color: Color3): void;
  42701. /**
  42702. * Creates an BoundingBoxGizmo
  42703. * @param gizmoLayer The utility layer the gizmo will be added to
  42704. * @param color The color of the gizmo
  42705. */
  42706. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42707. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42708. private _selectNode;
  42709. /**
  42710. * Updates the bounding box information for the Gizmo
  42711. */
  42712. updateBoundingBox(): void;
  42713. private _updateRotationSpheres;
  42714. private _updateScaleBoxes;
  42715. /**
  42716. * Enables rotation on the specified axis and disables rotation on the others
  42717. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42718. */
  42719. setEnabledRotationAxis(axis: string): void;
  42720. /**
  42721. * Enables/disables scaling
  42722. * @param enable if scaling should be enabled
  42723. */
  42724. setEnabledScaling(enable: boolean): void;
  42725. private _updateDummy;
  42726. /**
  42727. * Enables a pointer drag behavior on the bounding box of the gizmo
  42728. */
  42729. enableDragBehavior(): void;
  42730. /**
  42731. * Disposes of the gizmo
  42732. */
  42733. dispose(): void;
  42734. /**
  42735. * 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)
  42736. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42737. * @returns the bounding box mesh with the passed in mesh as a child
  42738. */
  42739. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42740. /**
  42741. * CustomMeshes are not supported by this gizmo
  42742. * @param mesh The mesh to replace the default mesh of the gizmo
  42743. */
  42744. setCustomMesh(mesh: Mesh): void;
  42745. }
  42746. }
  42747. declare module BABYLON {
  42748. /**
  42749. * Single plane rotation gizmo
  42750. */
  42751. export class PlaneRotationGizmo extends Gizmo {
  42752. /**
  42753. * Drag behavior responsible for the gizmos dragging interactions
  42754. */
  42755. dragBehavior: PointerDragBehavior;
  42756. private _pointerObserver;
  42757. /**
  42758. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42759. */
  42760. snapDistance: number;
  42761. /**
  42762. * Event that fires each time the gizmo snaps to a new location.
  42763. * * snapDistance is the the change in distance
  42764. */
  42765. onSnapObservable: Observable<{
  42766. snapDistance: number;
  42767. }>;
  42768. /**
  42769. * Creates a PlaneRotationGizmo
  42770. * @param gizmoLayer The utility layer the gizmo will be added to
  42771. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42772. * @param color The color of the gizmo
  42773. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42774. */
  42775. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42776. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42777. /**
  42778. * Disposes of the gizmo
  42779. */
  42780. dispose(): void;
  42781. }
  42782. }
  42783. declare module BABYLON {
  42784. /**
  42785. * Gizmo that enables rotating a mesh along 3 axis
  42786. */
  42787. export class RotationGizmo extends Gizmo {
  42788. /**
  42789. * Internal gizmo used for interactions on the x axis
  42790. */
  42791. xGizmo: PlaneRotationGizmo;
  42792. /**
  42793. * Internal gizmo used for interactions on the y axis
  42794. */
  42795. yGizmo: PlaneRotationGizmo;
  42796. /**
  42797. * Internal gizmo used for interactions on the z axis
  42798. */
  42799. zGizmo: PlaneRotationGizmo;
  42800. /** Fires an event when any of it's sub gizmos are dragged */
  42801. onDragStartObservable: Observable<{}>;
  42802. /** Fires an event when any of it's sub gizmos are released from dragging */
  42803. onDragEndObservable: Observable<{}>;
  42804. attachedMesh: Nullable<AbstractMesh>;
  42805. /**
  42806. * Creates a RotationGizmo
  42807. * @param gizmoLayer The utility layer the gizmo will be added to
  42808. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42809. */
  42810. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42811. updateGizmoRotationToMatchAttachedMesh: boolean;
  42812. /**
  42813. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42814. */
  42815. snapDistance: number;
  42816. /**
  42817. * Ratio for the scale of the gizmo (Default: 1)
  42818. */
  42819. scaleRatio: number;
  42820. /**
  42821. * Disposes of the gizmo
  42822. */
  42823. dispose(): void;
  42824. /**
  42825. * CustomMeshes are not supported by this gizmo
  42826. * @param mesh The mesh to replace the default mesh of the gizmo
  42827. */
  42828. setCustomMesh(mesh: Mesh): void;
  42829. }
  42830. }
  42831. declare module BABYLON {
  42832. /**
  42833. * Gizmo that enables dragging a mesh along 3 axis
  42834. */
  42835. export class PositionGizmo extends Gizmo {
  42836. /**
  42837. * Internal gizmo used for interactions on the x axis
  42838. */
  42839. xGizmo: AxisDragGizmo;
  42840. /**
  42841. * Internal gizmo used for interactions on the y axis
  42842. */
  42843. yGizmo: AxisDragGizmo;
  42844. /**
  42845. * Internal gizmo used for interactions on the z axis
  42846. */
  42847. zGizmo: AxisDragGizmo;
  42848. /** Fires an event when any of it's sub gizmos are dragged */
  42849. onDragStartObservable: Observable<{}>;
  42850. /** Fires an event when any of it's sub gizmos are released from dragging */
  42851. onDragEndObservable: Observable<{}>;
  42852. attachedMesh: Nullable<AbstractMesh>;
  42853. /**
  42854. * Creates a PositionGizmo
  42855. * @param gizmoLayer The utility layer the gizmo will be added to
  42856. */
  42857. constructor(gizmoLayer?: UtilityLayerRenderer);
  42858. updateGizmoRotationToMatchAttachedMesh: boolean;
  42859. /**
  42860. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42861. */
  42862. snapDistance: number;
  42863. /**
  42864. * Ratio for the scale of the gizmo (Default: 1)
  42865. */
  42866. scaleRatio: number;
  42867. /**
  42868. * Disposes of the gizmo
  42869. */
  42870. dispose(): void;
  42871. /**
  42872. * CustomMeshes are not supported by this gizmo
  42873. * @param mesh The mesh to replace the default mesh of the gizmo
  42874. */
  42875. setCustomMesh(mesh: Mesh): void;
  42876. }
  42877. }
  42878. declare module BABYLON {
  42879. /**
  42880. * Class containing static functions to help procedurally build meshes
  42881. */
  42882. export class PolyhedronBuilder {
  42883. /**
  42884. * Creates a polyhedron mesh
  42885. * * 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
  42886. * * The parameter `size` (positive float, default 1) sets the polygon size
  42887. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42888. * * 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`
  42889. * * 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
  42890. * * 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)`)
  42891. * * 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
  42892. * * 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
  42893. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42894. * * 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
  42895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42896. * @param name defines the name of the mesh
  42897. * @param options defines the options used to create the mesh
  42898. * @param scene defines the hosting scene
  42899. * @returns the polyhedron mesh
  42900. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42901. */
  42902. static CreatePolyhedron(name: string, options: {
  42903. type?: number;
  42904. size?: number;
  42905. sizeX?: number;
  42906. sizeY?: number;
  42907. sizeZ?: number;
  42908. custom?: any;
  42909. faceUV?: Vector4[];
  42910. faceColors?: Color4[];
  42911. flat?: boolean;
  42912. updatable?: boolean;
  42913. sideOrientation?: number;
  42914. frontUVs?: Vector4;
  42915. backUVs?: Vector4;
  42916. }, scene?: Nullable<Scene>): Mesh;
  42917. }
  42918. }
  42919. declare module BABYLON {
  42920. /**
  42921. * Gizmo that enables scaling a mesh along 3 axis
  42922. */
  42923. export class ScaleGizmo extends Gizmo {
  42924. /**
  42925. * Internal gizmo used for interactions on the x axis
  42926. */
  42927. xGizmo: AxisScaleGizmo;
  42928. /**
  42929. * Internal gizmo used for interactions on the y axis
  42930. */
  42931. yGizmo: AxisScaleGizmo;
  42932. /**
  42933. * Internal gizmo used for interactions on the z axis
  42934. */
  42935. zGizmo: AxisScaleGizmo;
  42936. /**
  42937. * Internal gizmo used to scale all axis equally
  42938. */
  42939. uniformScaleGizmo: AxisScaleGizmo;
  42940. /** Fires an event when any of it's sub gizmos are dragged */
  42941. onDragStartObservable: Observable<{}>;
  42942. /** Fires an event when any of it's sub gizmos are released from dragging */
  42943. onDragEndObservable: Observable<{}>;
  42944. attachedMesh: Nullable<AbstractMesh>;
  42945. /**
  42946. * Creates a ScaleGizmo
  42947. * @param gizmoLayer The utility layer the gizmo will be added to
  42948. */
  42949. constructor(gizmoLayer?: UtilityLayerRenderer);
  42950. updateGizmoRotationToMatchAttachedMesh: boolean;
  42951. /**
  42952. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42953. */
  42954. snapDistance: number;
  42955. /**
  42956. * Ratio for the scale of the gizmo (Default: 1)
  42957. */
  42958. scaleRatio: number;
  42959. /**
  42960. * Disposes of the gizmo
  42961. */
  42962. dispose(): void;
  42963. }
  42964. }
  42965. declare module BABYLON {
  42966. /**
  42967. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42968. */
  42969. export class GizmoManager implements IDisposable {
  42970. private scene;
  42971. /**
  42972. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42973. */
  42974. gizmos: {
  42975. positionGizmo: Nullable<PositionGizmo>;
  42976. rotationGizmo: Nullable<RotationGizmo>;
  42977. scaleGizmo: Nullable<ScaleGizmo>;
  42978. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42979. };
  42980. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42981. clearGizmoOnEmptyPointerEvent: boolean;
  42982. /** Fires an event when the manager is attached to a mesh */
  42983. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42984. private _gizmosEnabled;
  42985. private _pointerObserver;
  42986. private _attachedMesh;
  42987. private _boundingBoxColor;
  42988. private _defaultUtilityLayer;
  42989. private _defaultKeepDepthUtilityLayer;
  42990. /**
  42991. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42992. */
  42993. boundingBoxDragBehavior: SixDofDragBehavior;
  42994. /**
  42995. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42996. */
  42997. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42998. /**
  42999. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43000. */
  43001. usePointerToAttachGizmos: boolean;
  43002. /**
  43003. * Instatiates a gizmo manager
  43004. * @param scene the scene to overlay the gizmos on top of
  43005. */
  43006. constructor(scene: Scene);
  43007. /**
  43008. * Attaches a set of gizmos to the specified mesh
  43009. * @param mesh The mesh the gizmo's should be attached to
  43010. */
  43011. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43012. /**
  43013. * If the position gizmo is enabled
  43014. */
  43015. positionGizmoEnabled: boolean;
  43016. /**
  43017. * If the rotation gizmo is enabled
  43018. */
  43019. rotationGizmoEnabled: boolean;
  43020. /**
  43021. * If the scale gizmo is enabled
  43022. */
  43023. scaleGizmoEnabled: boolean;
  43024. /**
  43025. * If the boundingBox gizmo is enabled
  43026. */
  43027. boundingBoxGizmoEnabled: boolean;
  43028. /**
  43029. * Disposes of the gizmo manager
  43030. */
  43031. dispose(): void;
  43032. }
  43033. }
  43034. declare module BABYLON {
  43035. /**
  43036. * A directional light is defined by a direction (what a surprise!).
  43037. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  43038. * 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.
  43039. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43040. */
  43041. export class DirectionalLight extends ShadowLight {
  43042. private _shadowFrustumSize;
  43043. /**
  43044. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  43045. */
  43046. /**
  43047. * Specifies a fix frustum size for the shadow generation.
  43048. */
  43049. shadowFrustumSize: number;
  43050. private _shadowOrthoScale;
  43051. /**
  43052. * Gets the shadow projection scale against the optimal computed one.
  43053. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43054. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43055. */
  43056. /**
  43057. * Sets the shadow projection scale against the optimal computed one.
  43058. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43059. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43060. */
  43061. shadowOrthoScale: number;
  43062. /**
  43063. * Automatically compute the projection matrix to best fit (including all the casters)
  43064. * on each frame.
  43065. */
  43066. autoUpdateExtends: boolean;
  43067. private _orthoLeft;
  43068. private _orthoRight;
  43069. private _orthoTop;
  43070. private _orthoBottom;
  43071. /**
  43072. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  43073. * The directional light is emitted from everywhere in the given direction.
  43074. * It can cast shadows.
  43075. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43076. * @param name The friendly name of the light
  43077. * @param direction The direction of the light
  43078. * @param scene The scene the light belongs to
  43079. */
  43080. constructor(name: string, direction: Vector3, scene: Scene);
  43081. /**
  43082. * Returns the string "DirectionalLight".
  43083. * @return The class name
  43084. */
  43085. getClassName(): string;
  43086. /**
  43087. * Returns the integer 1.
  43088. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43089. */
  43090. getTypeID(): number;
  43091. /**
  43092. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  43093. * Returns the DirectionalLight Shadow projection matrix.
  43094. */
  43095. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43096. /**
  43097. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  43098. * Returns the DirectionalLight Shadow projection matrix.
  43099. */
  43100. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  43101. /**
  43102. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  43103. * Returns the DirectionalLight Shadow projection matrix.
  43104. */
  43105. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43106. protected _buildUniformLayout(): void;
  43107. /**
  43108. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  43109. * @param effect The effect to update
  43110. * @param lightIndex The index of the light in the effect to update
  43111. * @returns The directional light
  43112. */
  43113. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  43114. /**
  43115. * Gets the minZ used for shadow according to both the scene and the light.
  43116. *
  43117. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43118. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43119. * @param activeCamera The camera we are returning the min for
  43120. * @returns the depth min z
  43121. */
  43122. getDepthMinZ(activeCamera: Camera): number;
  43123. /**
  43124. * Gets the maxZ used for shadow according to both the scene and the light.
  43125. *
  43126. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43127. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43128. * @param activeCamera The camera we are returning the max for
  43129. * @returns the depth max z
  43130. */
  43131. getDepthMaxZ(activeCamera: Camera): number;
  43132. /**
  43133. * Prepares the list of defines specific to the light type.
  43134. * @param defines the list of defines
  43135. * @param lightIndex defines the index of the light for the effect
  43136. */
  43137. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43138. }
  43139. }
  43140. declare module BABYLON {
  43141. /**
  43142. * Class containing static functions to help procedurally build meshes
  43143. */
  43144. export class HemisphereBuilder {
  43145. /**
  43146. * Creates a hemisphere mesh
  43147. * @param name defines the name of the mesh
  43148. * @param options defines the options used to create the mesh
  43149. * @param scene defines the hosting scene
  43150. * @returns the hemisphere mesh
  43151. */
  43152. static CreateHemisphere(name: string, options: {
  43153. segments?: number;
  43154. diameter?: number;
  43155. sideOrientation?: number;
  43156. }, scene: any): Mesh;
  43157. }
  43158. }
  43159. declare module BABYLON {
  43160. /**
  43161. * A spot light is defined by a position, a direction, an angle, and an exponent.
  43162. * These values define a cone of light starting from the position, emitting toward the direction.
  43163. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  43164. * and the exponent defines the speed of the decay of the light with distance (reach).
  43165. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43166. */
  43167. export class SpotLight extends ShadowLight {
  43168. private _angle;
  43169. private _innerAngle;
  43170. private _cosHalfAngle;
  43171. private _lightAngleScale;
  43172. private _lightAngleOffset;
  43173. /**
  43174. * Gets the cone angle of the spot light in Radians.
  43175. */
  43176. /**
  43177. * Sets the cone angle of the spot light in Radians.
  43178. */
  43179. angle: number;
  43180. /**
  43181. * Only used in gltf falloff mode, this defines the angle where
  43182. * the directional falloff will start before cutting at angle which could be seen
  43183. * as outer angle.
  43184. */
  43185. /**
  43186. * Only used in gltf falloff mode, this defines the angle where
  43187. * the directional falloff will start before cutting at angle which could be seen
  43188. * as outer angle.
  43189. */
  43190. innerAngle: number;
  43191. private _shadowAngleScale;
  43192. /**
  43193. * Allows scaling the angle of the light for shadow generation only.
  43194. */
  43195. /**
  43196. * Allows scaling the angle of the light for shadow generation only.
  43197. */
  43198. shadowAngleScale: number;
  43199. /**
  43200. * The light decay speed with the distance from the emission spot.
  43201. */
  43202. exponent: number;
  43203. private _projectionTextureMatrix;
  43204. /**
  43205. * Allows reading the projecton texture
  43206. */
  43207. readonly projectionTextureMatrix: Matrix;
  43208. protected _projectionTextureLightNear: number;
  43209. /**
  43210. * Gets the near clip of the Spotlight for texture projection.
  43211. */
  43212. /**
  43213. * Sets the near clip of the Spotlight for texture projection.
  43214. */
  43215. projectionTextureLightNear: number;
  43216. protected _projectionTextureLightFar: number;
  43217. /**
  43218. * Gets the far clip of the Spotlight for texture projection.
  43219. */
  43220. /**
  43221. * Sets the far clip of the Spotlight for texture projection.
  43222. */
  43223. projectionTextureLightFar: number;
  43224. protected _projectionTextureUpDirection: Vector3;
  43225. /**
  43226. * Gets the Up vector of the Spotlight for texture projection.
  43227. */
  43228. /**
  43229. * Sets the Up vector of the Spotlight for texture projection.
  43230. */
  43231. projectionTextureUpDirection: Vector3;
  43232. private _projectionTexture;
  43233. /**
  43234. * Gets the projection texture of the light.
  43235. */
  43236. /**
  43237. * Sets the projection texture of the light.
  43238. */
  43239. projectionTexture: Nullable<BaseTexture>;
  43240. private _projectionTextureViewLightDirty;
  43241. private _projectionTextureProjectionLightDirty;
  43242. private _projectionTextureDirty;
  43243. private _projectionTextureViewTargetVector;
  43244. private _projectionTextureViewLightMatrix;
  43245. private _projectionTextureProjectionLightMatrix;
  43246. private _projectionTextureScalingMatrix;
  43247. /**
  43248. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  43249. * It can cast shadows.
  43250. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43251. * @param name The light friendly name
  43252. * @param position The position of the spot light in the scene
  43253. * @param direction The direction of the light in the scene
  43254. * @param angle The cone angle of the light in Radians
  43255. * @param exponent The light decay speed with the distance from the emission spot
  43256. * @param scene The scene the lights belongs to
  43257. */
  43258. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  43259. /**
  43260. * Returns the string "SpotLight".
  43261. * @returns the class name
  43262. */
  43263. getClassName(): string;
  43264. /**
  43265. * Returns the integer 2.
  43266. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43267. */
  43268. getTypeID(): number;
  43269. /**
  43270. * Overrides the direction setter to recompute the projection texture view light Matrix.
  43271. */
  43272. protected _setDirection(value: Vector3): void;
  43273. /**
  43274. * Overrides the position setter to recompute the projection texture view light Matrix.
  43275. */
  43276. protected _setPosition(value: Vector3): void;
  43277. /**
  43278. * 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.
  43279. * Returns the SpotLight.
  43280. */
  43281. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43282. protected _computeProjectionTextureViewLightMatrix(): void;
  43283. protected _computeProjectionTextureProjectionLightMatrix(): void;
  43284. /**
  43285. * Main function for light texture projection matrix computing.
  43286. */
  43287. protected _computeProjectionTextureMatrix(): void;
  43288. protected _buildUniformLayout(): void;
  43289. private _computeAngleValues;
  43290. /**
  43291. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  43292. * @param effect The effect to update
  43293. * @param lightIndex The index of the light in the effect to update
  43294. * @returns The spot light
  43295. */
  43296. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  43297. /**
  43298. * Disposes the light and the associated resources.
  43299. */
  43300. dispose(): void;
  43301. /**
  43302. * Prepares the list of defines specific to the light type.
  43303. * @param defines the list of defines
  43304. * @param lightIndex defines the index of the light for the effect
  43305. */
  43306. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43307. }
  43308. }
  43309. declare module BABYLON {
  43310. /**
  43311. * Gizmo that enables viewing a light
  43312. */
  43313. export class LightGizmo extends Gizmo {
  43314. private _lightMesh;
  43315. private _material;
  43316. private cachedPosition;
  43317. private cachedForward;
  43318. /**
  43319. * Creates a LightGizmo
  43320. * @param gizmoLayer The utility layer the gizmo will be added to
  43321. */
  43322. constructor(gizmoLayer?: UtilityLayerRenderer);
  43323. private _light;
  43324. /**
  43325. * The light that the gizmo is attached to
  43326. */
  43327. light: Nullable<Light>;
  43328. /**
  43329. * @hidden
  43330. * Updates the gizmo to match the attached mesh's position/rotation
  43331. */
  43332. protected _update(): void;
  43333. private static _Scale;
  43334. /**
  43335. * Creates the lines for a light mesh
  43336. */
  43337. private static _createLightLines;
  43338. /**
  43339. * Disposes of the light gizmo
  43340. */
  43341. dispose(): void;
  43342. private static _CreateHemisphericLightMesh;
  43343. private static _CreatePointLightMesh;
  43344. private static _CreateSpotLightMesh;
  43345. private static _CreateDirectionalLightMesh;
  43346. }
  43347. }
  43348. declare module BABYLON {
  43349. /** @hidden */
  43350. export var backgroundFragmentDeclaration: {
  43351. name: string;
  43352. shader: string;
  43353. };
  43354. }
  43355. declare module BABYLON {
  43356. /** @hidden */
  43357. export var backgroundUboDeclaration: {
  43358. name: string;
  43359. shader: string;
  43360. };
  43361. }
  43362. declare module BABYLON {
  43363. /** @hidden */
  43364. export var backgroundPixelShader: {
  43365. name: string;
  43366. shader: string;
  43367. };
  43368. }
  43369. declare module BABYLON {
  43370. /** @hidden */
  43371. export var backgroundVertexDeclaration: {
  43372. name: string;
  43373. shader: string;
  43374. };
  43375. }
  43376. declare module BABYLON {
  43377. /** @hidden */
  43378. export var backgroundVertexShader: {
  43379. name: string;
  43380. shader: string;
  43381. };
  43382. }
  43383. declare module BABYLON {
  43384. /**
  43385. * Background material used to create an efficient environement around your scene.
  43386. */
  43387. export class BackgroundMaterial extends PushMaterial {
  43388. /**
  43389. * Standard reflectance value at parallel view angle.
  43390. */
  43391. static StandardReflectance0: number;
  43392. /**
  43393. * Standard reflectance value at grazing angle.
  43394. */
  43395. static StandardReflectance90: number;
  43396. protected _primaryColor: Color3;
  43397. /**
  43398. * Key light Color (multiply against the environement texture)
  43399. */
  43400. primaryColor: Color3;
  43401. protected __perceptualColor: Nullable<Color3>;
  43402. /**
  43403. * Experimental Internal Use Only.
  43404. *
  43405. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43406. * This acts as a helper to set the primary color to a more "human friendly" value.
  43407. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43408. * output color as close as possible from the chosen value.
  43409. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43410. * part of lighting setup.)
  43411. */
  43412. _perceptualColor: Nullable<Color3>;
  43413. protected _primaryColorShadowLevel: float;
  43414. /**
  43415. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43416. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43417. */
  43418. primaryColorShadowLevel: float;
  43419. protected _primaryColorHighlightLevel: float;
  43420. /**
  43421. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43422. * The primary color is used at the level chosen to define what the white area would look.
  43423. */
  43424. primaryColorHighlightLevel: float;
  43425. protected _reflectionTexture: Nullable<BaseTexture>;
  43426. /**
  43427. * Reflection Texture used in the material.
  43428. * Should be author in a specific way for the best result (refer to the documentation).
  43429. */
  43430. reflectionTexture: Nullable<BaseTexture>;
  43431. protected _reflectionBlur: float;
  43432. /**
  43433. * Reflection Texture level of blur.
  43434. *
  43435. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43436. * texture twice.
  43437. */
  43438. reflectionBlur: float;
  43439. protected _diffuseTexture: Nullable<BaseTexture>;
  43440. /**
  43441. * Diffuse Texture used in the material.
  43442. * Should be author in a specific way for the best result (refer to the documentation).
  43443. */
  43444. diffuseTexture: Nullable<BaseTexture>;
  43445. protected _shadowLights: Nullable<IShadowLight[]>;
  43446. /**
  43447. * Specify the list of lights casting shadow on the material.
  43448. * All scene shadow lights will be included if null.
  43449. */
  43450. shadowLights: Nullable<IShadowLight[]>;
  43451. protected _shadowLevel: float;
  43452. /**
  43453. * Helps adjusting the shadow to a softer level if required.
  43454. * 0 means black shadows and 1 means no shadows.
  43455. */
  43456. shadowLevel: float;
  43457. protected _sceneCenter: Vector3;
  43458. /**
  43459. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43460. * It is usually zero but might be interesting to modify according to your setup.
  43461. */
  43462. sceneCenter: Vector3;
  43463. protected _opacityFresnel: boolean;
  43464. /**
  43465. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43466. * This helps ensuring a nice transition when the camera goes under the ground.
  43467. */
  43468. opacityFresnel: boolean;
  43469. protected _reflectionFresnel: boolean;
  43470. /**
  43471. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43472. * This helps adding a mirror texture on the ground.
  43473. */
  43474. reflectionFresnel: boolean;
  43475. protected _reflectionFalloffDistance: number;
  43476. /**
  43477. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43478. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43479. */
  43480. reflectionFalloffDistance: number;
  43481. protected _reflectionAmount: number;
  43482. /**
  43483. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43484. */
  43485. reflectionAmount: number;
  43486. protected _reflectionReflectance0: number;
  43487. /**
  43488. * This specifies the weight of the reflection at grazing angle.
  43489. */
  43490. reflectionReflectance0: number;
  43491. protected _reflectionReflectance90: number;
  43492. /**
  43493. * This specifies the weight of the reflection at a perpendicular point of view.
  43494. */
  43495. reflectionReflectance90: number;
  43496. /**
  43497. * Sets the reflection reflectance fresnel values according to the default standard
  43498. * empirically know to work well :-)
  43499. */
  43500. reflectionStandardFresnelWeight: number;
  43501. protected _useRGBColor: boolean;
  43502. /**
  43503. * Helps to directly use the maps channels instead of their level.
  43504. */
  43505. useRGBColor: boolean;
  43506. protected _enableNoise: boolean;
  43507. /**
  43508. * This helps reducing the banding effect that could occur on the background.
  43509. */
  43510. enableNoise: boolean;
  43511. /**
  43512. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43513. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43514. * Recommended to be keep at 1.0 except for special cases.
  43515. */
  43516. fovMultiplier: number;
  43517. private _fovMultiplier;
  43518. /**
  43519. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43520. */
  43521. useEquirectangularFOV: boolean;
  43522. private _maxSimultaneousLights;
  43523. /**
  43524. * Number of Simultaneous lights allowed on the material.
  43525. */
  43526. maxSimultaneousLights: int;
  43527. /**
  43528. * Default configuration related to image processing available in the Background Material.
  43529. */
  43530. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43531. /**
  43532. * Keep track of the image processing observer to allow dispose and replace.
  43533. */
  43534. private _imageProcessingObserver;
  43535. /**
  43536. * Attaches a new image processing configuration to the PBR Material.
  43537. * @param configuration (if null the scene configuration will be use)
  43538. */
  43539. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43540. /**
  43541. * Gets the image processing configuration used either in this material.
  43542. */
  43543. /**
  43544. * Sets the Default image processing configuration used either in the this material.
  43545. *
  43546. * If sets to null, the scene one is in use.
  43547. */
  43548. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43549. /**
  43550. * Gets wether the color curves effect is enabled.
  43551. */
  43552. /**
  43553. * Sets wether the color curves effect is enabled.
  43554. */
  43555. cameraColorCurvesEnabled: boolean;
  43556. /**
  43557. * Gets wether the color grading effect is enabled.
  43558. */
  43559. /**
  43560. * Gets wether the color grading effect is enabled.
  43561. */
  43562. cameraColorGradingEnabled: boolean;
  43563. /**
  43564. * Gets wether tonemapping is enabled or not.
  43565. */
  43566. /**
  43567. * Sets wether tonemapping is enabled or not
  43568. */
  43569. cameraToneMappingEnabled: boolean;
  43570. /**
  43571. * The camera exposure used on this material.
  43572. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43573. * This corresponds to a photographic exposure.
  43574. */
  43575. /**
  43576. * The camera exposure used on this material.
  43577. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43578. * This corresponds to a photographic exposure.
  43579. */
  43580. cameraExposure: float;
  43581. /**
  43582. * Gets The camera contrast used on this material.
  43583. */
  43584. /**
  43585. * Sets The camera contrast used on this material.
  43586. */
  43587. cameraContrast: float;
  43588. /**
  43589. * Gets the Color Grading 2D Lookup Texture.
  43590. */
  43591. /**
  43592. * Sets the Color Grading 2D Lookup Texture.
  43593. */
  43594. cameraColorGradingTexture: Nullable<BaseTexture>;
  43595. /**
  43596. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43597. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43598. * 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;
  43599. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43600. */
  43601. /**
  43602. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43603. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43604. * 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;
  43605. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43606. */
  43607. cameraColorCurves: Nullable<ColorCurves>;
  43608. /**
  43609. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43610. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43611. */
  43612. switchToBGR: boolean;
  43613. private _renderTargets;
  43614. private _reflectionControls;
  43615. private _white;
  43616. private _primaryShadowColor;
  43617. private _primaryHighlightColor;
  43618. /**
  43619. * Instantiates a Background Material in the given scene
  43620. * @param name The friendly name of the material
  43621. * @param scene The scene to add the material to
  43622. */
  43623. constructor(name: string, scene: Scene);
  43624. /**
  43625. * Gets a boolean indicating that current material needs to register RTT
  43626. */
  43627. readonly hasRenderTargetTextures: boolean;
  43628. /**
  43629. * The entire material has been created in order to prevent overdraw.
  43630. * @returns false
  43631. */
  43632. needAlphaTesting(): boolean;
  43633. /**
  43634. * The entire material has been created in order to prevent overdraw.
  43635. * @returns true if blending is enable
  43636. */
  43637. needAlphaBlending(): boolean;
  43638. /**
  43639. * Checks wether the material is ready to be rendered for a given mesh.
  43640. * @param mesh The mesh to render
  43641. * @param subMesh The submesh to check against
  43642. * @param useInstances Specify wether or not the material is used with instances
  43643. * @returns true if all the dependencies are ready (Textures, Effects...)
  43644. */
  43645. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43646. /**
  43647. * Compute the primary color according to the chosen perceptual color.
  43648. */
  43649. private _computePrimaryColorFromPerceptualColor;
  43650. /**
  43651. * Compute the highlights and shadow colors according to their chosen levels.
  43652. */
  43653. private _computePrimaryColors;
  43654. /**
  43655. * Build the uniform buffer used in the material.
  43656. */
  43657. buildUniformLayout(): void;
  43658. /**
  43659. * Unbind the material.
  43660. */
  43661. unbind(): void;
  43662. /**
  43663. * Bind only the world matrix to the material.
  43664. * @param world The world matrix to bind.
  43665. */
  43666. bindOnlyWorldMatrix(world: Matrix): void;
  43667. /**
  43668. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43669. * @param world The world matrix to bind.
  43670. * @param subMesh The submesh to bind for.
  43671. */
  43672. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43673. /**
  43674. * Dispose the material.
  43675. * @param forceDisposeEffect Force disposal of the associated effect.
  43676. * @param forceDisposeTextures Force disposal of the associated textures.
  43677. */
  43678. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43679. /**
  43680. * Clones the material.
  43681. * @param name The cloned name.
  43682. * @returns The cloned material.
  43683. */
  43684. clone(name: string): BackgroundMaterial;
  43685. /**
  43686. * Serializes the current material to its JSON representation.
  43687. * @returns The JSON representation.
  43688. */
  43689. serialize(): any;
  43690. /**
  43691. * Gets the class name of the material
  43692. * @returns "BackgroundMaterial"
  43693. */
  43694. getClassName(): string;
  43695. /**
  43696. * Parse a JSON input to create back a background material.
  43697. * @param source The JSON data to parse
  43698. * @param scene The scene to create the parsed material in
  43699. * @param rootUrl The root url of the assets the material depends upon
  43700. * @returns the instantiated BackgroundMaterial.
  43701. */
  43702. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43703. }
  43704. }
  43705. declare module BABYLON {
  43706. /**
  43707. * Represents the different options available during the creation of
  43708. * a Environment helper.
  43709. *
  43710. * This can control the default ground, skybox and image processing setup of your scene.
  43711. */
  43712. export interface IEnvironmentHelperOptions {
  43713. /**
  43714. * Specifies wether or not to create a ground.
  43715. * True by default.
  43716. */
  43717. createGround: boolean;
  43718. /**
  43719. * Specifies the ground size.
  43720. * 15 by default.
  43721. */
  43722. groundSize: number;
  43723. /**
  43724. * The texture used on the ground for the main color.
  43725. * Comes from the BabylonJS CDN by default.
  43726. *
  43727. * Remarks: Can be either a texture or a url.
  43728. */
  43729. groundTexture: string | BaseTexture;
  43730. /**
  43731. * The color mixed in the ground texture by default.
  43732. * BabylonJS clearColor by default.
  43733. */
  43734. groundColor: Color3;
  43735. /**
  43736. * Specifies the ground opacity.
  43737. * 1 by default.
  43738. */
  43739. groundOpacity: number;
  43740. /**
  43741. * Enables the ground to receive shadows.
  43742. * True by default.
  43743. */
  43744. enableGroundShadow: boolean;
  43745. /**
  43746. * Helps preventing the shadow to be fully black on the ground.
  43747. * 0.5 by default.
  43748. */
  43749. groundShadowLevel: number;
  43750. /**
  43751. * Creates a mirror texture attach to the ground.
  43752. * false by default.
  43753. */
  43754. enableGroundMirror: boolean;
  43755. /**
  43756. * Specifies the ground mirror size ratio.
  43757. * 0.3 by default as the default kernel is 64.
  43758. */
  43759. groundMirrorSizeRatio: number;
  43760. /**
  43761. * Specifies the ground mirror blur kernel size.
  43762. * 64 by default.
  43763. */
  43764. groundMirrorBlurKernel: number;
  43765. /**
  43766. * Specifies the ground mirror visibility amount.
  43767. * 1 by default
  43768. */
  43769. groundMirrorAmount: number;
  43770. /**
  43771. * Specifies the ground mirror reflectance weight.
  43772. * This uses the standard weight of the background material to setup the fresnel effect
  43773. * of the mirror.
  43774. * 1 by default.
  43775. */
  43776. groundMirrorFresnelWeight: number;
  43777. /**
  43778. * Specifies the ground mirror Falloff distance.
  43779. * This can helps reducing the size of the reflection.
  43780. * 0 by Default.
  43781. */
  43782. groundMirrorFallOffDistance: number;
  43783. /**
  43784. * Specifies the ground mirror texture type.
  43785. * Unsigned Int by Default.
  43786. */
  43787. groundMirrorTextureType: number;
  43788. /**
  43789. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43790. * the shown objects.
  43791. */
  43792. groundYBias: number;
  43793. /**
  43794. * Specifies wether or not to create a skybox.
  43795. * True by default.
  43796. */
  43797. createSkybox: boolean;
  43798. /**
  43799. * Specifies the skybox size.
  43800. * 20 by default.
  43801. */
  43802. skyboxSize: number;
  43803. /**
  43804. * The texture used on the skybox for the main color.
  43805. * Comes from the BabylonJS CDN by default.
  43806. *
  43807. * Remarks: Can be either a texture or a url.
  43808. */
  43809. skyboxTexture: string | BaseTexture;
  43810. /**
  43811. * The color mixed in the skybox texture by default.
  43812. * BabylonJS clearColor by default.
  43813. */
  43814. skyboxColor: Color3;
  43815. /**
  43816. * The background rotation around the Y axis of the scene.
  43817. * This helps aligning the key lights of your scene with the background.
  43818. * 0 by default.
  43819. */
  43820. backgroundYRotation: number;
  43821. /**
  43822. * Compute automatically the size of the elements to best fit with the scene.
  43823. */
  43824. sizeAuto: boolean;
  43825. /**
  43826. * Default position of the rootMesh if autoSize is not true.
  43827. */
  43828. rootPosition: Vector3;
  43829. /**
  43830. * Sets up the image processing in the scene.
  43831. * true by default.
  43832. */
  43833. setupImageProcessing: boolean;
  43834. /**
  43835. * The texture used as your environment texture in the scene.
  43836. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43837. *
  43838. * Remarks: Can be either a texture or a url.
  43839. */
  43840. environmentTexture: string | BaseTexture;
  43841. /**
  43842. * The value of the exposure to apply to the scene.
  43843. * 0.6 by default if setupImageProcessing is true.
  43844. */
  43845. cameraExposure: number;
  43846. /**
  43847. * The value of the contrast to apply to the scene.
  43848. * 1.6 by default if setupImageProcessing is true.
  43849. */
  43850. cameraContrast: number;
  43851. /**
  43852. * Specifies wether or not tonemapping should be enabled in the scene.
  43853. * true by default if setupImageProcessing is true.
  43854. */
  43855. toneMappingEnabled: boolean;
  43856. }
  43857. /**
  43858. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43859. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43860. * It also helps with the default setup of your imageProcessing configuration.
  43861. */
  43862. export class EnvironmentHelper {
  43863. /**
  43864. * Default ground texture URL.
  43865. */
  43866. private static _groundTextureCDNUrl;
  43867. /**
  43868. * Default skybox texture URL.
  43869. */
  43870. private static _skyboxTextureCDNUrl;
  43871. /**
  43872. * Default environment texture URL.
  43873. */
  43874. private static _environmentTextureCDNUrl;
  43875. /**
  43876. * Creates the default options for the helper.
  43877. */
  43878. private static _getDefaultOptions;
  43879. private _rootMesh;
  43880. /**
  43881. * Gets the root mesh created by the helper.
  43882. */
  43883. readonly rootMesh: Mesh;
  43884. private _skybox;
  43885. /**
  43886. * Gets the skybox created by the helper.
  43887. */
  43888. readonly skybox: Nullable<Mesh>;
  43889. private _skyboxTexture;
  43890. /**
  43891. * Gets the skybox texture created by the helper.
  43892. */
  43893. readonly skyboxTexture: Nullable<BaseTexture>;
  43894. private _skyboxMaterial;
  43895. /**
  43896. * Gets the skybox material created by the helper.
  43897. */
  43898. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43899. private _ground;
  43900. /**
  43901. * Gets the ground mesh created by the helper.
  43902. */
  43903. readonly ground: Nullable<Mesh>;
  43904. private _groundTexture;
  43905. /**
  43906. * Gets the ground texture created by the helper.
  43907. */
  43908. readonly groundTexture: Nullable<BaseTexture>;
  43909. private _groundMirror;
  43910. /**
  43911. * Gets the ground mirror created by the helper.
  43912. */
  43913. readonly groundMirror: Nullable<MirrorTexture>;
  43914. /**
  43915. * Gets the ground mirror render list to helps pushing the meshes
  43916. * you wish in the ground reflection.
  43917. */
  43918. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43919. private _groundMaterial;
  43920. /**
  43921. * Gets the ground material created by the helper.
  43922. */
  43923. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43924. /**
  43925. * Stores the creation options.
  43926. */
  43927. private readonly _scene;
  43928. private _options;
  43929. /**
  43930. * This observable will be notified with any error during the creation of the environment,
  43931. * mainly texture creation errors.
  43932. */
  43933. onErrorObservable: Observable<{
  43934. message?: string;
  43935. exception?: any;
  43936. }>;
  43937. /**
  43938. * constructor
  43939. * @param options Defines the options we want to customize the helper
  43940. * @param scene The scene to add the material to
  43941. */
  43942. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43943. /**
  43944. * Updates the background according to the new options
  43945. * @param options
  43946. */
  43947. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43948. /**
  43949. * Sets the primary color of all the available elements.
  43950. * @param color the main color to affect to the ground and the background
  43951. */
  43952. setMainColor(color: Color3): void;
  43953. /**
  43954. * Setup the image processing according to the specified options.
  43955. */
  43956. private _setupImageProcessing;
  43957. /**
  43958. * Setup the environment texture according to the specified options.
  43959. */
  43960. private _setupEnvironmentTexture;
  43961. /**
  43962. * Setup the background according to the specified options.
  43963. */
  43964. private _setupBackground;
  43965. /**
  43966. * Get the scene sizes according to the setup.
  43967. */
  43968. private _getSceneSize;
  43969. /**
  43970. * Setup the ground according to the specified options.
  43971. */
  43972. private _setupGround;
  43973. /**
  43974. * Setup the ground material according to the specified options.
  43975. */
  43976. private _setupGroundMaterial;
  43977. /**
  43978. * Setup the ground diffuse texture according to the specified options.
  43979. */
  43980. private _setupGroundDiffuseTexture;
  43981. /**
  43982. * Setup the ground mirror texture according to the specified options.
  43983. */
  43984. private _setupGroundMirrorTexture;
  43985. /**
  43986. * Setup the ground to receive the mirror texture.
  43987. */
  43988. private _setupMirrorInGroundMaterial;
  43989. /**
  43990. * Setup the skybox according to the specified options.
  43991. */
  43992. private _setupSkybox;
  43993. /**
  43994. * Setup the skybox material according to the specified options.
  43995. */
  43996. private _setupSkyboxMaterial;
  43997. /**
  43998. * Setup the skybox reflection texture according to the specified options.
  43999. */
  44000. private _setupSkyboxReflectionTexture;
  44001. private _errorHandler;
  44002. /**
  44003. * Dispose all the elements created by the Helper.
  44004. */
  44005. dispose(): void;
  44006. }
  44007. }
  44008. declare module BABYLON {
  44009. /**
  44010. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44011. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44012. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44013. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44014. */
  44015. export class PhotoDome extends TransformNode {
  44016. private _useDirectMapping;
  44017. /**
  44018. * The texture being displayed on the sphere
  44019. */
  44020. protected _photoTexture: Texture;
  44021. /**
  44022. * Gets or sets the texture being displayed on the sphere
  44023. */
  44024. photoTexture: Texture;
  44025. /**
  44026. * Observable raised when an error occured while loading the 360 image
  44027. */
  44028. onLoadErrorObservable: Observable<string>;
  44029. /**
  44030. * The skybox material
  44031. */
  44032. protected _material: BackgroundMaterial;
  44033. /**
  44034. * The surface used for the skybox
  44035. */
  44036. protected _mesh: Mesh;
  44037. /**
  44038. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44039. * Also see the options.resolution property.
  44040. */
  44041. fovMultiplier: number;
  44042. /**
  44043. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44044. * @param name Element's name, child elements will append suffixes for their own names.
  44045. * @param urlsOfPhoto defines the url of the photo to display
  44046. * @param options defines an object containing optional or exposed sub element properties
  44047. * @param onError defines a callback called when an error occured while loading the texture
  44048. */
  44049. constructor(name: string, urlOfPhoto: string, options: {
  44050. resolution?: number;
  44051. size?: number;
  44052. useDirectMapping?: boolean;
  44053. faceForward?: boolean;
  44054. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44055. /**
  44056. * Releases resources associated with this node.
  44057. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44058. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44059. */
  44060. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44061. }
  44062. }
  44063. declare module BABYLON {
  44064. /** @hidden */
  44065. export var rgbdDecodePixelShader: {
  44066. name: string;
  44067. shader: string;
  44068. };
  44069. }
  44070. declare module BABYLON {
  44071. /**
  44072. * Class used to host texture specific utilities
  44073. */
  44074. export class BRDFTextureTools {
  44075. /**
  44076. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  44077. * @param texture the texture to expand.
  44078. */
  44079. private static _ExpandDefaultBRDFTexture;
  44080. /**
  44081. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44082. * @param scene defines the hosting scene
  44083. * @returns the environment BRDF texture
  44084. */
  44085. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44086. private static _environmentBRDFBase64Texture;
  44087. }
  44088. }
  44089. declare module BABYLON {
  44090. /**
  44091. * @hidden
  44092. */
  44093. export interface IMaterialClearCoatDefines {
  44094. CLEARCOAT: boolean;
  44095. CLEARCOAT_DEFAULTIOR: boolean;
  44096. CLEARCOAT_TEXTURE: boolean;
  44097. CLEARCOAT_TEXTUREDIRECTUV: number;
  44098. CLEARCOAT_BUMP: boolean;
  44099. CLEARCOAT_BUMPDIRECTUV: number;
  44100. CLEARCOAT_TINT: boolean;
  44101. CLEARCOAT_TINT_TEXTURE: boolean;
  44102. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44103. /** @hidden */
  44104. _areTexturesDirty: boolean;
  44105. }
  44106. /**
  44107. * Define the code related to the clear coat parameters of the pbr material.
  44108. */
  44109. export class PBRClearCoatConfiguration {
  44110. /**
  44111. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44112. * The default fits with a polyurethane material.
  44113. */
  44114. private static readonly _DefaultIndiceOfRefraction;
  44115. private _isEnabled;
  44116. /**
  44117. * Defines if the clear coat is enabled in the material.
  44118. */
  44119. isEnabled: boolean;
  44120. /**
  44121. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44122. */
  44123. intensity: number;
  44124. /**
  44125. * Defines the clear coat layer roughness.
  44126. */
  44127. roughness: number;
  44128. private _indiceOfRefraction;
  44129. /**
  44130. * Defines the indice of refraction of the clear coat.
  44131. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44132. * The default fits with a polyurethane material.
  44133. * Changing the default value is more performance intensive.
  44134. */
  44135. indiceOfRefraction: number;
  44136. private _texture;
  44137. /**
  44138. * Stores the clear coat values in a texture.
  44139. */
  44140. texture: Nullable<BaseTexture>;
  44141. private _bumpTexture;
  44142. /**
  44143. * Define the clear coat specific bump texture.
  44144. */
  44145. bumpTexture: Nullable<BaseTexture>;
  44146. private _isTintEnabled;
  44147. /**
  44148. * Defines if the clear coat tint is enabled in the material.
  44149. */
  44150. isTintEnabled: boolean;
  44151. /**
  44152. * Defines the clear coat tint of the material.
  44153. * This is only use if tint is enabled
  44154. */
  44155. tintColor: Color3;
  44156. /**
  44157. * Defines the distance at which the tint color should be found in the
  44158. * clear coat media.
  44159. * This is only use if tint is enabled
  44160. */
  44161. tintColorAtDistance: number;
  44162. /**
  44163. * Defines the clear coat layer thickness.
  44164. * This is only use if tint is enabled
  44165. */
  44166. tintThickness: number;
  44167. private _tintTexture;
  44168. /**
  44169. * Stores the clear tint values in a texture.
  44170. * rgb is tint
  44171. * a is a thickness factor
  44172. */
  44173. tintTexture: Nullable<BaseTexture>;
  44174. /** @hidden */
  44175. private _internalMarkAllSubMeshesAsTexturesDirty;
  44176. /** @hidden */
  44177. _markAllSubMeshesAsTexturesDirty(): void;
  44178. /**
  44179. * Instantiate a new istance of clear coat configuration.
  44180. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44181. */
  44182. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44183. /**
  44184. * Gets wehter the submesh is ready to be used or not.
  44185. * @param defines the list of "defines" to update.
  44186. * @param scene defines the scene the material belongs to.
  44187. * @param engine defines the engine the material belongs to.
  44188. * @param disableBumpMap defines wether the material disables bump or not.
  44189. * @returns - boolean indicating that the submesh is ready or not.
  44190. */
  44191. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44192. /**
  44193. * Checks to see if a texture is used in the material.
  44194. * @param defines the list of "defines" to update.
  44195. * @param scene defines the scene to the material belongs to.
  44196. */
  44197. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44198. /**
  44199. * Binds the material data.
  44200. * @param uniformBuffer defines the Uniform buffer to fill in.
  44201. * @param scene defines the scene the material belongs to.
  44202. * @param engine defines the engine the material belongs to.
  44203. * @param disableBumpMap defines wether the material disables bump or not.
  44204. * @param isFrozen defines wether the material is frozen or not.
  44205. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44206. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44207. */
  44208. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44209. /**
  44210. * Checks to see if a texture is used in the material.
  44211. * @param texture - Base texture to use.
  44212. * @returns - Boolean specifying if a texture is used in the material.
  44213. */
  44214. hasTexture(texture: BaseTexture): boolean;
  44215. /**
  44216. * Returns an array of the actively used textures.
  44217. * @param activeTextures Array of BaseTextures
  44218. */
  44219. getActiveTextures(activeTextures: BaseTexture[]): void;
  44220. /**
  44221. * Returns the animatable textures.
  44222. * @param animatables Array of animatable textures.
  44223. */
  44224. getAnimatables(animatables: IAnimatable[]): void;
  44225. /**
  44226. * Disposes the resources of the material.
  44227. * @param forceDisposeTextures - Forces the disposal of all textures.
  44228. */
  44229. dispose(forceDisposeTextures?: boolean): void;
  44230. /**
  44231. * Get the current class name of the texture useful for serialization or dynamic coding.
  44232. * @returns "PBRClearCoatConfiguration"
  44233. */
  44234. getClassName(): string;
  44235. /**
  44236. * Add fallbacks to the effect fallbacks list.
  44237. * @param defines defines the Base texture to use.
  44238. * @param fallbacks defines the current fallback list.
  44239. * @param currentRank defines the current fallback rank.
  44240. * @returns the new fallback rank.
  44241. */
  44242. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44243. /**
  44244. * Add the required uniforms to the current list.
  44245. * @param uniforms defines the current uniform list.
  44246. */
  44247. static AddUniforms(uniforms: string[]): void;
  44248. /**
  44249. * Add the required samplers to the current list.
  44250. * @param samplers defines the current sampler list.
  44251. */
  44252. static AddSamplers(samplers: string[]): void;
  44253. /**
  44254. * Add the required uniforms to the current buffer.
  44255. * @param uniformBuffer defines the current uniform buffer.
  44256. */
  44257. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44258. /**
  44259. * Makes a duplicate of the current configuration into another one.
  44260. * @param clearCoatConfiguration define the config where to copy the info
  44261. */
  44262. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44263. /**
  44264. * Serializes this clear coat configuration.
  44265. * @returns - An object with the serialized config.
  44266. */
  44267. serialize(): any;
  44268. /**
  44269. * Parses a Clear Coat Configuration from a serialized object.
  44270. * @param source - Serialized object.
  44271. */
  44272. parse(source: any): void;
  44273. }
  44274. }
  44275. declare module BABYLON {
  44276. /**
  44277. * @hidden
  44278. */
  44279. export interface IMaterialAnisotropicDefines {
  44280. ANISOTROPIC: boolean;
  44281. ANISOTROPIC_TEXTURE: boolean;
  44282. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44283. MAINUV1: boolean;
  44284. _areTexturesDirty: boolean;
  44285. _needUVs: boolean;
  44286. }
  44287. /**
  44288. * Define the code related to the anisotropic parameters of the pbr material.
  44289. */
  44290. export class PBRAnisotropicConfiguration {
  44291. private _isEnabled;
  44292. /**
  44293. * Defines if the anisotropy is enabled in the material.
  44294. */
  44295. isEnabled: boolean;
  44296. /**
  44297. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44298. */
  44299. intensity: number;
  44300. /**
  44301. * Defines if the effect is along the tangents, bitangents or in between.
  44302. * By default, the effect is "strectching" the highlights along the tangents.
  44303. */
  44304. direction: Vector2;
  44305. private _texture;
  44306. /**
  44307. * Stores the anisotropy values in a texture.
  44308. * rg is direction (like normal from -1 to 1)
  44309. * b is a intensity
  44310. */
  44311. texture: Nullable<BaseTexture>;
  44312. /** @hidden */
  44313. private _internalMarkAllSubMeshesAsTexturesDirty;
  44314. /** @hidden */
  44315. _markAllSubMeshesAsTexturesDirty(): void;
  44316. /**
  44317. * Instantiate a new istance of anisotropy configuration.
  44318. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44319. */
  44320. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44321. /**
  44322. * Specifies that the submesh is ready to be used.
  44323. * @param defines the list of "defines" to update.
  44324. * @param scene defines the scene the material belongs to.
  44325. * @returns - boolean indicating that the submesh is ready or not.
  44326. */
  44327. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44328. /**
  44329. * Checks to see if a texture is used in the material.
  44330. * @param defines the list of "defines" to update.
  44331. * @param mesh the mesh we are preparing the defines for.
  44332. * @param scene defines the scene the material belongs to.
  44333. */
  44334. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44335. /**
  44336. * Binds the material data.
  44337. * @param uniformBuffer defines the Uniform buffer to fill in.
  44338. * @param scene defines the scene the material belongs to.
  44339. * @param isFrozen defines wether the material is frozen or not.
  44340. */
  44341. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44342. /**
  44343. * Checks to see if a texture is used in the material.
  44344. * @param texture - Base texture to use.
  44345. * @returns - Boolean specifying if a texture is used in the material.
  44346. */
  44347. hasTexture(texture: BaseTexture): boolean;
  44348. /**
  44349. * Returns an array of the actively used textures.
  44350. * @param activeTextures Array of BaseTextures
  44351. */
  44352. getActiveTextures(activeTextures: BaseTexture[]): void;
  44353. /**
  44354. * Returns the animatable textures.
  44355. * @param animatables Array of animatable textures.
  44356. */
  44357. getAnimatables(animatables: IAnimatable[]): void;
  44358. /**
  44359. * Disposes the resources of the material.
  44360. * @param forceDisposeTextures - Forces the disposal of all textures.
  44361. */
  44362. dispose(forceDisposeTextures?: boolean): void;
  44363. /**
  44364. * Get the current class name of the texture useful for serialization or dynamic coding.
  44365. * @returns "PBRAnisotropicConfiguration"
  44366. */
  44367. getClassName(): string;
  44368. /**
  44369. * Add fallbacks to the effect fallbacks list.
  44370. * @param defines defines the Base texture to use.
  44371. * @param fallbacks defines the current fallback list.
  44372. * @param currentRank defines the current fallback rank.
  44373. * @returns the new fallback rank.
  44374. */
  44375. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44376. /**
  44377. * Add the required uniforms to the current list.
  44378. * @param uniforms defines the current uniform list.
  44379. */
  44380. static AddUniforms(uniforms: string[]): void;
  44381. /**
  44382. * Add the required uniforms to the current buffer.
  44383. * @param uniformBuffer defines the current uniform buffer.
  44384. */
  44385. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44386. /**
  44387. * Add the required samplers to the current list.
  44388. * @param samplers defines the current sampler list.
  44389. */
  44390. static AddSamplers(samplers: string[]): void;
  44391. /**
  44392. * Makes a duplicate of the current configuration into another one.
  44393. * @param anisotropicConfiguration define the config where to copy the info
  44394. */
  44395. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44396. /**
  44397. * Serializes this anisotropy configuration.
  44398. * @returns - An object with the serialized config.
  44399. */
  44400. serialize(): any;
  44401. /**
  44402. * Parses a anisotropy Configuration from a serialized object.
  44403. * @param source - Serialized object.
  44404. */
  44405. parse(source: any): void;
  44406. }
  44407. }
  44408. declare module BABYLON {
  44409. /**
  44410. * @hidden
  44411. */
  44412. export interface IMaterialBRDFDefines {
  44413. BRDF_V_HEIGHT_CORRELATED: boolean;
  44414. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44415. SPHERICAL_HARMONICS: boolean;
  44416. /** @hidden */
  44417. _areMiscDirty: boolean;
  44418. }
  44419. /**
  44420. * Define the code related to the BRDF parameters of the pbr material.
  44421. */
  44422. export class PBRBRDFConfiguration {
  44423. /**
  44424. * Default value used for the energy conservation.
  44425. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44426. */
  44427. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  44428. /**
  44429. * Default value used for the Smith Visibility Height Correlated mode.
  44430. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44431. */
  44432. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  44433. /**
  44434. * Default value used for the IBL diffuse part.
  44435. * This can help switching back to the polynomials mode globally which is a tiny bit
  44436. * less GPU intensive at the drawback of a lower quality.
  44437. */
  44438. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  44439. private _useEnergyConservation;
  44440. /**
  44441. * Defines if the material uses energy conservation.
  44442. */
  44443. useEnergyConservation: boolean;
  44444. private _useSmithVisibilityHeightCorrelated;
  44445. /**
  44446. * LEGACY Mode set to false
  44447. * Defines if the material uses height smith correlated visibility term.
  44448. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44449. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44450. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44451. * Not relying on height correlated will also disable energy conservation.
  44452. */
  44453. useSmithVisibilityHeightCorrelated: boolean;
  44454. private _useSphericalHarmonics;
  44455. /**
  44456. * LEGACY Mode set to false
  44457. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  44458. * diffuse part of the IBL.
  44459. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  44460. * to the ground truth.
  44461. */
  44462. useSphericalHarmonics: boolean;
  44463. /** @hidden */
  44464. private _internalMarkAllSubMeshesAsMiscDirty;
  44465. /** @hidden */
  44466. _markAllSubMeshesAsMiscDirty(): void;
  44467. /**
  44468. * Instantiate a new istance of clear coat configuration.
  44469. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44470. */
  44471. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44472. /**
  44473. * Checks to see if a texture is used in the material.
  44474. * @param defines the list of "defines" to update.
  44475. */
  44476. prepareDefines(defines: IMaterialBRDFDefines): void;
  44477. /**
  44478. * Get the current class name of the texture useful for serialization or dynamic coding.
  44479. * @returns "PBRClearCoatConfiguration"
  44480. */
  44481. getClassName(): string;
  44482. /**
  44483. * Makes a duplicate of the current configuration into another one.
  44484. * @param brdfConfiguration define the config where to copy the info
  44485. */
  44486. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44487. /**
  44488. * Serializes this BRDF configuration.
  44489. * @returns - An object with the serialized config.
  44490. */
  44491. serialize(): any;
  44492. /**
  44493. * Parses a BRDF Configuration from a serialized object.
  44494. * @param source - Serialized object.
  44495. */
  44496. parse(source: any): void;
  44497. }
  44498. }
  44499. declare module BABYLON {
  44500. /**
  44501. * @hidden
  44502. */
  44503. export interface IMaterialSheenDefines {
  44504. SHEEN: boolean;
  44505. SHEEN_TEXTURE: boolean;
  44506. SHEEN_TEXTUREDIRECTUV: number;
  44507. SHEEN_LINKWITHALBEDO: boolean;
  44508. /** @hidden */
  44509. _areTexturesDirty: boolean;
  44510. }
  44511. /**
  44512. * Define the code related to the Sheen parameters of the pbr material.
  44513. */
  44514. export class PBRSheenConfiguration {
  44515. private _isEnabled;
  44516. /**
  44517. * Defines if the material uses sheen.
  44518. */
  44519. isEnabled: boolean;
  44520. private _linkSheenWithAlbedo;
  44521. /**
  44522. * Defines if the sheen is linked to the sheen color.
  44523. */
  44524. linkSheenWithAlbedo: boolean;
  44525. /**
  44526. * Defines the sheen intensity.
  44527. */
  44528. intensity: number;
  44529. /**
  44530. * Defines the sheen color.
  44531. */
  44532. color: Color3;
  44533. private _texture;
  44534. /**
  44535. * Stores the sheen tint values in a texture.
  44536. * rgb is tint
  44537. * a is a intensity
  44538. */
  44539. texture: Nullable<BaseTexture>;
  44540. /** @hidden */
  44541. private _internalMarkAllSubMeshesAsTexturesDirty;
  44542. /** @hidden */
  44543. _markAllSubMeshesAsTexturesDirty(): void;
  44544. /**
  44545. * Instantiate a new istance of clear coat configuration.
  44546. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44547. */
  44548. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44549. /**
  44550. * Specifies that the submesh is ready to be used.
  44551. * @param defines the list of "defines" to update.
  44552. * @param scene defines the scene the material belongs to.
  44553. * @returns - boolean indicating that the submesh is ready or not.
  44554. */
  44555. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44556. /**
  44557. * Checks to see if a texture is used in the material.
  44558. * @param defines the list of "defines" to update.
  44559. * @param scene defines the scene the material belongs to.
  44560. */
  44561. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44562. /**
  44563. * Binds the material data.
  44564. * @param uniformBuffer defines the Uniform buffer to fill in.
  44565. * @param scene defines the scene the material belongs to.
  44566. * @param isFrozen defines wether the material is frozen or not.
  44567. */
  44568. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44569. /**
  44570. * Checks to see if a texture is used in the material.
  44571. * @param texture - Base texture to use.
  44572. * @returns - Boolean specifying if a texture is used in the material.
  44573. */
  44574. hasTexture(texture: BaseTexture): boolean;
  44575. /**
  44576. * Returns an array of the actively used textures.
  44577. * @param activeTextures Array of BaseTextures
  44578. */
  44579. getActiveTextures(activeTextures: BaseTexture[]): void;
  44580. /**
  44581. * Returns the animatable textures.
  44582. * @param animatables Array of animatable textures.
  44583. */
  44584. getAnimatables(animatables: IAnimatable[]): void;
  44585. /**
  44586. * Disposes the resources of the material.
  44587. * @param forceDisposeTextures - Forces the disposal of all textures.
  44588. */
  44589. dispose(forceDisposeTextures?: boolean): void;
  44590. /**
  44591. * Get the current class name of the texture useful for serialization or dynamic coding.
  44592. * @returns "PBRSheenConfiguration"
  44593. */
  44594. getClassName(): string;
  44595. /**
  44596. * Add fallbacks to the effect fallbacks list.
  44597. * @param defines defines the Base texture to use.
  44598. * @param fallbacks defines the current fallback list.
  44599. * @param currentRank defines the current fallback rank.
  44600. * @returns the new fallback rank.
  44601. */
  44602. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44603. /**
  44604. * Add the required uniforms to the current list.
  44605. * @param uniforms defines the current uniform list.
  44606. */
  44607. static AddUniforms(uniforms: string[]): void;
  44608. /**
  44609. * Add the required uniforms to the current buffer.
  44610. * @param uniformBuffer defines the current uniform buffer.
  44611. */
  44612. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44613. /**
  44614. * Add the required samplers to the current list.
  44615. * @param samplers defines the current sampler list.
  44616. */
  44617. static AddSamplers(samplers: string[]): void;
  44618. /**
  44619. * Makes a duplicate of the current configuration into another one.
  44620. * @param sheenConfiguration define the config where to copy the info
  44621. */
  44622. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44623. /**
  44624. * Serializes this BRDF configuration.
  44625. * @returns - An object with the serialized config.
  44626. */
  44627. serialize(): any;
  44628. /**
  44629. * Parses a Sheen Configuration from a serialized object.
  44630. * @param source - Serialized object.
  44631. */
  44632. parse(source: any): void;
  44633. }
  44634. }
  44635. declare module BABYLON {
  44636. /**
  44637. * @hidden
  44638. */
  44639. export interface IMaterialSubSurfaceDefines {
  44640. SUBSURFACE: boolean;
  44641. SS_REFRACTION: boolean;
  44642. SS_TRANSLUCENCY: boolean;
  44643. SS_SCATERRING: boolean;
  44644. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44645. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44646. SS_REFRACTIONMAP_3D: boolean;
  44647. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44648. SS_LODINREFRACTIONALPHA: boolean;
  44649. SS_GAMMAREFRACTION: boolean;
  44650. SS_RGBDREFRACTION: boolean;
  44651. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44652. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44653. /** @hidden */
  44654. _areTexturesDirty: boolean;
  44655. }
  44656. /**
  44657. * Define the code related to the sub surface parameters of the pbr material.
  44658. */
  44659. export class PBRSubSurfaceConfiguration {
  44660. private _isRefractionEnabled;
  44661. /**
  44662. * Defines if the refraction is enabled in the material.
  44663. */
  44664. isRefractionEnabled: boolean;
  44665. private _isTranslucencyEnabled;
  44666. /**
  44667. * Defines if the translucency is enabled in the material.
  44668. */
  44669. isTranslucencyEnabled: boolean;
  44670. private _isScatteringEnabled;
  44671. /**
  44672. * Defines the refraction intensity of the material.
  44673. * The refraction when enabled replaces the Diffuse part of the material.
  44674. * The intensity helps transitionning between diffuse and refraction.
  44675. */
  44676. refractionIntensity: number;
  44677. /**
  44678. * Defines the translucency intensity of the material.
  44679. * When translucency has been enabled, this defines how much of the "translucency"
  44680. * is addded to the diffuse part of the material.
  44681. */
  44682. translucencyIntensity: number;
  44683. /**
  44684. * Defines the scattering intensity of the material.
  44685. * When scattering has been enabled, this defines how much of the "scattered light"
  44686. * is addded to the diffuse part of the material.
  44687. */
  44688. scatteringIntensity: number;
  44689. private _thicknessTexture;
  44690. /**
  44691. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  44692. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  44693. * 0 would mean minimumThickness
  44694. * 1 would mean maximumThickness
  44695. * The other channels might be use as a mask to vary the different effects intensity.
  44696. */
  44697. thicknessTexture: Nullable<BaseTexture>;
  44698. private _refractionTexture;
  44699. /**
  44700. * Defines the texture to use for refraction.
  44701. */
  44702. refractionTexture: Nullable<BaseTexture>;
  44703. private _indexOfRefraction;
  44704. /**
  44705. * Defines the indice of refraction used in the material.
  44706. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  44707. */
  44708. indexOfRefraction: number;
  44709. private _invertRefractionY;
  44710. /**
  44711. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44712. */
  44713. invertRefractionY: boolean;
  44714. private _linkRefractionWithTransparency;
  44715. /**
  44716. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44717. * Materials half opaque for instance using refraction could benefit from this control.
  44718. */
  44719. linkRefractionWithTransparency: boolean;
  44720. /**
  44721. * Defines the minimum thickness stored in the thickness map.
  44722. * If no thickness map is defined, this value will be used to simulate thickness.
  44723. */
  44724. minimumThickness: number;
  44725. /**
  44726. * Defines the maximum thickness stored in the thickness map.
  44727. */
  44728. maximumThickness: number;
  44729. /**
  44730. * Defines the volume tint of the material.
  44731. * This is used for both translucency and scattering.
  44732. */
  44733. tintColor: Color3;
  44734. /**
  44735. * Defines the distance at which the tint color should be found in the media.
  44736. * This is used for refraction only.
  44737. */
  44738. tintColorAtDistance: number;
  44739. /**
  44740. * Defines how far each channel transmit through the media.
  44741. * It is defined as a color to simplify it selection.
  44742. */
  44743. diffusionDistance: Color3;
  44744. private _useMaskFromThicknessTexture;
  44745. /**
  44746. * Stores the intensity of the different subsurface effects in the thickness texture.
  44747. * * the green channel is the translucency intensity.
  44748. * * the blue channel is the scattering intensity.
  44749. * * the alpha channel is the refraction intensity.
  44750. */
  44751. useMaskFromThicknessTexture: boolean;
  44752. /** @hidden */
  44753. private _internalMarkAllSubMeshesAsTexturesDirty;
  44754. /** @hidden */
  44755. _markAllSubMeshesAsTexturesDirty(): void;
  44756. /**
  44757. * Instantiate a new istance of sub surface configuration.
  44758. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44759. */
  44760. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44761. /**
  44762. * Gets wehter the submesh is ready to be used or not.
  44763. * @param defines the list of "defines" to update.
  44764. * @param scene defines the scene the material belongs to.
  44765. * @returns - boolean indicating that the submesh is ready or not.
  44766. */
  44767. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  44768. /**
  44769. * Checks to see if a texture is used in the material.
  44770. * @param defines the list of "defines" to update.
  44771. * @param scene defines the scene to the material belongs to.
  44772. */
  44773. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  44774. /**
  44775. * Binds the material data.
  44776. * @param uniformBuffer defines the Uniform buffer to fill in.
  44777. * @param scene defines the scene the material belongs to.
  44778. * @param engine defines the engine the material belongs to.
  44779. * @param isFrozen defines wether the material is frozen or not.
  44780. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  44781. */
  44782. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  44783. /**
  44784. * Unbinds the material from the mesh.
  44785. * @param activeEffect defines the effect that should be unbound from.
  44786. * @returns true if unbound, otherwise false
  44787. */
  44788. unbind(activeEffect: Effect): boolean;
  44789. /**
  44790. * Returns the texture used for refraction or null if none is used.
  44791. * @param scene defines the scene the material belongs to.
  44792. * @returns - Refraction texture if present. If no refraction texture and refraction
  44793. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44794. */
  44795. private _getRefractionTexture;
  44796. /**
  44797. * Returns true if alpha blending should be disabled.
  44798. */
  44799. readonly disableAlphaBlending: boolean;
  44800. /**
  44801. * Fills the list of render target textures.
  44802. * @param renderTargets the list of render targets to update
  44803. */
  44804. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  44805. /**
  44806. * Checks to see if a texture is used in the material.
  44807. * @param texture - Base texture to use.
  44808. * @returns - Boolean specifying if a texture is used in the material.
  44809. */
  44810. hasTexture(texture: BaseTexture): boolean;
  44811. /**
  44812. * Gets a boolean indicating that current material needs to register RTT
  44813. * @returns true if this uses a render target otherwise false.
  44814. */
  44815. hasRenderTargetTextures(): boolean;
  44816. /**
  44817. * Returns an array of the actively used textures.
  44818. * @param activeTextures Array of BaseTextures
  44819. */
  44820. getActiveTextures(activeTextures: BaseTexture[]): void;
  44821. /**
  44822. * Returns the animatable textures.
  44823. * @param animatables Array of animatable textures.
  44824. */
  44825. getAnimatables(animatables: IAnimatable[]): void;
  44826. /**
  44827. * Disposes the resources of the material.
  44828. * @param forceDisposeTextures - Forces the disposal of all textures.
  44829. */
  44830. dispose(forceDisposeTextures?: boolean): void;
  44831. /**
  44832. * Get the current class name of the texture useful for serialization or dynamic coding.
  44833. * @returns "PBRSubSurfaceConfiguration"
  44834. */
  44835. getClassName(): string;
  44836. /**
  44837. * Add fallbacks to the effect fallbacks list.
  44838. * @param defines defines the Base texture to use.
  44839. * @param fallbacks defines the current fallback list.
  44840. * @param currentRank defines the current fallback rank.
  44841. * @returns the new fallback rank.
  44842. */
  44843. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44844. /**
  44845. * Add the required uniforms to the current list.
  44846. * @param uniforms defines the current uniform list.
  44847. */
  44848. static AddUniforms(uniforms: string[]): void;
  44849. /**
  44850. * Add the required samplers to the current list.
  44851. * @param samplers defines the current sampler list.
  44852. */
  44853. static AddSamplers(samplers: string[]): void;
  44854. /**
  44855. * Add the required uniforms to the current buffer.
  44856. * @param uniformBuffer defines the current uniform buffer.
  44857. */
  44858. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44859. /**
  44860. * Makes a duplicate of the current configuration into another one.
  44861. * @param configuration define the config where to copy the info
  44862. */
  44863. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  44864. /**
  44865. * Serializes this Sub Surface configuration.
  44866. * @returns - An object with the serialized config.
  44867. */
  44868. serialize(): any;
  44869. /**
  44870. * Parses a Sub Surface Configuration from a serialized object.
  44871. * @param source - Serialized object.
  44872. */
  44873. parse(source: any): void;
  44874. }
  44875. }
  44876. declare module BABYLON {
  44877. /** @hidden */
  44878. export var pbrFragmentDeclaration: {
  44879. name: string;
  44880. shader: string;
  44881. };
  44882. }
  44883. declare module BABYLON {
  44884. /** @hidden */
  44885. export var pbrUboDeclaration: {
  44886. name: string;
  44887. shader: string;
  44888. };
  44889. }
  44890. declare module BABYLON {
  44891. /** @hidden */
  44892. export var pbrFragmentExtraDeclaration: {
  44893. name: string;
  44894. shader: string;
  44895. };
  44896. }
  44897. declare module BABYLON {
  44898. /** @hidden */
  44899. export var pbrFragmentSamplersDeclaration: {
  44900. name: string;
  44901. shader: string;
  44902. };
  44903. }
  44904. declare module BABYLON {
  44905. /** @hidden */
  44906. export var pbrHelperFunctions: {
  44907. name: string;
  44908. shader: string;
  44909. };
  44910. }
  44911. declare module BABYLON {
  44912. /** @hidden */
  44913. export var harmonicsFunctions: {
  44914. name: string;
  44915. shader: string;
  44916. };
  44917. }
  44918. declare module BABYLON {
  44919. /** @hidden */
  44920. export var pbrDirectLightingSetupFunctions: {
  44921. name: string;
  44922. shader: string;
  44923. };
  44924. }
  44925. declare module BABYLON {
  44926. /** @hidden */
  44927. export var pbrDirectLightingFalloffFunctions: {
  44928. name: string;
  44929. shader: string;
  44930. };
  44931. }
  44932. declare module BABYLON {
  44933. /** @hidden */
  44934. export var pbrBRDFFunctions: {
  44935. name: string;
  44936. shader: string;
  44937. };
  44938. }
  44939. declare module BABYLON {
  44940. /** @hidden */
  44941. export var pbrDirectLightingFunctions: {
  44942. name: string;
  44943. shader: string;
  44944. };
  44945. }
  44946. declare module BABYLON {
  44947. /** @hidden */
  44948. export var pbrIBLFunctions: {
  44949. name: string;
  44950. shader: string;
  44951. };
  44952. }
  44953. declare module BABYLON {
  44954. /** @hidden */
  44955. export var pbrDebug: {
  44956. name: string;
  44957. shader: string;
  44958. };
  44959. }
  44960. declare module BABYLON {
  44961. /** @hidden */
  44962. export var pbrPixelShader: {
  44963. name: string;
  44964. shader: string;
  44965. };
  44966. }
  44967. declare module BABYLON {
  44968. /** @hidden */
  44969. export var pbrVertexDeclaration: {
  44970. name: string;
  44971. shader: string;
  44972. };
  44973. }
  44974. declare module BABYLON {
  44975. /** @hidden */
  44976. export var pbrVertexShader: {
  44977. name: string;
  44978. shader: string;
  44979. };
  44980. }
  44981. declare module BABYLON {
  44982. /**
  44983. * Manages the defines for the PBR Material.
  44984. * @hidden
  44985. */
  44986. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  44987. PBR: boolean;
  44988. MAINUV1: boolean;
  44989. MAINUV2: boolean;
  44990. UV1: boolean;
  44991. UV2: boolean;
  44992. ALBEDO: boolean;
  44993. ALBEDODIRECTUV: number;
  44994. VERTEXCOLOR: boolean;
  44995. AMBIENT: boolean;
  44996. AMBIENTDIRECTUV: number;
  44997. AMBIENTINGRAYSCALE: boolean;
  44998. OPACITY: boolean;
  44999. VERTEXALPHA: boolean;
  45000. OPACITYDIRECTUV: number;
  45001. OPACITYRGB: boolean;
  45002. ALPHATEST: boolean;
  45003. DEPTHPREPASS: boolean;
  45004. ALPHABLEND: boolean;
  45005. ALPHAFROMALBEDO: boolean;
  45006. ALPHATESTVALUE: string;
  45007. SPECULAROVERALPHA: boolean;
  45008. RADIANCEOVERALPHA: boolean;
  45009. ALPHAFRESNEL: boolean;
  45010. LINEARALPHAFRESNEL: boolean;
  45011. PREMULTIPLYALPHA: boolean;
  45012. EMISSIVE: boolean;
  45013. EMISSIVEDIRECTUV: number;
  45014. REFLECTIVITY: boolean;
  45015. REFLECTIVITYDIRECTUV: number;
  45016. SPECULARTERM: boolean;
  45017. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  45018. MICROSURFACEAUTOMATIC: boolean;
  45019. LODBASEDMICROSFURACE: boolean;
  45020. MICROSURFACEMAP: boolean;
  45021. MICROSURFACEMAPDIRECTUV: number;
  45022. METALLICWORKFLOW: boolean;
  45023. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  45024. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  45025. METALLNESSSTOREINMETALMAPBLUE: boolean;
  45026. AOSTOREINMETALMAPRED: boolean;
  45027. ENVIRONMENTBRDF: boolean;
  45028. ENVIRONMENTBRDF_RGBD: boolean;
  45029. NORMAL: boolean;
  45030. TANGENT: boolean;
  45031. BUMP: boolean;
  45032. BUMPDIRECTUV: number;
  45033. OBJECTSPACE_NORMALMAP: boolean;
  45034. PARALLAX: boolean;
  45035. PARALLAXOCCLUSION: boolean;
  45036. NORMALXYSCALE: boolean;
  45037. LIGHTMAP: boolean;
  45038. LIGHTMAPDIRECTUV: number;
  45039. USELIGHTMAPASSHADOWMAP: boolean;
  45040. GAMMALIGHTMAP: boolean;
  45041. REFLECTION: boolean;
  45042. REFLECTIONMAP_3D: boolean;
  45043. REFLECTIONMAP_SPHERICAL: boolean;
  45044. REFLECTIONMAP_PLANAR: boolean;
  45045. REFLECTIONMAP_CUBIC: boolean;
  45046. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  45047. REFLECTIONMAP_PROJECTION: boolean;
  45048. REFLECTIONMAP_SKYBOX: boolean;
  45049. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  45050. REFLECTIONMAP_EXPLICIT: boolean;
  45051. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  45052. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  45053. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  45054. INVERTCUBICMAP: boolean;
  45055. USESPHERICALFROMREFLECTIONMAP: boolean;
  45056. SPHERICAL_HARMONICS: boolean;
  45057. USESPHERICALINVERTEX: boolean;
  45058. REFLECTIONMAP_OPPOSITEZ: boolean;
  45059. LODINREFLECTIONALPHA: boolean;
  45060. GAMMAREFLECTION: boolean;
  45061. RGBDREFLECTION: boolean;
  45062. RADIANCEOCCLUSION: boolean;
  45063. HORIZONOCCLUSION: boolean;
  45064. INSTANCES: boolean;
  45065. NUM_BONE_INFLUENCERS: number;
  45066. BonesPerMesh: number;
  45067. BONETEXTURE: boolean;
  45068. NONUNIFORMSCALING: boolean;
  45069. MORPHTARGETS: boolean;
  45070. MORPHTARGETS_NORMAL: boolean;
  45071. MORPHTARGETS_TANGENT: boolean;
  45072. NUM_MORPH_INFLUENCERS: number;
  45073. IMAGEPROCESSING: boolean;
  45074. VIGNETTE: boolean;
  45075. VIGNETTEBLENDMODEMULTIPLY: boolean;
  45076. VIGNETTEBLENDMODEOPAQUE: boolean;
  45077. TONEMAPPING: boolean;
  45078. TONEMAPPING_ACES: boolean;
  45079. CONTRAST: boolean;
  45080. COLORCURVES: boolean;
  45081. COLORGRADING: boolean;
  45082. COLORGRADING3D: boolean;
  45083. SAMPLER3DGREENDEPTH: boolean;
  45084. SAMPLER3DBGRMAP: boolean;
  45085. IMAGEPROCESSINGPOSTPROCESS: boolean;
  45086. EXPOSURE: boolean;
  45087. MULTIVIEW: boolean;
  45088. USEPHYSICALLIGHTFALLOFF: boolean;
  45089. USEGLTFLIGHTFALLOFF: boolean;
  45090. TWOSIDEDLIGHTING: boolean;
  45091. SHADOWFLOAT: boolean;
  45092. CLIPPLANE: boolean;
  45093. CLIPPLANE2: boolean;
  45094. CLIPPLANE3: boolean;
  45095. CLIPPLANE4: boolean;
  45096. POINTSIZE: boolean;
  45097. FOG: boolean;
  45098. LOGARITHMICDEPTH: boolean;
  45099. FORCENORMALFORWARD: boolean;
  45100. SPECULARAA: boolean;
  45101. CLEARCOAT: boolean;
  45102. CLEARCOAT_DEFAULTIOR: boolean;
  45103. CLEARCOAT_TEXTURE: boolean;
  45104. CLEARCOAT_TEXTUREDIRECTUV: number;
  45105. CLEARCOAT_BUMP: boolean;
  45106. CLEARCOAT_BUMPDIRECTUV: number;
  45107. CLEARCOAT_TINT: boolean;
  45108. CLEARCOAT_TINT_TEXTURE: boolean;
  45109. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45110. ANISOTROPIC: boolean;
  45111. ANISOTROPIC_TEXTURE: boolean;
  45112. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45113. BRDF_V_HEIGHT_CORRELATED: boolean;
  45114. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45115. SHEEN: boolean;
  45116. SHEEN_TEXTURE: boolean;
  45117. SHEEN_TEXTUREDIRECTUV: number;
  45118. SHEEN_LINKWITHALBEDO: boolean;
  45119. SUBSURFACE: boolean;
  45120. SS_REFRACTION: boolean;
  45121. SS_TRANSLUCENCY: boolean;
  45122. SS_SCATERRING: boolean;
  45123. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45124. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45125. SS_REFRACTIONMAP_3D: boolean;
  45126. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45127. SS_LODINREFRACTIONALPHA: boolean;
  45128. SS_GAMMAREFRACTION: boolean;
  45129. SS_RGBDREFRACTION: boolean;
  45130. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45131. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45132. UNLIT: boolean;
  45133. DEBUGMODE: number;
  45134. /**
  45135. * Initializes the PBR Material defines.
  45136. */
  45137. constructor();
  45138. /**
  45139. * Resets the PBR Material defines.
  45140. */
  45141. reset(): void;
  45142. }
  45143. /**
  45144. * The Physically based material base class of BJS.
  45145. *
  45146. * This offers the main features of a standard PBR material.
  45147. * For more information, please refer to the documentation :
  45148. * https://doc.babylonjs.com/how_to/physically_based_rendering
  45149. */
  45150. export abstract class PBRBaseMaterial extends PushMaterial {
  45151. /**
  45152. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45153. */
  45154. static readonly PBRMATERIAL_OPAQUE: number;
  45155. /**
  45156. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45157. */
  45158. static readonly PBRMATERIAL_ALPHATEST: number;
  45159. /**
  45160. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45161. */
  45162. static readonly PBRMATERIAL_ALPHABLEND: number;
  45163. /**
  45164. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45165. * They are also discarded below the alpha cutoff threshold to improve performances.
  45166. */
  45167. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45168. /**
  45169. * Defines the default value of how much AO map is occluding the analytical lights
  45170. * (point spot...).
  45171. */
  45172. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45173. /**
  45174. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45175. */
  45176. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45177. /**
  45178. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45179. * to enhance interoperability with other engines.
  45180. */
  45181. static readonly LIGHTFALLOFF_GLTF: number;
  45182. /**
  45183. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45184. * to enhance interoperability with other materials.
  45185. */
  45186. static readonly LIGHTFALLOFF_STANDARD: number;
  45187. /**
  45188. * Intensity of the direct lights e.g. the four lights available in your scene.
  45189. * This impacts both the direct diffuse and specular highlights.
  45190. */
  45191. protected _directIntensity: number;
  45192. /**
  45193. * Intensity of the emissive part of the material.
  45194. * This helps controlling the emissive effect without modifying the emissive color.
  45195. */
  45196. protected _emissiveIntensity: number;
  45197. /**
  45198. * Intensity of the environment e.g. how much the environment will light the object
  45199. * either through harmonics for rough material or through the refelction for shiny ones.
  45200. */
  45201. protected _environmentIntensity: number;
  45202. /**
  45203. * This is a special control allowing the reduction of the specular highlights coming from the
  45204. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45205. */
  45206. protected _specularIntensity: number;
  45207. /**
  45208. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45209. */
  45210. private _lightingInfos;
  45211. /**
  45212. * Debug Control allowing disabling the bump map on this material.
  45213. */
  45214. protected _disableBumpMap: boolean;
  45215. /**
  45216. * AKA Diffuse Texture in standard nomenclature.
  45217. */
  45218. protected _albedoTexture: Nullable<BaseTexture>;
  45219. /**
  45220. * AKA Occlusion Texture in other nomenclature.
  45221. */
  45222. protected _ambientTexture: Nullable<BaseTexture>;
  45223. /**
  45224. * AKA Occlusion Texture Intensity in other nomenclature.
  45225. */
  45226. protected _ambientTextureStrength: number;
  45227. /**
  45228. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45229. * 1 means it completely occludes it
  45230. * 0 mean it has no impact
  45231. */
  45232. protected _ambientTextureImpactOnAnalyticalLights: number;
  45233. /**
  45234. * Stores the alpha values in a texture.
  45235. */
  45236. protected _opacityTexture: Nullable<BaseTexture>;
  45237. /**
  45238. * Stores the reflection values in a texture.
  45239. */
  45240. protected _reflectionTexture: Nullable<BaseTexture>;
  45241. /**
  45242. * Stores the emissive values in a texture.
  45243. */
  45244. protected _emissiveTexture: Nullable<BaseTexture>;
  45245. /**
  45246. * AKA Specular texture in other nomenclature.
  45247. */
  45248. protected _reflectivityTexture: Nullable<BaseTexture>;
  45249. /**
  45250. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45251. */
  45252. protected _metallicTexture: Nullable<BaseTexture>;
  45253. /**
  45254. * Specifies the metallic scalar of the metallic/roughness workflow.
  45255. * Can also be used to scale the metalness values of the metallic texture.
  45256. */
  45257. protected _metallic: Nullable<number>;
  45258. /**
  45259. * Specifies the roughness scalar of the metallic/roughness workflow.
  45260. * Can also be used to scale the roughness values of the metallic texture.
  45261. */
  45262. protected _roughness: Nullable<number>;
  45263. /**
  45264. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45265. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45266. */
  45267. protected _microSurfaceTexture: Nullable<BaseTexture>;
  45268. /**
  45269. * Stores surface normal data used to displace a mesh in a texture.
  45270. */
  45271. protected _bumpTexture: Nullable<BaseTexture>;
  45272. /**
  45273. * Stores the pre-calculated light information of a mesh in a texture.
  45274. */
  45275. protected _lightmapTexture: Nullable<BaseTexture>;
  45276. /**
  45277. * The color of a material in ambient lighting.
  45278. */
  45279. protected _ambientColor: Color3;
  45280. /**
  45281. * AKA Diffuse Color in other nomenclature.
  45282. */
  45283. protected _albedoColor: Color3;
  45284. /**
  45285. * AKA Specular Color in other nomenclature.
  45286. */
  45287. protected _reflectivityColor: Color3;
  45288. /**
  45289. * The color applied when light is reflected from a material.
  45290. */
  45291. protected _reflectionColor: Color3;
  45292. /**
  45293. * The color applied when light is emitted from a material.
  45294. */
  45295. protected _emissiveColor: Color3;
  45296. /**
  45297. * AKA Glossiness in other nomenclature.
  45298. */
  45299. protected _microSurface: number;
  45300. /**
  45301. * Specifies that the material will use the light map as a show map.
  45302. */
  45303. protected _useLightmapAsShadowmap: boolean;
  45304. /**
  45305. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45306. * makes the reflect vector face the model (under horizon).
  45307. */
  45308. protected _useHorizonOcclusion: boolean;
  45309. /**
  45310. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45311. * too much the area relying on ambient texture to define their ambient occlusion.
  45312. */
  45313. protected _useRadianceOcclusion: boolean;
  45314. /**
  45315. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45316. */
  45317. protected _useAlphaFromAlbedoTexture: boolean;
  45318. /**
  45319. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45320. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45321. */
  45322. protected _useSpecularOverAlpha: boolean;
  45323. /**
  45324. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45325. */
  45326. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45327. /**
  45328. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45329. */
  45330. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45331. /**
  45332. * Specifies if the metallic texture contains the roughness information in its green channel.
  45333. */
  45334. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45335. /**
  45336. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45337. */
  45338. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45339. /**
  45340. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45341. */
  45342. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45343. /**
  45344. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45345. */
  45346. protected _useAmbientInGrayScale: boolean;
  45347. /**
  45348. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45349. * The material will try to infer what glossiness each pixel should be.
  45350. */
  45351. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45352. /**
  45353. * Defines the falloff type used in this material.
  45354. * It by default is Physical.
  45355. */
  45356. protected _lightFalloff: number;
  45357. /**
  45358. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45359. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45360. */
  45361. protected _useRadianceOverAlpha: boolean;
  45362. /**
  45363. * Allows using an object space normal map (instead of tangent space).
  45364. */
  45365. protected _useObjectSpaceNormalMap: boolean;
  45366. /**
  45367. * Allows using the bump map in parallax mode.
  45368. */
  45369. protected _useParallax: boolean;
  45370. /**
  45371. * Allows using the bump map in parallax occlusion mode.
  45372. */
  45373. protected _useParallaxOcclusion: boolean;
  45374. /**
  45375. * Controls the scale bias of the parallax mode.
  45376. */
  45377. protected _parallaxScaleBias: number;
  45378. /**
  45379. * If sets to true, disables all the lights affecting the material.
  45380. */
  45381. protected _disableLighting: boolean;
  45382. /**
  45383. * Number of Simultaneous lights allowed on the material.
  45384. */
  45385. protected _maxSimultaneousLights: number;
  45386. /**
  45387. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45388. */
  45389. protected _invertNormalMapX: boolean;
  45390. /**
  45391. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45392. */
  45393. protected _invertNormalMapY: boolean;
  45394. /**
  45395. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45396. */
  45397. protected _twoSidedLighting: boolean;
  45398. /**
  45399. * Defines the alpha limits in alpha test mode.
  45400. */
  45401. protected _alphaCutOff: number;
  45402. /**
  45403. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45404. */
  45405. protected _forceAlphaTest: boolean;
  45406. /**
  45407. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45408. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45409. */
  45410. protected _useAlphaFresnel: boolean;
  45411. /**
  45412. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45413. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45414. */
  45415. protected _useLinearAlphaFresnel: boolean;
  45416. /**
  45417. * The transparency mode of the material.
  45418. */
  45419. protected _transparencyMode: Nullable<number>;
  45420. /**
  45421. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45422. * from cos thetav and roughness:
  45423. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45424. */
  45425. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45426. /**
  45427. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45428. */
  45429. protected _forceIrradianceInFragment: boolean;
  45430. /**
  45431. * Force normal to face away from face.
  45432. */
  45433. protected _forceNormalForward: boolean;
  45434. /**
  45435. * Enables specular anti aliasing in the PBR shader.
  45436. * It will both interacts on the Geometry for analytical and IBL lighting.
  45437. * It also prefilter the roughness map based on the bump values.
  45438. */
  45439. protected _enableSpecularAntiAliasing: boolean;
  45440. /**
  45441. * Default configuration related to image processing available in the PBR Material.
  45442. */
  45443. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45444. /**
  45445. * Keep track of the image processing observer to allow dispose and replace.
  45446. */
  45447. private _imageProcessingObserver;
  45448. /**
  45449. * Attaches a new image processing configuration to the PBR Material.
  45450. * @param configuration
  45451. */
  45452. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45453. /**
  45454. * Stores the available render targets.
  45455. */
  45456. private _renderTargets;
  45457. /**
  45458. * Sets the global ambient color for the material used in lighting calculations.
  45459. */
  45460. private _globalAmbientColor;
  45461. /**
  45462. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45463. */
  45464. private _useLogarithmicDepth;
  45465. /**
  45466. * If set to true, no lighting calculations will be applied.
  45467. */
  45468. private _unlit;
  45469. private _debugMode;
  45470. /**
  45471. * @hidden
  45472. * This is reserved for the inspector.
  45473. * Defines the material debug mode.
  45474. * It helps seeing only some components of the material while troubleshooting.
  45475. */
  45476. debugMode: number;
  45477. /**
  45478. * @hidden
  45479. * This is reserved for the inspector.
  45480. * Specify from where on screen the debug mode should start.
  45481. * The value goes from -1 (full screen) to 1 (not visible)
  45482. * It helps with side by side comparison against the final render
  45483. * This defaults to -1
  45484. */
  45485. private debugLimit;
  45486. /**
  45487. * @hidden
  45488. * This is reserved for the inspector.
  45489. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45490. * You can use the factor to better multiply the final value.
  45491. */
  45492. private debugFactor;
  45493. /**
  45494. * Defines the clear coat layer parameters for the material.
  45495. */
  45496. readonly clearCoat: PBRClearCoatConfiguration;
  45497. /**
  45498. * Defines the anisotropic parameters for the material.
  45499. */
  45500. readonly anisotropy: PBRAnisotropicConfiguration;
  45501. /**
  45502. * Defines the BRDF parameters for the material.
  45503. */
  45504. readonly brdf: PBRBRDFConfiguration;
  45505. /**
  45506. * Defines the Sheen parameters for the material.
  45507. */
  45508. readonly sheen: PBRSheenConfiguration;
  45509. /**
  45510. * Defines the SubSurface parameters for the material.
  45511. */
  45512. readonly subSurface: PBRSubSurfaceConfiguration;
  45513. /**
  45514. * Custom callback helping to override the default shader used in the material.
  45515. */
  45516. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  45517. /**
  45518. * Instantiates a new PBRMaterial instance.
  45519. *
  45520. * @param name The material name
  45521. * @param scene The scene the material will be use in.
  45522. */
  45523. constructor(name: string, scene: Scene);
  45524. /**
  45525. * Gets a boolean indicating that current material needs to register RTT
  45526. */
  45527. readonly hasRenderTargetTextures: boolean;
  45528. /**
  45529. * Gets the name of the material class.
  45530. */
  45531. getClassName(): string;
  45532. /**
  45533. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45534. */
  45535. /**
  45536. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45537. */
  45538. useLogarithmicDepth: boolean;
  45539. /**
  45540. * Gets the current transparency mode.
  45541. */
  45542. /**
  45543. * Sets the transparency mode of the material.
  45544. *
  45545. * | Value | Type | Description |
  45546. * | ----- | ----------------------------------- | ----------- |
  45547. * | 0 | OPAQUE | |
  45548. * | 1 | ALPHATEST | |
  45549. * | 2 | ALPHABLEND | |
  45550. * | 3 | ALPHATESTANDBLEND | |
  45551. *
  45552. */
  45553. transparencyMode: Nullable<number>;
  45554. /**
  45555. * Returns true if alpha blending should be disabled.
  45556. */
  45557. private readonly _disableAlphaBlending;
  45558. /**
  45559. * Specifies whether or not this material should be rendered in alpha blend mode.
  45560. */
  45561. needAlphaBlending(): boolean;
  45562. /**
  45563. * Specifies if the mesh will require alpha blending.
  45564. * @param mesh - BJS mesh.
  45565. */
  45566. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45567. /**
  45568. * Specifies whether or not this material should be rendered in alpha test mode.
  45569. */
  45570. needAlphaTesting(): boolean;
  45571. /**
  45572. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45573. */
  45574. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45575. /**
  45576. * Gets the texture used for the alpha test.
  45577. */
  45578. getAlphaTestTexture(): Nullable<BaseTexture>;
  45579. /**
  45580. * Specifies that the submesh is ready to be used.
  45581. * @param mesh - BJS mesh.
  45582. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45583. * @param useInstances - Specifies that instances should be used.
  45584. * @returns - boolean indicating that the submesh is ready or not.
  45585. */
  45586. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45587. /**
  45588. * Specifies if the material uses metallic roughness workflow.
  45589. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45590. */
  45591. isMetallicWorkflow(): boolean;
  45592. private _prepareEffect;
  45593. private _prepareDefines;
  45594. /**
  45595. * Force shader compilation
  45596. */
  45597. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45598. clipPlane: boolean;
  45599. }>): void;
  45600. /**
  45601. * Initializes the uniform buffer layout for the shader.
  45602. */
  45603. buildUniformLayout(): void;
  45604. /**
  45605. * Unbinds the material from the mesh
  45606. */
  45607. unbind(): void;
  45608. /**
  45609. * Binds the submesh data.
  45610. * @param world - The world matrix.
  45611. * @param mesh - The BJS mesh.
  45612. * @param subMesh - A submesh of the BJS mesh.
  45613. */
  45614. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45615. /**
  45616. * Returns the animatable textures.
  45617. * @returns - Array of animatable textures.
  45618. */
  45619. getAnimatables(): IAnimatable[];
  45620. /**
  45621. * Returns the texture used for reflections.
  45622. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45623. */
  45624. private _getReflectionTexture;
  45625. /**
  45626. * Returns an array of the actively used textures.
  45627. * @returns - Array of BaseTextures
  45628. */
  45629. getActiveTextures(): BaseTexture[];
  45630. /**
  45631. * Checks to see if a texture is used in the material.
  45632. * @param texture - Base texture to use.
  45633. * @returns - Boolean specifying if a texture is used in the material.
  45634. */
  45635. hasTexture(texture: BaseTexture): boolean;
  45636. /**
  45637. * Disposes the resources of the material.
  45638. * @param forceDisposeEffect - Forces the disposal of effects.
  45639. * @param forceDisposeTextures - Forces the disposal of all textures.
  45640. */
  45641. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45642. }
  45643. }
  45644. declare module BABYLON {
  45645. /**
  45646. * The Physically based material of BJS.
  45647. *
  45648. * This offers the main features of a standard PBR material.
  45649. * For more information, please refer to the documentation :
  45650. * https://doc.babylonjs.com/how_to/physically_based_rendering
  45651. */
  45652. export class PBRMaterial extends PBRBaseMaterial {
  45653. /**
  45654. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45655. */
  45656. static readonly PBRMATERIAL_OPAQUE: number;
  45657. /**
  45658. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45659. */
  45660. static readonly PBRMATERIAL_ALPHATEST: number;
  45661. /**
  45662. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45663. */
  45664. static readonly PBRMATERIAL_ALPHABLEND: number;
  45665. /**
  45666. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45667. * They are also discarded below the alpha cutoff threshold to improve performances.
  45668. */
  45669. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45670. /**
  45671. * Defines the default value of how much AO map is occluding the analytical lights
  45672. * (point spot...).
  45673. */
  45674. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45675. /**
  45676. * Intensity of the direct lights e.g. the four lights available in your scene.
  45677. * This impacts both the direct diffuse and specular highlights.
  45678. */
  45679. directIntensity: number;
  45680. /**
  45681. * Intensity of the emissive part of the material.
  45682. * This helps controlling the emissive effect without modifying the emissive color.
  45683. */
  45684. emissiveIntensity: number;
  45685. /**
  45686. * Intensity of the environment e.g. how much the environment will light the object
  45687. * either through harmonics for rough material or through the refelction for shiny ones.
  45688. */
  45689. environmentIntensity: number;
  45690. /**
  45691. * This is a special control allowing the reduction of the specular highlights coming from the
  45692. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45693. */
  45694. specularIntensity: number;
  45695. /**
  45696. * Debug Control allowing disabling the bump map on this material.
  45697. */
  45698. disableBumpMap: boolean;
  45699. /**
  45700. * AKA Diffuse Texture in standard nomenclature.
  45701. */
  45702. albedoTexture: BaseTexture;
  45703. /**
  45704. * AKA Occlusion Texture in other nomenclature.
  45705. */
  45706. ambientTexture: BaseTexture;
  45707. /**
  45708. * AKA Occlusion Texture Intensity in other nomenclature.
  45709. */
  45710. ambientTextureStrength: number;
  45711. /**
  45712. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45713. * 1 means it completely occludes it
  45714. * 0 mean it has no impact
  45715. */
  45716. ambientTextureImpactOnAnalyticalLights: number;
  45717. /**
  45718. * Stores the alpha values in a texture.
  45719. */
  45720. opacityTexture: BaseTexture;
  45721. /**
  45722. * Stores the reflection values in a texture.
  45723. */
  45724. reflectionTexture: Nullable<BaseTexture>;
  45725. /**
  45726. * Stores the emissive values in a texture.
  45727. */
  45728. emissiveTexture: BaseTexture;
  45729. /**
  45730. * AKA Specular texture in other nomenclature.
  45731. */
  45732. reflectivityTexture: BaseTexture;
  45733. /**
  45734. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45735. */
  45736. metallicTexture: BaseTexture;
  45737. /**
  45738. * Specifies the metallic scalar of the metallic/roughness workflow.
  45739. * Can also be used to scale the metalness values of the metallic texture.
  45740. */
  45741. metallic: Nullable<number>;
  45742. /**
  45743. * Specifies the roughness scalar of the metallic/roughness workflow.
  45744. * Can also be used to scale the roughness values of the metallic texture.
  45745. */
  45746. roughness: Nullable<number>;
  45747. /**
  45748. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45749. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45750. */
  45751. microSurfaceTexture: BaseTexture;
  45752. /**
  45753. * Stores surface normal data used to displace a mesh in a texture.
  45754. */
  45755. bumpTexture: BaseTexture;
  45756. /**
  45757. * Stores the pre-calculated light information of a mesh in a texture.
  45758. */
  45759. lightmapTexture: BaseTexture;
  45760. /**
  45761. * Stores the refracted light information in a texture.
  45762. */
  45763. refractionTexture: Nullable<BaseTexture>;
  45764. /**
  45765. * The color of a material in ambient lighting.
  45766. */
  45767. ambientColor: Color3;
  45768. /**
  45769. * AKA Diffuse Color in other nomenclature.
  45770. */
  45771. albedoColor: Color3;
  45772. /**
  45773. * AKA Specular Color in other nomenclature.
  45774. */
  45775. reflectivityColor: Color3;
  45776. /**
  45777. * The color reflected from the material.
  45778. */
  45779. reflectionColor: Color3;
  45780. /**
  45781. * The color emitted from the material.
  45782. */
  45783. emissiveColor: Color3;
  45784. /**
  45785. * AKA Glossiness in other nomenclature.
  45786. */
  45787. microSurface: number;
  45788. /**
  45789. * source material index of refraction (IOR)' / 'destination material IOR.
  45790. */
  45791. indexOfRefraction: number;
  45792. /**
  45793. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45794. */
  45795. invertRefractionY: boolean;
  45796. /**
  45797. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45798. * Materials half opaque for instance using refraction could benefit from this control.
  45799. */
  45800. linkRefractionWithTransparency: boolean;
  45801. /**
  45802. * If true, the light map contains occlusion information instead of lighting info.
  45803. */
  45804. useLightmapAsShadowmap: boolean;
  45805. /**
  45806. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45807. */
  45808. useAlphaFromAlbedoTexture: boolean;
  45809. /**
  45810. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45811. */
  45812. forceAlphaTest: boolean;
  45813. /**
  45814. * Defines the alpha limits in alpha test mode.
  45815. */
  45816. alphaCutOff: number;
  45817. /**
  45818. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45819. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45820. */
  45821. useSpecularOverAlpha: boolean;
  45822. /**
  45823. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45824. */
  45825. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45826. /**
  45827. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45828. */
  45829. useRoughnessFromMetallicTextureAlpha: boolean;
  45830. /**
  45831. * Specifies if the metallic texture contains the roughness information in its green channel.
  45832. */
  45833. useRoughnessFromMetallicTextureGreen: boolean;
  45834. /**
  45835. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45836. */
  45837. useMetallnessFromMetallicTextureBlue: boolean;
  45838. /**
  45839. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45840. */
  45841. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45842. /**
  45843. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45844. */
  45845. useAmbientInGrayScale: boolean;
  45846. /**
  45847. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45848. * The material will try to infer what glossiness each pixel should be.
  45849. */
  45850. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45851. /**
  45852. * BJS is using an harcoded light falloff based on a manually sets up range.
  45853. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45854. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45855. */
  45856. /**
  45857. * BJS is using an harcoded light falloff based on a manually sets up range.
  45858. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45859. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45860. */
  45861. usePhysicalLightFalloff: boolean;
  45862. /**
  45863. * In order to support the falloff compatibility with gltf, a special mode has been added
  45864. * to reproduce the gltf light falloff.
  45865. */
  45866. /**
  45867. * In order to support the falloff compatibility with gltf, a special mode has been added
  45868. * to reproduce the gltf light falloff.
  45869. */
  45870. useGLTFLightFalloff: boolean;
  45871. /**
  45872. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45873. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45874. */
  45875. useRadianceOverAlpha: boolean;
  45876. /**
  45877. * Allows using an object space normal map (instead of tangent space).
  45878. */
  45879. useObjectSpaceNormalMap: boolean;
  45880. /**
  45881. * Allows using the bump map in parallax mode.
  45882. */
  45883. useParallax: boolean;
  45884. /**
  45885. * Allows using the bump map in parallax occlusion mode.
  45886. */
  45887. useParallaxOcclusion: boolean;
  45888. /**
  45889. * Controls the scale bias of the parallax mode.
  45890. */
  45891. parallaxScaleBias: number;
  45892. /**
  45893. * If sets to true, disables all the lights affecting the material.
  45894. */
  45895. disableLighting: boolean;
  45896. /**
  45897. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45898. */
  45899. forceIrradianceInFragment: boolean;
  45900. /**
  45901. * Number of Simultaneous lights allowed on the material.
  45902. */
  45903. maxSimultaneousLights: number;
  45904. /**
  45905. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45906. */
  45907. invertNormalMapX: boolean;
  45908. /**
  45909. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45910. */
  45911. invertNormalMapY: boolean;
  45912. /**
  45913. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45914. */
  45915. twoSidedLighting: boolean;
  45916. /**
  45917. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45918. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45919. */
  45920. useAlphaFresnel: boolean;
  45921. /**
  45922. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45923. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45924. */
  45925. useLinearAlphaFresnel: boolean;
  45926. /**
  45927. * Let user defines the brdf lookup texture used for IBL.
  45928. * A default 8bit version is embedded but you could point at :
  45929. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45930. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45931. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45932. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45933. */
  45934. environmentBRDFTexture: Nullable<BaseTexture>;
  45935. /**
  45936. * Force normal to face away from face.
  45937. */
  45938. forceNormalForward: boolean;
  45939. /**
  45940. * Enables specular anti aliasing in the PBR shader.
  45941. * It will both interacts on the Geometry for analytical and IBL lighting.
  45942. * It also prefilter the roughness map based on the bump values.
  45943. */
  45944. enableSpecularAntiAliasing: boolean;
  45945. /**
  45946. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45947. * makes the reflect vector face the model (under horizon).
  45948. */
  45949. useHorizonOcclusion: boolean;
  45950. /**
  45951. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45952. * too much the area relying on ambient texture to define their ambient occlusion.
  45953. */
  45954. useRadianceOcclusion: boolean;
  45955. /**
  45956. * If set to true, no lighting calculations will be applied.
  45957. */
  45958. unlit: boolean;
  45959. /**
  45960. * Gets the image processing configuration used either in this material.
  45961. */
  45962. /**
  45963. * Sets the Default image processing configuration used either in the this material.
  45964. *
  45965. * If sets to null, the scene one is in use.
  45966. */
  45967. imageProcessingConfiguration: ImageProcessingConfiguration;
  45968. /**
  45969. * Gets wether the color curves effect is enabled.
  45970. */
  45971. /**
  45972. * Sets wether the color curves effect is enabled.
  45973. */
  45974. cameraColorCurvesEnabled: boolean;
  45975. /**
  45976. * Gets wether the color grading effect is enabled.
  45977. */
  45978. /**
  45979. * Gets wether the color grading effect is enabled.
  45980. */
  45981. cameraColorGradingEnabled: boolean;
  45982. /**
  45983. * Gets wether tonemapping is enabled or not.
  45984. */
  45985. /**
  45986. * Sets wether tonemapping is enabled or not
  45987. */
  45988. cameraToneMappingEnabled: boolean;
  45989. /**
  45990. * The camera exposure used on this material.
  45991. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45992. * This corresponds to a photographic exposure.
  45993. */
  45994. /**
  45995. * The camera exposure used on this material.
  45996. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45997. * This corresponds to a photographic exposure.
  45998. */
  45999. cameraExposure: number;
  46000. /**
  46001. * Gets The camera contrast used on this material.
  46002. */
  46003. /**
  46004. * Sets The camera contrast used on this material.
  46005. */
  46006. cameraContrast: number;
  46007. /**
  46008. * Gets the Color Grading 2D Lookup Texture.
  46009. */
  46010. /**
  46011. * Sets the Color Grading 2D Lookup Texture.
  46012. */
  46013. cameraColorGradingTexture: Nullable<BaseTexture>;
  46014. /**
  46015. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46016. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46017. * 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;
  46018. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46019. */
  46020. /**
  46021. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46022. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46023. * 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;
  46024. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46025. */
  46026. cameraColorCurves: Nullable<ColorCurves>;
  46027. /**
  46028. * Instantiates a new PBRMaterial instance.
  46029. *
  46030. * @param name The material name
  46031. * @param scene The scene the material will be use in.
  46032. */
  46033. constructor(name: string, scene: Scene);
  46034. /**
  46035. * Returns the name of this material class.
  46036. */
  46037. getClassName(): string;
  46038. /**
  46039. * Makes a duplicate of the current material.
  46040. * @param name - name to use for the new material.
  46041. */
  46042. clone(name: string): PBRMaterial;
  46043. /**
  46044. * Serializes this PBR Material.
  46045. * @returns - An object with the serialized material.
  46046. */
  46047. serialize(): any;
  46048. /**
  46049. * Parses a PBR Material from a serialized object.
  46050. * @param source - Serialized object.
  46051. * @param scene - BJS scene instance.
  46052. * @param rootUrl - url for the scene object
  46053. * @returns - PBRMaterial
  46054. */
  46055. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46056. }
  46057. }
  46058. declare module BABYLON {
  46059. /**
  46060. * Direct draw surface info
  46061. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46062. */
  46063. export interface DDSInfo {
  46064. /**
  46065. * Width of the texture
  46066. */
  46067. width: number;
  46068. /**
  46069. * Width of the texture
  46070. */
  46071. height: number;
  46072. /**
  46073. * Number of Mipmaps for the texture
  46074. * @see https://en.wikipedia.org/wiki/Mipmap
  46075. */
  46076. mipmapCount: number;
  46077. /**
  46078. * If the textures format is a known fourCC format
  46079. * @see https://www.fourcc.org/
  46080. */
  46081. isFourCC: boolean;
  46082. /**
  46083. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46084. */
  46085. isRGB: boolean;
  46086. /**
  46087. * If the texture is a lumincance format
  46088. */
  46089. isLuminance: boolean;
  46090. /**
  46091. * If this is a cube texture
  46092. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46093. */
  46094. isCube: boolean;
  46095. /**
  46096. * If the texture is a compressed format eg. FOURCC_DXT1
  46097. */
  46098. isCompressed: boolean;
  46099. /**
  46100. * The dxgiFormat of the texture
  46101. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46102. */
  46103. dxgiFormat: number;
  46104. /**
  46105. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46106. */
  46107. textureType: number;
  46108. /**
  46109. * Sphericle polynomial created for the dds texture
  46110. */
  46111. sphericalPolynomial?: SphericalPolynomial;
  46112. }
  46113. /**
  46114. * Class used to provide DDS decompression tools
  46115. */
  46116. export class DDSTools {
  46117. /**
  46118. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46119. */
  46120. static StoreLODInAlphaChannel: boolean;
  46121. /**
  46122. * Gets DDS information from an array buffer
  46123. * @param arrayBuffer defines the array buffer to read data from
  46124. * @returns the DDS information
  46125. */
  46126. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46127. private static _FloatView;
  46128. private static _Int32View;
  46129. private static _ToHalfFloat;
  46130. private static _FromHalfFloat;
  46131. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46132. private static _GetHalfFloatRGBAArrayBuffer;
  46133. private static _GetFloatRGBAArrayBuffer;
  46134. private static _GetFloatAsUIntRGBAArrayBuffer;
  46135. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46136. private static _GetRGBAArrayBuffer;
  46137. private static _ExtractLongWordOrder;
  46138. private static _GetRGBArrayBuffer;
  46139. private static _GetLuminanceArrayBuffer;
  46140. /**
  46141. * Uploads DDS Levels to a Babylon Texture
  46142. * @hidden
  46143. */
  46144. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46145. }
  46146. interface Engine {
  46147. /**
  46148. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46149. * @param rootUrl defines the url where the file to load is located
  46150. * @param scene defines the current scene
  46151. * @param lodScale defines scale to apply to the mip map selection
  46152. * @param lodOffset defines offset to apply to the mip map selection
  46153. * @param onLoad defines an optional callback raised when the texture is loaded
  46154. * @param onError defines an optional callback raised if there is an issue to load the texture
  46155. * @param format defines the format of the data
  46156. * @param forcedExtension defines the extension to use to pick the right loader
  46157. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46158. * @returns the cube texture as an InternalTexture
  46159. */
  46160. 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;
  46161. }
  46162. }
  46163. declare module BABYLON {
  46164. /**
  46165. * Implementation of the DDS Texture Loader.
  46166. * @hidden
  46167. */
  46168. export class _DDSTextureLoader implements IInternalTextureLoader {
  46169. /**
  46170. * Defines wether the loader supports cascade loading the different faces.
  46171. */
  46172. readonly supportCascades: boolean;
  46173. /**
  46174. * This returns if the loader support the current file information.
  46175. * @param extension defines the file extension of the file being loaded
  46176. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46177. * @param fallback defines the fallback internal texture if any
  46178. * @param isBase64 defines whether the texture is encoded as a base64
  46179. * @param isBuffer defines whether the texture data are stored as a buffer
  46180. * @returns true if the loader can load the specified file
  46181. */
  46182. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46183. /**
  46184. * Transform the url before loading if required.
  46185. * @param rootUrl the url of the texture
  46186. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46187. * @returns the transformed texture
  46188. */
  46189. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46190. /**
  46191. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46192. * @param rootUrl the url of the texture
  46193. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46194. * @returns the fallback texture
  46195. */
  46196. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46197. /**
  46198. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46199. * @param data contains the texture data
  46200. * @param texture defines the BabylonJS internal texture
  46201. * @param createPolynomials will be true if polynomials have been requested
  46202. * @param onLoad defines the callback to trigger once the texture is ready
  46203. * @param onError defines the callback to trigger in case of error
  46204. */
  46205. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46206. /**
  46207. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46208. * @param data contains the texture data
  46209. * @param texture defines the BabylonJS internal texture
  46210. * @param callback defines the method to call once ready to upload
  46211. */
  46212. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46213. }
  46214. }
  46215. declare module BABYLON {
  46216. /** @hidden */
  46217. export var rgbdEncodePixelShader: {
  46218. name: string;
  46219. shader: string;
  46220. };
  46221. }
  46222. declare module BABYLON {
  46223. /**
  46224. * Raw texture data and descriptor sufficient for WebGL texture upload
  46225. */
  46226. export interface EnvironmentTextureInfo {
  46227. /**
  46228. * Version of the environment map
  46229. */
  46230. version: number;
  46231. /**
  46232. * Width of image
  46233. */
  46234. width: number;
  46235. /**
  46236. * Irradiance information stored in the file.
  46237. */
  46238. irradiance: any;
  46239. /**
  46240. * Specular information stored in the file.
  46241. */
  46242. specular: any;
  46243. }
  46244. /**
  46245. * Sets of helpers addressing the serialization and deserialization of environment texture
  46246. * stored in a BabylonJS env file.
  46247. * Those files are usually stored as .env files.
  46248. */
  46249. export class EnvironmentTextureTools {
  46250. /**
  46251. * Magic number identifying the env file.
  46252. */
  46253. private static _MagicBytes;
  46254. /**
  46255. * Gets the environment info from an env file.
  46256. * @param data The array buffer containing the .env bytes.
  46257. * @returns the environment file info (the json header) if successfully parsed.
  46258. */
  46259. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46260. /**
  46261. * Creates an environment texture from a loaded cube texture.
  46262. * @param texture defines the cube texture to convert in env file
  46263. * @return a promise containing the environment data if succesfull.
  46264. */
  46265. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46266. /**
  46267. * Creates a JSON representation of the spherical data.
  46268. * @param texture defines the texture containing the polynomials
  46269. * @return the JSON representation of the spherical info
  46270. */
  46271. private static _CreateEnvTextureIrradiance;
  46272. /**
  46273. * Uploads the texture info contained in the env file to the GPU.
  46274. * @param texture defines the internal texture to upload to
  46275. * @param arrayBuffer defines the buffer cotaining the data to load
  46276. * @param info defines the texture info retrieved through the GetEnvInfo method
  46277. * @returns a promise
  46278. */
  46279. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46280. /**
  46281. * Uploads the levels of image data to the GPU.
  46282. * @param texture defines the internal texture to upload to
  46283. * @param imageData defines the array buffer views of image data [mipmap][face]
  46284. * @returns a promise
  46285. */
  46286. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46287. /**
  46288. * Uploads spherical polynomials information to the texture.
  46289. * @param texture defines the texture we are trying to upload the information to
  46290. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46291. */
  46292. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46293. /** @hidden */
  46294. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46295. }
  46296. }
  46297. declare module BABYLON {
  46298. /**
  46299. * Implementation of the ENV Texture Loader.
  46300. * @hidden
  46301. */
  46302. export class _ENVTextureLoader implements IInternalTextureLoader {
  46303. /**
  46304. * Defines wether the loader supports cascade loading the different faces.
  46305. */
  46306. readonly supportCascades: boolean;
  46307. /**
  46308. * This returns if the loader support the current file information.
  46309. * @param extension defines the file extension of the file being loaded
  46310. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46311. * @param fallback defines the fallback internal texture if any
  46312. * @param isBase64 defines whether the texture is encoded as a base64
  46313. * @param isBuffer defines whether the texture data are stored as a buffer
  46314. * @returns true if the loader can load the specified file
  46315. */
  46316. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46317. /**
  46318. * Transform the url before loading if required.
  46319. * @param rootUrl the url of the texture
  46320. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46321. * @returns the transformed texture
  46322. */
  46323. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46324. /**
  46325. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46326. * @param rootUrl the url of the texture
  46327. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46328. * @returns the fallback texture
  46329. */
  46330. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46331. /**
  46332. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46333. * @param data contains the texture data
  46334. * @param texture defines the BabylonJS internal texture
  46335. * @param createPolynomials will be true if polynomials have been requested
  46336. * @param onLoad defines the callback to trigger once the texture is ready
  46337. * @param onError defines the callback to trigger in case of error
  46338. */
  46339. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46340. /**
  46341. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46342. * @param data contains the texture data
  46343. * @param texture defines the BabylonJS internal texture
  46344. * @param callback defines the method to call once ready to upload
  46345. */
  46346. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46347. }
  46348. }
  46349. declare module BABYLON {
  46350. /**
  46351. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46352. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46353. */
  46354. export class KhronosTextureContainer {
  46355. /** contents of the KTX container file */
  46356. arrayBuffer: any;
  46357. private static HEADER_LEN;
  46358. private static COMPRESSED_2D;
  46359. private static COMPRESSED_3D;
  46360. private static TEX_2D;
  46361. private static TEX_3D;
  46362. /**
  46363. * Gets the openGL type
  46364. */
  46365. glType: number;
  46366. /**
  46367. * Gets the openGL type size
  46368. */
  46369. glTypeSize: number;
  46370. /**
  46371. * Gets the openGL format
  46372. */
  46373. glFormat: number;
  46374. /**
  46375. * Gets the openGL internal format
  46376. */
  46377. glInternalFormat: number;
  46378. /**
  46379. * Gets the base internal format
  46380. */
  46381. glBaseInternalFormat: number;
  46382. /**
  46383. * Gets image width in pixel
  46384. */
  46385. pixelWidth: number;
  46386. /**
  46387. * Gets image height in pixel
  46388. */
  46389. pixelHeight: number;
  46390. /**
  46391. * Gets image depth in pixels
  46392. */
  46393. pixelDepth: number;
  46394. /**
  46395. * Gets the number of array elements
  46396. */
  46397. numberOfArrayElements: number;
  46398. /**
  46399. * Gets the number of faces
  46400. */
  46401. numberOfFaces: number;
  46402. /**
  46403. * Gets the number of mipmap levels
  46404. */
  46405. numberOfMipmapLevels: number;
  46406. /**
  46407. * Gets the bytes of key value data
  46408. */
  46409. bytesOfKeyValueData: number;
  46410. /**
  46411. * Gets the load type
  46412. */
  46413. loadType: number;
  46414. /**
  46415. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46416. */
  46417. isInvalid: boolean;
  46418. /**
  46419. * Creates a new KhronosTextureContainer
  46420. * @param arrayBuffer contents of the KTX container file
  46421. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46422. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46423. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46424. */
  46425. constructor(
  46426. /** contents of the KTX container file */
  46427. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46428. /**
  46429. * Uploads KTX content to a Babylon Texture.
  46430. * It is assumed that the texture has already been created & is currently bound
  46431. * @hidden
  46432. */
  46433. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46434. private _upload2DCompressedLevels;
  46435. }
  46436. }
  46437. declare module BABYLON {
  46438. /**
  46439. * Implementation of the KTX Texture Loader.
  46440. * @hidden
  46441. */
  46442. export class _KTXTextureLoader implements IInternalTextureLoader {
  46443. /**
  46444. * Defines wether the loader supports cascade loading the different faces.
  46445. */
  46446. readonly supportCascades: boolean;
  46447. /**
  46448. * This returns if the loader support the current file information.
  46449. * @param extension defines the file extension of the file being loaded
  46450. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46451. * @param fallback defines the fallback internal texture if any
  46452. * @param isBase64 defines whether the texture is encoded as a base64
  46453. * @param isBuffer defines whether the texture data are stored as a buffer
  46454. * @returns true if the loader can load the specified file
  46455. */
  46456. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46457. /**
  46458. * Transform the url before loading if required.
  46459. * @param rootUrl the url of the texture
  46460. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46461. * @returns the transformed texture
  46462. */
  46463. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46464. /**
  46465. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46466. * @param rootUrl the url of the texture
  46467. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46468. * @returns the fallback texture
  46469. */
  46470. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46471. /**
  46472. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46473. * @param data contains the texture data
  46474. * @param texture defines the BabylonJS internal texture
  46475. * @param createPolynomials will be true if polynomials have been requested
  46476. * @param onLoad defines the callback to trigger once the texture is ready
  46477. * @param onError defines the callback to trigger in case of error
  46478. */
  46479. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46480. /**
  46481. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46482. * @param data contains the texture data
  46483. * @param texture defines the BabylonJS internal texture
  46484. * @param callback defines the method to call once ready to upload
  46485. */
  46486. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46487. }
  46488. }
  46489. declare module BABYLON {
  46490. /** @hidden */
  46491. export var _forceSceneHelpersToBundle: boolean;
  46492. interface Scene {
  46493. /**
  46494. * Creates a default light for the scene.
  46495. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46496. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46497. */
  46498. createDefaultLight(replace?: boolean): void;
  46499. /**
  46500. * Creates a default camera for the scene.
  46501. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46502. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46503. * @param replace has default false, when true replaces the active camera in the scene
  46504. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46505. */
  46506. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46507. /**
  46508. * Creates a default camera and a default light.
  46509. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46510. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46511. * @param replace has the default false, when true replaces the active camera/light in the scene
  46512. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46513. */
  46514. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46515. /**
  46516. * Creates a new sky box
  46517. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46518. * @param environmentTexture defines the texture to use as environment texture
  46519. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46520. * @param scale defines the overall scale of the skybox
  46521. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46522. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46523. * @returns a new mesh holding the sky box
  46524. */
  46525. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46526. /**
  46527. * Creates a new environment
  46528. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46529. * @param options defines the options you can use to configure the environment
  46530. * @returns the new EnvironmentHelper
  46531. */
  46532. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46533. /**
  46534. * Creates a new VREXperienceHelper
  46535. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46536. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46537. * @returns a new VREXperienceHelper
  46538. */
  46539. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46540. /**
  46541. * Creates a new XREXperienceHelper
  46542. * @see http://doc.babylonjs.com/how_to/webxr
  46543. * @returns a promise for a new XREXperienceHelper
  46544. */
  46545. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46546. }
  46547. }
  46548. declare module BABYLON {
  46549. /**
  46550. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46551. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46552. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46553. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46554. */
  46555. export class VideoDome extends TransformNode {
  46556. /**
  46557. * Define the video source as a Monoscopic panoramic 360 video.
  46558. */
  46559. static readonly MODE_MONOSCOPIC: number;
  46560. /**
  46561. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46562. */
  46563. static readonly MODE_TOPBOTTOM: number;
  46564. /**
  46565. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46566. */
  46567. static readonly MODE_SIDEBYSIDE: number;
  46568. private _useDirectMapping;
  46569. /**
  46570. * The video texture being displayed on the sphere
  46571. */
  46572. protected _videoTexture: VideoTexture;
  46573. /**
  46574. * Gets the video texture being displayed on the sphere
  46575. */
  46576. readonly videoTexture: VideoTexture;
  46577. /**
  46578. * The skybox material
  46579. */
  46580. protected _material: BackgroundMaterial;
  46581. /**
  46582. * The surface used for the skybox
  46583. */
  46584. protected _mesh: Mesh;
  46585. /**
  46586. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46587. * Also see the options.resolution property.
  46588. */
  46589. fovMultiplier: number;
  46590. private _videoMode;
  46591. /**
  46592. * Gets or set the current video mode for the video. It can be:
  46593. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46594. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46595. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46596. */
  46597. videoMode: number;
  46598. /**
  46599. * Oberserver used in Stereoscopic VR Mode.
  46600. */
  46601. private _onBeforeCameraRenderObserver;
  46602. /**
  46603. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46604. * @param name Element's name, child elements will append suffixes for their own names.
  46605. * @param urlsOrVideo defines the url(s) or the video element to use
  46606. * @param options An object containing optional or exposed sub element properties
  46607. */
  46608. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46609. resolution?: number;
  46610. clickToPlay?: boolean;
  46611. autoPlay?: boolean;
  46612. loop?: boolean;
  46613. size?: number;
  46614. poster?: string;
  46615. faceForward?: boolean;
  46616. useDirectMapping?: boolean;
  46617. }, scene: Scene);
  46618. private _changeVideoMode;
  46619. /**
  46620. * Releases resources associated with this node.
  46621. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46622. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46623. */
  46624. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46625. }
  46626. }
  46627. declare module BABYLON {
  46628. /**
  46629. * This class can be used to get instrumentation data from a Babylon engine
  46630. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46631. */
  46632. export class EngineInstrumentation implements IDisposable {
  46633. /**
  46634. * Define the instrumented engine.
  46635. */
  46636. engine: Engine;
  46637. private _captureGPUFrameTime;
  46638. private _gpuFrameTimeToken;
  46639. private _gpuFrameTime;
  46640. private _captureShaderCompilationTime;
  46641. private _shaderCompilationTime;
  46642. private _onBeginFrameObserver;
  46643. private _onEndFrameObserver;
  46644. private _onBeforeShaderCompilationObserver;
  46645. private _onAfterShaderCompilationObserver;
  46646. /**
  46647. * Gets the perf counter used for GPU frame time
  46648. */
  46649. readonly gpuFrameTimeCounter: PerfCounter;
  46650. /**
  46651. * Gets the GPU frame time capture status
  46652. */
  46653. /**
  46654. * Enable or disable the GPU frame time capture
  46655. */
  46656. captureGPUFrameTime: boolean;
  46657. /**
  46658. * Gets the perf counter used for shader compilation time
  46659. */
  46660. readonly shaderCompilationTimeCounter: PerfCounter;
  46661. /**
  46662. * Gets the shader compilation time capture status
  46663. */
  46664. /**
  46665. * Enable or disable the shader compilation time capture
  46666. */
  46667. captureShaderCompilationTime: boolean;
  46668. /**
  46669. * Instantiates a new engine instrumentation.
  46670. * This class can be used to get instrumentation data from a Babylon engine
  46671. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46672. * @param engine Defines the engine to instrument
  46673. */
  46674. constructor(
  46675. /**
  46676. * Define the instrumented engine.
  46677. */
  46678. engine: Engine);
  46679. /**
  46680. * Dispose and release associated resources.
  46681. */
  46682. dispose(): void;
  46683. }
  46684. }
  46685. declare module BABYLON {
  46686. /**
  46687. * This class can be used to get instrumentation data from a Babylon engine
  46688. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46689. */
  46690. export class SceneInstrumentation implements IDisposable {
  46691. /**
  46692. * Defines the scene to instrument
  46693. */
  46694. scene: Scene;
  46695. private _captureActiveMeshesEvaluationTime;
  46696. private _activeMeshesEvaluationTime;
  46697. private _captureRenderTargetsRenderTime;
  46698. private _renderTargetsRenderTime;
  46699. private _captureFrameTime;
  46700. private _frameTime;
  46701. private _captureRenderTime;
  46702. private _renderTime;
  46703. private _captureInterFrameTime;
  46704. private _interFrameTime;
  46705. private _captureParticlesRenderTime;
  46706. private _particlesRenderTime;
  46707. private _captureSpritesRenderTime;
  46708. private _spritesRenderTime;
  46709. private _capturePhysicsTime;
  46710. private _physicsTime;
  46711. private _captureAnimationsTime;
  46712. private _animationsTime;
  46713. private _captureCameraRenderTime;
  46714. private _cameraRenderTime;
  46715. private _onBeforeActiveMeshesEvaluationObserver;
  46716. private _onAfterActiveMeshesEvaluationObserver;
  46717. private _onBeforeRenderTargetsRenderObserver;
  46718. private _onAfterRenderTargetsRenderObserver;
  46719. private _onAfterRenderObserver;
  46720. private _onBeforeDrawPhaseObserver;
  46721. private _onAfterDrawPhaseObserver;
  46722. private _onBeforeAnimationsObserver;
  46723. private _onBeforeParticlesRenderingObserver;
  46724. private _onAfterParticlesRenderingObserver;
  46725. private _onBeforeSpritesRenderingObserver;
  46726. private _onAfterSpritesRenderingObserver;
  46727. private _onBeforePhysicsObserver;
  46728. private _onAfterPhysicsObserver;
  46729. private _onAfterAnimationsObserver;
  46730. private _onBeforeCameraRenderObserver;
  46731. private _onAfterCameraRenderObserver;
  46732. /**
  46733. * Gets the perf counter used for active meshes evaluation time
  46734. */
  46735. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46736. /**
  46737. * Gets the active meshes evaluation time capture status
  46738. */
  46739. /**
  46740. * Enable or disable the active meshes evaluation time capture
  46741. */
  46742. captureActiveMeshesEvaluationTime: boolean;
  46743. /**
  46744. * Gets the perf counter used for render targets render time
  46745. */
  46746. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46747. /**
  46748. * Gets the render targets render time capture status
  46749. */
  46750. /**
  46751. * Enable or disable the render targets render time capture
  46752. */
  46753. captureRenderTargetsRenderTime: boolean;
  46754. /**
  46755. * Gets the perf counter used for particles render time
  46756. */
  46757. readonly particlesRenderTimeCounter: PerfCounter;
  46758. /**
  46759. * Gets the particles render time capture status
  46760. */
  46761. /**
  46762. * Enable or disable the particles render time capture
  46763. */
  46764. captureParticlesRenderTime: boolean;
  46765. /**
  46766. * Gets the perf counter used for sprites render time
  46767. */
  46768. readonly spritesRenderTimeCounter: PerfCounter;
  46769. /**
  46770. * Gets the sprites render time capture status
  46771. */
  46772. /**
  46773. * Enable or disable the sprites render time capture
  46774. */
  46775. captureSpritesRenderTime: boolean;
  46776. /**
  46777. * Gets the perf counter used for physics time
  46778. */
  46779. readonly physicsTimeCounter: PerfCounter;
  46780. /**
  46781. * Gets the physics time capture status
  46782. */
  46783. /**
  46784. * Enable or disable the physics time capture
  46785. */
  46786. capturePhysicsTime: boolean;
  46787. /**
  46788. * Gets the perf counter used for animations time
  46789. */
  46790. readonly animationsTimeCounter: PerfCounter;
  46791. /**
  46792. * Gets the animations time capture status
  46793. */
  46794. /**
  46795. * Enable or disable the animations time capture
  46796. */
  46797. captureAnimationsTime: boolean;
  46798. /**
  46799. * Gets the perf counter used for frame time capture
  46800. */
  46801. readonly frameTimeCounter: PerfCounter;
  46802. /**
  46803. * Gets the frame time capture status
  46804. */
  46805. /**
  46806. * Enable or disable the frame time capture
  46807. */
  46808. captureFrameTime: boolean;
  46809. /**
  46810. * Gets the perf counter used for inter-frames time capture
  46811. */
  46812. readonly interFrameTimeCounter: PerfCounter;
  46813. /**
  46814. * Gets the inter-frames time capture status
  46815. */
  46816. /**
  46817. * Enable or disable the inter-frames time capture
  46818. */
  46819. captureInterFrameTime: boolean;
  46820. /**
  46821. * Gets the perf counter used for render time capture
  46822. */
  46823. readonly renderTimeCounter: PerfCounter;
  46824. /**
  46825. * Gets the render time capture status
  46826. */
  46827. /**
  46828. * Enable or disable the render time capture
  46829. */
  46830. captureRenderTime: boolean;
  46831. /**
  46832. * Gets the perf counter used for camera render time capture
  46833. */
  46834. readonly cameraRenderTimeCounter: PerfCounter;
  46835. /**
  46836. * Gets the camera render time capture status
  46837. */
  46838. /**
  46839. * Enable or disable the camera render time capture
  46840. */
  46841. captureCameraRenderTime: boolean;
  46842. /**
  46843. * Gets the perf counter used for draw calls
  46844. */
  46845. readonly drawCallsCounter: PerfCounter;
  46846. /**
  46847. * Instantiates a new scene instrumentation.
  46848. * This class can be used to get instrumentation data from a Babylon engine
  46849. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46850. * @param scene Defines the scene to instrument
  46851. */
  46852. constructor(
  46853. /**
  46854. * Defines the scene to instrument
  46855. */
  46856. scene: Scene);
  46857. /**
  46858. * Dispose and release associated resources.
  46859. */
  46860. dispose(): void;
  46861. }
  46862. }
  46863. declare module BABYLON {
  46864. /** @hidden */
  46865. export var glowMapGenerationPixelShader: {
  46866. name: string;
  46867. shader: string;
  46868. };
  46869. }
  46870. declare module BABYLON {
  46871. /** @hidden */
  46872. export var glowMapGenerationVertexShader: {
  46873. name: string;
  46874. shader: string;
  46875. };
  46876. }
  46877. declare module BABYLON {
  46878. /**
  46879. * Effect layer options. This helps customizing the behaviour
  46880. * of the effect layer.
  46881. */
  46882. export interface IEffectLayerOptions {
  46883. /**
  46884. * Multiplication factor apply to the canvas size to compute the render target size
  46885. * used to generated the objects (the smaller the faster).
  46886. */
  46887. mainTextureRatio: number;
  46888. /**
  46889. * Enforces a fixed size texture to ensure effect stability across devices.
  46890. */
  46891. mainTextureFixedSize?: number;
  46892. /**
  46893. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46894. */
  46895. alphaBlendingMode: number;
  46896. /**
  46897. * The camera attached to the layer.
  46898. */
  46899. camera: Nullable<Camera>;
  46900. /**
  46901. * The rendering group to draw the layer in.
  46902. */
  46903. renderingGroupId: number;
  46904. }
  46905. /**
  46906. * The effect layer Helps adding post process effect blended with the main pass.
  46907. *
  46908. * This can be for instance use to generate glow or higlight effects on the scene.
  46909. *
  46910. * The effect layer class can not be used directly and is intented to inherited from to be
  46911. * customized per effects.
  46912. */
  46913. export abstract class EffectLayer {
  46914. private _vertexBuffers;
  46915. private _indexBuffer;
  46916. private _cachedDefines;
  46917. private _effectLayerMapGenerationEffect;
  46918. private _effectLayerOptions;
  46919. private _mergeEffect;
  46920. protected _scene: Scene;
  46921. protected _engine: Engine;
  46922. protected _maxSize: number;
  46923. protected _mainTextureDesiredSize: ISize;
  46924. protected _mainTexture: RenderTargetTexture;
  46925. protected _shouldRender: boolean;
  46926. protected _postProcesses: PostProcess[];
  46927. protected _textures: BaseTexture[];
  46928. protected _emissiveTextureAndColor: {
  46929. texture: Nullable<BaseTexture>;
  46930. color: Color4;
  46931. };
  46932. /**
  46933. * The name of the layer
  46934. */
  46935. name: string;
  46936. /**
  46937. * The clear color of the texture used to generate the glow map.
  46938. */
  46939. neutralColor: Color4;
  46940. /**
  46941. * Specifies wether the highlight layer is enabled or not.
  46942. */
  46943. isEnabled: boolean;
  46944. /**
  46945. * Gets the camera attached to the layer.
  46946. */
  46947. readonly camera: Nullable<Camera>;
  46948. /**
  46949. * Gets the rendering group id the layer should render in.
  46950. */
  46951. readonly renderingGroupId: number;
  46952. /**
  46953. * An event triggered when the effect layer has been disposed.
  46954. */
  46955. onDisposeObservable: Observable<EffectLayer>;
  46956. /**
  46957. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46958. */
  46959. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46960. /**
  46961. * An event triggered when the generated texture is being merged in the scene.
  46962. */
  46963. onBeforeComposeObservable: Observable<EffectLayer>;
  46964. /**
  46965. * An event triggered when the generated texture has been merged in the scene.
  46966. */
  46967. onAfterComposeObservable: Observable<EffectLayer>;
  46968. /**
  46969. * An event triggered when the efffect layer changes its size.
  46970. */
  46971. onSizeChangedObservable: Observable<EffectLayer>;
  46972. /** @hidden */
  46973. static _SceneComponentInitialization: (scene: Scene) => void;
  46974. /**
  46975. * Instantiates a new effect Layer and references it in the scene.
  46976. * @param name The name of the layer
  46977. * @param scene The scene to use the layer in
  46978. */
  46979. constructor(
  46980. /** The Friendly of the effect in the scene */
  46981. name: string, scene: Scene);
  46982. /**
  46983. * Get the effect name of the layer.
  46984. * @return The effect name
  46985. */
  46986. abstract getEffectName(): string;
  46987. /**
  46988. * Checks for the readiness of the element composing the layer.
  46989. * @param subMesh the mesh to check for
  46990. * @param useInstances specify wether or not to use instances to render the mesh
  46991. * @return true if ready otherwise, false
  46992. */
  46993. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46994. /**
  46995. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46996. * @returns true if the effect requires stencil during the main canvas render pass.
  46997. */
  46998. abstract needStencil(): boolean;
  46999. /**
  47000. * Create the merge effect. This is the shader use to blit the information back
  47001. * to the main canvas at the end of the scene rendering.
  47002. * @returns The effect containing the shader used to merge the effect on the main canvas
  47003. */
  47004. protected abstract _createMergeEffect(): Effect;
  47005. /**
  47006. * Creates the render target textures and post processes used in the effect layer.
  47007. */
  47008. protected abstract _createTextureAndPostProcesses(): void;
  47009. /**
  47010. * Implementation specific of rendering the generating effect on the main canvas.
  47011. * @param effect The effect used to render through
  47012. */
  47013. protected abstract _internalRender(effect: Effect): void;
  47014. /**
  47015. * Sets the required values for both the emissive texture and and the main color.
  47016. */
  47017. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47018. /**
  47019. * Free any resources and references associated to a mesh.
  47020. * Internal use
  47021. * @param mesh The mesh to free.
  47022. */
  47023. abstract _disposeMesh(mesh: Mesh): void;
  47024. /**
  47025. * Serializes this layer (Glow or Highlight for example)
  47026. * @returns a serialized layer object
  47027. */
  47028. abstract serialize?(): any;
  47029. /**
  47030. * Initializes the effect layer with the required options.
  47031. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47032. */
  47033. protected _init(options: Partial<IEffectLayerOptions>): void;
  47034. /**
  47035. * Generates the index buffer of the full screen quad blending to the main canvas.
  47036. */
  47037. private _generateIndexBuffer;
  47038. /**
  47039. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47040. */
  47041. private _generateVertexBuffer;
  47042. /**
  47043. * Sets the main texture desired size which is the closest power of two
  47044. * of the engine canvas size.
  47045. */
  47046. private _setMainTextureSize;
  47047. /**
  47048. * Creates the main texture for the effect layer.
  47049. */
  47050. protected _createMainTexture(): void;
  47051. /**
  47052. * Adds specific effects defines.
  47053. * @param defines The defines to add specifics to.
  47054. */
  47055. protected _addCustomEffectDefines(defines: string[]): void;
  47056. /**
  47057. * Checks for the readiness of the element composing the layer.
  47058. * @param subMesh the mesh to check for
  47059. * @param useInstances specify wether or not to use instances to render the mesh
  47060. * @param emissiveTexture the associated emissive texture used to generate the glow
  47061. * @return true if ready otherwise, false
  47062. */
  47063. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47064. /**
  47065. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47066. */
  47067. render(): void;
  47068. /**
  47069. * Determine if a given mesh will be used in the current effect.
  47070. * @param mesh mesh to test
  47071. * @returns true if the mesh will be used
  47072. */
  47073. hasMesh(mesh: AbstractMesh): boolean;
  47074. /**
  47075. * Returns true if the layer contains information to display, otherwise false.
  47076. * @returns true if the glow layer should be rendered
  47077. */
  47078. shouldRender(): boolean;
  47079. /**
  47080. * Returns true if the mesh should render, otherwise false.
  47081. * @param mesh The mesh to render
  47082. * @returns true if it should render otherwise false
  47083. */
  47084. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47085. /**
  47086. * Returns true if the mesh can be rendered, otherwise false.
  47087. * @param mesh The mesh to render
  47088. * @param material The material used on the mesh
  47089. * @returns true if it can be rendered otherwise false
  47090. */
  47091. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47092. /**
  47093. * Returns true if the mesh should render, otherwise false.
  47094. * @param mesh The mesh to render
  47095. * @returns true if it should render otherwise false
  47096. */
  47097. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47098. /**
  47099. * Renders the submesh passed in parameter to the generation map.
  47100. */
  47101. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  47102. /**
  47103. * Rebuild the required buffers.
  47104. * @hidden Internal use only.
  47105. */
  47106. _rebuild(): void;
  47107. /**
  47108. * Dispose only the render target textures and post process.
  47109. */
  47110. private _disposeTextureAndPostProcesses;
  47111. /**
  47112. * Dispose the highlight layer and free resources.
  47113. */
  47114. dispose(): void;
  47115. /**
  47116. * Gets the class name of the effect layer
  47117. * @returns the string with the class name of the effect layer
  47118. */
  47119. getClassName(): string;
  47120. /**
  47121. * Creates an effect layer from parsed effect layer data
  47122. * @param parsedEffectLayer defines effect layer data
  47123. * @param scene defines the current scene
  47124. * @param rootUrl defines the root URL containing the effect layer information
  47125. * @returns a parsed effect Layer
  47126. */
  47127. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47128. }
  47129. }
  47130. declare module BABYLON {
  47131. interface AbstractScene {
  47132. /**
  47133. * The list of effect layers (highlights/glow) added to the scene
  47134. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47135. * @see http://doc.babylonjs.com/how_to/glow_layer
  47136. */
  47137. effectLayers: Array<EffectLayer>;
  47138. /**
  47139. * Removes the given effect layer from this scene.
  47140. * @param toRemove defines the effect layer to remove
  47141. * @returns the index of the removed effect layer
  47142. */
  47143. removeEffectLayer(toRemove: EffectLayer): number;
  47144. /**
  47145. * Adds the given effect layer to this scene
  47146. * @param newEffectLayer defines the effect layer to add
  47147. */
  47148. addEffectLayer(newEffectLayer: EffectLayer): void;
  47149. }
  47150. /**
  47151. * Defines the layer scene component responsible to manage any effect layers
  47152. * in a given scene.
  47153. */
  47154. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47155. /**
  47156. * The component name helpfull to identify the component in the list of scene components.
  47157. */
  47158. readonly name: string;
  47159. /**
  47160. * The scene the component belongs to.
  47161. */
  47162. scene: Scene;
  47163. private _engine;
  47164. private _renderEffects;
  47165. private _needStencil;
  47166. private _previousStencilState;
  47167. /**
  47168. * Creates a new instance of the component for the given scene
  47169. * @param scene Defines the scene to register the component in
  47170. */
  47171. constructor(scene: Scene);
  47172. /**
  47173. * Registers the component in a given scene
  47174. */
  47175. register(): void;
  47176. /**
  47177. * Rebuilds the elements related to this component in case of
  47178. * context lost for instance.
  47179. */
  47180. rebuild(): void;
  47181. /**
  47182. * Serializes the component data to the specified json object
  47183. * @param serializationObject The object to serialize to
  47184. */
  47185. serialize(serializationObject: any): void;
  47186. /**
  47187. * Adds all the elements from the container to the scene
  47188. * @param container the container holding the elements
  47189. */
  47190. addFromContainer(container: AbstractScene): void;
  47191. /**
  47192. * Removes all the elements in the container from the scene
  47193. * @param container contains the elements to remove
  47194. * @param dispose if the removed element should be disposed (default: false)
  47195. */
  47196. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47197. /**
  47198. * Disposes the component and the associated ressources.
  47199. */
  47200. dispose(): void;
  47201. private _isReadyForMesh;
  47202. private _renderMainTexture;
  47203. private _setStencil;
  47204. private _setStencilBack;
  47205. private _draw;
  47206. private _drawCamera;
  47207. private _drawRenderingGroup;
  47208. }
  47209. }
  47210. declare module BABYLON {
  47211. /** @hidden */
  47212. export var glowMapMergePixelShader: {
  47213. name: string;
  47214. shader: string;
  47215. };
  47216. }
  47217. declare module BABYLON {
  47218. /** @hidden */
  47219. export var glowMapMergeVertexShader: {
  47220. name: string;
  47221. shader: string;
  47222. };
  47223. }
  47224. declare module BABYLON {
  47225. interface AbstractScene {
  47226. /**
  47227. * Return a the first highlight layer of the scene with a given name.
  47228. * @param name The name of the highlight layer to look for.
  47229. * @return The highlight layer if found otherwise null.
  47230. */
  47231. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47232. }
  47233. /**
  47234. * Glow layer options. This helps customizing the behaviour
  47235. * of the glow layer.
  47236. */
  47237. export interface IGlowLayerOptions {
  47238. /**
  47239. * Multiplication factor apply to the canvas size to compute the render target size
  47240. * used to generated the glowing objects (the smaller the faster).
  47241. */
  47242. mainTextureRatio: number;
  47243. /**
  47244. * Enforces a fixed size texture to ensure resize independant blur.
  47245. */
  47246. mainTextureFixedSize?: number;
  47247. /**
  47248. * How big is the kernel of the blur texture.
  47249. */
  47250. blurKernelSize: number;
  47251. /**
  47252. * The camera attached to the layer.
  47253. */
  47254. camera: Nullable<Camera>;
  47255. /**
  47256. * Enable MSAA by chosing the number of samples.
  47257. */
  47258. mainTextureSamples?: number;
  47259. /**
  47260. * The rendering group to draw the layer in.
  47261. */
  47262. renderingGroupId: number;
  47263. }
  47264. /**
  47265. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47266. *
  47267. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47268. * glowy meshes to your scene.
  47269. *
  47270. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47271. */
  47272. export class GlowLayer extends EffectLayer {
  47273. /**
  47274. * Effect Name of the layer.
  47275. */
  47276. static readonly EffectName: string;
  47277. /**
  47278. * The default blur kernel size used for the glow.
  47279. */
  47280. static DefaultBlurKernelSize: number;
  47281. /**
  47282. * The default texture size ratio used for the glow.
  47283. */
  47284. static DefaultTextureRatio: number;
  47285. /**
  47286. * Sets the kernel size of the blur.
  47287. */
  47288. /**
  47289. * Gets the kernel size of the blur.
  47290. */
  47291. blurKernelSize: number;
  47292. /**
  47293. * Sets the glow intensity.
  47294. */
  47295. /**
  47296. * Gets the glow intensity.
  47297. */
  47298. intensity: number;
  47299. private _options;
  47300. private _intensity;
  47301. private _horizontalBlurPostprocess1;
  47302. private _verticalBlurPostprocess1;
  47303. private _horizontalBlurPostprocess2;
  47304. private _verticalBlurPostprocess2;
  47305. private _blurTexture1;
  47306. private _blurTexture2;
  47307. private _postProcesses1;
  47308. private _postProcesses2;
  47309. private _includedOnlyMeshes;
  47310. private _excludedMeshes;
  47311. /**
  47312. * Callback used to let the user override the color selection on a per mesh basis
  47313. */
  47314. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47315. /**
  47316. * Callback used to let the user override the texture selection on a per mesh basis
  47317. */
  47318. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47319. /**
  47320. * Instantiates a new glow Layer and references it to the scene.
  47321. * @param name The name of the layer
  47322. * @param scene The scene to use the layer in
  47323. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47324. */
  47325. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47326. /**
  47327. * Get the effect name of the layer.
  47328. * @return The effect name
  47329. */
  47330. getEffectName(): string;
  47331. /**
  47332. * Create the merge effect. This is the shader use to blit the information back
  47333. * to the main canvas at the end of the scene rendering.
  47334. */
  47335. protected _createMergeEffect(): Effect;
  47336. /**
  47337. * Creates the render target textures and post processes used in the glow layer.
  47338. */
  47339. protected _createTextureAndPostProcesses(): void;
  47340. /**
  47341. * Checks for the readiness of the element composing the layer.
  47342. * @param subMesh the mesh to check for
  47343. * @param useInstances specify wether or not to use instances to render the mesh
  47344. * @param emissiveTexture the associated emissive texture used to generate the glow
  47345. * @return true if ready otherwise, false
  47346. */
  47347. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47348. /**
  47349. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47350. */
  47351. needStencil(): boolean;
  47352. /**
  47353. * Returns true if the mesh can be rendered, otherwise false.
  47354. * @param mesh The mesh to render
  47355. * @param material The material used on the mesh
  47356. * @returns true if it can be rendered otherwise false
  47357. */
  47358. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47359. /**
  47360. * Implementation specific of rendering the generating effect on the main canvas.
  47361. * @param effect The effect used to render through
  47362. */
  47363. protected _internalRender(effect: Effect): void;
  47364. /**
  47365. * Sets the required values for both the emissive texture and and the main color.
  47366. */
  47367. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47368. /**
  47369. * Returns true if the mesh should render, otherwise false.
  47370. * @param mesh The mesh to render
  47371. * @returns true if it should render otherwise false
  47372. */
  47373. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47374. /**
  47375. * Adds specific effects defines.
  47376. * @param defines The defines to add specifics to.
  47377. */
  47378. protected _addCustomEffectDefines(defines: string[]): void;
  47379. /**
  47380. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47381. * @param mesh The mesh to exclude from the glow layer
  47382. */
  47383. addExcludedMesh(mesh: Mesh): void;
  47384. /**
  47385. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47386. * @param mesh The mesh to remove
  47387. */
  47388. removeExcludedMesh(mesh: Mesh): void;
  47389. /**
  47390. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47391. * @param mesh The mesh to include in the glow layer
  47392. */
  47393. addIncludedOnlyMesh(mesh: Mesh): void;
  47394. /**
  47395. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47396. * @param mesh The mesh to remove
  47397. */
  47398. removeIncludedOnlyMesh(mesh: Mesh): void;
  47399. /**
  47400. * Determine if a given mesh will be used in the glow layer
  47401. * @param mesh The mesh to test
  47402. * @returns true if the mesh will be highlighted by the current glow layer
  47403. */
  47404. hasMesh(mesh: AbstractMesh): boolean;
  47405. /**
  47406. * Free any resources and references associated to a mesh.
  47407. * Internal use
  47408. * @param mesh The mesh to free.
  47409. * @hidden
  47410. */
  47411. _disposeMesh(mesh: Mesh): void;
  47412. /**
  47413. * Gets the class name of the effect layer
  47414. * @returns the string with the class name of the effect layer
  47415. */
  47416. getClassName(): string;
  47417. /**
  47418. * Serializes this glow layer
  47419. * @returns a serialized glow layer object
  47420. */
  47421. serialize(): any;
  47422. /**
  47423. * Creates a Glow Layer from parsed glow layer data
  47424. * @param parsedGlowLayer defines glow layer data
  47425. * @param scene defines the current scene
  47426. * @param rootUrl defines the root URL containing the glow layer information
  47427. * @returns a parsed Glow Layer
  47428. */
  47429. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47430. }
  47431. }
  47432. declare module BABYLON {
  47433. /** @hidden */
  47434. export var glowBlurPostProcessPixelShader: {
  47435. name: string;
  47436. shader: string;
  47437. };
  47438. }
  47439. declare module BABYLON {
  47440. interface AbstractScene {
  47441. /**
  47442. * Return a the first highlight layer of the scene with a given name.
  47443. * @param name The name of the highlight layer to look for.
  47444. * @return The highlight layer if found otherwise null.
  47445. */
  47446. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47447. }
  47448. /**
  47449. * Highlight layer options. This helps customizing the behaviour
  47450. * of the highlight layer.
  47451. */
  47452. export interface IHighlightLayerOptions {
  47453. /**
  47454. * Multiplication factor apply to the canvas size to compute the render target size
  47455. * used to generated the glowing objects (the smaller the faster).
  47456. */
  47457. mainTextureRatio: number;
  47458. /**
  47459. * Enforces a fixed size texture to ensure resize independant blur.
  47460. */
  47461. mainTextureFixedSize?: number;
  47462. /**
  47463. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47464. * of the picture to blur (the smaller the faster).
  47465. */
  47466. blurTextureSizeRatio: number;
  47467. /**
  47468. * How big in texel of the blur texture is the vertical blur.
  47469. */
  47470. blurVerticalSize: number;
  47471. /**
  47472. * How big in texel of the blur texture is the horizontal blur.
  47473. */
  47474. blurHorizontalSize: number;
  47475. /**
  47476. * Alpha blending mode used to apply the blur. Default is combine.
  47477. */
  47478. alphaBlendingMode: number;
  47479. /**
  47480. * The camera attached to the layer.
  47481. */
  47482. camera: Nullable<Camera>;
  47483. /**
  47484. * Should we display highlight as a solid stroke?
  47485. */
  47486. isStroke?: boolean;
  47487. /**
  47488. * The rendering group to draw the layer in.
  47489. */
  47490. renderingGroupId: number;
  47491. }
  47492. /**
  47493. * The highlight layer Helps adding a glow effect around a mesh.
  47494. *
  47495. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47496. * glowy meshes to your scene.
  47497. *
  47498. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47499. */
  47500. export class HighlightLayer extends EffectLayer {
  47501. name: string;
  47502. /**
  47503. * Effect Name of the highlight layer.
  47504. */
  47505. static readonly EffectName: string;
  47506. /**
  47507. * The neutral color used during the preparation of the glow effect.
  47508. * This is black by default as the blend operation is a blend operation.
  47509. */
  47510. static NeutralColor: Color4;
  47511. /**
  47512. * Stencil value used for glowing meshes.
  47513. */
  47514. static GlowingMeshStencilReference: number;
  47515. /**
  47516. * Stencil value used for the other meshes in the scene.
  47517. */
  47518. static NormalMeshStencilReference: number;
  47519. /**
  47520. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47521. */
  47522. innerGlow: boolean;
  47523. /**
  47524. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47525. */
  47526. outerGlow: boolean;
  47527. /**
  47528. * Specifies the horizontal size of the blur.
  47529. */
  47530. /**
  47531. * Gets the horizontal size of the blur.
  47532. */
  47533. blurHorizontalSize: number;
  47534. /**
  47535. * Specifies the vertical size of the blur.
  47536. */
  47537. /**
  47538. * Gets the vertical size of the blur.
  47539. */
  47540. blurVerticalSize: number;
  47541. /**
  47542. * An event triggered when the highlight layer is being blurred.
  47543. */
  47544. onBeforeBlurObservable: Observable<HighlightLayer>;
  47545. /**
  47546. * An event triggered when the highlight layer has been blurred.
  47547. */
  47548. onAfterBlurObservable: Observable<HighlightLayer>;
  47549. private _instanceGlowingMeshStencilReference;
  47550. private _options;
  47551. private _downSamplePostprocess;
  47552. private _horizontalBlurPostprocess;
  47553. private _verticalBlurPostprocess;
  47554. private _blurTexture;
  47555. private _meshes;
  47556. private _excludedMeshes;
  47557. /**
  47558. * Instantiates a new highlight Layer and references it to the scene..
  47559. * @param name The name of the layer
  47560. * @param scene The scene to use the layer in
  47561. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47562. */
  47563. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47564. /**
  47565. * Get the effect name of the layer.
  47566. * @return The effect name
  47567. */
  47568. getEffectName(): string;
  47569. /**
  47570. * Create the merge effect. This is the shader use to blit the information back
  47571. * to the main canvas at the end of the scene rendering.
  47572. */
  47573. protected _createMergeEffect(): Effect;
  47574. /**
  47575. * Creates the render target textures and post processes used in the highlight layer.
  47576. */
  47577. protected _createTextureAndPostProcesses(): void;
  47578. /**
  47579. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47580. */
  47581. needStencil(): boolean;
  47582. /**
  47583. * Checks for the readiness of the element composing the layer.
  47584. * @param subMesh the mesh to check for
  47585. * @param useInstances specify wether or not to use instances to render the mesh
  47586. * @param emissiveTexture the associated emissive texture used to generate the glow
  47587. * @return true if ready otherwise, false
  47588. */
  47589. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  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 _internalRender(effect: Effect): void;
  47595. /**
  47596. * Returns true if the layer contains information to display, otherwise false.
  47597. */
  47598. shouldRender(): boolean;
  47599. /**
  47600. * Returns true if the mesh should render, otherwise false.
  47601. * @param mesh The mesh to render
  47602. * @returns true if it should render otherwise false
  47603. */
  47604. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47605. /**
  47606. * Sets the required values for both the emissive texture and and the main color.
  47607. */
  47608. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47609. /**
  47610. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47611. * @param mesh The mesh to exclude from the highlight layer
  47612. */
  47613. addExcludedMesh(mesh: Mesh): void;
  47614. /**
  47615. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47616. * @param mesh The mesh to highlight
  47617. */
  47618. removeExcludedMesh(mesh: Mesh): void;
  47619. /**
  47620. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47621. * @param mesh mesh to test
  47622. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47623. */
  47624. hasMesh(mesh: AbstractMesh): boolean;
  47625. /**
  47626. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47627. * @param mesh The mesh to highlight
  47628. * @param color The color of the highlight
  47629. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47630. */
  47631. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47632. /**
  47633. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47634. * @param mesh The mesh to highlight
  47635. */
  47636. removeMesh(mesh: Mesh): void;
  47637. /**
  47638. * Force the stencil to the normal expected value for none glowing parts
  47639. */
  47640. private _defaultStencilReference;
  47641. /**
  47642. * Free any resources and references associated to a mesh.
  47643. * Internal use
  47644. * @param mesh The mesh to free.
  47645. * @hidden
  47646. */
  47647. _disposeMesh(mesh: Mesh): void;
  47648. /**
  47649. * Dispose the highlight layer and free resources.
  47650. */
  47651. dispose(): void;
  47652. /**
  47653. * Gets the class name of the effect layer
  47654. * @returns the string with the class name of the effect layer
  47655. */
  47656. getClassName(): string;
  47657. /**
  47658. * Serializes this Highlight layer
  47659. * @returns a serialized Highlight layer object
  47660. */
  47661. serialize(): any;
  47662. /**
  47663. * Creates a Highlight layer from parsed Highlight layer data
  47664. * @param parsedHightlightLayer defines the Highlight layer data
  47665. * @param scene defines the current scene
  47666. * @param rootUrl defines the root URL containing the Highlight layer information
  47667. * @returns a parsed Highlight layer
  47668. */
  47669. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47670. }
  47671. }
  47672. declare module BABYLON {
  47673. interface AbstractScene {
  47674. /**
  47675. * The list of layers (background and foreground) of the scene
  47676. */
  47677. layers: Array<Layer>;
  47678. }
  47679. /**
  47680. * Defines the layer scene component responsible to manage any layers
  47681. * in a given scene.
  47682. */
  47683. export class LayerSceneComponent implements ISceneComponent {
  47684. /**
  47685. * The component name helpfull to identify the component in the list of scene components.
  47686. */
  47687. readonly name: string;
  47688. /**
  47689. * The scene the component belongs to.
  47690. */
  47691. scene: Scene;
  47692. private _engine;
  47693. /**
  47694. * Creates a new instance of the component for the given scene
  47695. * @param scene Defines the scene to register the component in
  47696. */
  47697. constructor(scene: Scene);
  47698. /**
  47699. * Registers the component in a given scene
  47700. */
  47701. register(): void;
  47702. /**
  47703. * Rebuilds the elements related to this component in case of
  47704. * context lost for instance.
  47705. */
  47706. rebuild(): void;
  47707. /**
  47708. * Disposes the component and the associated ressources.
  47709. */
  47710. dispose(): void;
  47711. private _draw;
  47712. private _drawCameraPredicate;
  47713. private _drawCameraBackground;
  47714. private _drawCameraForeground;
  47715. private _drawRenderTargetPredicate;
  47716. private _drawRenderTargetBackground;
  47717. private _drawRenderTargetForeground;
  47718. /**
  47719. * Adds all the elements from the container to the scene
  47720. * @param container the container holding the elements
  47721. */
  47722. addFromContainer(container: AbstractScene): void;
  47723. /**
  47724. * Removes all the elements in the container from the scene
  47725. * @param container contains the elements to remove
  47726. * @param dispose if the removed element should be disposed (default: false)
  47727. */
  47728. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47729. }
  47730. }
  47731. declare module BABYLON {
  47732. /** @hidden */
  47733. export var layerPixelShader: {
  47734. name: string;
  47735. shader: string;
  47736. };
  47737. }
  47738. declare module BABYLON {
  47739. /** @hidden */
  47740. export var layerVertexShader: {
  47741. name: string;
  47742. shader: string;
  47743. };
  47744. }
  47745. declare module BABYLON {
  47746. /**
  47747. * This represents a full screen 2d layer.
  47748. * This can be useful to display a picture in the background of your scene for instance.
  47749. * @see https://www.babylonjs-playground.com/#08A2BS#1
  47750. */
  47751. export class Layer {
  47752. /**
  47753. * Define the name of the layer.
  47754. */
  47755. name: string;
  47756. /**
  47757. * Define the texture the layer should display.
  47758. */
  47759. texture: Nullable<Texture>;
  47760. /**
  47761. * Is the layer in background or foreground.
  47762. */
  47763. isBackground: boolean;
  47764. /**
  47765. * Define the color of the layer (instead of texture).
  47766. */
  47767. color: Color4;
  47768. /**
  47769. * Define the scale of the layer in order to zoom in out of the texture.
  47770. */
  47771. scale: Vector2;
  47772. /**
  47773. * Define an offset for the layer in order to shift the texture.
  47774. */
  47775. offset: Vector2;
  47776. /**
  47777. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  47778. */
  47779. alphaBlendingMode: number;
  47780. /**
  47781. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  47782. * Alpha test will not mix with the background color in case of transparency.
  47783. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  47784. */
  47785. alphaTest: boolean;
  47786. /**
  47787. * Define a mask to restrict the layer to only some of the scene cameras.
  47788. */
  47789. layerMask: number;
  47790. /**
  47791. * Define the list of render target the layer is visible into.
  47792. */
  47793. renderTargetTextures: RenderTargetTexture[];
  47794. /**
  47795. * Define if the layer is only used in renderTarget or if it also
  47796. * renders in the main frame buffer of the canvas.
  47797. */
  47798. renderOnlyInRenderTargetTextures: boolean;
  47799. private _scene;
  47800. private _vertexBuffers;
  47801. private _indexBuffer;
  47802. private _effect;
  47803. private _alphaTestEffect;
  47804. /**
  47805. * An event triggered when the layer is disposed.
  47806. */
  47807. onDisposeObservable: Observable<Layer>;
  47808. private _onDisposeObserver;
  47809. /**
  47810. * Back compatibility with callback before the onDisposeObservable existed.
  47811. * The set callback will be triggered when the layer has been disposed.
  47812. */
  47813. onDispose: () => void;
  47814. /**
  47815. * An event triggered before rendering the scene
  47816. */
  47817. onBeforeRenderObservable: Observable<Layer>;
  47818. private _onBeforeRenderObserver;
  47819. /**
  47820. * Back compatibility with callback before the onBeforeRenderObservable existed.
  47821. * The set callback will be triggered just before rendering the layer.
  47822. */
  47823. onBeforeRender: () => void;
  47824. /**
  47825. * An event triggered after rendering the scene
  47826. */
  47827. onAfterRenderObservable: Observable<Layer>;
  47828. private _onAfterRenderObserver;
  47829. /**
  47830. * Back compatibility with callback before the onAfterRenderObservable existed.
  47831. * The set callback will be triggered just after rendering the layer.
  47832. */
  47833. onAfterRender: () => void;
  47834. /**
  47835. * Instantiates a new layer.
  47836. * This represents a full screen 2d layer.
  47837. * This can be useful to display a picture in the background of your scene for instance.
  47838. * @see https://www.babylonjs-playground.com/#08A2BS#1
  47839. * @param name Define the name of the layer in the scene
  47840. * @param imgUrl Define the url of the texture to display in the layer
  47841. * @param scene Define the scene the layer belongs to
  47842. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  47843. * @param color Defines a color for the layer
  47844. */
  47845. constructor(
  47846. /**
  47847. * Define the name of the layer.
  47848. */
  47849. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  47850. private _createIndexBuffer;
  47851. /** @hidden */
  47852. _rebuild(): void;
  47853. /**
  47854. * Renders the layer in the scene.
  47855. */
  47856. render(): void;
  47857. /**
  47858. * Disposes and releases the associated ressources.
  47859. */
  47860. dispose(): void;
  47861. }
  47862. }
  47863. declare module BABYLON {
  47864. /** @hidden */
  47865. export var lensFlarePixelShader: {
  47866. name: string;
  47867. shader: string;
  47868. };
  47869. }
  47870. declare module BABYLON {
  47871. /** @hidden */
  47872. export var lensFlareVertexShader: {
  47873. name: string;
  47874. shader: string;
  47875. };
  47876. }
  47877. declare module BABYLON {
  47878. /**
  47879. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47880. * It is usually composed of several `lensFlare`.
  47881. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47882. */
  47883. export class LensFlareSystem {
  47884. /**
  47885. * Define the name of the lens flare system
  47886. */
  47887. name: string;
  47888. /**
  47889. * List of lens flares used in this system.
  47890. */
  47891. lensFlares: LensFlare[];
  47892. /**
  47893. * Define a limit from the border the lens flare can be visible.
  47894. */
  47895. borderLimit: number;
  47896. /**
  47897. * Define a viewport border we do not want to see the lens flare in.
  47898. */
  47899. viewportBorder: number;
  47900. /**
  47901. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47902. */
  47903. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47904. /**
  47905. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47906. */
  47907. layerMask: number;
  47908. /**
  47909. * Define the id of the lens flare system in the scene.
  47910. * (equal to name by default)
  47911. */
  47912. id: string;
  47913. private _scene;
  47914. private _emitter;
  47915. private _vertexBuffers;
  47916. private _indexBuffer;
  47917. private _effect;
  47918. private _positionX;
  47919. private _positionY;
  47920. private _isEnabled;
  47921. /** @hidden */
  47922. static _SceneComponentInitialization: (scene: Scene) => void;
  47923. /**
  47924. * Instantiates a lens flare system.
  47925. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47926. * It is usually composed of several `lensFlare`.
  47927. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47928. * @param name Define the name of the lens flare system in the scene
  47929. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47930. * @param scene Define the scene the lens flare system belongs to
  47931. */
  47932. constructor(
  47933. /**
  47934. * Define the name of the lens flare system
  47935. */
  47936. name: string, emitter: any, scene: Scene);
  47937. /**
  47938. * Define if the lens flare system is enabled.
  47939. */
  47940. isEnabled: boolean;
  47941. /**
  47942. * Get the scene the effects belongs to.
  47943. * @returns the scene holding the lens flare system
  47944. */
  47945. getScene(): Scene;
  47946. /**
  47947. * Get the emitter of the lens flare system.
  47948. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47949. * @returns the emitter of the lens flare system
  47950. */
  47951. getEmitter(): any;
  47952. /**
  47953. * Set the emitter of the lens flare system.
  47954. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47955. * @param newEmitter Define the new emitter of the system
  47956. */
  47957. setEmitter(newEmitter: any): void;
  47958. /**
  47959. * Get the lens flare system emitter position.
  47960. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47961. * @returns the position
  47962. */
  47963. getEmitterPosition(): Vector3;
  47964. /**
  47965. * @hidden
  47966. */
  47967. computeEffectivePosition(globalViewport: Viewport): boolean;
  47968. /** @hidden */
  47969. _isVisible(): boolean;
  47970. /**
  47971. * @hidden
  47972. */
  47973. render(): boolean;
  47974. /**
  47975. * Dispose and release the lens flare with its associated resources.
  47976. */
  47977. dispose(): void;
  47978. /**
  47979. * Parse a lens flare system from a JSON repressentation
  47980. * @param parsedLensFlareSystem Define the JSON to parse
  47981. * @param scene Define the scene the parsed system should be instantiated in
  47982. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47983. * @returns the parsed system
  47984. */
  47985. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47986. /**
  47987. * Serialize the current Lens Flare System into a JSON representation.
  47988. * @returns the serialized JSON
  47989. */
  47990. serialize(): any;
  47991. }
  47992. }
  47993. declare module BABYLON {
  47994. /**
  47995. * This represents one of the lens effect in a `lensFlareSystem`.
  47996. * It controls one of the indiviual texture used in the effect.
  47997. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47998. */
  47999. export class LensFlare {
  48000. /**
  48001. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48002. */
  48003. size: number;
  48004. /**
  48005. * 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.
  48006. */
  48007. position: number;
  48008. /**
  48009. * Define the lens color.
  48010. */
  48011. color: Color3;
  48012. /**
  48013. * Define the lens texture.
  48014. */
  48015. texture: Nullable<Texture>;
  48016. /**
  48017. * Define the alpha mode to render this particular lens.
  48018. */
  48019. alphaMode: number;
  48020. private _system;
  48021. /**
  48022. * Creates a new Lens Flare.
  48023. * This represents one of the lens effect in a `lensFlareSystem`.
  48024. * It controls one of the indiviual texture used in the effect.
  48025. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48026. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  48027. * @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.
  48028. * @param color Define the lens color
  48029. * @param imgUrl Define the lens texture url
  48030. * @param system Define the `lensFlareSystem` this flare is part of
  48031. * @returns The newly created Lens Flare
  48032. */
  48033. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  48034. /**
  48035. * Instantiates a new Lens Flare.
  48036. * This represents one of the lens effect in a `lensFlareSystem`.
  48037. * It controls one of the indiviual texture used in the effect.
  48038. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48039. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  48040. * @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.
  48041. * @param color Define the lens color
  48042. * @param imgUrl Define the lens texture url
  48043. * @param system Define the `lensFlareSystem` this flare is part of
  48044. */
  48045. constructor(
  48046. /**
  48047. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48048. */
  48049. size: number,
  48050. /**
  48051. * 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.
  48052. */
  48053. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  48054. /**
  48055. * Dispose and release the lens flare with its associated resources.
  48056. */
  48057. dispose(): void;
  48058. }
  48059. }
  48060. declare module BABYLON {
  48061. interface AbstractScene {
  48062. /**
  48063. * The list of lens flare system added to the scene
  48064. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48065. */
  48066. lensFlareSystems: Array<LensFlareSystem>;
  48067. /**
  48068. * Removes the given lens flare system from this scene.
  48069. * @param toRemove The lens flare system to remove
  48070. * @returns The index of the removed lens flare system
  48071. */
  48072. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  48073. /**
  48074. * Adds the given lens flare system to this scene
  48075. * @param newLensFlareSystem The lens flare system to add
  48076. */
  48077. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  48078. /**
  48079. * Gets a lens flare system using its name
  48080. * @param name defines the name to look for
  48081. * @returns the lens flare system or null if not found
  48082. */
  48083. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  48084. /**
  48085. * Gets a lens flare system using its id
  48086. * @param id defines the id to look for
  48087. * @returns the lens flare system or null if not found
  48088. */
  48089. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  48090. }
  48091. /**
  48092. * Defines the lens flare scene component responsible to manage any lens flares
  48093. * in a given scene.
  48094. */
  48095. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48096. /**
  48097. * The component name helpfull to identify the component in the list of scene components.
  48098. */
  48099. readonly name: string;
  48100. /**
  48101. * The scene the component belongs to.
  48102. */
  48103. scene: Scene;
  48104. /**
  48105. * Creates a new instance of the component for the given scene
  48106. * @param scene Defines the scene to register the component in
  48107. */
  48108. constructor(scene: Scene);
  48109. /**
  48110. * Registers the component in a given scene
  48111. */
  48112. register(): void;
  48113. /**
  48114. * Rebuilds the elements related to this component in case of
  48115. * context lost for instance.
  48116. */
  48117. rebuild(): void;
  48118. /**
  48119. * Adds all the elements from the container to the scene
  48120. * @param container the container holding the elements
  48121. */
  48122. addFromContainer(container: AbstractScene): void;
  48123. /**
  48124. * Removes all the elements in the container from the scene
  48125. * @param container contains the elements to remove
  48126. * @param dispose if the removed element should be disposed (default: false)
  48127. */
  48128. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48129. /**
  48130. * Serializes the component data to the specified json object
  48131. * @param serializationObject The object to serialize to
  48132. */
  48133. serialize(serializationObject: any): void;
  48134. /**
  48135. * Disposes the component and the associated ressources.
  48136. */
  48137. dispose(): void;
  48138. private _draw;
  48139. }
  48140. }
  48141. declare module BABYLON {
  48142. /**
  48143. * Defines the shadow generator component responsible to manage any shadow generators
  48144. * in a given scene.
  48145. */
  48146. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48147. /**
  48148. * The component name helpfull to identify the component in the list of scene components.
  48149. */
  48150. readonly name: string;
  48151. /**
  48152. * The scene the component belongs to.
  48153. */
  48154. scene: Scene;
  48155. /**
  48156. * Creates a new instance of the component for the given scene
  48157. * @param scene Defines the scene to register the component in
  48158. */
  48159. constructor(scene: Scene);
  48160. /**
  48161. * Registers the component in a given scene
  48162. */
  48163. register(): void;
  48164. /**
  48165. * Rebuilds the elements related to this component in case of
  48166. * context lost for instance.
  48167. */
  48168. rebuild(): void;
  48169. /**
  48170. * Serializes the component data to the specified json object
  48171. * @param serializationObject The object to serialize to
  48172. */
  48173. serialize(serializationObject: any): void;
  48174. /**
  48175. * Adds all the elements from the container to the scene
  48176. * @param container the container holding the elements
  48177. */
  48178. addFromContainer(container: AbstractScene): void;
  48179. /**
  48180. * Removes all the elements in the container from the scene
  48181. * @param container contains the elements to remove
  48182. * @param dispose if the removed element should be disposed (default: false)
  48183. */
  48184. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48185. /**
  48186. * Rebuilds the elements related to this component in case of
  48187. * context lost for instance.
  48188. */
  48189. dispose(): void;
  48190. private _gatherRenderTargets;
  48191. }
  48192. }
  48193. declare module BABYLON {
  48194. /**
  48195. * A point light is a light defined by an unique point in world space.
  48196. * The light is emitted in every direction from this point.
  48197. * A good example of a point light is a standard light bulb.
  48198. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48199. */
  48200. export class PointLight extends ShadowLight {
  48201. private _shadowAngle;
  48202. /**
  48203. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48204. * This specifies what angle the shadow will use to be created.
  48205. *
  48206. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48207. */
  48208. /**
  48209. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48210. * This specifies what angle the shadow will use to be created.
  48211. *
  48212. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48213. */
  48214. shadowAngle: number;
  48215. /**
  48216. * Gets the direction if it has been set.
  48217. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48218. */
  48219. /**
  48220. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48221. */
  48222. direction: Vector3;
  48223. /**
  48224. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48225. * A PointLight emits the light in every direction.
  48226. * It can cast shadows.
  48227. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48228. * ```javascript
  48229. * var pointLight = new PointLight("pl", camera.position, scene);
  48230. * ```
  48231. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48232. * @param name The light friendly name
  48233. * @param position The position of the point light in the scene
  48234. * @param scene The scene the lights belongs to
  48235. */
  48236. constructor(name: string, position: Vector3, scene: Scene);
  48237. /**
  48238. * Returns the string "PointLight"
  48239. * @returns the class name
  48240. */
  48241. getClassName(): string;
  48242. /**
  48243. * Returns the integer 0.
  48244. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48245. */
  48246. getTypeID(): number;
  48247. /**
  48248. * Specifies wether or not the shadowmap should be a cube texture.
  48249. * @returns true if the shadowmap needs to be a cube texture.
  48250. */
  48251. needCube(): boolean;
  48252. /**
  48253. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48254. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48255. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48256. */
  48257. getShadowDirection(faceIndex?: number): Vector3;
  48258. /**
  48259. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48260. * - fov = PI / 2
  48261. * - aspect ratio : 1.0
  48262. * - z-near and far equal to the active camera minZ and maxZ.
  48263. * Returns the PointLight.
  48264. */
  48265. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48266. protected _buildUniformLayout(): void;
  48267. /**
  48268. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48269. * @param effect The effect to update
  48270. * @param lightIndex The index of the light in the effect to update
  48271. * @returns The point light
  48272. */
  48273. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48274. /**
  48275. * Prepares the list of defines specific to the light type.
  48276. * @param defines the list of defines
  48277. * @param lightIndex defines the index of the light for the effect
  48278. */
  48279. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48280. }
  48281. }
  48282. declare module BABYLON {
  48283. /**
  48284. * Header information of HDR texture files.
  48285. */
  48286. export interface HDRInfo {
  48287. /**
  48288. * The height of the texture in pixels.
  48289. */
  48290. height: number;
  48291. /**
  48292. * The width of the texture in pixels.
  48293. */
  48294. width: number;
  48295. /**
  48296. * The index of the beginning of the data in the binary file.
  48297. */
  48298. dataPosition: number;
  48299. }
  48300. /**
  48301. * This groups tools to convert HDR texture to native colors array.
  48302. */
  48303. export class HDRTools {
  48304. private static Ldexp;
  48305. private static Rgbe2float;
  48306. private static readStringLine;
  48307. /**
  48308. * Reads header information from an RGBE texture stored in a native array.
  48309. * More information on this format are available here:
  48310. * https://en.wikipedia.org/wiki/RGBE_image_format
  48311. *
  48312. * @param uint8array The binary file stored in native array.
  48313. * @return The header information.
  48314. */
  48315. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48316. /**
  48317. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48318. * This RGBE texture needs to store the information as a panorama.
  48319. *
  48320. * More information on this format are available here:
  48321. * https://en.wikipedia.org/wiki/RGBE_image_format
  48322. *
  48323. * @param buffer The binary file stored in an array buffer.
  48324. * @param size The expected size of the extracted cubemap.
  48325. * @return The Cube Map information.
  48326. */
  48327. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48328. /**
  48329. * Returns the pixels data extracted from an RGBE texture.
  48330. * This pixels will be stored left to right up to down in the R G B order in one array.
  48331. *
  48332. * More information on this format are available here:
  48333. * https://en.wikipedia.org/wiki/RGBE_image_format
  48334. *
  48335. * @param uint8array The binary file stored in an array buffer.
  48336. * @param hdrInfo The header information of the file.
  48337. * @return The pixels data in RGB right to left up to down order.
  48338. */
  48339. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48340. private static RGBE_ReadPixels_RLE;
  48341. }
  48342. }
  48343. declare module BABYLON {
  48344. /**
  48345. * This represents a texture coming from an HDR input.
  48346. *
  48347. * The only supported format is currently panorama picture stored in RGBE format.
  48348. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48349. */
  48350. export class HDRCubeTexture extends BaseTexture {
  48351. private static _facesMapping;
  48352. private _generateHarmonics;
  48353. private _noMipmap;
  48354. private _textureMatrix;
  48355. private _size;
  48356. private _onLoad;
  48357. private _onError;
  48358. /**
  48359. * The texture URL.
  48360. */
  48361. url: string;
  48362. /**
  48363. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48364. */
  48365. coordinatesMode: number;
  48366. protected _isBlocking: boolean;
  48367. /**
  48368. * Sets wether or not the texture is blocking during loading.
  48369. */
  48370. /**
  48371. * Gets wether or not the texture is blocking during loading.
  48372. */
  48373. isBlocking: boolean;
  48374. protected _rotationY: number;
  48375. /**
  48376. * Sets texture matrix rotation angle around Y axis in radians.
  48377. */
  48378. /**
  48379. * Gets texture matrix rotation angle around Y axis radians.
  48380. */
  48381. rotationY: number;
  48382. /**
  48383. * Gets or sets the center of the bounding box associated with the cube texture
  48384. * It must define where the camera used to render the texture was set
  48385. */
  48386. boundingBoxPosition: Vector3;
  48387. private _boundingBoxSize;
  48388. /**
  48389. * Gets or sets the size of the bounding box associated with the cube texture
  48390. * When defined, the cubemap will switch to local mode
  48391. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48392. * @example https://www.babylonjs-playground.com/#RNASML
  48393. */
  48394. boundingBoxSize: Vector3;
  48395. /**
  48396. * Instantiates an HDRTexture from the following parameters.
  48397. *
  48398. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48399. * @param scene The scene the texture will be used in
  48400. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48401. * @param noMipmap Forces to not generate the mipmap if true
  48402. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48403. * @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)
  48404. * @param reserved Reserved flag for internal use.
  48405. */
  48406. 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>);
  48407. /**
  48408. * Get the current class name of the texture useful for serialization or dynamic coding.
  48409. * @returns "HDRCubeTexture"
  48410. */
  48411. getClassName(): string;
  48412. /**
  48413. * Occurs when the file is raw .hdr file.
  48414. */
  48415. private loadTexture;
  48416. clone(): HDRCubeTexture;
  48417. delayLoad(): void;
  48418. /**
  48419. * Get the texture reflection matrix used to rotate/transform the reflection.
  48420. * @returns the reflection matrix
  48421. */
  48422. getReflectionTextureMatrix(): Matrix;
  48423. /**
  48424. * Set the texture reflection matrix used to rotate/transform the reflection.
  48425. * @param value Define the reflection matrix to set
  48426. */
  48427. setReflectionTextureMatrix(value: Matrix): void;
  48428. /**
  48429. * Parses a JSON representation of an HDR Texture in order to create the texture
  48430. * @param parsedTexture Define the JSON representation
  48431. * @param scene Define the scene the texture should be created in
  48432. * @param rootUrl Define the root url in case we need to load relative dependencies
  48433. * @returns the newly created texture after parsing
  48434. */
  48435. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48436. serialize(): any;
  48437. }
  48438. }
  48439. declare module BABYLON {
  48440. /**
  48441. * Class used to control physics engine
  48442. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48443. */
  48444. export class PhysicsEngine implements IPhysicsEngine {
  48445. private _physicsPlugin;
  48446. /**
  48447. * Global value used to control the smallest number supported by the simulation
  48448. */
  48449. static Epsilon: number;
  48450. private _impostors;
  48451. private _joints;
  48452. /**
  48453. * Gets the gravity vector used by the simulation
  48454. */
  48455. gravity: Vector3;
  48456. /**
  48457. * Factory used to create the default physics plugin.
  48458. * @returns The default physics plugin
  48459. */
  48460. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48461. /**
  48462. * Creates a new Physics Engine
  48463. * @param gravity defines the gravity vector used by the simulation
  48464. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48465. */
  48466. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48467. /**
  48468. * Sets the gravity vector used by the simulation
  48469. * @param gravity defines the gravity vector to use
  48470. */
  48471. setGravity(gravity: Vector3): void;
  48472. /**
  48473. * Set the time step of the physics engine.
  48474. * Default is 1/60.
  48475. * To slow it down, enter 1/600 for example.
  48476. * To speed it up, 1/30
  48477. * @param newTimeStep defines the new timestep to apply to this world.
  48478. */
  48479. setTimeStep(newTimeStep?: number): void;
  48480. /**
  48481. * Get the time step of the physics engine.
  48482. * @returns the current time step
  48483. */
  48484. getTimeStep(): number;
  48485. /**
  48486. * Release all resources
  48487. */
  48488. dispose(): void;
  48489. /**
  48490. * Gets the name of the current physics plugin
  48491. * @returns the name of the plugin
  48492. */
  48493. getPhysicsPluginName(): string;
  48494. /**
  48495. * Adding a new impostor for the impostor tracking.
  48496. * This will be done by the impostor itself.
  48497. * @param impostor the impostor to add
  48498. */
  48499. addImpostor(impostor: PhysicsImpostor): void;
  48500. /**
  48501. * Remove an impostor from the engine.
  48502. * This impostor and its mesh will not longer be updated by the physics engine.
  48503. * @param impostor the impostor to remove
  48504. */
  48505. removeImpostor(impostor: PhysicsImpostor): void;
  48506. /**
  48507. * Add a joint to the physics engine
  48508. * @param mainImpostor defines the main impostor to which the joint is added.
  48509. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48510. * @param joint defines the joint that will connect both impostors.
  48511. */
  48512. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48513. /**
  48514. * Removes a joint from the simulation
  48515. * @param mainImpostor defines the impostor used with the joint
  48516. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48517. * @param joint defines the joint to remove
  48518. */
  48519. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48520. /**
  48521. * Called by the scene. No need to call it.
  48522. * @param delta defines the timespam between frames
  48523. */
  48524. _step(delta: number): void;
  48525. /**
  48526. * Gets the current plugin used to run the simulation
  48527. * @returns current plugin
  48528. */
  48529. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48530. /**
  48531. * Gets the list of physic impostors
  48532. * @returns an array of PhysicsImpostor
  48533. */
  48534. getImpostors(): Array<PhysicsImpostor>;
  48535. /**
  48536. * Gets the impostor for a physics enabled object
  48537. * @param object defines the object impersonated by the impostor
  48538. * @returns the PhysicsImpostor or null if not found
  48539. */
  48540. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48541. /**
  48542. * Gets the impostor for a physics body object
  48543. * @param body defines physics body used by the impostor
  48544. * @returns the PhysicsImpostor or null if not found
  48545. */
  48546. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48547. /**
  48548. * Does a raycast in the physics world
  48549. * @param from when should the ray start?
  48550. * @param to when should the ray end?
  48551. * @returns PhysicsRaycastResult
  48552. */
  48553. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48554. }
  48555. }
  48556. declare module BABYLON {
  48557. /** @hidden */
  48558. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48559. private _useDeltaForWorldStep;
  48560. world: any;
  48561. name: string;
  48562. private _physicsMaterials;
  48563. private _fixedTimeStep;
  48564. private _cannonRaycastResult;
  48565. private _raycastResult;
  48566. private _removeAfterStep;
  48567. BJSCANNON: any;
  48568. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48569. setGravity(gravity: Vector3): void;
  48570. setTimeStep(timeStep: number): void;
  48571. getTimeStep(): number;
  48572. executeStep(delta: number): void;
  48573. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48574. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48575. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48576. private _processChildMeshes;
  48577. removePhysicsBody(impostor: PhysicsImpostor): void;
  48578. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48579. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48580. private _addMaterial;
  48581. private _checkWithEpsilon;
  48582. private _createShape;
  48583. private _createHeightmap;
  48584. private _minus90X;
  48585. private _plus90X;
  48586. private _tmpPosition;
  48587. private _tmpDeltaPosition;
  48588. private _tmpUnityRotation;
  48589. private _updatePhysicsBodyTransformation;
  48590. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48591. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48592. isSupported(): boolean;
  48593. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48594. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48595. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48596. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48597. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48598. getBodyMass(impostor: PhysicsImpostor): number;
  48599. getBodyFriction(impostor: PhysicsImpostor): number;
  48600. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48601. getBodyRestitution(impostor: PhysicsImpostor): number;
  48602. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48603. sleepBody(impostor: PhysicsImpostor): void;
  48604. wakeUpBody(impostor: PhysicsImpostor): void;
  48605. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48606. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48607. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48608. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48609. getRadius(impostor: PhysicsImpostor): number;
  48610. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48611. dispose(): void;
  48612. private _extendNamespace;
  48613. /**
  48614. * Does a raycast in the physics world
  48615. * @param from when should the ray start?
  48616. * @param to when should the ray end?
  48617. * @returns PhysicsRaycastResult
  48618. */
  48619. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48620. }
  48621. }
  48622. declare module BABYLON {
  48623. /** @hidden */
  48624. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48625. world: any;
  48626. name: string;
  48627. BJSOIMO: any;
  48628. private _raycastResult;
  48629. constructor(iterations?: number, oimoInjection?: any);
  48630. setGravity(gravity: Vector3): void;
  48631. setTimeStep(timeStep: number): void;
  48632. getTimeStep(): number;
  48633. private _tmpImpostorsArray;
  48634. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48635. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48636. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48637. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48638. private _tmpPositionVector;
  48639. removePhysicsBody(impostor: PhysicsImpostor): void;
  48640. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48641. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48642. isSupported(): boolean;
  48643. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48644. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48645. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48646. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48647. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48648. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48649. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48650. getBodyMass(impostor: PhysicsImpostor): number;
  48651. getBodyFriction(impostor: PhysicsImpostor): number;
  48652. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48653. getBodyRestitution(impostor: PhysicsImpostor): number;
  48654. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48655. sleepBody(impostor: PhysicsImpostor): void;
  48656. wakeUpBody(impostor: PhysicsImpostor): void;
  48657. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48658. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48659. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48660. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48661. getRadius(impostor: PhysicsImpostor): number;
  48662. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48663. dispose(): void;
  48664. /**
  48665. * Does a raycast in the physics world
  48666. * @param from when should the ray start?
  48667. * @param to when should the ray end?
  48668. * @returns PhysicsRaycastResult
  48669. */
  48670. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48671. }
  48672. }
  48673. declare module BABYLON {
  48674. /**
  48675. * Class containing static functions to help procedurally build meshes
  48676. */
  48677. export class RibbonBuilder {
  48678. /**
  48679. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48680. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48681. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48682. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48683. * * 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
  48684. * * 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
  48685. * * 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
  48686. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48687. * * 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
  48688. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48689. * * 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
  48690. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48691. * * 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
  48692. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48694. * @param name defines the name of the mesh
  48695. * @param options defines the options used to create the mesh
  48696. * @param scene defines the hosting scene
  48697. * @returns the ribbon mesh
  48698. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48699. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48700. */
  48701. static CreateRibbon(name: string, options: {
  48702. pathArray: Vector3[][];
  48703. closeArray?: boolean;
  48704. closePath?: boolean;
  48705. offset?: number;
  48706. updatable?: boolean;
  48707. sideOrientation?: number;
  48708. frontUVs?: Vector4;
  48709. backUVs?: Vector4;
  48710. instance?: Mesh;
  48711. invertUV?: boolean;
  48712. uvs?: Vector2[];
  48713. colors?: Color4[];
  48714. }, scene?: Nullable<Scene>): Mesh;
  48715. }
  48716. }
  48717. declare module BABYLON {
  48718. /**
  48719. * Class containing static functions to help procedurally build meshes
  48720. */
  48721. export class ShapeBuilder {
  48722. /**
  48723. * 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.
  48724. * * 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.
  48725. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48726. * * 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.
  48727. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  48728. * * 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
  48729. * * 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
  48730. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  48731. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48732. * * 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
  48733. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  48734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48735. * @param name defines the name of the mesh
  48736. * @param options defines the options used to create the mesh
  48737. * @param scene defines the hosting scene
  48738. * @returns the extruded shape mesh
  48739. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48740. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48741. */
  48742. static ExtrudeShape(name: string, options: {
  48743. shape: Vector3[];
  48744. path: Vector3[];
  48745. scale?: number;
  48746. rotation?: number;
  48747. cap?: number;
  48748. updatable?: boolean;
  48749. sideOrientation?: number;
  48750. frontUVs?: Vector4;
  48751. backUVs?: Vector4;
  48752. instance?: Mesh;
  48753. invertUV?: boolean;
  48754. }, scene?: Nullable<Scene>): Mesh;
  48755. /**
  48756. * Creates an custom extruded shape mesh.
  48757. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  48758. * * 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.
  48759. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48760. * * 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
  48761. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  48762. * * 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
  48763. * * It must returns a float value that will be the scale value applied to the shape on each path point
  48764. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  48765. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  48766. * * 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
  48767. * * 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
  48768. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  48769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48770. * * 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
  48771. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48773. * @param name defines the name of the mesh
  48774. * @param options defines the options used to create the mesh
  48775. * @param scene defines the hosting scene
  48776. * @returns the custom extruded shape mesh
  48777. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  48778. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48779. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48780. */
  48781. static ExtrudeShapeCustom(name: string, options: {
  48782. shape: Vector3[];
  48783. path: Vector3[];
  48784. scaleFunction?: any;
  48785. rotationFunction?: any;
  48786. ribbonCloseArray?: boolean;
  48787. ribbonClosePath?: boolean;
  48788. cap?: number;
  48789. updatable?: boolean;
  48790. sideOrientation?: number;
  48791. frontUVs?: Vector4;
  48792. backUVs?: Vector4;
  48793. instance?: Mesh;
  48794. invertUV?: boolean;
  48795. }, scene?: Nullable<Scene>): Mesh;
  48796. private static _ExtrudeShapeGeneric;
  48797. }
  48798. }
  48799. declare module BABYLON {
  48800. /**
  48801. * AmmoJS Physics plugin
  48802. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48803. * @see https://github.com/kripken/ammo.js/
  48804. */
  48805. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48806. private _useDeltaForWorldStep;
  48807. /**
  48808. * Reference to the Ammo library
  48809. */
  48810. bjsAMMO: any;
  48811. /**
  48812. * Created ammoJS world which physics bodies are added to
  48813. */
  48814. world: any;
  48815. /**
  48816. * Name of the plugin
  48817. */
  48818. name: string;
  48819. private _timeStep;
  48820. private _fixedTimeStep;
  48821. private _maxSteps;
  48822. private _tmpQuaternion;
  48823. private _tmpAmmoTransform;
  48824. private _tmpAmmoQuaternion;
  48825. private _tmpAmmoConcreteContactResultCallback;
  48826. private _collisionConfiguration;
  48827. private _dispatcher;
  48828. private _overlappingPairCache;
  48829. private _solver;
  48830. private _softBodySolver;
  48831. private _tmpAmmoVectorA;
  48832. private _tmpAmmoVectorB;
  48833. private _tmpAmmoVectorC;
  48834. private _tmpAmmoVectorD;
  48835. private _tmpContactCallbackResult;
  48836. private _tmpAmmoVectorRCA;
  48837. private _tmpAmmoVectorRCB;
  48838. private _raycastResult;
  48839. private static readonly DISABLE_COLLISION_FLAG;
  48840. private static readonly KINEMATIC_FLAG;
  48841. private static readonly DISABLE_DEACTIVATION_FLAG;
  48842. /**
  48843. * Initializes the ammoJS plugin
  48844. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48845. * @param ammoInjection can be used to inject your own ammo reference
  48846. */
  48847. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  48848. /**
  48849. * Sets the gravity of the physics world (m/(s^2))
  48850. * @param gravity Gravity to set
  48851. */
  48852. setGravity(gravity: Vector3): void;
  48853. /**
  48854. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48855. * @param timeStep timestep to use in seconds
  48856. */
  48857. setTimeStep(timeStep: number): void;
  48858. /**
  48859. * 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)
  48860. * @param fixedTimeStep fixedTimeStep to use in seconds
  48861. */
  48862. setFixedTimeStep(fixedTimeStep: number): void;
  48863. /**
  48864. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  48865. * @param maxSteps the maximum number of steps by the physics engine per frame
  48866. */
  48867. setMaxSteps(maxSteps: number): void;
  48868. /**
  48869. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  48870. * @returns the current timestep in seconds
  48871. */
  48872. getTimeStep(): number;
  48873. private _isImpostorInContact;
  48874. private _isImpostorPairInContact;
  48875. private _stepSimulation;
  48876. /**
  48877. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  48878. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  48879. * After the step the babylon meshes are set to the position of the physics imposters
  48880. * @param delta amount of time to step forward
  48881. * @param impostors array of imposters to update before/after the step
  48882. */
  48883. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48884. /**
  48885. * Update babylon mesh to match physics world object
  48886. * @param impostor imposter to match
  48887. */
  48888. private _afterSoftStep;
  48889. /**
  48890. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48891. * @param impostor imposter to match
  48892. */
  48893. private _ropeStep;
  48894. /**
  48895. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48896. * @param impostor imposter to match
  48897. */
  48898. private _softbodyOrClothStep;
  48899. private _tmpVector;
  48900. private _tmpMatrix;
  48901. /**
  48902. * Applies an impulse on the imposter
  48903. * @param impostor imposter to apply impulse to
  48904. * @param force amount of force to be applied to the imposter
  48905. * @param contactPoint the location to apply the impulse on the imposter
  48906. */
  48907. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48908. /**
  48909. * Applies a force on the imposter
  48910. * @param impostor imposter to apply force
  48911. * @param force amount of force to be applied to the imposter
  48912. * @param contactPoint the location to apply the force on the imposter
  48913. */
  48914. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48915. /**
  48916. * Creates a physics body using the plugin
  48917. * @param impostor the imposter to create the physics body on
  48918. */
  48919. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48920. /**
  48921. * Removes the physics body from the imposter and disposes of the body's memory
  48922. * @param impostor imposter to remove the physics body from
  48923. */
  48924. removePhysicsBody(impostor: PhysicsImpostor): void;
  48925. /**
  48926. * Generates a joint
  48927. * @param impostorJoint the imposter joint to create the joint with
  48928. */
  48929. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48930. /**
  48931. * Removes a joint
  48932. * @param impostorJoint the imposter joint to remove the joint from
  48933. */
  48934. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48935. private _addMeshVerts;
  48936. /**
  48937. * Initialise the soft body vertices to match its object's (mesh) vertices
  48938. * Softbody vertices (nodes) are in world space and to match this
  48939. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  48940. * @param impostor to create the softbody for
  48941. */
  48942. private _softVertexData;
  48943. /**
  48944. * Create an impostor's soft body
  48945. * @param impostor to create the softbody for
  48946. */
  48947. private _createSoftbody;
  48948. /**
  48949. * Create cloth for an impostor
  48950. * @param impostor to create the softbody for
  48951. */
  48952. private _createCloth;
  48953. /**
  48954. * Create rope for an impostor
  48955. * @param impostor to create the softbody for
  48956. */
  48957. private _createRope;
  48958. private _addHullVerts;
  48959. private _createShape;
  48960. /**
  48961. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48962. * @param impostor imposter containing the physics body and babylon object
  48963. */
  48964. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48965. /**
  48966. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48967. * @param impostor imposter containing the physics body and babylon object
  48968. * @param newPosition new position
  48969. * @param newRotation new rotation
  48970. */
  48971. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48972. /**
  48973. * If this plugin is supported
  48974. * @returns true if its supported
  48975. */
  48976. isSupported(): boolean;
  48977. /**
  48978. * Sets the linear velocity of the physics body
  48979. * @param impostor imposter to set the velocity on
  48980. * @param velocity velocity to set
  48981. */
  48982. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48983. /**
  48984. * Sets the angular velocity of the physics body
  48985. * @param impostor imposter to set the velocity on
  48986. * @param velocity velocity to set
  48987. */
  48988. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48989. /**
  48990. * gets the linear velocity
  48991. * @param impostor imposter to get linear velocity from
  48992. * @returns linear velocity
  48993. */
  48994. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48995. /**
  48996. * gets the angular velocity
  48997. * @param impostor imposter to get angular velocity from
  48998. * @returns angular velocity
  48999. */
  49000. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49001. /**
  49002. * Sets the mass of physics body
  49003. * @param impostor imposter to set the mass on
  49004. * @param mass mass to set
  49005. */
  49006. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49007. /**
  49008. * Gets the mass of the physics body
  49009. * @param impostor imposter to get the mass from
  49010. * @returns mass
  49011. */
  49012. getBodyMass(impostor: PhysicsImpostor): number;
  49013. /**
  49014. * Gets friction of the impostor
  49015. * @param impostor impostor to get friction from
  49016. * @returns friction value
  49017. */
  49018. getBodyFriction(impostor: PhysicsImpostor): number;
  49019. /**
  49020. * Sets friction of the impostor
  49021. * @param impostor impostor to set friction on
  49022. * @param friction friction value
  49023. */
  49024. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49025. /**
  49026. * Gets restitution of the impostor
  49027. * @param impostor impostor to get restitution from
  49028. * @returns restitution value
  49029. */
  49030. getBodyRestitution(impostor: PhysicsImpostor): number;
  49031. /**
  49032. * Sets resitution of the impostor
  49033. * @param impostor impostor to set resitution on
  49034. * @param restitution resitution value
  49035. */
  49036. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49037. /**
  49038. * Gets pressure inside the impostor
  49039. * @param impostor impostor to get pressure from
  49040. * @returns pressure value
  49041. */
  49042. getBodyPressure(impostor: PhysicsImpostor): number;
  49043. /**
  49044. * Sets pressure inside a soft body impostor
  49045. * Cloth and rope must remain 0 pressure
  49046. * @param impostor impostor to set pressure on
  49047. * @param pressure pressure value
  49048. */
  49049. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  49050. /**
  49051. * Gets stiffness of the impostor
  49052. * @param impostor impostor to get stiffness from
  49053. * @returns pressure value
  49054. */
  49055. getBodyStiffness(impostor: PhysicsImpostor): number;
  49056. /**
  49057. * Sets stiffness of the impostor
  49058. * @param impostor impostor to set stiffness on
  49059. * @param stiffness stiffness value from 0 to 1
  49060. */
  49061. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  49062. /**
  49063. * Gets velocityIterations of the impostor
  49064. * @param impostor impostor to get velocity iterations from
  49065. * @returns velocityIterations value
  49066. */
  49067. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  49068. /**
  49069. * Sets velocityIterations of the impostor
  49070. * @param impostor impostor to set velocity iterations on
  49071. * @param velocityIterations velocityIterations value
  49072. */
  49073. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  49074. /**
  49075. * Gets positionIterations of the impostor
  49076. * @param impostor impostor to get position iterations from
  49077. * @returns positionIterations value
  49078. */
  49079. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  49080. /**
  49081. * Sets positionIterations of the impostor
  49082. * @param impostor impostor to set position on
  49083. * @param positionIterations positionIterations value
  49084. */
  49085. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  49086. /**
  49087. * Append an anchor to a cloth object
  49088. * @param impostor is the cloth impostor to add anchor to
  49089. * @param otherImpostor is the rigid impostor to anchor to
  49090. * @param width ratio across width from 0 to 1
  49091. * @param height ratio up height from 0 to 1
  49092. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  49093. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49094. */
  49095. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49096. /**
  49097. * Append an hook to a rope object
  49098. * @param impostor is the rope impostor to add hook to
  49099. * @param otherImpostor is the rigid impostor to hook to
  49100. * @param length ratio along the rope from 0 to 1
  49101. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  49102. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49103. */
  49104. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49105. /**
  49106. * Sleeps the physics body and stops it from being active
  49107. * @param impostor impostor to sleep
  49108. */
  49109. sleepBody(impostor: PhysicsImpostor): void;
  49110. /**
  49111. * Activates the physics body
  49112. * @param impostor impostor to activate
  49113. */
  49114. wakeUpBody(impostor: PhysicsImpostor): void;
  49115. /**
  49116. * Updates the distance parameters of the joint
  49117. * @param joint joint to update
  49118. * @param maxDistance maximum distance of the joint
  49119. * @param minDistance minimum distance of the joint
  49120. */
  49121. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49122. /**
  49123. * Sets a motor on the joint
  49124. * @param joint joint to set motor on
  49125. * @param speed speed of the motor
  49126. * @param maxForce maximum force of the motor
  49127. * @param motorIndex index of the motor
  49128. */
  49129. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49130. /**
  49131. * Sets the motors limit
  49132. * @param joint joint to set limit on
  49133. * @param upperLimit upper limit
  49134. * @param lowerLimit lower limit
  49135. */
  49136. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49137. /**
  49138. * Syncs the position and rotation of a mesh with the impostor
  49139. * @param mesh mesh to sync
  49140. * @param impostor impostor to update the mesh with
  49141. */
  49142. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49143. /**
  49144. * Gets the radius of the impostor
  49145. * @param impostor impostor to get radius from
  49146. * @returns the radius
  49147. */
  49148. getRadius(impostor: PhysicsImpostor): number;
  49149. /**
  49150. * Gets the box size of the impostor
  49151. * @param impostor impostor to get box size from
  49152. * @param result the resulting box size
  49153. */
  49154. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49155. /**
  49156. * Disposes of the impostor
  49157. */
  49158. dispose(): void;
  49159. /**
  49160. * Does a raycast in the physics world
  49161. * @param from when should the ray start?
  49162. * @param to when should the ray end?
  49163. * @returns PhysicsRaycastResult
  49164. */
  49165. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49166. }
  49167. }
  49168. declare module BABYLON {
  49169. interface AbstractScene {
  49170. /**
  49171. * The list of reflection probes added to the scene
  49172. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49173. */
  49174. reflectionProbes: Array<ReflectionProbe>;
  49175. /**
  49176. * Removes the given reflection probe from this scene.
  49177. * @param toRemove The reflection probe to remove
  49178. * @returns The index of the removed reflection probe
  49179. */
  49180. removeReflectionProbe(toRemove: ReflectionProbe): number;
  49181. /**
  49182. * Adds the given reflection probe to this scene.
  49183. * @param newReflectionProbe The reflection probe to add
  49184. */
  49185. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  49186. }
  49187. /**
  49188. * Class used to generate realtime reflection / refraction cube textures
  49189. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49190. */
  49191. export class ReflectionProbe {
  49192. /** defines the name of the probe */
  49193. name: string;
  49194. private _scene;
  49195. private _renderTargetTexture;
  49196. private _projectionMatrix;
  49197. private _viewMatrix;
  49198. private _target;
  49199. private _add;
  49200. private _attachedMesh;
  49201. private _invertYAxis;
  49202. /** Gets or sets probe position (center of the cube map) */
  49203. position: Vector3;
  49204. /**
  49205. * Creates a new reflection probe
  49206. * @param name defines the name of the probe
  49207. * @param size defines the texture resolution (for each face)
  49208. * @param scene defines the hosting scene
  49209. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49210. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49211. */
  49212. constructor(
  49213. /** defines the name of the probe */
  49214. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49215. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49216. samples: number;
  49217. /** Gets or sets the refresh rate to use (on every frame by default) */
  49218. refreshRate: number;
  49219. /**
  49220. * Gets the hosting scene
  49221. * @returns a Scene
  49222. */
  49223. getScene(): Scene;
  49224. /** Gets the internal CubeTexture used to render to */
  49225. readonly cubeTexture: RenderTargetTexture;
  49226. /** Gets the list of meshes to render */
  49227. readonly renderList: Nullable<AbstractMesh[]>;
  49228. /**
  49229. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49230. * @param mesh defines the mesh to attach to
  49231. */
  49232. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49233. /**
  49234. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49235. * @param renderingGroupId The rendering group id corresponding to its index
  49236. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49237. */
  49238. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49239. /**
  49240. * Clean all associated resources
  49241. */
  49242. dispose(): void;
  49243. /**
  49244. * Converts the reflection probe information to a readable string for debug purpose.
  49245. * @param fullDetails Supports for multiple levels of logging within scene loading
  49246. * @returns the human readable reflection probe info
  49247. */
  49248. toString(fullDetails?: boolean): string;
  49249. /**
  49250. * Get the class name of the relfection probe.
  49251. * @returns "ReflectionProbe"
  49252. */
  49253. getClassName(): string;
  49254. /**
  49255. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49256. * @returns The JSON representation of the texture
  49257. */
  49258. serialize(): any;
  49259. /**
  49260. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49261. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49262. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49263. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49264. * @returns The parsed reflection probe if successful
  49265. */
  49266. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49267. }
  49268. }
  49269. declare module BABYLON {
  49270. /** @hidden */
  49271. export var _BabylonLoaderRegistered: boolean;
  49272. }
  49273. declare module BABYLON {
  49274. /**
  49275. * The Physically based simple base material of BJS.
  49276. *
  49277. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49278. * It is used as the base class for both the specGloss and metalRough conventions.
  49279. */
  49280. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49281. /**
  49282. * Number of Simultaneous lights allowed on the material.
  49283. */
  49284. maxSimultaneousLights: number;
  49285. /**
  49286. * If sets to true, disables all the lights affecting the material.
  49287. */
  49288. disableLighting: boolean;
  49289. /**
  49290. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49291. */
  49292. environmentTexture: BaseTexture;
  49293. /**
  49294. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49295. */
  49296. invertNormalMapX: boolean;
  49297. /**
  49298. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49299. */
  49300. invertNormalMapY: boolean;
  49301. /**
  49302. * Normal map used in the model.
  49303. */
  49304. normalTexture: BaseTexture;
  49305. /**
  49306. * Emissivie color used to self-illuminate the model.
  49307. */
  49308. emissiveColor: Color3;
  49309. /**
  49310. * Emissivie texture used to self-illuminate the model.
  49311. */
  49312. emissiveTexture: BaseTexture;
  49313. /**
  49314. * Occlusion Channel Strenght.
  49315. */
  49316. occlusionStrength: number;
  49317. /**
  49318. * Occlusion Texture of the material (adding extra occlusion effects).
  49319. */
  49320. occlusionTexture: BaseTexture;
  49321. /**
  49322. * Defines the alpha limits in alpha test mode.
  49323. */
  49324. alphaCutOff: number;
  49325. /**
  49326. * Gets the current double sided mode.
  49327. */
  49328. /**
  49329. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49330. */
  49331. doubleSided: boolean;
  49332. /**
  49333. * Stores the pre-calculated light information of a mesh in a texture.
  49334. */
  49335. lightmapTexture: BaseTexture;
  49336. /**
  49337. * If true, the light map contains occlusion information instead of lighting info.
  49338. */
  49339. useLightmapAsShadowmap: boolean;
  49340. /**
  49341. * Instantiates a new PBRMaterial instance.
  49342. *
  49343. * @param name The material name
  49344. * @param scene The scene the material will be use in.
  49345. */
  49346. constructor(name: string, scene: Scene);
  49347. getClassName(): string;
  49348. }
  49349. }
  49350. declare module BABYLON {
  49351. /**
  49352. * The PBR material of BJS following the metal roughness convention.
  49353. *
  49354. * This fits to the PBR convention in the GLTF definition:
  49355. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49356. */
  49357. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49358. /**
  49359. * The base color has two different interpretations depending on the value of metalness.
  49360. * When the material is a metal, the base color is the specific measured reflectance value
  49361. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49362. * of the material.
  49363. */
  49364. baseColor: Color3;
  49365. /**
  49366. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49367. * well as opacity information in the alpha channel.
  49368. */
  49369. baseTexture: BaseTexture;
  49370. /**
  49371. * Specifies the metallic scalar value of the material.
  49372. * Can also be used to scale the metalness values of the metallic texture.
  49373. */
  49374. metallic: number;
  49375. /**
  49376. * Specifies the roughness scalar value of the material.
  49377. * Can also be used to scale the roughness values of the metallic texture.
  49378. */
  49379. roughness: number;
  49380. /**
  49381. * Texture containing both the metallic value in the B channel and the
  49382. * roughness value in the G channel to keep better precision.
  49383. */
  49384. metallicRoughnessTexture: BaseTexture;
  49385. /**
  49386. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49387. *
  49388. * @param name The material name
  49389. * @param scene The scene the material will be use in.
  49390. */
  49391. constructor(name: string, scene: Scene);
  49392. /**
  49393. * Return the currrent class name of the material.
  49394. */
  49395. getClassName(): string;
  49396. /**
  49397. * Makes a duplicate of the current material.
  49398. * @param name - name to use for the new material.
  49399. */
  49400. clone(name: string): PBRMetallicRoughnessMaterial;
  49401. /**
  49402. * Serialize the material to a parsable JSON object.
  49403. */
  49404. serialize(): any;
  49405. /**
  49406. * Parses a JSON object correponding to the serialize function.
  49407. */
  49408. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49409. }
  49410. }
  49411. declare module BABYLON {
  49412. /**
  49413. * The PBR material of BJS following the specular glossiness convention.
  49414. *
  49415. * This fits to the PBR convention in the GLTF definition:
  49416. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49417. */
  49418. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49419. /**
  49420. * Specifies the diffuse color of the material.
  49421. */
  49422. diffuseColor: Color3;
  49423. /**
  49424. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49425. * channel.
  49426. */
  49427. diffuseTexture: BaseTexture;
  49428. /**
  49429. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49430. */
  49431. specularColor: Color3;
  49432. /**
  49433. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49434. */
  49435. glossiness: number;
  49436. /**
  49437. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49438. */
  49439. specularGlossinessTexture: BaseTexture;
  49440. /**
  49441. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49442. *
  49443. * @param name The material name
  49444. * @param scene The scene the material will be use in.
  49445. */
  49446. constructor(name: string, scene: Scene);
  49447. /**
  49448. * Return the currrent class name of the material.
  49449. */
  49450. getClassName(): string;
  49451. /**
  49452. * Makes a duplicate of the current material.
  49453. * @param name - name to use for the new material.
  49454. */
  49455. clone(name: string): PBRSpecularGlossinessMaterial;
  49456. /**
  49457. * Serialize the material to a parsable JSON object.
  49458. */
  49459. serialize(): any;
  49460. /**
  49461. * Parses a JSON object correponding to the serialize function.
  49462. */
  49463. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49464. }
  49465. }
  49466. declare module BABYLON {
  49467. /**
  49468. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49469. * It can help converting any input color in a desired output one. This can then be used to create effects
  49470. * from sepia, black and white to sixties or futuristic rendering...
  49471. *
  49472. * The only supported format is currently 3dl.
  49473. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49474. */
  49475. export class ColorGradingTexture extends BaseTexture {
  49476. /**
  49477. * The current texture matrix. (will always be identity in color grading texture)
  49478. */
  49479. private _textureMatrix;
  49480. /**
  49481. * The texture URL.
  49482. */
  49483. url: string;
  49484. /**
  49485. * Empty line regex stored for GC.
  49486. */
  49487. private static _noneEmptyLineRegex;
  49488. private _engine;
  49489. /**
  49490. * Instantiates a ColorGradingTexture from the following parameters.
  49491. *
  49492. * @param url The location of the color gradind data (currently only supporting 3dl)
  49493. * @param scene The scene the texture will be used in
  49494. */
  49495. constructor(url: string, scene: Scene);
  49496. /**
  49497. * Returns the texture matrix used in most of the material.
  49498. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49499. */
  49500. getTextureMatrix(): Matrix;
  49501. /**
  49502. * Occurs when the file being loaded is a .3dl LUT file.
  49503. */
  49504. private load3dlTexture;
  49505. /**
  49506. * Starts the loading process of the texture.
  49507. */
  49508. private loadTexture;
  49509. /**
  49510. * Clones the color gradind texture.
  49511. */
  49512. clone(): ColorGradingTexture;
  49513. /**
  49514. * Called during delayed load for textures.
  49515. */
  49516. delayLoad(): void;
  49517. /**
  49518. * Parses a color grading texture serialized by Babylon.
  49519. * @param parsedTexture The texture information being parsedTexture
  49520. * @param scene The scene to load the texture in
  49521. * @param rootUrl The root url of the data assets to load
  49522. * @return A color gradind texture
  49523. */
  49524. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49525. /**
  49526. * Serializes the LUT texture to json format.
  49527. */
  49528. serialize(): any;
  49529. }
  49530. }
  49531. declare module BABYLON {
  49532. /**
  49533. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49534. */
  49535. export class EquiRectangularCubeTexture extends BaseTexture {
  49536. /** The six faces of the cube. */
  49537. private static _FacesMapping;
  49538. private _noMipmap;
  49539. private _onLoad;
  49540. private _onError;
  49541. /** The size of the cubemap. */
  49542. private _size;
  49543. /** The buffer of the image. */
  49544. private _buffer;
  49545. /** The width of the input image. */
  49546. private _width;
  49547. /** The height of the input image. */
  49548. private _height;
  49549. /** The URL to the image. */
  49550. url: string;
  49551. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49552. coordinatesMode: number;
  49553. /**
  49554. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49555. * @param url The location of the image
  49556. * @param scene The scene the texture will be used in
  49557. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49558. * @param noMipmap Forces to not generate the mipmap if true
  49559. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49560. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49561. * @param onLoad — defines a callback called when texture is loaded
  49562. * @param onError — defines a callback called if there is an error
  49563. */
  49564. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49565. /**
  49566. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49567. */
  49568. private loadImage;
  49569. /**
  49570. * Convert the image buffer into a cubemap and create a CubeTexture.
  49571. */
  49572. private loadTexture;
  49573. /**
  49574. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49575. * @param buffer The ArrayBuffer that should be converted.
  49576. * @returns The buffer as Float32Array.
  49577. */
  49578. private getFloat32ArrayFromArrayBuffer;
  49579. /**
  49580. * Get the current class name of the texture useful for serialization or dynamic coding.
  49581. * @returns "EquiRectangularCubeTexture"
  49582. */
  49583. getClassName(): string;
  49584. /**
  49585. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49586. * @returns A clone of the current EquiRectangularCubeTexture.
  49587. */
  49588. clone(): EquiRectangularCubeTexture;
  49589. }
  49590. }
  49591. declare module BABYLON {
  49592. /**
  49593. * Based on jsTGALoader - Javascript loader for TGA file
  49594. * By Vincent Thibault
  49595. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49596. */
  49597. export class TGATools {
  49598. private static _TYPE_INDEXED;
  49599. private static _TYPE_RGB;
  49600. private static _TYPE_GREY;
  49601. private static _TYPE_RLE_INDEXED;
  49602. private static _TYPE_RLE_RGB;
  49603. private static _TYPE_RLE_GREY;
  49604. private static _ORIGIN_MASK;
  49605. private static _ORIGIN_SHIFT;
  49606. private static _ORIGIN_BL;
  49607. private static _ORIGIN_BR;
  49608. private static _ORIGIN_UL;
  49609. private static _ORIGIN_UR;
  49610. /**
  49611. * Gets the header of a TGA file
  49612. * @param data defines the TGA data
  49613. * @returns the header
  49614. */
  49615. static GetTGAHeader(data: Uint8Array): any;
  49616. /**
  49617. * Uploads TGA content to a Babylon Texture
  49618. * @hidden
  49619. */
  49620. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49621. /** @hidden */
  49622. 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;
  49623. /** @hidden */
  49624. 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;
  49625. /** @hidden */
  49626. 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;
  49627. /** @hidden */
  49628. 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;
  49629. /** @hidden */
  49630. 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;
  49631. /** @hidden */
  49632. 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;
  49633. }
  49634. }
  49635. declare module BABYLON {
  49636. /**
  49637. * Implementation of the TGA Texture Loader.
  49638. * @hidden
  49639. */
  49640. export class _TGATextureLoader implements IInternalTextureLoader {
  49641. /**
  49642. * Defines wether the loader supports cascade loading the different faces.
  49643. */
  49644. readonly supportCascades: boolean;
  49645. /**
  49646. * This returns if the loader support the current file information.
  49647. * @param extension defines the file extension of the file being loaded
  49648. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49649. * @param fallback defines the fallback internal texture if any
  49650. * @param isBase64 defines whether the texture is encoded as a base64
  49651. * @param isBuffer defines whether the texture data are stored as a buffer
  49652. * @returns true if the loader can load the specified file
  49653. */
  49654. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49655. /**
  49656. * Transform the url before loading if required.
  49657. * @param rootUrl the url of the texture
  49658. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49659. * @returns the transformed texture
  49660. */
  49661. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49662. /**
  49663. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49664. * @param rootUrl the url of the texture
  49665. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49666. * @returns the fallback texture
  49667. */
  49668. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49669. /**
  49670. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49671. * @param data contains the texture data
  49672. * @param texture defines the BabylonJS internal texture
  49673. * @param createPolynomials will be true if polynomials have been requested
  49674. * @param onLoad defines the callback to trigger once the texture is ready
  49675. * @param onError defines the callback to trigger in case of error
  49676. */
  49677. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49678. /**
  49679. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49680. * @param data contains the texture data
  49681. * @param texture defines the BabylonJS internal texture
  49682. * @param callback defines the method to call once ready to upload
  49683. */
  49684. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49685. }
  49686. }
  49687. declare module BABYLON {
  49688. /**
  49689. * 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.
  49690. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49691. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49692. */
  49693. export class CustomProceduralTexture extends ProceduralTexture {
  49694. private _animate;
  49695. private _time;
  49696. private _config;
  49697. private _texturePath;
  49698. /**
  49699. * Instantiates a new Custom Procedural Texture.
  49700. * 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.
  49701. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49702. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49703. * @param name Define the name of the texture
  49704. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49705. * @param size Define the size of the texture to create
  49706. * @param scene Define the scene the texture belongs to
  49707. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49708. * @param generateMipMaps Define if the texture should creates mip maps or not
  49709. */
  49710. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49711. private _loadJson;
  49712. /**
  49713. * Is the texture ready to be used ? (rendered at least once)
  49714. * @returns true if ready, otherwise, false.
  49715. */
  49716. isReady(): boolean;
  49717. /**
  49718. * Render the texture to its associated render target.
  49719. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49720. */
  49721. render(useCameraPostProcess?: boolean): void;
  49722. /**
  49723. * Update the list of dependant textures samplers in the shader.
  49724. */
  49725. updateTextures(): void;
  49726. /**
  49727. * Update the uniform values of the procedural texture in the shader.
  49728. */
  49729. updateShaderUniforms(): void;
  49730. /**
  49731. * Define if the texture animates or not.
  49732. */
  49733. animate: boolean;
  49734. }
  49735. }
  49736. declare module BABYLON {
  49737. /** @hidden */
  49738. export var noisePixelShader: {
  49739. name: string;
  49740. shader: string;
  49741. };
  49742. }
  49743. declare module BABYLON {
  49744. /**
  49745. * Class used to generate noise procedural textures
  49746. */
  49747. export class NoiseProceduralTexture extends ProceduralTexture {
  49748. private _time;
  49749. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49750. brightness: number;
  49751. /** Defines the number of octaves to process */
  49752. octaves: number;
  49753. /** Defines the level of persistence (0.8 by default) */
  49754. persistence: number;
  49755. /** Gets or sets animation speed factor (default is 1) */
  49756. animationSpeedFactor: number;
  49757. /**
  49758. * Creates a new NoiseProceduralTexture
  49759. * @param name defines the name fo the texture
  49760. * @param size defines the size of the texture (default is 256)
  49761. * @param scene defines the hosting scene
  49762. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49763. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49764. */
  49765. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49766. private _updateShaderUniforms;
  49767. protected _getDefines(): string;
  49768. /** Generate the current state of the procedural texture */
  49769. render(useCameraPostProcess?: boolean): void;
  49770. /**
  49771. * Serializes this noise procedural texture
  49772. * @returns a serialized noise procedural texture object
  49773. */
  49774. serialize(): any;
  49775. /**
  49776. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49777. * @param parsedTexture defines parsed texture data
  49778. * @param scene defines the current scene
  49779. * @param rootUrl defines the root URL containing noise procedural texture information
  49780. * @returns a parsed NoiseProceduralTexture
  49781. */
  49782. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49783. }
  49784. }
  49785. declare module BABYLON {
  49786. /**
  49787. * Raw cube texture where the raw buffers are passed in
  49788. */
  49789. export class RawCubeTexture extends CubeTexture {
  49790. /**
  49791. * Creates a cube texture where the raw buffers are passed in.
  49792. * @param scene defines the scene the texture is attached to
  49793. * @param data defines the array of data to use to create each face
  49794. * @param size defines the size of the textures
  49795. * @param format defines the format of the data
  49796. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49797. * @param generateMipMaps defines if the engine should generate the mip levels
  49798. * @param invertY defines if data must be stored with Y axis inverted
  49799. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49800. * @param compression defines the compression used (null by default)
  49801. */
  49802. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49803. /**
  49804. * Updates the raw cube texture.
  49805. * @param data defines the data to store
  49806. * @param format defines the data format
  49807. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49808. * @param invertY defines if data must be stored with Y axis inverted
  49809. * @param compression defines the compression used (null by default)
  49810. * @param level defines which level of the texture to update
  49811. */
  49812. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49813. /**
  49814. * Updates a raw cube texture with RGBD encoded data.
  49815. * @param data defines the array of data [mipmap][face] to use to create each face
  49816. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49817. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49818. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49819. * @returns a promsie that resolves when the operation is complete
  49820. */
  49821. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49822. /**
  49823. * Clones the raw cube texture.
  49824. * @return a new cube texture
  49825. */
  49826. clone(): CubeTexture;
  49827. /** @hidden */
  49828. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49829. }
  49830. }
  49831. declare module BABYLON {
  49832. /**
  49833. * Class used to store 3D textures containing user data
  49834. */
  49835. export class RawTexture3D extends Texture {
  49836. /** Gets or sets the texture format to use */
  49837. format: number;
  49838. private _engine;
  49839. /**
  49840. * Create a new RawTexture3D
  49841. * @param data defines the data of the texture
  49842. * @param width defines the width of the texture
  49843. * @param height defines the height of the texture
  49844. * @param depth defines the depth of the texture
  49845. * @param format defines the texture format to use
  49846. * @param scene defines the hosting scene
  49847. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49848. * @param invertY defines if texture must be stored with Y axis inverted
  49849. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49850. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49851. */
  49852. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49853. /** Gets or sets the texture format to use */
  49854. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49855. /**
  49856. * Update the texture with new data
  49857. * @param data defines the data to store in the texture
  49858. */
  49859. update(data: ArrayBufferView): void;
  49860. }
  49861. }
  49862. declare module BABYLON {
  49863. /**
  49864. * Creates a refraction texture used by refraction channel of the standard material.
  49865. * It is like a mirror but to see through a material.
  49866. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49867. */
  49868. export class RefractionTexture extends RenderTargetTexture {
  49869. /**
  49870. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49871. * 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.
  49872. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49873. */
  49874. refractionPlane: Plane;
  49875. /**
  49876. * Define how deep under the surface we should see.
  49877. */
  49878. depth: number;
  49879. /**
  49880. * Creates a refraction texture used by refraction channel of the standard material.
  49881. * It is like a mirror but to see through a material.
  49882. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49883. * @param name Define the texture name
  49884. * @param size Define the size of the underlying texture
  49885. * @param scene Define the scene the refraction belongs to
  49886. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49887. */
  49888. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49889. /**
  49890. * Clone the refraction texture.
  49891. * @returns the cloned texture
  49892. */
  49893. clone(): RefractionTexture;
  49894. /**
  49895. * Serialize the texture to a JSON representation you could use in Parse later on
  49896. * @returns the serialized JSON representation
  49897. */
  49898. serialize(): any;
  49899. }
  49900. }
  49901. declare module BABYLON {
  49902. /**
  49903. * Defines the options related to the creation of an HtmlElementTexture
  49904. */
  49905. export interface IHtmlElementTextureOptions {
  49906. /**
  49907. * Defines wether mip maps should be created or not.
  49908. */
  49909. generateMipMaps?: boolean;
  49910. /**
  49911. * Defines the sampling mode of the texture.
  49912. */
  49913. samplingMode?: number;
  49914. /**
  49915. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  49916. */
  49917. engine: Nullable<Engine>;
  49918. /**
  49919. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  49920. */
  49921. scene: Nullable<Scene>;
  49922. }
  49923. /**
  49924. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  49925. * To be as efficient as possible depending on your constraints nothing aside the first upload
  49926. * is automatically managed.
  49927. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  49928. * in your application.
  49929. *
  49930. * As the update is not automatic, you need to call them manually.
  49931. */
  49932. export class HtmlElementTexture extends BaseTexture {
  49933. /**
  49934. * The texture URL.
  49935. */
  49936. element: HTMLVideoElement | HTMLCanvasElement;
  49937. private static readonly DefaultOptions;
  49938. private _textureMatrix;
  49939. private _engine;
  49940. private _isVideo;
  49941. private _generateMipMaps;
  49942. private _samplingMode;
  49943. /**
  49944. * Instantiates a HtmlElementTexture from the following parameters.
  49945. *
  49946. * @param name Defines the name of the texture
  49947. * @param element Defines the video or canvas the texture is filled with
  49948. * @param options Defines the other none mandatory texture creation options
  49949. */
  49950. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  49951. private _createInternalTexture;
  49952. /**
  49953. * Returns the texture matrix used in most of the material.
  49954. */
  49955. getTextureMatrix(): Matrix;
  49956. /**
  49957. * Updates the content of the texture.
  49958. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  49959. */
  49960. update(invertY?: Nullable<boolean>): void;
  49961. }
  49962. }
  49963. declare module BABYLON {
  49964. /**
  49965. * Enum used to define the target of a block
  49966. */
  49967. export enum NodeMaterialBlockTargets {
  49968. /** Vertex shader */
  49969. Vertex = 1,
  49970. /** Fragment shader */
  49971. Fragment = 2,
  49972. /** Vertex and Fragment */
  49973. VertexAndFragment = 3
  49974. }
  49975. }
  49976. declare module BABYLON {
  49977. /**
  49978. * Defines the kind of connection point for node based material
  49979. */
  49980. export enum NodeMaterialBlockConnectionPointTypes {
  49981. /** Float */
  49982. Float = 1,
  49983. /** Int */
  49984. Int = 2,
  49985. /** Vector2 */
  49986. Vector2 = 4,
  49987. /** Vector3 */
  49988. Vector3 = 8,
  49989. /** Vector4 */
  49990. Vector4 = 16,
  49991. /** Color3 */
  49992. Color3 = 32,
  49993. /** Color4 */
  49994. Color4 = 64,
  49995. /** Matrix */
  49996. Matrix = 128,
  49997. /** Texture */
  49998. Texture = 256,
  49999. /** Texture3D */
  50000. Texture3D = 512,
  50001. /** Vector3 or Color3 */
  50002. Vector3OrColor3 = 40,
  50003. /** Vector3 or Vector4 */
  50004. Vector3OrVector4 = 24,
  50005. /** Vector4 or Color4 */
  50006. Vector4OrColor4 = 80,
  50007. /** Color3 or Color4 */
  50008. Color3OrColor4 = 96,
  50009. /** Vector3 or Color3 */
  50010. Vector3OrColor3OrVector4OrColor4 = 120
  50011. }
  50012. }
  50013. declare module BABYLON {
  50014. /**
  50015. * Enum used to define well known values e.g. values automatically provided by the system
  50016. */
  50017. export enum NodeMaterialWellKnownValues {
  50018. /** World */
  50019. World = 1,
  50020. /** View */
  50021. View = 2,
  50022. /** Projection */
  50023. Projection = 3,
  50024. /** ViewProjection */
  50025. ViewProjection = 4,
  50026. /** WorldView */
  50027. WorldView = 5,
  50028. /** WorldViewProjection */
  50029. WorldViewProjection = 6,
  50030. /** Will be filled by the block itself */
  50031. BlockBased = 7
  50032. }
  50033. }
  50034. declare module BABYLON {
  50035. /**
  50036. * Class used to store shared data between 2 NodeMaterialBuildState
  50037. */
  50038. export class NodeMaterialBuildStateSharedData {
  50039. /**
  50040. * Gets the list of emitted varyings
  50041. */
  50042. varyings: string[];
  50043. /**
  50044. * Gets the varying declaration string
  50045. */
  50046. varyingDeclaration: string;
  50047. /**
  50048. * Uniform connection points
  50049. */
  50050. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  50051. /**
  50052. * Bindable blocks (Blocks that need to set data to the effect)
  50053. */
  50054. bindableBlocks: NodeMaterialBlock[];
  50055. /**
  50056. * List of blocks that can provide a compilation fallback
  50057. */
  50058. blocksWithFallbacks: NodeMaterialBlock[];
  50059. /**
  50060. * List of blocks that can provide a define update
  50061. */
  50062. blocksWithDefines: NodeMaterialBlock[];
  50063. /**
  50064. * List of blocks that can provide a repeatable content
  50065. */
  50066. repeatableContentBlocks: NodeMaterialBlock[];
  50067. /**
  50068. * List of blocks that can block the isReady function for the material
  50069. */
  50070. blockingBlocks: NodeMaterialBlock[];
  50071. /**
  50072. * Build Id used to avoid multiple recompilations
  50073. */
  50074. buildId: number;
  50075. /** List of emitted variables */
  50076. variableNames: {
  50077. [key: string]: number;
  50078. };
  50079. /** List of emitted defines */
  50080. defineNames: {
  50081. [key: string]: number;
  50082. };
  50083. /** Should emit comments? */
  50084. emitComments: boolean;
  50085. /** Emit build activity */
  50086. verbose: boolean;
  50087. /**
  50088. * Gets the compilation hints emitted at compilation time
  50089. */
  50090. hints: {
  50091. needWorldViewMatrix: boolean;
  50092. needWorldViewProjectionMatrix: boolean;
  50093. needAlphaBlending: boolean;
  50094. needAlphaTesting: boolean;
  50095. };
  50096. /**
  50097. * List of compilation checks
  50098. */
  50099. checks: {
  50100. emitVertex: boolean;
  50101. emitFragment: boolean;
  50102. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  50103. };
  50104. /** Creates a new shared data */
  50105. constructor();
  50106. /**
  50107. * Emits console errors and exceptions if there is a failing check
  50108. */
  50109. emitErrors(): void;
  50110. }
  50111. }
  50112. declare module BABYLON {
  50113. /**
  50114. * Class used to store node based material build state
  50115. */
  50116. export class NodeMaterialBuildState {
  50117. /**
  50118. * Gets the list of emitted attributes
  50119. */
  50120. attributes: string[];
  50121. /**
  50122. * Gets the list of emitted uniforms
  50123. */
  50124. uniforms: string[];
  50125. /**
  50126. * Gets the list of emitted samplers
  50127. */
  50128. samplers: string[];
  50129. /**
  50130. * Gets the list of emitted functions
  50131. */
  50132. functions: {
  50133. [key: string]: string;
  50134. };
  50135. /**
  50136. * Gets the target of the compilation state
  50137. */
  50138. target: NodeMaterialBlockTargets;
  50139. /**
  50140. * Shared data between multiple NodeMaterialBuildState instances
  50141. */
  50142. sharedData: NodeMaterialBuildStateSharedData;
  50143. /** @hidden */
  50144. _vertexState: NodeMaterialBuildState;
  50145. private _attributeDeclaration;
  50146. private _uniformDeclaration;
  50147. private _samplerDeclaration;
  50148. private _varyingTransfer;
  50149. private _repeatableContentAnchorIndex;
  50150. /** @hidden */
  50151. _builtCompilationString: string;
  50152. /**
  50153. * Gets the emitted compilation strings
  50154. */
  50155. compilationString: string;
  50156. /**
  50157. * Finalize the compilation strings
  50158. * @param state defines the current compilation state
  50159. */
  50160. finalize(state: NodeMaterialBuildState): void;
  50161. /** @hidden */
  50162. readonly _repeatableContentAnchor: string;
  50163. /** @hidden */
  50164. _getFreeVariableName(prefix: string): string;
  50165. /** @hidden */
  50166. _getFreeDefineName(prefix: string): string;
  50167. /** @hidden */
  50168. _excludeVariableName(name: string): void;
  50169. /** @hidden */
  50170. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  50171. /** @hidden */
  50172. _emitFunction(name: string, code: string, comments: string): void;
  50173. /** @hidden */
  50174. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  50175. replaceStrings?: {
  50176. search: RegExp;
  50177. replace: string;
  50178. }[];
  50179. }): string;
  50180. /** @hidden */
  50181. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  50182. repeatKey?: string;
  50183. removeAttributes?: boolean;
  50184. removeUniforms?: boolean;
  50185. removeVaryings?: boolean;
  50186. removeIfDef?: boolean;
  50187. replaceStrings?: {
  50188. search: RegExp;
  50189. replace: string;
  50190. }[];
  50191. }): void;
  50192. /** @hidden */
  50193. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string): void;
  50194. private _emitDefine;
  50195. /** @hidden */
  50196. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  50197. }
  50198. }
  50199. declare module BABYLON {
  50200. /**
  50201. * Root class for all node material optimizers
  50202. */
  50203. export class NodeMaterialOptimizer {
  50204. /**
  50205. * Function used to optimize a NodeMaterial graph
  50206. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  50207. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  50208. */
  50209. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  50210. }
  50211. }
  50212. declare module BABYLON {
  50213. /**
  50214. * Interface used to configure the node material editor
  50215. */
  50216. export interface INodeMaterialEditorOptions {
  50217. /** Define the URl to load node editor script */
  50218. editorURL?: string;
  50219. }
  50220. /** @hidden */
  50221. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  50222. /** BONES */
  50223. NUM_BONE_INFLUENCERS: number;
  50224. BonesPerMesh: number;
  50225. BONETEXTURE: boolean;
  50226. /** MORPH TARGETS */
  50227. MORPHTARGETS: boolean;
  50228. MORPHTARGETS_NORMAL: boolean;
  50229. MORPHTARGETS_TANGENT: boolean;
  50230. NUM_MORPH_INFLUENCERS: number;
  50231. /** IMAGE PROCESSING */
  50232. IMAGEPROCESSING: boolean;
  50233. VIGNETTE: boolean;
  50234. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50235. VIGNETTEBLENDMODEOPAQUE: boolean;
  50236. TONEMAPPING: boolean;
  50237. TONEMAPPING_ACES: boolean;
  50238. CONTRAST: boolean;
  50239. EXPOSURE: boolean;
  50240. COLORCURVES: boolean;
  50241. COLORGRADING: boolean;
  50242. COLORGRADING3D: boolean;
  50243. SAMPLER3DGREENDEPTH: boolean;
  50244. SAMPLER3DBGRMAP: boolean;
  50245. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50246. constructor();
  50247. setValue(name: string, value: boolean): void;
  50248. }
  50249. /**
  50250. * Class used to configure NodeMaterial
  50251. */
  50252. export interface INodeMaterialOptions {
  50253. /**
  50254. * Defines if blocks should emit comments
  50255. */
  50256. emitComments: boolean;
  50257. }
  50258. /**
  50259. * Class used to create a node based material built by assembling shader blocks
  50260. */
  50261. export class NodeMaterial extends PushMaterial {
  50262. private _options;
  50263. private _vertexCompilationState;
  50264. private _fragmentCompilationState;
  50265. private _sharedData;
  50266. private _buildId;
  50267. private _buildWasSuccessful;
  50268. private _cachedWorldViewMatrix;
  50269. private _cachedWorldViewProjectionMatrix;
  50270. private _textureConnectionPoints;
  50271. private _optimizers;
  50272. /** Define the URl to load node editor script */
  50273. static EditorURL: string;
  50274. private BJSNODEMATERIALEDITOR;
  50275. /** Get the inspector from bundle or global */
  50276. private _getGlobalNodeMaterialEditor;
  50277. /**
  50278. * Defines the maximum number of lights that can be used in the material
  50279. */
  50280. maxSimultaneousLights: number;
  50281. /**
  50282. * Observable raised when the material is built
  50283. */
  50284. onBuildObservable: Observable<NodeMaterial>;
  50285. /**
  50286. * Gets or sets the root nodes of the material vertex shader
  50287. */
  50288. _vertexOutputNodes: NodeMaterialBlock[];
  50289. /**
  50290. * Gets or sets the root nodes of the material fragment (pixel) shader
  50291. */
  50292. _fragmentOutputNodes: NodeMaterialBlock[];
  50293. /** Gets or sets options to control the node material overall behavior */
  50294. options: INodeMaterialOptions;
  50295. /**
  50296. * Default configuration related to image processing available in the standard Material.
  50297. */
  50298. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50299. /**
  50300. * Gets the image processing configuration used either in this material.
  50301. */
  50302. /**
  50303. * Sets the Default image processing configuration used either in the this material.
  50304. *
  50305. * If sets to null, the scene one is in use.
  50306. */
  50307. imageProcessingConfiguration: ImageProcessingConfiguration;
  50308. /**
  50309. * Create a new node based material
  50310. * @param name defines the material name
  50311. * @param scene defines the hosting scene
  50312. * @param options defines creation option
  50313. */
  50314. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  50315. /**
  50316. * Gets the current class name of the material e.g. "NodeMaterial"
  50317. * @returns the class name
  50318. */
  50319. getClassName(): string;
  50320. /**
  50321. * Keep track of the image processing observer to allow dispose and replace.
  50322. */
  50323. private _imageProcessingObserver;
  50324. /**
  50325. * Attaches a new image processing configuration to the Standard Material.
  50326. * @param configuration
  50327. */
  50328. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50329. /**
  50330. * Adds a new optimizer to the list of optimizers
  50331. * @param optimizer defines the optimizers to add
  50332. * @returns the current material
  50333. */
  50334. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  50335. /**
  50336. * Remove an optimizer from the list of optimizers
  50337. * @param optimizer defines the optimizers to remove
  50338. * @returns the current material
  50339. */
  50340. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  50341. /**
  50342. * Add a new block to the list of output nodes
  50343. * @param node defines the node to add
  50344. * @returns the current material
  50345. */
  50346. addOutputNode(node: NodeMaterialBlock): this;
  50347. /**
  50348. * Remove a block from the list of root nodes
  50349. * @param node defines the node to remove
  50350. * @returns the current material
  50351. */
  50352. removeOutputNode(node: NodeMaterialBlock): this;
  50353. private _addVertexOutputNode;
  50354. private _removeVertexOutputNode;
  50355. private _addFragmentOutputNode;
  50356. private _removeFragmentOutputNode;
  50357. /**
  50358. * Specifies if the material will require alpha blending
  50359. * @returns a boolean specifying if alpha blending is needed
  50360. */
  50361. needAlphaBlending(): boolean;
  50362. /**
  50363. * Specifies if this material should be rendered in alpha test mode
  50364. * @returns a boolean specifying if an alpha test is needed.
  50365. */
  50366. needAlphaTesting(): boolean;
  50367. private _initializeBlock;
  50368. private _resetDualBlocks;
  50369. /**
  50370. * Build the material and generates the inner effect
  50371. * @param verbose defines if the build should log activity
  50372. */
  50373. build(verbose?: boolean): void;
  50374. /**
  50375. * Runs an otpimization phase to try to improve the shader code
  50376. */
  50377. optimize(): void;
  50378. private _prepareDefinesForAttributes;
  50379. /**
  50380. * Get if the submesh is ready to be used and all its information available.
  50381. * Child classes can use it to update shaders
  50382. * @param mesh defines the mesh to check
  50383. * @param subMesh defines which submesh to check
  50384. * @param useInstances specifies that instances should be used
  50385. * @returns a boolean indicating that the submesh is ready or not
  50386. */
  50387. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50388. /**
  50389. * Binds the world matrix to the material
  50390. * @param world defines the world transformation matrix
  50391. */
  50392. bindOnlyWorldMatrix(world: Matrix): void;
  50393. /**
  50394. * Binds the submesh to this material by preparing the effect and shader to draw
  50395. * @param world defines the world transformation matrix
  50396. * @param mesh defines the mesh containing the submesh
  50397. * @param subMesh defines the submesh to bind the material to
  50398. */
  50399. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50400. /**
  50401. * Gets the active textures from the material
  50402. * @returns an array of textures
  50403. */
  50404. getActiveTextures(): BaseTexture[];
  50405. /**
  50406. * Specifies if the material uses a texture
  50407. * @param texture defines the texture to check against the material
  50408. * @returns a boolean specifying if the material uses the texture
  50409. */
  50410. hasTexture(texture: BaseTexture): boolean;
  50411. /**
  50412. * Disposes the material
  50413. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  50414. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  50415. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  50416. */
  50417. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  50418. /** Creates the node editor window. */
  50419. private _createNodeEditor;
  50420. /**
  50421. * Launch the node material editor
  50422. * @param config Define the configuration of the editor
  50423. * @return a promise fulfilled when the node editor is visible
  50424. */
  50425. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  50426. }
  50427. }
  50428. declare module BABYLON {
  50429. /**
  50430. * Defines a block that can be used inside a node based material
  50431. */
  50432. export class NodeMaterialBlock {
  50433. private _buildId;
  50434. private _target;
  50435. private _isFinalMerger;
  50436. /** @hidden */
  50437. _inputs: NodeMaterialConnectionPoint[];
  50438. /** @hidden */
  50439. _outputs: NodeMaterialConnectionPoint[];
  50440. /**
  50441. * Gets or sets the name of the block
  50442. */
  50443. name: string;
  50444. /**
  50445. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  50446. */
  50447. readonly isFinalMerger: boolean;
  50448. /**
  50449. * Gets or sets the build Id
  50450. */
  50451. buildId: number;
  50452. /**
  50453. * Gets or sets the target of the block
  50454. */
  50455. target: NodeMaterialBlockTargets;
  50456. /**
  50457. * Gets the list of input points
  50458. */
  50459. readonly inputs: NodeMaterialConnectionPoint[];
  50460. /** Gets the list of output points */
  50461. readonly outputs: NodeMaterialConnectionPoint[];
  50462. /**
  50463. * Find an input by its name
  50464. * @param name defines the name of the input to look for
  50465. * @returns the input or null if not found
  50466. */
  50467. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  50468. /**
  50469. * Find an output by its name
  50470. * @param name defines the name of the outputto look for
  50471. * @returns the output or null if not found
  50472. */
  50473. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  50474. /**
  50475. * Creates a new NodeMaterialBlock
  50476. * @param name defines the block name
  50477. * @param target defines the target of that block (Vertex by default)
  50478. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  50479. */
  50480. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  50481. /**
  50482. * Initialize the block and prepare the context for build
  50483. * @param state defines the state that will be used for the build
  50484. */
  50485. initialize(state: NodeMaterialBuildState): void;
  50486. /**
  50487. * Bind data to effect. Will only be called for blocks with isBindable === true
  50488. * @param effect defines the effect to bind data to
  50489. * @param nodeMaterial defines the hosting NodeMaterial
  50490. * @param mesh defines the mesh that will be rendered
  50491. */
  50492. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  50493. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  50494. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  50495. protected _writeFloat(value: number): string;
  50496. /**
  50497. * Gets the current class name e.g. "NodeMaterialBlock"
  50498. * @returns the class name
  50499. */
  50500. getClassName(): string;
  50501. /**
  50502. * Register a new input. Must be called inside a block constructor
  50503. * @param name defines the connection point name
  50504. * @param type defines the connection point type
  50505. * @param isOptional defines a boolean indicating that this input can be omitted
  50506. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  50507. * @returns the current block
  50508. */
  50509. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  50510. /**
  50511. * Register a new output. Must be called inside a block constructor
  50512. * @param name defines the connection point name
  50513. * @param type defines the connection point type
  50514. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  50515. * @returns the current block
  50516. */
  50517. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  50518. /**
  50519. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  50520. * @param forOutput defines an optional connection point to check compatibility with
  50521. * @returns the first available input or null
  50522. */
  50523. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  50524. /**
  50525. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  50526. * @param forBlock defines an optional block to check compatibility with
  50527. * @returns the first available input or null
  50528. */
  50529. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  50530. /**
  50531. * Connect current block with another block
  50532. * @param other defines the block to connect with
  50533. * @param options define the various options to help pick the right connections
  50534. * @returns the current block
  50535. */
  50536. connectTo(other: NodeMaterialBlock, options?: {
  50537. input?: string;
  50538. output?: string;
  50539. outputSwizzle?: string;
  50540. }): this | undefined;
  50541. protected _buildBlock(state: NodeMaterialBuildState): void;
  50542. /**
  50543. * Add potential fallbacks if shader compilation fails
  50544. * @param mesh defines the mesh to be rendered
  50545. * @param fallbacks defines the current prioritized list of fallbacks
  50546. */
  50547. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  50548. /**
  50549. * Update defines for shader compilation
  50550. * @param mesh defines the mesh to be rendered
  50551. * @param nodeMaterial defines the node material requesting the update
  50552. * @param defines defines the material defines to update
  50553. * @param useInstances specifies that instances should be used
  50554. */
  50555. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  50556. /**
  50557. * Lets the block try to connect some inputs automatically
  50558. */
  50559. autoConfigure(): void;
  50560. /**
  50561. * Function called when a block is declared as repeatable content generator
  50562. * @param vertexShaderState defines the current compilation state for the vertex shader
  50563. * @param fragmentShaderState defines the current compilation state for the fragment shader
  50564. * @param mesh defines the mesh to be rendered
  50565. * @param defines defines the material defines to update
  50566. */
  50567. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  50568. /**
  50569. * Checks if the block is ready
  50570. * @param mesh defines the mesh to be rendered
  50571. * @param nodeMaterial defines the node material requesting the update
  50572. * @param defines defines the material defines to update
  50573. * @param useInstances specifies that instances should be used
  50574. * @returns true if the block is ready
  50575. */
  50576. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  50577. /**
  50578. * Compile the current node and generate the shader code
  50579. * @param state defines the current compilation state (uniforms, samplers, current string)
  50580. * @returns the current block
  50581. */
  50582. build(state: NodeMaterialBuildState): this | undefined;
  50583. }
  50584. }
  50585. declare module BABYLON {
  50586. /**
  50587. * Defines a connection point for a block
  50588. */
  50589. export class NodeMaterialConnectionPoint {
  50590. /** @hidden */
  50591. _ownerBlock: NodeMaterialBlock;
  50592. /** @hidden */
  50593. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  50594. private _associatedVariableName;
  50595. private _endpoints;
  50596. private _storedValue;
  50597. private _valueCallback;
  50598. private _isVarying;
  50599. /** @hidden */
  50600. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  50601. /**
  50602. * Gets or sets the connection point type (default is float)
  50603. */
  50604. type: NodeMaterialBlockConnectionPointTypes;
  50605. /**
  50606. * Gets or sets the connection point name
  50607. */
  50608. name: string;
  50609. /**
  50610. * Gets or sets the swizzle to apply to this connection point when reading or writing
  50611. */
  50612. swizzle: string;
  50613. /**
  50614. * Gets or sets a boolean indicating that this connection point can be omitted
  50615. */
  50616. isOptional: boolean;
  50617. /**
  50618. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  50619. */
  50620. define: string;
  50621. /** Gets or sets the target of that connection point */
  50622. target: NodeMaterialBlockTargets;
  50623. /**
  50624. * Gets or sets the value of that point.
  50625. * Please note that this value will be ignored if valueCallback is defined
  50626. */
  50627. value: any;
  50628. /**
  50629. * Gets or sets a callback used to get the value of that point.
  50630. * Please note that setting this value will force the connection point to ignore the value property
  50631. */
  50632. valueCallback: () => any;
  50633. /**
  50634. * Gets or sets the associated variable name in the shader
  50635. */
  50636. associatedVariableName: string;
  50637. /**
  50638. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  50639. * In this case the connection point name must be the name of the uniform to use.
  50640. * Can only be set on inputs
  50641. */
  50642. isUniform: boolean;
  50643. /**
  50644. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  50645. * In this case the connection point name must be the name of the attribute to use
  50646. * Can only be set on inputs
  50647. */
  50648. isAttribute: boolean;
  50649. /**
  50650. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  50651. * Can only be set on exit points
  50652. */
  50653. isVarying: boolean;
  50654. /** Get the other side of the connection (if any) */
  50655. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  50656. /** Get the block that owns this connection point */
  50657. readonly ownerBlock: NodeMaterialBlock;
  50658. /** Get the block connected on the other side of this connection (if any) */
  50659. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  50660. /** Get the block connected on the endpoints of this connection (if any) */
  50661. readonly connectedBlocks: Array<NodeMaterialBlock>;
  50662. /**
  50663. * Creates a new connection point
  50664. * @param name defines the connection point name
  50665. * @param ownerBlock defines the block hosting this connection point
  50666. */
  50667. constructor(name: string, ownerBlock: NodeMaterialBlock);
  50668. /**
  50669. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  50670. * @returns the class name
  50671. */
  50672. getClassName(): string;
  50673. /**
  50674. * Set the source of this connection point to a vertex attribute
  50675. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  50676. * @returns the current connection point
  50677. */
  50678. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  50679. /**
  50680. * Set the source of this connection point to a well known value
  50681. * @param value define the well known value to use (world, view, etc...)
  50682. * @returns the current connection point
  50683. */
  50684. setAsWellKnownValue(value: NodeMaterialWellKnownValues): NodeMaterialConnectionPoint;
  50685. private _getTypeLength;
  50686. /**
  50687. * Connect this point to another connection point
  50688. * @param connectionPoint defines the other connection point
  50689. * @returns the current connection point
  50690. */
  50691. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  50692. /**
  50693. * Disconnect this point from one of his endpoint
  50694. * @param endpoint defines the other connection point
  50695. * @returns the current connection point
  50696. */
  50697. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  50698. /**
  50699. * When connection point is an uniform, this function will send its value to the effect
  50700. * @param effect defines the effect to transmit value to
  50701. * @param world defines the world matrix
  50702. * @param worldView defines the worldxview matrix
  50703. * @param worldViewProjection defines the worldxviewxprojection matrix
  50704. */
  50705. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  50706. /**
  50707. * When connection point is an uniform, this function will send its value to the effect
  50708. * @param effect defines the effect to transmit value to
  50709. * @param scene defines the hosting scene
  50710. */
  50711. transmit(effect: Effect, scene: Scene): void;
  50712. }
  50713. }
  50714. declare module BABYLON {
  50715. /**
  50716. * Block used to output the vertex position
  50717. */
  50718. export class VertexOutputBlock extends NodeMaterialBlock {
  50719. /**
  50720. * Creates a new VertexOutputBlock
  50721. * @param name defines the block name
  50722. */
  50723. constructor(name: string);
  50724. /**
  50725. * Gets the current class name
  50726. * @returns the class name
  50727. */
  50728. getClassName(): string;
  50729. /**
  50730. * Gets the vector input component
  50731. */
  50732. readonly vector: NodeMaterialConnectionPoint;
  50733. protected _buildBlock(state: NodeMaterialBuildState): this;
  50734. }
  50735. }
  50736. declare module BABYLON {
  50737. /**
  50738. * Block used to add support for vertex skinning (bones)
  50739. */
  50740. export class BonesBlock extends NodeMaterialBlock {
  50741. /**
  50742. * Creates a new BonesBlock
  50743. * @param name defines the block name
  50744. */
  50745. constructor(name: string);
  50746. /**
  50747. * Initialize the block and prepare the context for build
  50748. * @param state defines the state that will be used for the build
  50749. */
  50750. initialize(state: NodeMaterialBuildState): void;
  50751. /**
  50752. * Gets the current class name
  50753. * @returns the class name
  50754. */
  50755. getClassName(): string;
  50756. /**
  50757. * Gets the matrix indices input component
  50758. */
  50759. readonly matricesIndices: NodeMaterialConnectionPoint;
  50760. /**
  50761. * Gets the matrix weights input component
  50762. */
  50763. readonly matricesWeights: NodeMaterialConnectionPoint;
  50764. /**
  50765. * Gets the extra matrix indices input component
  50766. */
  50767. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  50768. /**
  50769. * Gets the extra matrix weights input component
  50770. */
  50771. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  50772. /**
  50773. * Gets the world input component
  50774. */
  50775. readonly world: NodeMaterialConnectionPoint;
  50776. autoConfigure(): void;
  50777. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  50778. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  50779. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  50780. protected _buildBlock(state: NodeMaterialBuildState): this;
  50781. }
  50782. }
  50783. declare module BABYLON {
  50784. /**
  50785. * Block used to add support for instances
  50786. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  50787. */
  50788. export class InstancesBlock extends NodeMaterialBlock {
  50789. /**
  50790. * Creates a new InstancesBlock
  50791. * @param name defines the block name
  50792. */
  50793. constructor(name: string);
  50794. /**
  50795. * Gets the current class name
  50796. * @returns the class name
  50797. */
  50798. getClassName(): string;
  50799. /**
  50800. * Gets the first world row input component
  50801. */
  50802. readonly world0: NodeMaterialConnectionPoint;
  50803. /**
  50804. * Gets the second world row input component
  50805. */
  50806. readonly world1: NodeMaterialConnectionPoint;
  50807. /**
  50808. * Gets the third world row input component
  50809. */
  50810. readonly world2: NodeMaterialConnectionPoint;
  50811. /**
  50812. * Gets the forth world row input component
  50813. */
  50814. readonly world3: NodeMaterialConnectionPoint;
  50815. /**
  50816. * Gets the world input component
  50817. */
  50818. readonly world: NodeMaterialConnectionPoint;
  50819. /**
  50820. * Gets the output component
  50821. */
  50822. readonly output: NodeMaterialConnectionPoint;
  50823. autoConfigure(): void;
  50824. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  50825. protected _buildBlock(state: NodeMaterialBuildState): this;
  50826. }
  50827. }
  50828. declare module BABYLON {
  50829. /**
  50830. * Block used to add morph targets support to vertex shader
  50831. */
  50832. export class MorphTargetsBlock extends NodeMaterialBlock {
  50833. private _repeatableContentAnchor;
  50834. private _repeatebleContentGenerated;
  50835. /**
  50836. * Create a new MorphTargetsBlock
  50837. * @param name defines the block name
  50838. */
  50839. constructor(name: string);
  50840. /**
  50841. * Gets the current class name
  50842. * @returns the class name
  50843. */
  50844. getClassName(): string;
  50845. /**
  50846. * Gets the position input component
  50847. */
  50848. readonly position: NodeMaterialConnectionPoint;
  50849. /**
  50850. * Gets the normal input component
  50851. */
  50852. readonly normal: NodeMaterialConnectionPoint;
  50853. /**
  50854. * Gets the tangent input component
  50855. */
  50856. readonly tangent: NodeMaterialConnectionPoint;
  50857. /**
  50858. * Gets the position output component
  50859. */
  50860. readonly positionOutput: NodeMaterialConnectionPoint;
  50861. /**
  50862. * Gets the normal output component
  50863. */
  50864. readonly normalOutput: NodeMaterialConnectionPoint;
  50865. /**
  50866. * Gets the tangent output component
  50867. */
  50868. readonly tangentOutput: NodeMaterialConnectionPoint;
  50869. initialize(state: NodeMaterialBuildState): void;
  50870. autoConfigure(): void;
  50871. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  50872. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  50873. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  50874. protected _buildBlock(state: NodeMaterialBuildState): this;
  50875. }
  50876. }
  50877. declare module BABYLON {
  50878. /**
  50879. * Block used to output the final color
  50880. */
  50881. export class FragmentOutputBlock extends NodeMaterialBlock {
  50882. /**
  50883. * Gets or sets a boolean indicating if this block will output an alpha value
  50884. */
  50885. alphaBlendingEnabled: boolean;
  50886. /**
  50887. * Create a new FragmentOutputBlock
  50888. * @param name defines the block name
  50889. */
  50890. constructor(name: string);
  50891. /**
  50892. * Gets the current class name
  50893. * @returns the class name
  50894. */
  50895. getClassName(): string;
  50896. /**
  50897. * Gets the color input component
  50898. */
  50899. readonly color: NodeMaterialConnectionPoint;
  50900. protected _buildBlock(state: NodeMaterialBuildState): this;
  50901. }
  50902. }
  50903. declare module BABYLON {
  50904. /**
  50905. * Block used to add an alpha test in the fragment shader
  50906. */
  50907. export class AlphaTestBlock extends NodeMaterialBlock {
  50908. /**
  50909. * Gets or sets the alpha value where alpha testing happens
  50910. */
  50911. alphaCutOff: number;
  50912. /**
  50913. * Create a new AlphaTestBlock
  50914. * @param name defines the block name
  50915. */
  50916. constructor(name: string);
  50917. /**
  50918. * Gets the current class name
  50919. * @returns the class name
  50920. */
  50921. getClassName(): string;
  50922. /**
  50923. * Gets the color input component
  50924. */
  50925. readonly color: NodeMaterialConnectionPoint;
  50926. protected _buildBlock(state: NodeMaterialBuildState): this;
  50927. }
  50928. }
  50929. declare module BABYLON {
  50930. /**
  50931. * Block used to create a Color4 out of 4 inputs (one for each component)
  50932. */
  50933. export class RGBAMergerBlock extends NodeMaterialBlock {
  50934. /**
  50935. * Create a new RGBAMergerBlock
  50936. * @param name defines the block name
  50937. */
  50938. constructor(name: string);
  50939. /**
  50940. * Gets the current class name
  50941. * @returns the class name
  50942. */
  50943. getClassName(): string;
  50944. /**
  50945. * Gets the R input component
  50946. */
  50947. readonly r: NodeMaterialConnectionPoint;
  50948. /**
  50949. * Gets the G input component
  50950. */
  50951. readonly g: NodeMaterialConnectionPoint;
  50952. /**
  50953. * Gets the B input component
  50954. */
  50955. readonly b: NodeMaterialConnectionPoint;
  50956. /**
  50957. * Gets the RGB input component
  50958. */
  50959. readonly rgb: NodeMaterialConnectionPoint;
  50960. /**
  50961. * Gets the R input component
  50962. */
  50963. readonly a: NodeMaterialConnectionPoint;
  50964. protected _buildBlock(state: NodeMaterialBuildState): this;
  50965. }
  50966. }
  50967. declare module BABYLON {
  50968. /**
  50969. * Block used to create a Color3 out of 3 inputs (one for each component)
  50970. */
  50971. export class RGBMergerBlock extends NodeMaterialBlock {
  50972. /**
  50973. * Create a new RGBMergerBlock
  50974. * @param name defines the block name
  50975. */
  50976. constructor(name: string);
  50977. /**
  50978. * Gets the current class name
  50979. * @returns the class name
  50980. */
  50981. getClassName(): string;
  50982. /**
  50983. * Gets the R component input
  50984. */
  50985. readonly r: NodeMaterialConnectionPoint;
  50986. /**
  50987. * Gets the G component input
  50988. */
  50989. readonly g: NodeMaterialConnectionPoint;
  50990. /**
  50991. * Gets the B component input
  50992. */
  50993. readonly b: NodeMaterialConnectionPoint;
  50994. protected _buildBlock(state: NodeMaterialBuildState): this;
  50995. }
  50996. }
  50997. declare module BABYLON {
  50998. /**
  50999. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  51000. */
  51001. export class RGBASplitterBlock extends NodeMaterialBlock {
  51002. /**
  51003. * Create a new RGBASplitterBlock
  51004. * @param name defines the block name
  51005. */
  51006. constructor(name: string);
  51007. /**
  51008. * Gets the current class name
  51009. * @returns the class name
  51010. */
  51011. getClassName(): string;
  51012. /**
  51013. * Gets the input component
  51014. */
  51015. readonly input: NodeMaterialConnectionPoint;
  51016. protected _buildBlock(state: NodeMaterialBuildState): this;
  51017. }
  51018. }
  51019. declare module BABYLON {
  51020. /**
  51021. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  51022. */
  51023. export class RGBSplitterBlock extends NodeMaterialBlock {
  51024. /**
  51025. * Create a new RGBSplitterBlock
  51026. * @param name defines the block name
  51027. */
  51028. constructor(name: string);
  51029. /**
  51030. * Gets the current class name
  51031. * @returns the class name
  51032. */
  51033. getClassName(): string;
  51034. /**
  51035. * Gets the input component
  51036. */
  51037. readonly input: NodeMaterialConnectionPoint;
  51038. protected _buildBlock(state: NodeMaterialBuildState): this;
  51039. }
  51040. }
  51041. declare module BABYLON {
  51042. /**
  51043. * Block used to read a texture from a sampler
  51044. */
  51045. export class TextureBlock extends NodeMaterialBlock {
  51046. private _defineName;
  51047. /**
  51048. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  51049. */
  51050. autoConnectTextureMatrix: boolean;
  51051. /**
  51052. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  51053. */
  51054. autoSelectUV: boolean;
  51055. /**
  51056. * Create a new TextureBlock
  51057. * @param name defines the block name
  51058. */
  51059. constructor(name: string);
  51060. /**
  51061. * Gets the current class name
  51062. * @returns the class name
  51063. */
  51064. getClassName(): string;
  51065. /**
  51066. * Gets the uv input component
  51067. */
  51068. readonly uv: NodeMaterialConnectionPoint;
  51069. /**
  51070. * Gets the texture information input component
  51071. */
  51072. readonly textureInfo: NodeMaterialConnectionPoint;
  51073. /**
  51074. * Gets the transformed uv input component
  51075. */
  51076. readonly transformedUV: NodeMaterialConnectionPoint;
  51077. /**
  51078. * Gets the texture input component
  51079. */
  51080. readonly texture: NodeMaterialConnectionPoint;
  51081. /**
  51082. * Gets the texture transform input component
  51083. */
  51084. readonly textureTransform: NodeMaterialConnectionPoint;
  51085. autoConfigure(): void;
  51086. initialize(state: NodeMaterialBuildState): void;
  51087. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51088. isReady(): boolean;
  51089. private _injectVertexCode;
  51090. protected _buildBlock(state: NodeMaterialBuildState): this;
  51091. }
  51092. }
  51093. declare module BABYLON {
  51094. /**
  51095. * Block used to add image processing support to fragment shader
  51096. */
  51097. export class ImageProcessingBlock extends NodeMaterialBlock {
  51098. /**
  51099. * Create a new ImageProcessingBlock
  51100. * @param name defines the block name
  51101. */
  51102. constructor(name: string);
  51103. /**
  51104. * Gets the current class name
  51105. * @returns the class name
  51106. */
  51107. getClassName(): string;
  51108. /**
  51109. * Gets the color input component
  51110. */
  51111. readonly color: NodeMaterialConnectionPoint;
  51112. /**
  51113. * Initialize the block and prepare the context for build
  51114. * @param state defines the state that will be used for the build
  51115. */
  51116. initialize(state: NodeMaterialBuildState): void;
  51117. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  51118. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51119. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51120. protected _buildBlock(state: NodeMaterialBuildState): this;
  51121. }
  51122. }
  51123. declare module BABYLON {
  51124. /**
  51125. * Block used to add support for scene fog
  51126. */
  51127. export class FogBlock extends NodeMaterialBlock {
  51128. /**
  51129. * Create a new FogBlock
  51130. * @param name defines the block name
  51131. */
  51132. constructor(name: string);
  51133. /**
  51134. * Gets the current class name
  51135. * @returns the class name
  51136. */
  51137. getClassName(): string;
  51138. /**
  51139. * Gets the world position input component
  51140. */
  51141. readonly worldPosition: NodeMaterialConnectionPoint;
  51142. /**
  51143. * Gets the view input component
  51144. */
  51145. readonly view: NodeMaterialConnectionPoint;
  51146. /**
  51147. * Gets the color input component
  51148. */
  51149. readonly color: NodeMaterialConnectionPoint;
  51150. /**
  51151. * Gets the fog color input component
  51152. */
  51153. readonly fogColor: NodeMaterialConnectionPoint;
  51154. /**
  51155. * Gets the for parameter input component
  51156. */
  51157. readonly fogParameters: NodeMaterialConnectionPoint;
  51158. autoConfigure(): void;
  51159. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51160. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51161. protected _buildBlock(state: NodeMaterialBuildState): this;
  51162. }
  51163. }
  51164. declare module BABYLON {
  51165. /**
  51166. * Block used to multiply 2 vector4
  51167. */
  51168. export class MultiplyBlock extends NodeMaterialBlock {
  51169. /**
  51170. * Creates a new MultiplyBlock
  51171. * @param name defines the block name
  51172. */
  51173. constructor(name: string);
  51174. /**
  51175. * Gets the current class name
  51176. * @returns the class name
  51177. */
  51178. getClassName(): string;
  51179. /**
  51180. * Gets the left operand input component
  51181. */
  51182. readonly left: NodeMaterialConnectionPoint;
  51183. /**
  51184. * Gets the right operand input component
  51185. */
  51186. readonly right: NodeMaterialConnectionPoint;
  51187. protected _buildBlock(state: NodeMaterialBuildState): this;
  51188. }
  51189. }
  51190. declare module BABYLON {
  51191. /**
  51192. * Block used to add 2 vector4
  51193. */
  51194. export class AddBlock extends NodeMaterialBlock {
  51195. /**
  51196. * Creates a new AddBlock
  51197. * @param name defines the block name
  51198. */
  51199. constructor(name: string);
  51200. /**
  51201. * Gets the current class name
  51202. * @returns the class name
  51203. */
  51204. getClassName(): string;
  51205. /**
  51206. * Gets the left operand input component
  51207. */
  51208. readonly left: NodeMaterialConnectionPoint;
  51209. /**
  51210. * Gets the right operand input component
  51211. */
  51212. readonly right: NodeMaterialConnectionPoint;
  51213. protected _buildBlock(state: NodeMaterialBuildState): this;
  51214. }
  51215. }
  51216. declare module BABYLON {
  51217. /**
  51218. * Block used to clamp a float
  51219. */
  51220. export class ClampBlock extends NodeMaterialBlock {
  51221. /** Gets or sets the minimum range */
  51222. minimum: number;
  51223. /** Gets or sets the maximum range */
  51224. maximum: number;
  51225. /**
  51226. * Creates a new ClampBlock
  51227. * @param name defines the block name
  51228. */
  51229. constructor(name: string);
  51230. /**
  51231. * Gets the current class name
  51232. * @returns the class name
  51233. */
  51234. getClassName(): string;
  51235. /**
  51236. * Gets the value input component
  51237. */
  51238. readonly value: NodeMaterialConnectionPoint;
  51239. protected _buildBlock(state: NodeMaterialBuildState): this;
  51240. }
  51241. }
  51242. declare module BABYLON {
  51243. /**
  51244. * Block used to transform a vector2 with a matrix
  51245. */
  51246. export class Vector2TransformBlock extends NodeMaterialBlock {
  51247. /**
  51248. * Defines the value to use to complement Vector2 to transform it to a Vector4
  51249. */
  51250. complementZ: number;
  51251. /**
  51252. * Defines the value to use to complement Vector2 to transform it to a Vector4
  51253. */
  51254. complementW: number;
  51255. /**
  51256. * Creates a new Vector2TransformBlock
  51257. * @param name defines the block name
  51258. */
  51259. constructor(name: string);
  51260. /**
  51261. * Gets the vector input
  51262. */
  51263. readonly vector: NodeMaterialConnectionPoint;
  51264. /**
  51265. * Gets the matrix transform input
  51266. */
  51267. readonly transform: NodeMaterialConnectionPoint;
  51268. /**
  51269. * Gets the current class name
  51270. * @returns the class name
  51271. */
  51272. getClassName(): string;
  51273. protected _buildBlock(state: NodeMaterialBuildState): this;
  51274. }
  51275. }
  51276. declare module BABYLON {
  51277. /**
  51278. * Block used to transform a vector3 with a matrix
  51279. */
  51280. export class Vector3TransformBlock extends NodeMaterialBlock {
  51281. /**
  51282. * Defines the value to use to complement Vector3 to transform it to a Vector4
  51283. */
  51284. complement: number;
  51285. /**
  51286. * Creates a new Vector3TransformBlock
  51287. * @param name defines the block name
  51288. */
  51289. constructor(name: string);
  51290. /**
  51291. * Gets the vector input
  51292. */
  51293. readonly vector: NodeMaterialConnectionPoint;
  51294. /**
  51295. * Gets the matrix transform input
  51296. */
  51297. readonly transform: NodeMaterialConnectionPoint;
  51298. /**
  51299. * Gets the current class name
  51300. * @returns the class name
  51301. */
  51302. getClassName(): string;
  51303. protected _buildBlock(state: NodeMaterialBuildState): this;
  51304. }
  51305. }
  51306. declare module BABYLON {
  51307. /**
  51308. * Block used to transform a vector4 with a matrix
  51309. */
  51310. export class Vector4TransformBlock extends NodeMaterialBlock {
  51311. /**
  51312. * Defines the value to use to complement Vector3 to transform it to a Vector4
  51313. */
  51314. complementW: number;
  51315. /**
  51316. * Creates a new Vector4TransformBlock
  51317. * @param name defines the block name
  51318. */
  51319. constructor(name: string);
  51320. /**
  51321. * Gets the current class name
  51322. * @returns the class name
  51323. */
  51324. getClassName(): string;
  51325. /**
  51326. * Gets the vector input
  51327. */
  51328. readonly vector: NodeMaterialConnectionPoint;
  51329. /**
  51330. * Gets the matrix transform input
  51331. */
  51332. readonly transform: NodeMaterialConnectionPoint;
  51333. protected _buildBlock(state: NodeMaterialBuildState): this;
  51334. }
  51335. }
  51336. declare module BABYLON {
  51337. /**
  51338. * Block used to multiply two matrices
  51339. */
  51340. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  51341. /**
  51342. * Creates a new MatrixMultiplicationBlock
  51343. * @param name defines the block name
  51344. */
  51345. constructor(name: string);
  51346. /**
  51347. * Gets the left operand
  51348. */
  51349. readonly left: NodeMaterialConnectionPoint;
  51350. /**
  51351. * Gets the right operand
  51352. */
  51353. readonly right: NodeMaterialConnectionPoint;
  51354. /**
  51355. * Gets the current class name
  51356. * @returns the class name
  51357. */
  51358. getClassName(): string;
  51359. protected _buildBlock(state: NodeMaterialBuildState): this;
  51360. }
  51361. }
  51362. declare module BABYLON {
  51363. /**
  51364. * Helper class to push actions to a pool of workers.
  51365. */
  51366. export class WorkerPool implements IDisposable {
  51367. private _workerInfos;
  51368. private _pendingActions;
  51369. /**
  51370. * Constructor
  51371. * @param workers Array of workers to use for actions
  51372. */
  51373. constructor(workers: Array<Worker>);
  51374. /**
  51375. * Terminates all workers and clears any pending actions.
  51376. */
  51377. dispose(): void;
  51378. /**
  51379. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51380. * pended until a worker has completed its action.
  51381. * @param action The action to perform. Call onComplete when the action is complete.
  51382. */
  51383. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51384. private _execute;
  51385. }
  51386. }
  51387. declare module BABYLON {
  51388. /**
  51389. * Configuration for Draco compression
  51390. */
  51391. export interface IDracoCompressionConfiguration {
  51392. /**
  51393. * Configuration for the decoder.
  51394. */
  51395. decoder: {
  51396. /**
  51397. * The url to the WebAssembly module.
  51398. */
  51399. wasmUrl?: string;
  51400. /**
  51401. * The url to the WebAssembly binary.
  51402. */
  51403. wasmBinaryUrl?: string;
  51404. /**
  51405. * The url to the fallback JavaScript module.
  51406. */
  51407. fallbackUrl?: string;
  51408. };
  51409. }
  51410. /**
  51411. * Draco compression (https://google.github.io/draco/)
  51412. *
  51413. * This class wraps the Draco module.
  51414. *
  51415. * **Encoder**
  51416. *
  51417. * The encoder is not currently implemented.
  51418. *
  51419. * **Decoder**
  51420. *
  51421. * 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.
  51422. *
  51423. * To update the configuration, use the following code:
  51424. * ```javascript
  51425. * DracoCompression.Configuration = {
  51426. * decoder: {
  51427. * wasmUrl: "<url to the WebAssembly library>",
  51428. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51429. * fallbackUrl: "<url to the fallback JavaScript library>",
  51430. * }
  51431. * };
  51432. * ```
  51433. *
  51434. * 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.
  51435. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51436. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  51437. *
  51438. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  51439. * ```javascript
  51440. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  51441. * ```
  51442. *
  51443. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  51444. */
  51445. export class DracoCompression implements IDisposable {
  51446. private _workerPoolPromise?;
  51447. private _decoderModulePromise?;
  51448. /**
  51449. * The configuration. Defaults to the following urls:
  51450. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  51451. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  51452. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  51453. */
  51454. static Configuration: IDracoCompressionConfiguration;
  51455. /**
  51456. * Returns true if the decoder configuration is available.
  51457. */
  51458. static readonly DecoderAvailable: boolean;
  51459. /**
  51460. * Default number of workers to create when creating the draco compression object.
  51461. */
  51462. static DefaultNumWorkers: number;
  51463. private static GetDefaultNumWorkers;
  51464. private static _Default;
  51465. /**
  51466. * Default instance for the draco compression object.
  51467. */
  51468. static readonly Default: DracoCompression;
  51469. /**
  51470. * Constructor
  51471. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  51472. */
  51473. constructor(numWorkers?: number);
  51474. /**
  51475. * Stop all async operations and release resources.
  51476. */
  51477. dispose(): void;
  51478. /**
  51479. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  51480. * @returns a promise that resolves when ready
  51481. */
  51482. whenReadyAsync(): Promise<void>;
  51483. /**
  51484. * Decode Draco compressed mesh data to vertex data.
  51485. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  51486. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  51487. * @returns A promise that resolves with the decoded vertex data
  51488. */
  51489. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  51490. [kind: string]: number;
  51491. }): Promise<VertexData>;
  51492. }
  51493. }
  51494. declare module BABYLON {
  51495. /**
  51496. * Class for building Constructive Solid Geometry
  51497. */
  51498. export class CSG {
  51499. private polygons;
  51500. /**
  51501. * The world matrix
  51502. */
  51503. matrix: Matrix;
  51504. /**
  51505. * Stores the position
  51506. */
  51507. position: Vector3;
  51508. /**
  51509. * Stores the rotation
  51510. */
  51511. rotation: Vector3;
  51512. /**
  51513. * Stores the rotation quaternion
  51514. */
  51515. rotationQuaternion: Nullable<Quaternion>;
  51516. /**
  51517. * Stores the scaling vector
  51518. */
  51519. scaling: Vector3;
  51520. /**
  51521. * Convert the Mesh to CSG
  51522. * @param mesh The Mesh to convert to CSG
  51523. * @returns A new CSG from the Mesh
  51524. */
  51525. static FromMesh(mesh: Mesh): CSG;
  51526. /**
  51527. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  51528. * @param polygons Polygons used to construct a CSG solid
  51529. */
  51530. private static FromPolygons;
  51531. /**
  51532. * Clones, or makes a deep copy, of the CSG
  51533. * @returns A new CSG
  51534. */
  51535. clone(): CSG;
  51536. /**
  51537. * Unions this CSG with another CSG
  51538. * @param csg The CSG to union against this CSG
  51539. * @returns The unioned CSG
  51540. */
  51541. union(csg: CSG): CSG;
  51542. /**
  51543. * Unions this CSG with another CSG in place
  51544. * @param csg The CSG to union against this CSG
  51545. */
  51546. unionInPlace(csg: CSG): void;
  51547. /**
  51548. * Subtracts this CSG with another CSG
  51549. * @param csg The CSG to subtract against this CSG
  51550. * @returns A new CSG
  51551. */
  51552. subtract(csg: CSG): CSG;
  51553. /**
  51554. * Subtracts this CSG with another CSG in place
  51555. * @param csg The CSG to subtact against this CSG
  51556. */
  51557. subtractInPlace(csg: CSG): void;
  51558. /**
  51559. * Intersect this CSG with another CSG
  51560. * @param csg The CSG to intersect against this CSG
  51561. * @returns A new CSG
  51562. */
  51563. intersect(csg: CSG): CSG;
  51564. /**
  51565. * Intersects this CSG with another CSG in place
  51566. * @param csg The CSG to intersect against this CSG
  51567. */
  51568. intersectInPlace(csg: CSG): void;
  51569. /**
  51570. * Return a new CSG solid with solid and empty space switched. This solid is
  51571. * not modified.
  51572. * @returns A new CSG solid with solid and empty space switched
  51573. */
  51574. inverse(): CSG;
  51575. /**
  51576. * Inverses the CSG in place
  51577. */
  51578. inverseInPlace(): void;
  51579. /**
  51580. * This is used to keep meshes transformations so they can be restored
  51581. * when we build back a Babylon Mesh
  51582. * NB : All CSG operations are performed in world coordinates
  51583. * @param csg The CSG to copy the transform attributes from
  51584. * @returns This CSG
  51585. */
  51586. copyTransformAttributes(csg: CSG): CSG;
  51587. /**
  51588. * Build Raw mesh from CSG
  51589. * Coordinates here are in world space
  51590. * @param name The name of the mesh geometry
  51591. * @param scene The Scene
  51592. * @param keepSubMeshes Specifies if the submeshes should be kept
  51593. * @returns A new Mesh
  51594. */
  51595. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  51596. /**
  51597. * Build Mesh from CSG taking material and transforms into account
  51598. * @param name The name of the Mesh
  51599. * @param material The material of the Mesh
  51600. * @param scene The Scene
  51601. * @param keepSubMeshes Specifies if submeshes should be kept
  51602. * @returns The new Mesh
  51603. */
  51604. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  51605. }
  51606. }
  51607. declare module BABYLON {
  51608. /**
  51609. * Class used to create a trail following a mesh
  51610. */
  51611. export class TrailMesh extends Mesh {
  51612. private _generator;
  51613. private _autoStart;
  51614. private _running;
  51615. private _diameter;
  51616. private _length;
  51617. private _sectionPolygonPointsCount;
  51618. private _sectionVectors;
  51619. private _sectionNormalVectors;
  51620. private _beforeRenderObserver;
  51621. /**
  51622. * @constructor
  51623. * @param name The value used by scene.getMeshByName() to do a lookup.
  51624. * @param generator The mesh to generate a trail.
  51625. * @param scene The scene to add this mesh to.
  51626. * @param diameter Diameter of trailing mesh. Default is 1.
  51627. * @param length Length of trailing mesh. Default is 60.
  51628. * @param autoStart Automatically start trailing mesh. Default true.
  51629. */
  51630. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  51631. /**
  51632. * "TrailMesh"
  51633. * @returns "TrailMesh"
  51634. */
  51635. getClassName(): string;
  51636. private _createMesh;
  51637. /**
  51638. * Start trailing mesh.
  51639. */
  51640. start(): void;
  51641. /**
  51642. * Stop trailing mesh.
  51643. */
  51644. stop(): void;
  51645. /**
  51646. * Update trailing mesh geometry.
  51647. */
  51648. update(): void;
  51649. /**
  51650. * Returns a new TrailMesh object.
  51651. * @param name is a string, the name given to the new mesh
  51652. * @param newGenerator use new generator object for cloned trail mesh
  51653. * @returns a new mesh
  51654. */
  51655. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  51656. /**
  51657. * Serializes this trail mesh
  51658. * @param serializationObject object to write serialization to
  51659. */
  51660. serialize(serializationObject: any): void;
  51661. /**
  51662. * Parses a serialized trail mesh
  51663. * @param parsedMesh the serialized mesh
  51664. * @param scene the scene to create the trail mesh in
  51665. * @returns the created trail mesh
  51666. */
  51667. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  51668. }
  51669. }
  51670. declare module BABYLON {
  51671. /**
  51672. * Class containing static functions to help procedurally build meshes
  51673. */
  51674. export class TiledBoxBuilder {
  51675. /**
  51676. * Creates a box mesh
  51677. * 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)
  51678. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51680. * * 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
  51681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51682. * @param name defines the name of the mesh
  51683. * @param options defines the options used to create the mesh
  51684. * @param scene defines the hosting scene
  51685. * @returns the box mesh
  51686. */
  51687. static CreateTiledBox(name: string, options: {
  51688. pattern?: number;
  51689. width?: number;
  51690. height?: number;
  51691. depth?: number;
  51692. tileSize?: number;
  51693. tileWidth?: number;
  51694. tileHeight?: number;
  51695. alignHorizontal?: number;
  51696. alignVertical?: number;
  51697. faceUV?: Vector4[];
  51698. faceColors?: Color4[];
  51699. sideOrientation?: number;
  51700. updatable?: boolean;
  51701. }, scene?: Nullable<Scene>): Mesh;
  51702. }
  51703. }
  51704. declare module BABYLON {
  51705. /**
  51706. * Class containing static functions to help procedurally build meshes
  51707. */
  51708. export class TorusKnotBuilder {
  51709. /**
  51710. * Creates a torus knot mesh
  51711. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51712. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51713. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51714. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51715. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51716. * * 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
  51717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51718. * @param name defines the name of the mesh
  51719. * @param options defines the options used to create the mesh
  51720. * @param scene defines the hosting scene
  51721. * @returns the torus knot mesh
  51722. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51723. */
  51724. static CreateTorusKnot(name: string, options: {
  51725. radius?: number;
  51726. tube?: number;
  51727. radialSegments?: number;
  51728. tubularSegments?: number;
  51729. p?: number;
  51730. q?: number;
  51731. updatable?: boolean;
  51732. sideOrientation?: number;
  51733. frontUVs?: Vector4;
  51734. backUVs?: Vector4;
  51735. }, scene: any): Mesh;
  51736. }
  51737. }
  51738. declare module BABYLON {
  51739. /**
  51740. * Polygon
  51741. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  51742. */
  51743. export class Polygon {
  51744. /**
  51745. * Creates a rectangle
  51746. * @param xmin bottom X coord
  51747. * @param ymin bottom Y coord
  51748. * @param xmax top X coord
  51749. * @param ymax top Y coord
  51750. * @returns points that make the resulting rectation
  51751. */
  51752. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  51753. /**
  51754. * Creates a circle
  51755. * @param radius radius of circle
  51756. * @param cx scale in x
  51757. * @param cy scale in y
  51758. * @param numberOfSides number of sides that make up the circle
  51759. * @returns points that make the resulting circle
  51760. */
  51761. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  51762. /**
  51763. * Creates a polygon from input string
  51764. * @param input Input polygon data
  51765. * @returns the parsed points
  51766. */
  51767. static Parse(input: string): Vector2[];
  51768. /**
  51769. * Starts building a polygon from x and y coordinates
  51770. * @param x x coordinate
  51771. * @param y y coordinate
  51772. * @returns the started path2
  51773. */
  51774. static StartingAt(x: number, y: number): Path2;
  51775. }
  51776. /**
  51777. * Builds a polygon
  51778. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  51779. */
  51780. export class PolygonMeshBuilder {
  51781. private _points;
  51782. private _outlinepoints;
  51783. private _holes;
  51784. private _name;
  51785. private _scene;
  51786. private _epoints;
  51787. private _eholes;
  51788. private _addToepoint;
  51789. /**
  51790. * Babylon reference to the earcut plugin.
  51791. */
  51792. bjsEarcut: any;
  51793. /**
  51794. * Creates a PolygonMeshBuilder
  51795. * @param name name of the builder
  51796. * @param contours Path of the polygon
  51797. * @param scene scene to add to when creating the mesh
  51798. * @param earcutInjection can be used to inject your own earcut reference
  51799. */
  51800. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  51801. /**
  51802. * Adds a whole within the polygon
  51803. * @param hole Array of points defining the hole
  51804. * @returns this
  51805. */
  51806. addHole(hole: Vector2[]): PolygonMeshBuilder;
  51807. /**
  51808. * Creates the polygon
  51809. * @param updatable If the mesh should be updatable
  51810. * @param depth The depth of the mesh created
  51811. * @returns the created mesh
  51812. */
  51813. build(updatable?: boolean, depth?: number): Mesh;
  51814. /**
  51815. * Creates the polygon
  51816. * @param depth The depth of the mesh created
  51817. * @returns the created VertexData
  51818. */
  51819. buildVertexData(depth?: number): VertexData;
  51820. /**
  51821. * Adds a side to the polygon
  51822. * @param positions points that make the polygon
  51823. * @param normals normals of the polygon
  51824. * @param uvs uvs of the polygon
  51825. * @param indices indices of the polygon
  51826. * @param bounds bounds of the polygon
  51827. * @param points points of the polygon
  51828. * @param depth depth of the polygon
  51829. * @param flip flip of the polygon
  51830. */
  51831. private addSide;
  51832. }
  51833. }
  51834. declare module BABYLON {
  51835. /**
  51836. * Class containing static functions to help procedurally build meshes
  51837. */
  51838. export class PolygonBuilder {
  51839. /**
  51840. * Creates a polygon mesh
  51841. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51842. * * 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
  51843. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51845. * * 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)
  51846. * * Remember you can only change the shape positions, not their number when updating a polygon
  51847. * @param name defines the name of the mesh
  51848. * @param options defines the options used to create the mesh
  51849. * @param scene defines the hosting scene
  51850. * @param earcutInjection can be used to inject your own earcut reference
  51851. * @returns the polygon mesh
  51852. */
  51853. static CreatePolygon(name: string, options: {
  51854. shape: Vector3[];
  51855. holes?: Vector3[][];
  51856. depth?: number;
  51857. faceUV?: Vector4[];
  51858. faceColors?: Color4[];
  51859. updatable?: boolean;
  51860. sideOrientation?: number;
  51861. frontUVs?: Vector4;
  51862. backUVs?: Vector4;
  51863. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51864. /**
  51865. * Creates an extruded polygon mesh, with depth in the Y direction.
  51866. * * 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)
  51867. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51868. * @param name defines the name of the mesh
  51869. * @param options defines the options used to create the mesh
  51870. * @param scene defines the hosting scene
  51871. * @param earcutInjection can be used to inject your own earcut reference
  51872. * @returns the polygon mesh
  51873. */
  51874. static ExtrudePolygon(name: string, options: {
  51875. shape: Vector3[];
  51876. holes?: Vector3[][];
  51877. depth?: number;
  51878. faceUV?: Vector4[];
  51879. faceColors?: Color4[];
  51880. updatable?: boolean;
  51881. sideOrientation?: number;
  51882. frontUVs?: Vector4;
  51883. backUVs?: Vector4;
  51884. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51885. }
  51886. }
  51887. declare module BABYLON {
  51888. /**
  51889. * Class containing static functions to help procedurally build meshes
  51890. */
  51891. export class LatheBuilder {
  51892. /**
  51893. * Creates lathe mesh.
  51894. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  51895. * * 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
  51896. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  51897. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  51898. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  51899. * * 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
  51900. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  51901. * * 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
  51902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51903. * * 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
  51904. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51906. * @param name defines the name of the mesh
  51907. * @param options defines the options used to create the mesh
  51908. * @param scene defines the hosting scene
  51909. * @returns the lathe mesh
  51910. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  51911. */
  51912. static CreateLathe(name: string, options: {
  51913. shape: Vector3[];
  51914. radius?: number;
  51915. tessellation?: number;
  51916. clip?: number;
  51917. arc?: number;
  51918. closed?: boolean;
  51919. updatable?: boolean;
  51920. sideOrientation?: number;
  51921. frontUVs?: Vector4;
  51922. backUVs?: Vector4;
  51923. cap?: number;
  51924. invertUV?: boolean;
  51925. }, scene?: Nullable<Scene>): Mesh;
  51926. }
  51927. }
  51928. declare module BABYLON {
  51929. /**
  51930. * Class containing static functions to help procedurally build meshes
  51931. */
  51932. export class TiledPlaneBuilder {
  51933. /**
  51934. * Creates a tiled plane mesh
  51935. * * The parameter `pattern` will, depending on value, do nothing or
  51936. * * * flip (reflect about central vertical) alternate tiles across and up
  51937. * * * flip every tile on alternate rows
  51938. * * * rotate (180 degs) alternate tiles across and up
  51939. * * * rotate every tile on alternate rows
  51940. * * * flip and rotate alternate tiles across and up
  51941. * * * flip and rotate every tile on alternate rows
  51942. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  51943. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  51944. * * 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
  51945. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51946. * * 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)
  51947. * * 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)
  51948. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51949. * @param name defines the name of the mesh
  51950. * @param options defines the options used to create the mesh
  51951. * @param scene defines the hosting scene
  51952. * @returns the box mesh
  51953. */
  51954. static CreateTiledPlane(name: string, options: {
  51955. pattern?: number;
  51956. tileSize?: number;
  51957. tileWidth?: number;
  51958. tileHeight?: number;
  51959. size?: number;
  51960. width?: number;
  51961. height?: number;
  51962. alignHorizontal?: number;
  51963. alignVertical?: number;
  51964. sideOrientation?: number;
  51965. frontUVs?: Vector4;
  51966. backUVs?: Vector4;
  51967. updatable?: boolean;
  51968. }, scene?: Nullable<Scene>): Mesh;
  51969. }
  51970. }
  51971. declare module BABYLON {
  51972. /**
  51973. * Class containing static functions to help procedurally build meshes
  51974. */
  51975. export class TubeBuilder {
  51976. /**
  51977. * Creates a tube mesh.
  51978. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51979. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51980. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51981. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51982. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51983. * * 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)
  51984. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51985. * * 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
  51986. * * 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
  51987. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51988. * * 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
  51989. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51991. * @param name defines the name of the mesh
  51992. * @param options defines the options used to create the mesh
  51993. * @param scene defines the hosting scene
  51994. * @returns the tube mesh
  51995. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51996. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  51997. */
  51998. static CreateTube(name: string, options: {
  51999. path: Vector3[];
  52000. radius?: number;
  52001. tessellation?: number;
  52002. radiusFunction?: {
  52003. (i: number, distance: number): number;
  52004. };
  52005. cap?: number;
  52006. arc?: number;
  52007. updatable?: boolean;
  52008. sideOrientation?: number;
  52009. frontUVs?: Vector4;
  52010. backUVs?: Vector4;
  52011. instance?: Mesh;
  52012. invertUV?: boolean;
  52013. }, scene?: Nullable<Scene>): Mesh;
  52014. }
  52015. }
  52016. declare module BABYLON {
  52017. /**
  52018. * Class containing static functions to help procedurally build meshes
  52019. */
  52020. export class IcoSphereBuilder {
  52021. /**
  52022. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52023. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52024. * * 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`)
  52025. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52026. * * 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
  52027. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52028. * * 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
  52029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52030. * @param name defines the name of the mesh
  52031. * @param options defines the options used to create the mesh
  52032. * @param scene defines the hosting scene
  52033. * @returns the icosahedron mesh
  52034. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52035. */
  52036. static CreateIcoSphere(name: string, options: {
  52037. radius?: number;
  52038. radiusX?: number;
  52039. radiusY?: number;
  52040. radiusZ?: number;
  52041. flat?: boolean;
  52042. subdivisions?: number;
  52043. sideOrientation?: number;
  52044. frontUVs?: Vector4;
  52045. backUVs?: Vector4;
  52046. updatable?: boolean;
  52047. }, scene?: Nullable<Scene>): Mesh;
  52048. }
  52049. }
  52050. declare module BABYLON {
  52051. /**
  52052. * Class containing static functions to help procedurally build meshes
  52053. */
  52054. export class DecalBuilder {
  52055. /**
  52056. * Creates a decal mesh.
  52057. * 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
  52058. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52059. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52060. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52061. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52062. * @param name defines the name of the mesh
  52063. * @param sourceMesh defines the mesh where the decal must be applied
  52064. * @param options defines the options used to create the mesh
  52065. * @param scene defines the hosting scene
  52066. * @returns the decal mesh
  52067. * @see https://doc.babylonjs.com/how_to/decals
  52068. */
  52069. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52070. position?: Vector3;
  52071. normal?: Vector3;
  52072. size?: Vector3;
  52073. angle?: number;
  52074. }): Mesh;
  52075. }
  52076. }
  52077. declare module BABYLON {
  52078. /**
  52079. * Class containing static functions to help procedurally build meshes
  52080. */
  52081. export class MeshBuilder {
  52082. /**
  52083. * Creates a box mesh
  52084. * * The parameter `size` sets the size (float) of each box side (default 1)
  52085. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52086. * * 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)
  52087. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52089. * * 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
  52090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52091. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52092. * @param name defines the name of the mesh
  52093. * @param options defines the options used to create the mesh
  52094. * @param scene defines the hosting scene
  52095. * @returns the box mesh
  52096. */
  52097. static CreateBox(name: string, options: {
  52098. size?: number;
  52099. width?: number;
  52100. height?: number;
  52101. depth?: number;
  52102. faceUV?: Vector4[];
  52103. faceColors?: Color4[];
  52104. sideOrientation?: number;
  52105. frontUVs?: Vector4;
  52106. backUVs?: Vector4;
  52107. updatable?: boolean;
  52108. }, scene?: Nullable<Scene>): Mesh;
  52109. /**
  52110. * Creates a tiled box mesh
  52111. * * faceTiles sets the pattern, tile size and number of tiles for a face
  52112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52113. * @param name defines the name of the mesh
  52114. * @param options defines the options used to create the mesh
  52115. * @param scene defines the hosting scene
  52116. * @returns the tiled box mesh
  52117. */
  52118. static CreateTiledBox(name: string, options: {
  52119. pattern?: number;
  52120. size?: number;
  52121. width?: number;
  52122. height?: number;
  52123. depth: number;
  52124. tileSize?: number;
  52125. tileWidth?: number;
  52126. tileHeight?: number;
  52127. faceUV?: Vector4[];
  52128. faceColors?: Color4[];
  52129. alignHorizontal?: number;
  52130. alignVertical?: number;
  52131. sideOrientation?: number;
  52132. updatable?: boolean;
  52133. }, scene?: Nullable<Scene>): Mesh;
  52134. /**
  52135. * Creates a sphere mesh
  52136. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52137. * * 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`)
  52138. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52139. * * 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
  52140. * * 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)
  52141. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52142. * * 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
  52143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52144. * @param name defines the name of the mesh
  52145. * @param options defines the options used to create the mesh
  52146. * @param scene defines the hosting scene
  52147. * @returns the sphere mesh
  52148. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52149. */
  52150. static CreateSphere(name: string, options: {
  52151. segments?: number;
  52152. diameter?: number;
  52153. diameterX?: number;
  52154. diameterY?: number;
  52155. diameterZ?: number;
  52156. arc?: number;
  52157. slice?: number;
  52158. sideOrientation?: number;
  52159. frontUVs?: Vector4;
  52160. backUVs?: Vector4;
  52161. updatable?: boolean;
  52162. }, scene?: Nullable<Scene>): Mesh;
  52163. /**
  52164. * Creates a plane polygonal mesh. By default, this is a disc
  52165. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52166. * * 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
  52167. * * 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
  52168. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52169. * * 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
  52170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52171. * @param name defines the name of the mesh
  52172. * @param options defines the options used to create the mesh
  52173. * @param scene defines the hosting scene
  52174. * @returns the plane polygonal mesh
  52175. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52176. */
  52177. static CreateDisc(name: string, options: {
  52178. radius?: number;
  52179. tessellation?: number;
  52180. arc?: number;
  52181. updatable?: boolean;
  52182. sideOrientation?: number;
  52183. frontUVs?: Vector4;
  52184. backUVs?: Vector4;
  52185. }, scene?: Nullable<Scene>): Mesh;
  52186. /**
  52187. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52188. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52189. * * 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`)
  52190. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52191. * * 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
  52192. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52193. * * 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
  52194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52195. * @param name defines the name of the mesh
  52196. * @param options defines the options used to create the mesh
  52197. * @param scene defines the hosting scene
  52198. * @returns the icosahedron mesh
  52199. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52200. */
  52201. static CreateIcoSphere(name: string, options: {
  52202. radius?: number;
  52203. radiusX?: number;
  52204. radiusY?: number;
  52205. radiusZ?: number;
  52206. flat?: boolean;
  52207. subdivisions?: number;
  52208. sideOrientation?: number;
  52209. frontUVs?: Vector4;
  52210. backUVs?: Vector4;
  52211. updatable?: boolean;
  52212. }, scene?: Nullable<Scene>): Mesh;
  52213. /**
  52214. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52215. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52216. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52217. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52218. * * 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
  52219. * * 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
  52220. * * 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
  52221. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52222. * * 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
  52223. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52224. * * 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
  52225. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52226. * * 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
  52227. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52229. * @param name defines the name of the mesh
  52230. * @param options defines the options used to create the mesh
  52231. * @param scene defines the hosting scene
  52232. * @returns the ribbon mesh
  52233. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52234. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52235. */
  52236. static CreateRibbon(name: string, options: {
  52237. pathArray: Vector3[][];
  52238. closeArray?: boolean;
  52239. closePath?: boolean;
  52240. offset?: number;
  52241. updatable?: boolean;
  52242. sideOrientation?: number;
  52243. frontUVs?: Vector4;
  52244. backUVs?: Vector4;
  52245. instance?: Mesh;
  52246. invertUV?: boolean;
  52247. uvs?: Vector2[];
  52248. colors?: Color4[];
  52249. }, scene?: Nullable<Scene>): Mesh;
  52250. /**
  52251. * Creates a cylinder or a cone mesh
  52252. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52253. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52254. * * 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.
  52255. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52256. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52257. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52258. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52259. * * 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).
  52260. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52261. * * 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).
  52262. * * 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
  52263. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52264. * * 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
  52265. * * 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.
  52266. * * If `enclose` is false, a ring surface is one element.
  52267. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52268. * * 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
  52269. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52270. * * 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
  52271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52272. * @param name defines the name of the mesh
  52273. * @param options defines the options used to create the mesh
  52274. * @param scene defines the hosting scene
  52275. * @returns the cylinder mesh
  52276. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52277. */
  52278. static CreateCylinder(name: string, options: {
  52279. height?: number;
  52280. diameterTop?: number;
  52281. diameterBottom?: number;
  52282. diameter?: number;
  52283. tessellation?: number;
  52284. subdivisions?: number;
  52285. arc?: number;
  52286. faceColors?: Color4[];
  52287. faceUV?: Vector4[];
  52288. updatable?: boolean;
  52289. hasRings?: boolean;
  52290. enclose?: boolean;
  52291. cap?: number;
  52292. sideOrientation?: number;
  52293. frontUVs?: Vector4;
  52294. backUVs?: Vector4;
  52295. }, scene?: Nullable<Scene>): Mesh;
  52296. /**
  52297. * Creates a torus mesh
  52298. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52299. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52300. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52301. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52302. * * 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
  52303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52304. * @param name defines the name of the mesh
  52305. * @param options defines the options used to create the mesh
  52306. * @param scene defines the hosting scene
  52307. * @returns the torus mesh
  52308. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52309. */
  52310. static CreateTorus(name: string, options: {
  52311. diameter?: number;
  52312. thickness?: number;
  52313. tessellation?: number;
  52314. updatable?: boolean;
  52315. sideOrientation?: number;
  52316. frontUVs?: Vector4;
  52317. backUVs?: Vector4;
  52318. }, scene?: Nullable<Scene>): Mesh;
  52319. /**
  52320. * Creates a torus knot mesh
  52321. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52322. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52323. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52324. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52325. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52326. * * 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
  52327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52328. * @param name defines the name of the mesh
  52329. * @param options defines the options used to create the mesh
  52330. * @param scene defines the hosting scene
  52331. * @returns the torus knot mesh
  52332. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52333. */
  52334. static CreateTorusKnot(name: string, options: {
  52335. radius?: number;
  52336. tube?: number;
  52337. radialSegments?: number;
  52338. tubularSegments?: number;
  52339. p?: number;
  52340. q?: number;
  52341. updatable?: boolean;
  52342. sideOrientation?: number;
  52343. frontUVs?: Vector4;
  52344. backUVs?: Vector4;
  52345. }, scene?: Nullable<Scene>): Mesh;
  52346. /**
  52347. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52348. * * 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
  52349. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52350. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52351. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52352. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52353. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52354. * * 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
  52355. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52357. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52358. * @param name defines the name of the new line system
  52359. * @param options defines the options used to create the line system
  52360. * @param scene defines the hosting scene
  52361. * @returns a new line system mesh
  52362. */
  52363. static CreateLineSystem(name: string, options: {
  52364. lines: Vector3[][];
  52365. updatable?: boolean;
  52366. instance?: Nullable<LinesMesh>;
  52367. colors?: Nullable<Color4[][]>;
  52368. useVertexAlpha?: boolean;
  52369. }, scene: Nullable<Scene>): LinesMesh;
  52370. /**
  52371. * Creates a line mesh
  52372. * 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
  52373. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52374. * * The parameter `points` is an array successive Vector3
  52375. * * 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
  52376. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52377. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52378. * * When updating an instance, remember that only point positions can change, not the number of points
  52379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52380. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52381. * @param name defines the name of the new line system
  52382. * @param options defines the options used to create the line system
  52383. * @param scene defines the hosting scene
  52384. * @returns a new line mesh
  52385. */
  52386. static CreateLines(name: string, options: {
  52387. points: Vector3[];
  52388. updatable?: boolean;
  52389. instance?: Nullable<LinesMesh>;
  52390. colors?: Color4[];
  52391. useVertexAlpha?: boolean;
  52392. }, scene?: Nullable<Scene>): LinesMesh;
  52393. /**
  52394. * Creates a dashed line mesh
  52395. * * 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
  52396. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52397. * * The parameter `points` is an array successive Vector3
  52398. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52399. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52400. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52401. * * 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
  52402. * * When updating an instance, remember that only point positions can change, not the number of points
  52403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52404. * @param name defines the name of the mesh
  52405. * @param options defines the options used to create the mesh
  52406. * @param scene defines the hosting scene
  52407. * @returns the dashed line mesh
  52408. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52409. */
  52410. static CreateDashedLines(name: string, options: {
  52411. points: Vector3[];
  52412. dashSize?: number;
  52413. gapSize?: number;
  52414. dashNb?: number;
  52415. updatable?: boolean;
  52416. instance?: LinesMesh;
  52417. }, scene?: Nullable<Scene>): LinesMesh;
  52418. /**
  52419. * 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.
  52420. * * 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.
  52421. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52422. * * 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.
  52423. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52424. * * 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
  52425. * * 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
  52426. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52428. * * 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
  52429. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52431. * @param name defines the name of the mesh
  52432. * @param options defines the options used to create the mesh
  52433. * @param scene defines the hosting scene
  52434. * @returns the extruded shape mesh
  52435. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52436. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52437. */
  52438. static ExtrudeShape(name: string, options: {
  52439. shape: Vector3[];
  52440. path: Vector3[];
  52441. scale?: number;
  52442. rotation?: number;
  52443. cap?: number;
  52444. updatable?: boolean;
  52445. sideOrientation?: number;
  52446. frontUVs?: Vector4;
  52447. backUVs?: Vector4;
  52448. instance?: Mesh;
  52449. invertUV?: boolean;
  52450. }, scene?: Nullable<Scene>): Mesh;
  52451. /**
  52452. * Creates an custom extruded shape mesh.
  52453. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52454. * * 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.
  52455. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52456. * * 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
  52457. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52458. * * 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
  52459. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52460. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52461. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52462. * * 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
  52463. * * 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
  52464. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52465. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52466. * * 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
  52467. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52469. * @param name defines the name of the mesh
  52470. * @param options defines the options used to create the mesh
  52471. * @param scene defines the hosting scene
  52472. * @returns the custom extruded shape mesh
  52473. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52474. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52475. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52476. */
  52477. static ExtrudeShapeCustom(name: string, options: {
  52478. shape: Vector3[];
  52479. path: Vector3[];
  52480. scaleFunction?: any;
  52481. rotationFunction?: any;
  52482. ribbonCloseArray?: boolean;
  52483. ribbonClosePath?: boolean;
  52484. cap?: number;
  52485. updatable?: boolean;
  52486. sideOrientation?: number;
  52487. frontUVs?: Vector4;
  52488. backUVs?: Vector4;
  52489. instance?: Mesh;
  52490. invertUV?: boolean;
  52491. }, scene?: Nullable<Scene>): Mesh;
  52492. /**
  52493. * Creates lathe mesh.
  52494. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52495. * * 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
  52496. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52497. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52498. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52499. * * 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
  52500. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52501. * * 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
  52502. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52503. * * 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
  52504. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52506. * @param name defines the name of the mesh
  52507. * @param options defines the options used to create the mesh
  52508. * @param scene defines the hosting scene
  52509. * @returns the lathe mesh
  52510. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52511. */
  52512. static CreateLathe(name: string, options: {
  52513. shape: Vector3[];
  52514. radius?: number;
  52515. tessellation?: number;
  52516. clip?: number;
  52517. arc?: number;
  52518. closed?: boolean;
  52519. updatable?: boolean;
  52520. sideOrientation?: number;
  52521. frontUVs?: Vector4;
  52522. backUVs?: Vector4;
  52523. cap?: number;
  52524. invertUV?: boolean;
  52525. }, scene?: Nullable<Scene>): Mesh;
  52526. /**
  52527. * Creates a tiled plane mesh
  52528. * * You can set a limited pattern arrangement with the tiles
  52529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52530. * * 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
  52531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52532. * @param name defines the name of the mesh
  52533. * @param options defines the options used to create the mesh
  52534. * @param scene defines the hosting scene
  52535. * @returns the plane mesh
  52536. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52537. */
  52538. static CreateTiledPlane(name: string, options: {
  52539. pattern?: number;
  52540. tileSize?: number;
  52541. tileWidth?: number;
  52542. tileHeight?: number;
  52543. size?: number;
  52544. width?: number;
  52545. height?: number;
  52546. alignHorizontal?: number;
  52547. alignVertical?: number;
  52548. sideOrientation?: number;
  52549. frontUVs?: Vector4;
  52550. backUVs?: Vector4;
  52551. updatable?: boolean;
  52552. }, scene?: Nullable<Scene>): Mesh;
  52553. /**
  52554. * Creates a plane mesh
  52555. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  52556. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  52557. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  52558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52559. * * 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
  52560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52561. * @param name defines the name of the mesh
  52562. * @param options defines the options used to create the mesh
  52563. * @param scene defines the hosting scene
  52564. * @returns the plane mesh
  52565. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52566. */
  52567. static CreatePlane(name: string, options: {
  52568. size?: number;
  52569. width?: number;
  52570. height?: number;
  52571. sideOrientation?: number;
  52572. frontUVs?: Vector4;
  52573. backUVs?: Vector4;
  52574. updatable?: boolean;
  52575. sourcePlane?: Plane;
  52576. }, scene?: Nullable<Scene>): Mesh;
  52577. /**
  52578. * Creates a ground mesh
  52579. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52580. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52582. * @param name defines the name of the mesh
  52583. * @param options defines the options used to create the mesh
  52584. * @param scene defines the hosting scene
  52585. * @returns the ground mesh
  52586. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52587. */
  52588. static CreateGround(name: string, options: {
  52589. width?: number;
  52590. height?: number;
  52591. subdivisions?: number;
  52592. subdivisionsX?: number;
  52593. subdivisionsY?: number;
  52594. updatable?: boolean;
  52595. }, scene?: Nullable<Scene>): Mesh;
  52596. /**
  52597. * Creates a tiled ground mesh
  52598. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52599. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52600. * * 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
  52601. * * 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
  52602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52603. * @param name defines the name of the mesh
  52604. * @param options defines the options used to create the mesh
  52605. * @param scene defines the hosting scene
  52606. * @returns the tiled ground mesh
  52607. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52608. */
  52609. static CreateTiledGround(name: string, options: {
  52610. xmin: number;
  52611. zmin: number;
  52612. xmax: number;
  52613. zmax: number;
  52614. subdivisions?: {
  52615. w: number;
  52616. h: number;
  52617. };
  52618. precision?: {
  52619. w: number;
  52620. h: number;
  52621. };
  52622. updatable?: boolean;
  52623. }, scene?: Nullable<Scene>): Mesh;
  52624. /**
  52625. * Creates a ground mesh from a height map
  52626. * * The parameter `url` sets the URL of the height map image resource.
  52627. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52628. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52629. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52630. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52631. * * 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.
  52632. * * 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).
  52633. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52635. * @param name defines the name of the mesh
  52636. * @param url defines the url to the height map
  52637. * @param options defines the options used to create the mesh
  52638. * @param scene defines the hosting scene
  52639. * @returns the ground mesh
  52640. * @see https://doc.babylonjs.com/babylon101/height_map
  52641. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52642. */
  52643. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52644. width?: number;
  52645. height?: number;
  52646. subdivisions?: number;
  52647. minHeight?: number;
  52648. maxHeight?: number;
  52649. colorFilter?: Color3;
  52650. alphaFilter?: number;
  52651. updatable?: boolean;
  52652. onReady?: (mesh: GroundMesh) => void;
  52653. }, scene?: Nullable<Scene>): GroundMesh;
  52654. /**
  52655. * Creates a polygon mesh
  52656. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52657. * * 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
  52658. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52660. * * 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)
  52661. * * Remember you can only change the shape positions, not their number when updating a polygon
  52662. * @param name defines the name of the mesh
  52663. * @param options defines the options used to create the mesh
  52664. * @param scene defines the hosting scene
  52665. * @param earcutInjection can be used to inject your own earcut reference
  52666. * @returns the polygon mesh
  52667. */
  52668. static CreatePolygon(name: string, options: {
  52669. shape: Vector3[];
  52670. holes?: Vector3[][];
  52671. depth?: number;
  52672. faceUV?: Vector4[];
  52673. faceColors?: Color4[];
  52674. updatable?: boolean;
  52675. sideOrientation?: number;
  52676. frontUVs?: Vector4;
  52677. backUVs?: Vector4;
  52678. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52679. /**
  52680. * Creates an extruded polygon mesh, with depth in the Y direction.
  52681. * * 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)
  52682. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52683. * @param name defines the name of the mesh
  52684. * @param options defines the options used to create the mesh
  52685. * @param scene defines the hosting scene
  52686. * @param earcutInjection can be used to inject your own earcut reference
  52687. * @returns the polygon mesh
  52688. */
  52689. static ExtrudePolygon(name: string, options: {
  52690. shape: Vector3[];
  52691. holes?: Vector3[][];
  52692. depth?: number;
  52693. faceUV?: Vector4[];
  52694. faceColors?: Color4[];
  52695. updatable?: boolean;
  52696. sideOrientation?: number;
  52697. frontUVs?: Vector4;
  52698. backUVs?: Vector4;
  52699. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52700. /**
  52701. * Creates a tube mesh.
  52702. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52703. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52704. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52705. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52706. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52707. * * 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)
  52708. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52709. * * 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
  52710. * * 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
  52711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52712. * * 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
  52713. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52715. * @param name defines the name of the mesh
  52716. * @param options defines the options used to create the mesh
  52717. * @param scene defines the hosting scene
  52718. * @returns the tube mesh
  52719. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52720. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52721. */
  52722. static CreateTube(name: string, options: {
  52723. path: Vector3[];
  52724. radius?: number;
  52725. tessellation?: number;
  52726. radiusFunction?: {
  52727. (i: number, distance: number): number;
  52728. };
  52729. cap?: number;
  52730. arc?: number;
  52731. updatable?: boolean;
  52732. sideOrientation?: number;
  52733. frontUVs?: Vector4;
  52734. backUVs?: Vector4;
  52735. instance?: Mesh;
  52736. invertUV?: boolean;
  52737. }, scene?: Nullable<Scene>): Mesh;
  52738. /**
  52739. * Creates a polyhedron mesh
  52740. * * 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
  52741. * * The parameter `size` (positive float, default 1) sets the polygon size
  52742. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52743. * * 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`
  52744. * * 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
  52745. * * 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)`)
  52746. * * 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
  52747. * * 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
  52748. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52749. * * 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
  52750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52751. * @param name defines the name of the mesh
  52752. * @param options defines the options used to create the mesh
  52753. * @param scene defines the hosting scene
  52754. * @returns the polyhedron mesh
  52755. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52756. */
  52757. static CreatePolyhedron(name: string, options: {
  52758. type?: number;
  52759. size?: number;
  52760. sizeX?: number;
  52761. sizeY?: number;
  52762. sizeZ?: number;
  52763. custom?: any;
  52764. faceUV?: Vector4[];
  52765. faceColors?: Color4[];
  52766. flat?: boolean;
  52767. updatable?: boolean;
  52768. sideOrientation?: number;
  52769. frontUVs?: Vector4;
  52770. backUVs?: Vector4;
  52771. }, scene?: Nullable<Scene>): Mesh;
  52772. /**
  52773. * Creates a decal mesh.
  52774. * 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
  52775. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52776. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52777. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52778. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52779. * @param name defines the name of the mesh
  52780. * @param sourceMesh defines the mesh where the decal must be applied
  52781. * @param options defines the options used to create the mesh
  52782. * @param scene defines the hosting scene
  52783. * @returns the decal mesh
  52784. * @see https://doc.babylonjs.com/how_to/decals
  52785. */
  52786. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52787. position?: Vector3;
  52788. normal?: Vector3;
  52789. size?: Vector3;
  52790. angle?: number;
  52791. }): Mesh;
  52792. }
  52793. }
  52794. declare module BABYLON {
  52795. /**
  52796. * A simplifier interface for future simplification implementations
  52797. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52798. */
  52799. export interface ISimplifier {
  52800. /**
  52801. * Simplification of a given mesh according to the given settings.
  52802. * Since this requires computation, it is assumed that the function runs async.
  52803. * @param settings The settings of the simplification, including quality and distance
  52804. * @param successCallback A callback that will be called after the mesh was simplified.
  52805. * @param errorCallback in case of an error, this callback will be called. optional.
  52806. */
  52807. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  52808. }
  52809. /**
  52810. * Expected simplification settings.
  52811. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  52812. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52813. */
  52814. export interface ISimplificationSettings {
  52815. /**
  52816. * Gets or sets the expected quality
  52817. */
  52818. quality: number;
  52819. /**
  52820. * Gets or sets the distance when this optimized version should be used
  52821. */
  52822. distance: number;
  52823. /**
  52824. * Gets an already optimized mesh
  52825. */
  52826. optimizeMesh?: boolean;
  52827. }
  52828. /**
  52829. * Class used to specify simplification options
  52830. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52831. */
  52832. export class SimplificationSettings implements ISimplificationSettings {
  52833. /** expected quality */
  52834. quality: number;
  52835. /** distance when this optimized version should be used */
  52836. distance: number;
  52837. /** already optimized mesh */
  52838. optimizeMesh?: boolean | undefined;
  52839. /**
  52840. * Creates a SimplificationSettings
  52841. * @param quality expected quality
  52842. * @param distance distance when this optimized version should be used
  52843. * @param optimizeMesh already optimized mesh
  52844. */
  52845. constructor(
  52846. /** expected quality */
  52847. quality: number,
  52848. /** distance when this optimized version should be used */
  52849. distance: number,
  52850. /** already optimized mesh */
  52851. optimizeMesh?: boolean | undefined);
  52852. }
  52853. /**
  52854. * Interface used to define a simplification task
  52855. */
  52856. export interface ISimplificationTask {
  52857. /**
  52858. * Array of settings
  52859. */
  52860. settings: Array<ISimplificationSettings>;
  52861. /**
  52862. * Simplification type
  52863. */
  52864. simplificationType: SimplificationType;
  52865. /**
  52866. * Mesh to simplify
  52867. */
  52868. mesh: Mesh;
  52869. /**
  52870. * Callback called on success
  52871. */
  52872. successCallback?: () => void;
  52873. /**
  52874. * Defines if parallel processing can be used
  52875. */
  52876. parallelProcessing: boolean;
  52877. }
  52878. /**
  52879. * Queue used to order the simplification tasks
  52880. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52881. */
  52882. export class SimplificationQueue {
  52883. private _simplificationArray;
  52884. /**
  52885. * Gets a boolean indicating that the process is still running
  52886. */
  52887. running: boolean;
  52888. /**
  52889. * Creates a new queue
  52890. */
  52891. constructor();
  52892. /**
  52893. * Adds a new simplification task
  52894. * @param task defines a task to add
  52895. */
  52896. addTask(task: ISimplificationTask): void;
  52897. /**
  52898. * Execute next task
  52899. */
  52900. executeNext(): void;
  52901. /**
  52902. * Execute a simplification task
  52903. * @param task defines the task to run
  52904. */
  52905. runSimplification(task: ISimplificationTask): void;
  52906. private getSimplifier;
  52907. }
  52908. /**
  52909. * The implemented types of simplification
  52910. * At the moment only Quadratic Error Decimation is implemented
  52911. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52912. */
  52913. export enum SimplificationType {
  52914. /** Quadratic error decimation */
  52915. QUADRATIC = 0
  52916. }
  52917. }
  52918. declare module BABYLON {
  52919. interface Scene {
  52920. /** @hidden (Backing field) */
  52921. _simplificationQueue: SimplificationQueue;
  52922. /**
  52923. * Gets or sets the simplification queue attached to the scene
  52924. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52925. */
  52926. simplificationQueue: SimplificationQueue;
  52927. }
  52928. interface Mesh {
  52929. /**
  52930. * Simplify the mesh according to the given array of settings.
  52931. * Function will return immediately and will simplify async
  52932. * @param settings a collection of simplification settings
  52933. * @param parallelProcessing should all levels calculate parallel or one after the other
  52934. * @param simplificationType the type of simplification to run
  52935. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  52936. * @returns the current mesh
  52937. */
  52938. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  52939. }
  52940. /**
  52941. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  52942. * created in a scene
  52943. */
  52944. export class SimplicationQueueSceneComponent implements ISceneComponent {
  52945. /**
  52946. * The component name helpfull to identify the component in the list of scene components.
  52947. */
  52948. readonly name: string;
  52949. /**
  52950. * The scene the component belongs to.
  52951. */
  52952. scene: Scene;
  52953. /**
  52954. * Creates a new instance of the component for the given scene
  52955. * @param scene Defines the scene to register the component in
  52956. */
  52957. constructor(scene: Scene);
  52958. /**
  52959. * Registers the component in a given scene
  52960. */
  52961. register(): void;
  52962. /**
  52963. * Rebuilds the elements related to this component in case of
  52964. * context lost for instance.
  52965. */
  52966. rebuild(): void;
  52967. /**
  52968. * Disposes the component and the associated ressources
  52969. */
  52970. dispose(): void;
  52971. private _beforeCameraUpdate;
  52972. }
  52973. }
  52974. declare module BABYLON {
  52975. /**
  52976. * Class used to enable access to IndexedDB
  52977. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  52978. */
  52979. export class Database implements IOfflineProvider {
  52980. private _callbackManifestChecked;
  52981. private _currentSceneUrl;
  52982. private _db;
  52983. private _enableSceneOffline;
  52984. private _enableTexturesOffline;
  52985. private _manifestVersionFound;
  52986. private _mustUpdateRessources;
  52987. private _hasReachedQuota;
  52988. private _isSupported;
  52989. private _idbFactory;
  52990. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  52991. private static IsUASupportingBlobStorage;
  52992. /**
  52993. * Gets a boolean indicating if Database storate is enabled (off by default)
  52994. */
  52995. static IDBStorageEnabled: boolean;
  52996. /**
  52997. * Gets a boolean indicating if scene must be saved in the database
  52998. */
  52999. readonly enableSceneOffline: boolean;
  53000. /**
  53001. * Gets a boolean indicating if textures must be saved in the database
  53002. */
  53003. readonly enableTexturesOffline: boolean;
  53004. /**
  53005. * Creates a new Database
  53006. * @param urlToScene defines the url to load the scene
  53007. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53008. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53009. */
  53010. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53011. private static _ParseURL;
  53012. private static _ReturnFullUrlLocation;
  53013. private _checkManifestFile;
  53014. /**
  53015. * Open the database and make it available
  53016. * @param successCallback defines the callback to call on success
  53017. * @param errorCallback defines the callback to call on error
  53018. */
  53019. open(successCallback: () => void, errorCallback: () => void): void;
  53020. /**
  53021. * Loads an image from the database
  53022. * @param url defines the url to load from
  53023. * @param image defines the target DOM image
  53024. */
  53025. loadImage(url: string, image: HTMLImageElement): void;
  53026. private _loadImageFromDBAsync;
  53027. private _saveImageIntoDBAsync;
  53028. private _checkVersionFromDB;
  53029. private _loadVersionFromDBAsync;
  53030. private _saveVersionIntoDBAsync;
  53031. /**
  53032. * Loads a file from database
  53033. * @param url defines the URL to load from
  53034. * @param sceneLoaded defines a callback to call on success
  53035. * @param progressCallBack defines a callback to call when progress changed
  53036. * @param errorCallback defines a callback to call on error
  53037. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53038. */
  53039. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53040. private _loadFileAsync;
  53041. private _saveFileAsync;
  53042. /**
  53043. * Validates if xhr data is correct
  53044. * @param xhr defines the request to validate
  53045. * @param dataType defines the expected data type
  53046. * @returns true if data is correct
  53047. */
  53048. private static _ValidateXHRData;
  53049. }
  53050. }
  53051. declare module BABYLON {
  53052. /** @hidden */
  53053. export var gpuUpdateParticlesPixelShader: {
  53054. name: string;
  53055. shader: string;
  53056. };
  53057. }
  53058. declare module BABYLON {
  53059. /** @hidden */
  53060. export var gpuUpdateParticlesVertexShader: {
  53061. name: string;
  53062. shader: string;
  53063. };
  53064. }
  53065. declare module BABYLON {
  53066. /** @hidden */
  53067. export var clipPlaneFragmentDeclaration2: {
  53068. name: string;
  53069. shader: string;
  53070. };
  53071. }
  53072. declare module BABYLON {
  53073. /** @hidden */
  53074. export var gpuRenderParticlesPixelShader: {
  53075. name: string;
  53076. shader: string;
  53077. };
  53078. }
  53079. declare module BABYLON {
  53080. /** @hidden */
  53081. export var clipPlaneVertexDeclaration2: {
  53082. name: string;
  53083. shader: string;
  53084. };
  53085. }
  53086. declare module BABYLON {
  53087. /** @hidden */
  53088. export var gpuRenderParticlesVertexShader: {
  53089. name: string;
  53090. shader: string;
  53091. };
  53092. }
  53093. declare module BABYLON {
  53094. /**
  53095. * This represents a GPU particle system in Babylon
  53096. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53097. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53098. */
  53099. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53100. /**
  53101. * The layer mask we are rendering the particles through.
  53102. */
  53103. layerMask: number;
  53104. private _capacity;
  53105. private _activeCount;
  53106. private _currentActiveCount;
  53107. private _accumulatedCount;
  53108. private _renderEffect;
  53109. private _updateEffect;
  53110. private _buffer0;
  53111. private _buffer1;
  53112. private _spriteBuffer;
  53113. private _updateVAO;
  53114. private _renderVAO;
  53115. private _targetIndex;
  53116. private _sourceBuffer;
  53117. private _targetBuffer;
  53118. private _engine;
  53119. private _currentRenderId;
  53120. private _started;
  53121. private _stopped;
  53122. private _timeDelta;
  53123. private _randomTexture;
  53124. private _randomTexture2;
  53125. private _attributesStrideSize;
  53126. private _updateEffectOptions;
  53127. private _randomTextureSize;
  53128. private _actualFrame;
  53129. private readonly _rawTextureWidth;
  53130. /**
  53131. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53132. */
  53133. static readonly IsSupported: boolean;
  53134. /**
  53135. * An event triggered when the system is disposed.
  53136. */
  53137. onDisposeObservable: Observable<GPUParticleSystem>;
  53138. /**
  53139. * Gets the maximum number of particles active at the same time.
  53140. * @returns The max number of active particles.
  53141. */
  53142. getCapacity(): number;
  53143. /**
  53144. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53145. * to override the particles.
  53146. */
  53147. forceDepthWrite: boolean;
  53148. /**
  53149. * Gets or set the number of active particles
  53150. */
  53151. activeParticleCount: number;
  53152. private _preWarmDone;
  53153. /**
  53154. * Is this system ready to be used/rendered
  53155. * @return true if the system is ready
  53156. */
  53157. isReady(): boolean;
  53158. /**
  53159. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53160. * @returns True if it has been started, otherwise false.
  53161. */
  53162. isStarted(): boolean;
  53163. /**
  53164. * Starts the particle system and begins to emit
  53165. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53166. */
  53167. start(delay?: number): void;
  53168. /**
  53169. * Stops the particle system.
  53170. */
  53171. stop(): void;
  53172. /**
  53173. * Remove all active particles
  53174. */
  53175. reset(): void;
  53176. /**
  53177. * Returns the string "GPUParticleSystem"
  53178. * @returns a string containing the class name
  53179. */
  53180. getClassName(): string;
  53181. private _colorGradientsTexture;
  53182. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53183. /**
  53184. * Adds a new color gradient
  53185. * @param gradient defines the gradient to use (between 0 and 1)
  53186. * @param color1 defines the color to affect to the specified gradient
  53187. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53188. * @returns the current particle system
  53189. */
  53190. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53191. /**
  53192. * Remove a specific color gradient
  53193. * @param gradient defines the gradient to remove
  53194. * @returns the current particle system
  53195. */
  53196. removeColorGradient(gradient: number): GPUParticleSystem;
  53197. private _angularSpeedGradientsTexture;
  53198. private _sizeGradientsTexture;
  53199. private _velocityGradientsTexture;
  53200. private _limitVelocityGradientsTexture;
  53201. private _dragGradientsTexture;
  53202. private _addFactorGradient;
  53203. /**
  53204. * Adds a new size gradient
  53205. * @param gradient defines the gradient to use (between 0 and 1)
  53206. * @param factor defines the size factor to affect to the specified gradient
  53207. * @returns the current particle system
  53208. */
  53209. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53210. /**
  53211. * Remove a specific size gradient
  53212. * @param gradient defines the gradient to remove
  53213. * @returns the current particle system
  53214. */
  53215. removeSizeGradient(gradient: number): GPUParticleSystem;
  53216. /**
  53217. * Adds a new angular speed gradient
  53218. * @param gradient defines the gradient to use (between 0 and 1)
  53219. * @param factor defines the angular speed to affect to the specified gradient
  53220. * @returns the current particle system
  53221. */
  53222. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53223. /**
  53224. * Remove a specific angular speed gradient
  53225. * @param gradient defines the gradient to remove
  53226. * @returns the current particle system
  53227. */
  53228. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53229. /**
  53230. * Adds a new velocity gradient
  53231. * @param gradient defines the gradient to use (between 0 and 1)
  53232. * @param factor defines the velocity to affect to the specified gradient
  53233. * @returns the current particle system
  53234. */
  53235. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53236. /**
  53237. * Remove a specific velocity gradient
  53238. * @param gradient defines the gradient to remove
  53239. * @returns the current particle system
  53240. */
  53241. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53242. /**
  53243. * Adds a new limit velocity gradient
  53244. * @param gradient defines the gradient to use (between 0 and 1)
  53245. * @param factor defines the limit velocity value to affect to the specified gradient
  53246. * @returns the current particle system
  53247. */
  53248. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53249. /**
  53250. * Remove a specific limit velocity gradient
  53251. * @param gradient defines the gradient to remove
  53252. * @returns the current particle system
  53253. */
  53254. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53255. /**
  53256. * Adds a new drag gradient
  53257. * @param gradient defines the gradient to use (between 0 and 1)
  53258. * @param factor defines the drag value to affect to the specified gradient
  53259. * @returns the current particle system
  53260. */
  53261. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53262. /**
  53263. * Remove a specific drag gradient
  53264. * @param gradient defines the gradient to remove
  53265. * @returns the current particle system
  53266. */
  53267. removeDragGradient(gradient: number): GPUParticleSystem;
  53268. /**
  53269. * Not supported by GPUParticleSystem
  53270. * @param gradient defines the gradient to use (between 0 and 1)
  53271. * @param factor defines the emit rate value to affect to the specified gradient
  53272. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53273. * @returns the current particle system
  53274. */
  53275. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53276. /**
  53277. * Not supported by GPUParticleSystem
  53278. * @param gradient defines the gradient to remove
  53279. * @returns the current particle system
  53280. */
  53281. removeEmitRateGradient(gradient: number): IParticleSystem;
  53282. /**
  53283. * Not supported by GPUParticleSystem
  53284. * @param gradient defines the gradient to use (between 0 and 1)
  53285. * @param factor defines the start size value to affect to the specified gradient
  53286. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53287. * @returns the current particle system
  53288. */
  53289. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53290. /**
  53291. * Not supported by GPUParticleSystem
  53292. * @param gradient defines the gradient to remove
  53293. * @returns the current particle system
  53294. */
  53295. removeStartSizeGradient(gradient: number): IParticleSystem;
  53296. /**
  53297. * Not supported by GPUParticleSystem
  53298. * @param gradient defines the gradient to use (between 0 and 1)
  53299. * @param min defines the color remap minimal range
  53300. * @param max defines the color remap maximal range
  53301. * @returns the current particle system
  53302. */
  53303. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53304. /**
  53305. * Not supported by GPUParticleSystem
  53306. * @param gradient defines the gradient to remove
  53307. * @returns the current particle system
  53308. */
  53309. removeColorRemapGradient(): IParticleSystem;
  53310. /**
  53311. * Not supported by GPUParticleSystem
  53312. * @param gradient defines the gradient to use (between 0 and 1)
  53313. * @param min defines the alpha remap minimal range
  53314. * @param max defines the alpha remap maximal range
  53315. * @returns the current particle system
  53316. */
  53317. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53318. /**
  53319. * Not supported by GPUParticleSystem
  53320. * @param gradient defines the gradient to remove
  53321. * @returns the current particle system
  53322. */
  53323. removeAlphaRemapGradient(): IParticleSystem;
  53324. /**
  53325. * Not supported by GPUParticleSystem
  53326. * @param gradient defines the gradient to use (between 0 and 1)
  53327. * @param color defines the color to affect to the specified gradient
  53328. * @returns the current particle system
  53329. */
  53330. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53331. /**
  53332. * Not supported by GPUParticleSystem
  53333. * @param gradient defines the gradient to remove
  53334. * @returns the current particle system
  53335. */
  53336. removeRampGradient(): IParticleSystem;
  53337. /**
  53338. * Not supported by GPUParticleSystem
  53339. * @returns the list of ramp gradients
  53340. */
  53341. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53342. /**
  53343. * Not supported by GPUParticleSystem
  53344. * Gets or sets a boolean indicating that ramp gradients must be used
  53345. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53346. */
  53347. useRampGradients: boolean;
  53348. /**
  53349. * Not supported by GPUParticleSystem
  53350. * @param gradient defines the gradient to use (between 0 and 1)
  53351. * @param factor defines the life time factor to affect to the specified gradient
  53352. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53353. * @returns the current particle system
  53354. */
  53355. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53356. /**
  53357. * Not supported by GPUParticleSystem
  53358. * @param gradient defines the gradient to remove
  53359. * @returns the current particle system
  53360. */
  53361. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53362. /**
  53363. * Instantiates a GPU particle system.
  53364. * 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.
  53365. * @param name The name of the particle system
  53366. * @param options The options used to create the system
  53367. * @param scene The scene the particle system belongs to
  53368. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53369. */
  53370. constructor(name: string, options: Partial<{
  53371. capacity: number;
  53372. randomTextureSize: number;
  53373. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53374. protected _reset(): void;
  53375. private _createUpdateVAO;
  53376. private _createRenderVAO;
  53377. private _initialize;
  53378. /** @hidden */
  53379. _recreateUpdateEffect(): void;
  53380. /** @hidden */
  53381. _recreateRenderEffect(): void;
  53382. /**
  53383. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53384. * @param preWarm defines if we are in the pre-warmimg phase
  53385. */
  53386. animate(preWarm?: boolean): void;
  53387. private _createFactorGradientTexture;
  53388. private _createSizeGradientTexture;
  53389. private _createAngularSpeedGradientTexture;
  53390. private _createVelocityGradientTexture;
  53391. private _createLimitVelocityGradientTexture;
  53392. private _createDragGradientTexture;
  53393. private _createColorGradientTexture;
  53394. /**
  53395. * Renders the particle system in its current state
  53396. * @param preWarm defines if the system should only update the particles but not render them
  53397. * @returns the current number of particles
  53398. */
  53399. render(preWarm?: boolean): number;
  53400. /**
  53401. * Rebuilds the particle system
  53402. */
  53403. rebuild(): void;
  53404. private _releaseBuffers;
  53405. private _releaseVAOs;
  53406. /**
  53407. * Disposes the particle system and free the associated resources
  53408. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53409. */
  53410. dispose(disposeTexture?: boolean): void;
  53411. /**
  53412. * Clones the particle system.
  53413. * @param name The name of the cloned object
  53414. * @param newEmitter The new emitter to use
  53415. * @returns the cloned particle system
  53416. */
  53417. clone(name: string, newEmitter: any): GPUParticleSystem;
  53418. /**
  53419. * Serializes the particle system to a JSON object.
  53420. * @returns the JSON object
  53421. */
  53422. serialize(): any;
  53423. /**
  53424. * Parses a JSON object to create a GPU particle system.
  53425. * @param parsedParticleSystem The JSON object to parse
  53426. * @param scene The scene to create the particle system in
  53427. * @param rootUrl The root url to use to load external dependencies like texture
  53428. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53429. * @returns the parsed GPU particle system
  53430. */
  53431. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53432. }
  53433. }
  53434. declare module BABYLON {
  53435. /**
  53436. * Represents a set of particle systems working together to create a specific effect
  53437. */
  53438. export class ParticleSystemSet implements IDisposable {
  53439. private _emitterCreationOptions;
  53440. private _emitterNode;
  53441. /**
  53442. * Gets the particle system list
  53443. */
  53444. systems: IParticleSystem[];
  53445. /**
  53446. * Gets the emitter node used with this set
  53447. */
  53448. readonly emitterNode: Nullable<TransformNode>;
  53449. /**
  53450. * Creates a new emitter mesh as a sphere
  53451. * @param options defines the options used to create the sphere
  53452. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  53453. * @param scene defines the hosting scene
  53454. */
  53455. setEmitterAsSphere(options: {
  53456. diameter: number;
  53457. segments: number;
  53458. color: Color3;
  53459. }, renderingGroupId: number, scene: Scene): void;
  53460. /**
  53461. * Starts all particle systems of the set
  53462. * @param emitter defines an optional mesh to use as emitter for the particle systems
  53463. */
  53464. start(emitter?: AbstractMesh): void;
  53465. /**
  53466. * Release all associated resources
  53467. */
  53468. dispose(): void;
  53469. /**
  53470. * Serialize the set into a JSON compatible object
  53471. * @returns a JSON compatible representation of the set
  53472. */
  53473. serialize(): any;
  53474. /**
  53475. * Parse a new ParticleSystemSet from a serialized source
  53476. * @param data defines a JSON compatible representation of the set
  53477. * @param scene defines the hosting scene
  53478. * @param gpu defines if we want GPU particles or CPU particles
  53479. * @returns a new ParticleSystemSet
  53480. */
  53481. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  53482. }
  53483. }
  53484. declare module BABYLON {
  53485. /**
  53486. * This class is made for on one-liner static method to help creating particle system set.
  53487. */
  53488. export class ParticleHelper {
  53489. /**
  53490. * Gets or sets base Assets URL
  53491. */
  53492. static BaseAssetsUrl: string;
  53493. /**
  53494. * Create a default particle system that you can tweak
  53495. * @param emitter defines the emitter to use
  53496. * @param capacity defines the system capacity (default is 500 particles)
  53497. * @param scene defines the hosting scene
  53498. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  53499. * @returns the new Particle system
  53500. */
  53501. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  53502. /**
  53503. * This is the main static method (one-liner) of this helper to create different particle systems
  53504. * @param type This string represents the type to the particle system to create
  53505. * @param scene The scene where the particle system should live
  53506. * @param gpu If the system will use gpu
  53507. * @returns the ParticleSystemSet created
  53508. */
  53509. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  53510. /**
  53511. * Static function used to export a particle system to a ParticleSystemSet variable.
  53512. * Please note that the emitter shape is not exported
  53513. * @param systems defines the particle systems to export
  53514. * @returns the created particle system set
  53515. */
  53516. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  53517. }
  53518. }
  53519. declare module BABYLON {
  53520. interface Engine {
  53521. /**
  53522. * Create an effect to use with particle systems.
  53523. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  53524. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  53525. * @param uniformsNames defines a list of attribute names
  53526. * @param samplers defines an array of string used to represent textures
  53527. * @param defines defines the string containing the defines to use to compile the shaders
  53528. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  53529. * @param onCompiled defines a function to call when the effect creation is successful
  53530. * @param onError defines a function to call when the effect creation has failed
  53531. * @returns the new Effect
  53532. */
  53533. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  53534. }
  53535. interface Mesh {
  53536. /**
  53537. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  53538. * @returns an array of IParticleSystem
  53539. */
  53540. getEmittedParticleSystems(): IParticleSystem[];
  53541. /**
  53542. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  53543. * @returns an array of IParticleSystem
  53544. */
  53545. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  53546. }
  53547. /**
  53548. * @hidden
  53549. */
  53550. export var _IDoNeedToBeInTheBuild: number;
  53551. }
  53552. declare module BABYLON {
  53553. interface Scene {
  53554. /** @hidden (Backing field) */
  53555. _physicsEngine: Nullable<IPhysicsEngine>;
  53556. /**
  53557. * Gets the current physics engine
  53558. * @returns a IPhysicsEngine or null if none attached
  53559. */
  53560. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  53561. /**
  53562. * Enables physics to the current scene
  53563. * @param gravity defines the scene's gravity for the physics engine
  53564. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  53565. * @return a boolean indicating if the physics engine was initialized
  53566. */
  53567. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  53568. /**
  53569. * Disables and disposes the physics engine associated with the scene
  53570. */
  53571. disablePhysicsEngine(): void;
  53572. /**
  53573. * Gets a boolean indicating if there is an active physics engine
  53574. * @returns a boolean indicating if there is an active physics engine
  53575. */
  53576. isPhysicsEnabled(): boolean;
  53577. /**
  53578. * Deletes a physics compound impostor
  53579. * @param compound defines the compound to delete
  53580. */
  53581. deleteCompoundImpostor(compound: any): void;
  53582. /**
  53583. * An event triggered when physic simulation is about to be run
  53584. */
  53585. onBeforePhysicsObservable: Observable<Scene>;
  53586. /**
  53587. * An event triggered when physic simulation has been done
  53588. */
  53589. onAfterPhysicsObservable: Observable<Scene>;
  53590. }
  53591. interface AbstractMesh {
  53592. /** @hidden */
  53593. _physicsImpostor: Nullable<PhysicsImpostor>;
  53594. /**
  53595. * Gets or sets impostor used for physic simulation
  53596. * @see http://doc.babylonjs.com/features/physics_engine
  53597. */
  53598. physicsImpostor: Nullable<PhysicsImpostor>;
  53599. /**
  53600. * Gets the current physics impostor
  53601. * @see http://doc.babylonjs.com/features/physics_engine
  53602. * @returns a physics impostor or null
  53603. */
  53604. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  53605. /** Apply a physic impulse to the mesh
  53606. * @param force defines the force to apply
  53607. * @param contactPoint defines where to apply the force
  53608. * @returns the current mesh
  53609. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53610. */
  53611. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  53612. /**
  53613. * Creates a physic joint between two meshes
  53614. * @param otherMesh defines the other mesh to use
  53615. * @param pivot1 defines the pivot to use on this mesh
  53616. * @param pivot2 defines the pivot to use on the other mesh
  53617. * @param options defines additional options (can be plugin dependent)
  53618. * @returns the current mesh
  53619. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  53620. */
  53621. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  53622. /** @hidden */
  53623. _disposePhysicsObserver: Nullable<Observer<Node>>;
  53624. }
  53625. /**
  53626. * Defines the physics engine scene component responsible to manage a physics engine
  53627. */
  53628. export class PhysicsEngineSceneComponent implements ISceneComponent {
  53629. /**
  53630. * The component name helpful to identify the component in the list of scene components.
  53631. */
  53632. readonly name: string;
  53633. /**
  53634. * The scene the component belongs to.
  53635. */
  53636. scene: Scene;
  53637. /**
  53638. * Creates a new instance of the component for the given scene
  53639. * @param scene Defines the scene to register the component in
  53640. */
  53641. constructor(scene: Scene);
  53642. /**
  53643. * Registers the component in a given scene
  53644. */
  53645. register(): void;
  53646. /**
  53647. * Rebuilds the elements related to this component in case of
  53648. * context lost for instance.
  53649. */
  53650. rebuild(): void;
  53651. /**
  53652. * Disposes the component and the associated ressources
  53653. */
  53654. dispose(): void;
  53655. }
  53656. }
  53657. declare module BABYLON {
  53658. /**
  53659. * A helper for physics simulations
  53660. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53661. */
  53662. export class PhysicsHelper {
  53663. private _scene;
  53664. private _physicsEngine;
  53665. /**
  53666. * Initializes the Physics helper
  53667. * @param scene Babylon.js scene
  53668. */
  53669. constructor(scene: Scene);
  53670. /**
  53671. * Applies a radial explosion impulse
  53672. * @param origin the origin of the explosion
  53673. * @param radiusOrEventOptions the radius or the options of radial explosion
  53674. * @param strength the explosion strength
  53675. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53676. * @returns A physics radial explosion event, or null
  53677. */
  53678. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53679. /**
  53680. * Applies a radial explosion force
  53681. * @param origin the origin of the explosion
  53682. * @param radiusOrEventOptions the radius or the options of radial explosion
  53683. * @param strength the explosion strength
  53684. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53685. * @returns A physics radial explosion event, or null
  53686. */
  53687. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53688. /**
  53689. * Creates a gravitational field
  53690. * @param origin the origin of the explosion
  53691. * @param radiusOrEventOptions the radius or the options of radial explosion
  53692. * @param strength the explosion strength
  53693. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53694. * @returns A physics gravitational field event, or null
  53695. */
  53696. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  53697. /**
  53698. * Creates a physics updraft event
  53699. * @param origin the origin of the updraft
  53700. * @param radiusOrEventOptions the radius or the options of the updraft
  53701. * @param strength the strength of the updraft
  53702. * @param height the height of the updraft
  53703. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  53704. * @returns A physics updraft event, or null
  53705. */
  53706. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  53707. /**
  53708. * Creates a physics vortex event
  53709. * @param origin the of the vortex
  53710. * @param radiusOrEventOptions the radius or the options of the vortex
  53711. * @param strength the strength of the vortex
  53712. * @param height the height of the vortex
  53713. * @returns a Physics vortex event, or null
  53714. * A physics vortex event or null
  53715. */
  53716. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  53717. }
  53718. /**
  53719. * Represents a physics radial explosion event
  53720. */
  53721. class PhysicsRadialExplosionEvent {
  53722. private _scene;
  53723. private _options;
  53724. private _sphere;
  53725. private _dataFetched;
  53726. /**
  53727. * Initializes a radial explosioin event
  53728. * @param _scene BabylonJS scene
  53729. * @param _options The options for the vortex event
  53730. */
  53731. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  53732. /**
  53733. * Returns the data related to the radial explosion event (sphere).
  53734. * @returns The radial explosion event data
  53735. */
  53736. getData(): PhysicsRadialExplosionEventData;
  53737. /**
  53738. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  53739. * @param impostor A physics imposter
  53740. * @param origin the origin of the explosion
  53741. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  53742. */
  53743. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  53744. /**
  53745. * Triggers affecterd impostors callbacks
  53746. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  53747. */
  53748. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  53749. /**
  53750. * Disposes the sphere.
  53751. * @param force Specifies if the sphere should be disposed by force
  53752. */
  53753. dispose(force?: boolean): void;
  53754. /*** Helpers ***/
  53755. private _prepareSphere;
  53756. private _intersectsWithSphere;
  53757. }
  53758. /**
  53759. * Represents a gravitational field event
  53760. */
  53761. class PhysicsGravitationalFieldEvent {
  53762. private _physicsHelper;
  53763. private _scene;
  53764. private _origin;
  53765. private _options;
  53766. private _tickCallback;
  53767. private _sphere;
  53768. private _dataFetched;
  53769. /**
  53770. * Initializes the physics gravitational field event
  53771. * @param _physicsHelper A physics helper
  53772. * @param _scene BabylonJS scene
  53773. * @param _origin The origin position of the gravitational field event
  53774. * @param _options The options for the vortex event
  53775. */
  53776. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  53777. /**
  53778. * Returns the data related to the gravitational field event (sphere).
  53779. * @returns A gravitational field event
  53780. */
  53781. getData(): PhysicsGravitationalFieldEventData;
  53782. /**
  53783. * Enables the gravitational field.
  53784. */
  53785. enable(): void;
  53786. /**
  53787. * Disables the gravitational field.
  53788. */
  53789. disable(): void;
  53790. /**
  53791. * Disposes the sphere.
  53792. * @param force The force to dispose from the gravitational field event
  53793. */
  53794. dispose(force?: boolean): void;
  53795. private _tick;
  53796. }
  53797. /**
  53798. * Represents a physics updraft event
  53799. */
  53800. class PhysicsUpdraftEvent {
  53801. private _scene;
  53802. private _origin;
  53803. private _options;
  53804. private _physicsEngine;
  53805. private _originTop;
  53806. private _originDirection;
  53807. private _tickCallback;
  53808. private _cylinder;
  53809. private _cylinderPosition;
  53810. private _dataFetched;
  53811. /**
  53812. * Initializes the physics updraft event
  53813. * @param _scene BabylonJS scene
  53814. * @param _origin The origin position of the updraft
  53815. * @param _options The options for the updraft event
  53816. */
  53817. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  53818. /**
  53819. * Returns the data related to the updraft event (cylinder).
  53820. * @returns A physics updraft event
  53821. */
  53822. getData(): PhysicsUpdraftEventData;
  53823. /**
  53824. * Enables the updraft.
  53825. */
  53826. enable(): void;
  53827. /**
  53828. * Disables the updraft.
  53829. */
  53830. disable(): void;
  53831. /**
  53832. * Disposes the cylinder.
  53833. * @param force Specifies if the updraft should be disposed by force
  53834. */
  53835. dispose(force?: boolean): void;
  53836. private getImpostorHitData;
  53837. private _tick;
  53838. /*** Helpers ***/
  53839. private _prepareCylinder;
  53840. private _intersectsWithCylinder;
  53841. }
  53842. /**
  53843. * Represents a physics vortex event
  53844. */
  53845. class PhysicsVortexEvent {
  53846. private _scene;
  53847. private _origin;
  53848. private _options;
  53849. private _physicsEngine;
  53850. private _originTop;
  53851. private _tickCallback;
  53852. private _cylinder;
  53853. private _cylinderPosition;
  53854. private _dataFetched;
  53855. /**
  53856. * Initializes the physics vortex event
  53857. * @param _scene The BabylonJS scene
  53858. * @param _origin The origin position of the vortex
  53859. * @param _options The options for the vortex event
  53860. */
  53861. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  53862. /**
  53863. * Returns the data related to the vortex event (cylinder).
  53864. * @returns The physics vortex event data
  53865. */
  53866. getData(): PhysicsVortexEventData;
  53867. /**
  53868. * Enables the vortex.
  53869. */
  53870. enable(): void;
  53871. /**
  53872. * Disables the cortex.
  53873. */
  53874. disable(): void;
  53875. /**
  53876. * Disposes the sphere.
  53877. * @param force
  53878. */
  53879. dispose(force?: boolean): void;
  53880. private getImpostorHitData;
  53881. private _tick;
  53882. /*** Helpers ***/
  53883. private _prepareCylinder;
  53884. private _intersectsWithCylinder;
  53885. }
  53886. /**
  53887. * Options fot the radial explosion event
  53888. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53889. */
  53890. export class PhysicsRadialExplosionEventOptions {
  53891. /**
  53892. * The radius of the sphere for the radial explosion.
  53893. */
  53894. radius: number;
  53895. /**
  53896. * The strenth of the explosion.
  53897. */
  53898. strength: number;
  53899. /**
  53900. * The strenght of the force in correspondence to the distance of the affected object
  53901. */
  53902. falloff: PhysicsRadialImpulseFalloff;
  53903. /**
  53904. * Sphere options for the radial explosion.
  53905. */
  53906. sphere: {
  53907. segments: number;
  53908. diameter: number;
  53909. };
  53910. /**
  53911. * Sphere options for the radial explosion.
  53912. */
  53913. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  53914. }
  53915. /**
  53916. * Options fot the updraft event
  53917. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53918. */
  53919. export class PhysicsUpdraftEventOptions {
  53920. /**
  53921. * The radius of the cylinder for the vortex
  53922. */
  53923. radius: number;
  53924. /**
  53925. * The strenth of the updraft.
  53926. */
  53927. strength: number;
  53928. /**
  53929. * The height of the cylinder for the updraft.
  53930. */
  53931. height: number;
  53932. /**
  53933. * The mode for the the updraft.
  53934. */
  53935. updraftMode: PhysicsUpdraftMode;
  53936. }
  53937. /**
  53938. * Options fot the vortex event
  53939. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53940. */
  53941. export class PhysicsVortexEventOptions {
  53942. /**
  53943. * The radius of the cylinder for the vortex
  53944. */
  53945. radius: number;
  53946. /**
  53947. * The strenth of the vortex.
  53948. */
  53949. strength: number;
  53950. /**
  53951. * The height of the cylinder for the vortex.
  53952. */
  53953. height: number;
  53954. /**
  53955. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  53956. */
  53957. centripetalForceThreshold: number;
  53958. /**
  53959. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  53960. */
  53961. centripetalForceMultiplier: number;
  53962. /**
  53963. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  53964. */
  53965. centrifugalForceMultiplier: number;
  53966. /**
  53967. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  53968. */
  53969. updraftForceMultiplier: number;
  53970. }
  53971. /**
  53972. * The strenght of the force in correspondence to the distance of the affected object
  53973. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53974. */
  53975. export enum PhysicsRadialImpulseFalloff {
  53976. /** Defines that impulse is constant in strength across it's whole radius */
  53977. Constant = 0,
  53978. /** Defines that impulse gets weaker if it's further from the origin */
  53979. Linear = 1
  53980. }
  53981. /**
  53982. * The strength of the force in correspondence to the distance of the affected object
  53983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53984. */
  53985. export enum PhysicsUpdraftMode {
  53986. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  53987. Center = 0,
  53988. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  53989. Perpendicular = 1
  53990. }
  53991. /**
  53992. * Interface for a physics hit data
  53993. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53994. */
  53995. export interface PhysicsHitData {
  53996. /**
  53997. * The force applied at the contact point
  53998. */
  53999. force: Vector3;
  54000. /**
  54001. * The contact point
  54002. */
  54003. contactPoint: Vector3;
  54004. /**
  54005. * The distance from the origin to the contact point
  54006. */
  54007. distanceFromOrigin: number;
  54008. }
  54009. /**
  54010. * Interface for radial explosion event data
  54011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54012. */
  54013. export interface PhysicsRadialExplosionEventData {
  54014. /**
  54015. * A sphere used for the radial explosion event
  54016. */
  54017. sphere: Mesh;
  54018. }
  54019. /**
  54020. * Interface for gravitational field event data
  54021. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54022. */
  54023. export interface PhysicsGravitationalFieldEventData {
  54024. /**
  54025. * A sphere mesh used for the gravitational field event
  54026. */
  54027. sphere: Mesh;
  54028. }
  54029. /**
  54030. * Interface for updraft event data
  54031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54032. */
  54033. export interface PhysicsUpdraftEventData {
  54034. /**
  54035. * A cylinder used for the updraft event
  54036. */
  54037. cylinder: Mesh;
  54038. }
  54039. /**
  54040. * Interface for vortex event data
  54041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54042. */
  54043. export interface PhysicsVortexEventData {
  54044. /**
  54045. * A cylinder used for the vortex event
  54046. */
  54047. cylinder: Mesh;
  54048. }
  54049. /**
  54050. * Interface for an affected physics impostor
  54051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54052. */
  54053. export interface PhysicsAffectedImpostorWithData {
  54054. /**
  54055. * The impostor affected by the effect
  54056. */
  54057. impostor: PhysicsImpostor;
  54058. /**
  54059. * The data about the hit/horce from the explosion
  54060. */
  54061. hitData: PhysicsHitData;
  54062. }
  54063. }
  54064. declare module BABYLON {
  54065. /** @hidden */
  54066. export var blackAndWhitePixelShader: {
  54067. name: string;
  54068. shader: string;
  54069. };
  54070. }
  54071. declare module BABYLON {
  54072. /**
  54073. * Post process used to render in black and white
  54074. */
  54075. export class BlackAndWhitePostProcess extends PostProcess {
  54076. /**
  54077. * Linear about to convert he result to black and white (default: 1)
  54078. */
  54079. degree: number;
  54080. /**
  54081. * Creates a black and white post process
  54082. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54083. * @param name The name of the effect.
  54084. * @param options The required width/height ratio to downsize to before computing the render pass.
  54085. * @param camera The camera to apply the render pass to.
  54086. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54087. * @param engine The engine which the post process will be applied. (default: current engine)
  54088. * @param reusable If the post process can be reused on the same frame. (default: false)
  54089. */
  54090. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54091. }
  54092. }
  54093. declare module BABYLON {
  54094. /**
  54095. * This represents a set of one or more post processes in Babylon.
  54096. * A post process can be used to apply a shader to a texture after it is rendered.
  54097. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54098. */
  54099. export class PostProcessRenderEffect {
  54100. private _postProcesses;
  54101. private _getPostProcesses;
  54102. private _singleInstance;
  54103. private _cameras;
  54104. private _indicesForCamera;
  54105. /**
  54106. * Name of the effect
  54107. * @hidden
  54108. */
  54109. _name: string;
  54110. /**
  54111. * Instantiates a post process render effect.
  54112. * A post process can be used to apply a shader to a texture after it is rendered.
  54113. * @param engine The engine the effect is tied to
  54114. * @param name The name of the effect
  54115. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54116. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54117. */
  54118. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54119. /**
  54120. * Checks if all the post processes in the effect are supported.
  54121. */
  54122. readonly isSupported: boolean;
  54123. /**
  54124. * Updates the current state of the effect
  54125. * @hidden
  54126. */
  54127. _update(): void;
  54128. /**
  54129. * Attaches the effect on cameras
  54130. * @param cameras The camera to attach to.
  54131. * @hidden
  54132. */
  54133. _attachCameras(cameras: Camera): void;
  54134. /**
  54135. * Attaches the effect on cameras
  54136. * @param cameras The camera to attach to.
  54137. * @hidden
  54138. */
  54139. _attachCameras(cameras: Camera[]): void;
  54140. /**
  54141. * Detaches the effect on cameras
  54142. * @param cameras The camera to detatch from.
  54143. * @hidden
  54144. */
  54145. _detachCameras(cameras: Camera): void;
  54146. /**
  54147. * Detatches the effect on cameras
  54148. * @param cameras The camera to detatch from.
  54149. * @hidden
  54150. */
  54151. _detachCameras(cameras: Camera[]): void;
  54152. /**
  54153. * Enables the effect on given cameras
  54154. * @param cameras The camera to enable.
  54155. * @hidden
  54156. */
  54157. _enable(cameras: Camera): void;
  54158. /**
  54159. * Enables the effect on given cameras
  54160. * @param cameras The camera to enable.
  54161. * @hidden
  54162. */
  54163. _enable(cameras: Nullable<Camera[]>): void;
  54164. /**
  54165. * Disables the effect on the given cameras
  54166. * @param cameras The camera to disable.
  54167. * @hidden
  54168. */
  54169. _disable(cameras: Camera): void;
  54170. /**
  54171. * Disables the effect on the given cameras
  54172. * @param cameras The camera to disable.
  54173. * @hidden
  54174. */
  54175. _disable(cameras: Nullable<Camera[]>): void;
  54176. /**
  54177. * Gets a list of the post processes contained in the effect.
  54178. * @param camera The camera to get the post processes on.
  54179. * @returns The list of the post processes in the effect.
  54180. */
  54181. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54182. }
  54183. }
  54184. declare module BABYLON {
  54185. /** @hidden */
  54186. export var extractHighlightsPixelShader: {
  54187. name: string;
  54188. shader: string;
  54189. };
  54190. }
  54191. declare module BABYLON {
  54192. /**
  54193. * 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.
  54194. */
  54195. export class ExtractHighlightsPostProcess extends PostProcess {
  54196. /**
  54197. * The luminance threshold, pixels below this value will be set to black.
  54198. */
  54199. threshold: number;
  54200. /** @hidden */
  54201. _exposure: number;
  54202. /**
  54203. * Post process which has the input texture to be used when performing highlight extraction
  54204. * @hidden
  54205. */
  54206. _inputPostProcess: Nullable<PostProcess>;
  54207. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54208. }
  54209. }
  54210. declare module BABYLON {
  54211. /** @hidden */
  54212. export var bloomMergePixelShader: {
  54213. name: string;
  54214. shader: string;
  54215. };
  54216. }
  54217. declare module BABYLON {
  54218. /**
  54219. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54220. */
  54221. export class BloomMergePostProcess extends PostProcess {
  54222. /** Weight of the bloom to be added to the original input. */
  54223. weight: number;
  54224. /**
  54225. * Creates a new instance of @see BloomMergePostProcess
  54226. * @param name The name of the effect.
  54227. * @param originalFromInput Post process which's input will be used for the merge.
  54228. * @param blurred Blurred highlights post process which's output will be used.
  54229. * @param weight Weight of the bloom to be added to the original input.
  54230. * @param options The required width/height ratio to downsize to before computing the render pass.
  54231. * @param camera The camera to apply the render pass to.
  54232. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54233. * @param engine The engine which the post process will be applied. (default: current engine)
  54234. * @param reusable If the post process can be reused on the same frame. (default: false)
  54235. * @param textureType Type of textures used when performing the post process. (default: 0)
  54236. * @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)
  54237. */
  54238. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54239. /** Weight of the bloom to be added to the original input. */
  54240. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54241. }
  54242. }
  54243. declare module BABYLON {
  54244. /**
  54245. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54246. */
  54247. export class BloomEffect extends PostProcessRenderEffect {
  54248. private bloomScale;
  54249. /**
  54250. * @hidden Internal
  54251. */
  54252. _effects: Array<PostProcess>;
  54253. /**
  54254. * @hidden Internal
  54255. */
  54256. _downscale: ExtractHighlightsPostProcess;
  54257. private _blurX;
  54258. private _blurY;
  54259. private _merge;
  54260. /**
  54261. * The luminance threshold to find bright areas of the image to bloom.
  54262. */
  54263. threshold: number;
  54264. /**
  54265. * The strength of the bloom.
  54266. */
  54267. weight: number;
  54268. /**
  54269. * Specifies the size of the bloom blur kernel, relative to the final output size
  54270. */
  54271. kernel: number;
  54272. /**
  54273. * Creates a new instance of @see BloomEffect
  54274. * @param scene The scene the effect belongs to.
  54275. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54276. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54277. * @param bloomWeight The the strength of bloom.
  54278. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54279. * @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)
  54280. */
  54281. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54282. /**
  54283. * Disposes each of the internal effects for a given camera.
  54284. * @param camera The camera to dispose the effect on.
  54285. */
  54286. disposeEffects(camera: Camera): void;
  54287. /**
  54288. * @hidden Internal
  54289. */
  54290. _updateEffects(): void;
  54291. /**
  54292. * Internal
  54293. * @returns if all the contained post processes are ready.
  54294. * @hidden
  54295. */
  54296. _isReady(): boolean;
  54297. }
  54298. }
  54299. declare module BABYLON {
  54300. /** @hidden */
  54301. export var chromaticAberrationPixelShader: {
  54302. name: string;
  54303. shader: string;
  54304. };
  54305. }
  54306. declare module BABYLON {
  54307. /**
  54308. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54309. */
  54310. export class ChromaticAberrationPostProcess extends PostProcess {
  54311. /**
  54312. * The amount of seperation of rgb channels (default: 30)
  54313. */
  54314. aberrationAmount: number;
  54315. /**
  54316. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54317. */
  54318. radialIntensity: number;
  54319. /**
  54320. * 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))
  54321. */
  54322. direction: Vector2;
  54323. /**
  54324. * 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))
  54325. */
  54326. centerPosition: Vector2;
  54327. /**
  54328. * Creates a new instance ChromaticAberrationPostProcess
  54329. * @param name The name of the effect.
  54330. * @param screenWidth The width of the screen to apply the effect on.
  54331. * @param screenHeight The height of the screen to apply the effect on.
  54332. * @param options The required width/height ratio to downsize to before computing the render pass.
  54333. * @param camera The camera to apply the render pass to.
  54334. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54335. * @param engine The engine which the post process will be applied. (default: current engine)
  54336. * @param reusable If the post process can be reused on the same frame. (default: false)
  54337. * @param textureType Type of textures used when performing the post process. (default: 0)
  54338. * @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)
  54339. */
  54340. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54341. }
  54342. }
  54343. declare module BABYLON {
  54344. /** @hidden */
  54345. export var circleOfConfusionPixelShader: {
  54346. name: string;
  54347. shader: string;
  54348. };
  54349. }
  54350. declare module BABYLON {
  54351. /**
  54352. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  54353. */
  54354. export class CircleOfConfusionPostProcess extends PostProcess {
  54355. /**
  54356. * 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.
  54357. */
  54358. lensSize: number;
  54359. /**
  54360. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54361. */
  54362. fStop: number;
  54363. /**
  54364. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54365. */
  54366. focusDistance: number;
  54367. /**
  54368. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  54369. */
  54370. focalLength: number;
  54371. private _depthTexture;
  54372. /**
  54373. * Creates a new instance CircleOfConfusionPostProcess
  54374. * @param name The name of the effect.
  54375. * @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.
  54376. * @param options The required width/height ratio to downsize to before computing the render pass.
  54377. * @param camera The camera to apply the render pass to.
  54378. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54379. * @param engine The engine which the post process will be applied. (default: current engine)
  54380. * @param reusable If the post process can be reused on the same frame. (default: false)
  54381. * @param textureType Type of textures used when performing the post process. (default: 0)
  54382. * @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)
  54383. */
  54384. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54385. /**
  54386. * 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.
  54387. */
  54388. depthTexture: RenderTargetTexture;
  54389. }
  54390. }
  54391. declare module BABYLON {
  54392. /** @hidden */
  54393. export var colorCorrectionPixelShader: {
  54394. name: string;
  54395. shader: string;
  54396. };
  54397. }
  54398. declare module BABYLON {
  54399. /**
  54400. *
  54401. * This post-process allows the modification of rendered colors by using
  54402. * a 'look-up table' (LUT). This effect is also called Color Grading.
  54403. *
  54404. * The object needs to be provided an url to a texture containing the color
  54405. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  54406. * Use an image editing software to tweak the LUT to match your needs.
  54407. *
  54408. * For an example of a color LUT, see here:
  54409. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  54410. * For explanations on color grading, see here:
  54411. * @see http://udn.epicgames.com/Three/ColorGrading.html
  54412. *
  54413. */
  54414. export class ColorCorrectionPostProcess extends PostProcess {
  54415. private _colorTableTexture;
  54416. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54417. }
  54418. }
  54419. declare module BABYLON {
  54420. /** @hidden */
  54421. export var convolutionPixelShader: {
  54422. name: string;
  54423. shader: string;
  54424. };
  54425. }
  54426. declare module BABYLON {
  54427. /**
  54428. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  54429. * input texture to perform effects such as edge detection or sharpening
  54430. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54431. */
  54432. export class ConvolutionPostProcess extends PostProcess {
  54433. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54434. kernel: number[];
  54435. /**
  54436. * Creates a new instance ConvolutionPostProcess
  54437. * @param name The name of the effect.
  54438. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  54439. * @param options The required width/height ratio to downsize to before computing the render pass.
  54440. * @param camera The camera to apply the render pass to.
  54441. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54442. * @param engine The engine which the post process will be applied. (default: current engine)
  54443. * @param reusable If the post process can be reused on the same frame. (default: false)
  54444. * @param textureType Type of textures used when performing the post process. (default: 0)
  54445. */
  54446. constructor(name: string,
  54447. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54448. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54449. /**
  54450. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54451. */
  54452. static EdgeDetect0Kernel: number[];
  54453. /**
  54454. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54455. */
  54456. static EdgeDetect1Kernel: number[];
  54457. /**
  54458. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54459. */
  54460. static EdgeDetect2Kernel: number[];
  54461. /**
  54462. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54463. */
  54464. static SharpenKernel: number[];
  54465. /**
  54466. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54467. */
  54468. static EmbossKernel: number[];
  54469. /**
  54470. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54471. */
  54472. static GaussianKernel: number[];
  54473. }
  54474. }
  54475. declare module BABYLON {
  54476. /**
  54477. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  54478. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  54479. * based on samples that have a large difference in distance than the center pixel.
  54480. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  54481. */
  54482. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  54483. direction: Vector2;
  54484. /**
  54485. * Creates a new instance CircleOfConfusionPostProcess
  54486. * @param name The name of the effect.
  54487. * @param scene The scene the effect belongs to.
  54488. * @param direction The direction the blur should be applied.
  54489. * @param kernel The size of the kernel used to blur.
  54490. * @param options The required width/height ratio to downsize to before computing the render pass.
  54491. * @param camera The camera to apply the render pass to.
  54492. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  54493. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  54494. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54495. * @param engine The engine which the post process will be applied. (default: current engine)
  54496. * @param reusable If the post process can be reused on the same frame. (default: false)
  54497. * @param textureType Type of textures used when performing the post process. (default: 0)
  54498. * @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)
  54499. */
  54500. 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);
  54501. }
  54502. }
  54503. declare module BABYLON {
  54504. /** @hidden */
  54505. export var depthOfFieldMergePixelShader: {
  54506. name: string;
  54507. shader: string;
  54508. };
  54509. }
  54510. declare module BABYLON {
  54511. /**
  54512. * Options to be set when merging outputs from the default pipeline.
  54513. */
  54514. export class DepthOfFieldMergePostProcessOptions {
  54515. /**
  54516. * The original image to merge on top of
  54517. */
  54518. originalFromInput: PostProcess;
  54519. /**
  54520. * Parameters to perform the merge of the depth of field effect
  54521. */
  54522. depthOfField?: {
  54523. circleOfConfusion: PostProcess;
  54524. blurSteps: Array<PostProcess>;
  54525. };
  54526. /**
  54527. * Parameters to perform the merge of bloom effect
  54528. */
  54529. bloom?: {
  54530. blurred: PostProcess;
  54531. weight: number;
  54532. };
  54533. }
  54534. /**
  54535. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54536. */
  54537. export class DepthOfFieldMergePostProcess extends PostProcess {
  54538. private blurSteps;
  54539. /**
  54540. * Creates a new instance of DepthOfFieldMergePostProcess
  54541. * @param name The name of the effect.
  54542. * @param originalFromInput Post process which's input will be used for the merge.
  54543. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  54544. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  54545. * @param options The required width/height ratio to downsize to before computing the render pass.
  54546. * @param camera The camera to apply the render pass to.
  54547. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54548. * @param engine The engine which the post process will be applied. (default: current engine)
  54549. * @param reusable If the post process can be reused on the same frame. (default: false)
  54550. * @param textureType Type of textures used when performing the post process. (default: 0)
  54551. * @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)
  54552. */
  54553. 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);
  54554. /**
  54555. * Updates the effect with the current post process compile time values and recompiles the shader.
  54556. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  54557. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  54558. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  54559. * @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
  54560. * @param onCompiled Called when the shader has been compiled.
  54561. * @param onError Called if there is an error when compiling a shader.
  54562. */
  54563. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  54564. }
  54565. }
  54566. declare module BABYLON {
  54567. /**
  54568. * Specifies the level of max blur that should be applied when using the depth of field effect
  54569. */
  54570. export enum DepthOfFieldEffectBlurLevel {
  54571. /**
  54572. * Subtle blur
  54573. */
  54574. Low = 0,
  54575. /**
  54576. * Medium blur
  54577. */
  54578. Medium = 1,
  54579. /**
  54580. * Large blur
  54581. */
  54582. High = 2
  54583. }
  54584. /**
  54585. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  54586. */
  54587. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  54588. private _circleOfConfusion;
  54589. /**
  54590. * @hidden Internal, blurs from high to low
  54591. */
  54592. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  54593. private _depthOfFieldBlurY;
  54594. private _dofMerge;
  54595. /**
  54596. * @hidden Internal post processes in depth of field effect
  54597. */
  54598. _effects: Array<PostProcess>;
  54599. /**
  54600. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  54601. */
  54602. focalLength: number;
  54603. /**
  54604. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54605. */
  54606. fStop: number;
  54607. /**
  54608. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54609. */
  54610. focusDistance: number;
  54611. /**
  54612. * 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.
  54613. */
  54614. lensSize: number;
  54615. /**
  54616. * Creates a new instance DepthOfFieldEffect
  54617. * @param scene The scene the effect belongs to.
  54618. * @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.
  54619. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54620. * @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)
  54621. */
  54622. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  54623. /**
  54624. * Get the current class name of the current effet
  54625. * @returns "DepthOfFieldEffect"
  54626. */
  54627. getClassName(): string;
  54628. /**
  54629. * 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.
  54630. */
  54631. depthTexture: RenderTargetTexture;
  54632. /**
  54633. * Disposes each of the internal effects for a given camera.
  54634. * @param camera The camera to dispose the effect on.
  54635. */
  54636. disposeEffects(camera: Camera): void;
  54637. /**
  54638. * @hidden Internal
  54639. */
  54640. _updateEffects(): void;
  54641. /**
  54642. * Internal
  54643. * @returns if all the contained post processes are ready.
  54644. * @hidden
  54645. */
  54646. _isReady(): boolean;
  54647. }
  54648. }
  54649. declare module BABYLON {
  54650. /** @hidden */
  54651. export var displayPassPixelShader: {
  54652. name: string;
  54653. shader: string;
  54654. };
  54655. }
  54656. declare module BABYLON {
  54657. /**
  54658. * DisplayPassPostProcess which produces an output the same as it's input
  54659. */
  54660. export class DisplayPassPostProcess extends PostProcess {
  54661. /**
  54662. * Creates the DisplayPassPostProcess
  54663. * @param name The name of the effect.
  54664. * @param options The required width/height ratio to downsize to before computing the render pass.
  54665. * @param camera The camera to apply the render pass to.
  54666. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54667. * @param engine The engine which the post process will be applied. (default: current engine)
  54668. * @param reusable If the post process can be reused on the same frame. (default: false)
  54669. */
  54670. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54671. }
  54672. }
  54673. declare module BABYLON {
  54674. /** @hidden */
  54675. export var filterPixelShader: {
  54676. name: string;
  54677. shader: string;
  54678. };
  54679. }
  54680. declare module BABYLON {
  54681. /**
  54682. * Applies a kernel filter to the image
  54683. */
  54684. export class FilterPostProcess extends PostProcess {
  54685. /** The matrix to be applied to the image */
  54686. kernelMatrix: Matrix;
  54687. /**
  54688. *
  54689. * @param name The name of the effect.
  54690. * @param kernelMatrix The matrix to be applied to the image
  54691. * @param options The required width/height ratio to downsize to before computing the render pass.
  54692. * @param camera The camera to apply the render pass to.
  54693. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54694. * @param engine The engine which the post process will be applied. (default: current engine)
  54695. * @param reusable If the post process can be reused on the same frame. (default: false)
  54696. */
  54697. constructor(name: string,
  54698. /** The matrix to be applied to the image */
  54699. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54700. }
  54701. }
  54702. declare module BABYLON {
  54703. /** @hidden */
  54704. export var fxaaPixelShader: {
  54705. name: string;
  54706. shader: string;
  54707. };
  54708. }
  54709. declare module BABYLON {
  54710. /** @hidden */
  54711. export var fxaaVertexShader: {
  54712. name: string;
  54713. shader: string;
  54714. };
  54715. }
  54716. declare module BABYLON {
  54717. /**
  54718. * Fxaa post process
  54719. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  54720. */
  54721. export class FxaaPostProcess extends PostProcess {
  54722. /** @hidden */
  54723. texelWidth: number;
  54724. /** @hidden */
  54725. texelHeight: number;
  54726. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54727. private _getDefines;
  54728. }
  54729. }
  54730. declare module BABYLON {
  54731. /** @hidden */
  54732. export var grainPixelShader: {
  54733. name: string;
  54734. shader: string;
  54735. };
  54736. }
  54737. declare module BABYLON {
  54738. /**
  54739. * The GrainPostProcess adds noise to the image at mid luminance levels
  54740. */
  54741. export class GrainPostProcess extends PostProcess {
  54742. /**
  54743. * The intensity of the grain added (default: 30)
  54744. */
  54745. intensity: number;
  54746. /**
  54747. * If the grain should be randomized on every frame
  54748. */
  54749. animated: boolean;
  54750. /**
  54751. * Creates a new instance of @see GrainPostProcess
  54752. * @param name The name of the effect.
  54753. * @param options The required width/height ratio to downsize to before computing the render pass.
  54754. * @param camera The camera to apply the render pass to.
  54755. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54756. * @param engine The engine which the post process will be applied. (default: current engine)
  54757. * @param reusable If the post process can be reused on the same frame. (default: false)
  54758. * @param textureType Type of textures used when performing the post process. (default: 0)
  54759. * @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)
  54760. */
  54761. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54762. }
  54763. }
  54764. declare module BABYLON {
  54765. /** @hidden */
  54766. export var highlightsPixelShader: {
  54767. name: string;
  54768. shader: string;
  54769. };
  54770. }
  54771. declare module BABYLON {
  54772. /**
  54773. * Extracts highlights from the image
  54774. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54775. */
  54776. export class HighlightsPostProcess extends PostProcess {
  54777. /**
  54778. * Extracts highlights from the image
  54779. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54780. * @param name The name of the effect.
  54781. * @param options The required width/height ratio to downsize to before computing the render pass.
  54782. * @param camera The camera to apply the render pass to.
  54783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54784. * @param engine The engine which the post process will be applied. (default: current engine)
  54785. * @param reusable If the post process can be reused on the same frame. (default: false)
  54786. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  54787. */
  54788. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54789. }
  54790. }
  54791. declare module BABYLON {
  54792. /** @hidden */
  54793. export var mrtFragmentDeclaration: {
  54794. name: string;
  54795. shader: string;
  54796. };
  54797. }
  54798. declare module BABYLON {
  54799. /** @hidden */
  54800. export var geometryPixelShader: {
  54801. name: string;
  54802. shader: string;
  54803. };
  54804. }
  54805. declare module BABYLON {
  54806. /** @hidden */
  54807. export var geometryVertexShader: {
  54808. name: string;
  54809. shader: string;
  54810. };
  54811. }
  54812. declare module BABYLON {
  54813. /** @hidden */
  54814. interface ISavedTransformationMatrix {
  54815. world: Matrix;
  54816. viewProjection: Matrix;
  54817. }
  54818. /**
  54819. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  54820. */
  54821. export class GeometryBufferRenderer {
  54822. /**
  54823. * Constant used to retrieve the position texture index in the G-Buffer textures array
  54824. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  54825. */
  54826. static readonly POSITION_TEXTURE_TYPE: number;
  54827. /**
  54828. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  54829. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  54830. */
  54831. static readonly VELOCITY_TEXTURE_TYPE: number;
  54832. /**
  54833. * Dictionary used to store the previous transformation matrices of each rendered mesh
  54834. * in order to compute objects velocities when enableVelocity is set to "true"
  54835. * @hidden
  54836. */
  54837. _previousTransformationMatrices: {
  54838. [index: number]: ISavedTransformationMatrix;
  54839. };
  54840. /**
  54841. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  54842. * in order to compute objects velocities when enableVelocity is set to "true"
  54843. * @hidden
  54844. */
  54845. _previousBonesTransformationMatrices: {
  54846. [index: number]: Float32Array;
  54847. };
  54848. /**
  54849. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  54850. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  54851. */
  54852. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  54853. private _scene;
  54854. private _multiRenderTarget;
  54855. private _ratio;
  54856. private _enablePosition;
  54857. private _enableVelocity;
  54858. private _positionIndex;
  54859. private _velocityIndex;
  54860. protected _effect: Effect;
  54861. protected _cachedDefines: string;
  54862. /**
  54863. * Set the render list (meshes to be rendered) used in the G buffer.
  54864. */
  54865. renderList: Mesh[];
  54866. /**
  54867. * Gets wether or not G buffer are supported by the running hardware.
  54868. * This requires draw buffer supports
  54869. */
  54870. readonly isSupported: boolean;
  54871. /**
  54872. * Returns the index of the given texture type in the G-Buffer textures array
  54873. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  54874. * @returns the index of the given texture type in the G-Buffer textures array
  54875. */
  54876. getTextureIndex(textureType: number): number;
  54877. /**
  54878. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  54879. */
  54880. /**
  54881. * Sets whether or not objects positions are enabled for the G buffer.
  54882. */
  54883. enablePosition: boolean;
  54884. /**
  54885. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  54886. */
  54887. /**
  54888. * Sets wether or not objects velocities are enabled for the G buffer.
  54889. */
  54890. enableVelocity: boolean;
  54891. /**
  54892. * Gets the scene associated with the buffer.
  54893. */
  54894. readonly scene: Scene;
  54895. /**
  54896. * Gets the ratio used by the buffer during its creation.
  54897. * How big is the buffer related to the main canvas.
  54898. */
  54899. readonly ratio: number;
  54900. /** @hidden */
  54901. static _SceneComponentInitialization: (scene: Scene) => void;
  54902. /**
  54903. * Creates a new G Buffer for the scene
  54904. * @param scene The scene the buffer belongs to
  54905. * @param ratio How big is the buffer related to the main canvas.
  54906. */
  54907. constructor(scene: Scene, ratio?: number);
  54908. /**
  54909. * Checks wether everything is ready to render a submesh to the G buffer.
  54910. * @param subMesh the submesh to check readiness for
  54911. * @param useInstances is the mesh drawn using instance or not
  54912. * @returns true if ready otherwise false
  54913. */
  54914. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54915. /**
  54916. * Gets the current underlying G Buffer.
  54917. * @returns the buffer
  54918. */
  54919. getGBuffer(): MultiRenderTarget;
  54920. /**
  54921. * Gets the number of samples used to render the buffer (anti aliasing).
  54922. */
  54923. /**
  54924. * Sets the number of samples used to render the buffer (anti aliasing).
  54925. */
  54926. samples: number;
  54927. /**
  54928. * Disposes the renderer and frees up associated resources.
  54929. */
  54930. dispose(): void;
  54931. protected _createRenderTargets(): void;
  54932. private _copyBonesTransformationMatrices;
  54933. }
  54934. }
  54935. declare module BABYLON {
  54936. interface Scene {
  54937. /** @hidden (Backing field) */
  54938. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54939. /**
  54940. * Gets or Sets the current geometry buffer associated to the scene.
  54941. */
  54942. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54943. /**
  54944. * Enables a GeometryBufferRender and associates it with the scene
  54945. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  54946. * @returns the GeometryBufferRenderer
  54947. */
  54948. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  54949. /**
  54950. * Disables the GeometryBufferRender associated with the scene
  54951. */
  54952. disableGeometryBufferRenderer(): void;
  54953. }
  54954. /**
  54955. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  54956. * in several rendering techniques.
  54957. */
  54958. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  54959. /**
  54960. * The component name helpful to identify the component in the list of scene components.
  54961. */
  54962. readonly name: string;
  54963. /**
  54964. * The scene the component belongs to.
  54965. */
  54966. scene: Scene;
  54967. /**
  54968. * Creates a new instance of the component for the given scene
  54969. * @param scene Defines the scene to register the component in
  54970. */
  54971. constructor(scene: Scene);
  54972. /**
  54973. * Registers the component in a given scene
  54974. */
  54975. register(): void;
  54976. /**
  54977. * Rebuilds the elements related to this component in case of
  54978. * context lost for instance.
  54979. */
  54980. rebuild(): void;
  54981. /**
  54982. * Disposes the component and the associated ressources
  54983. */
  54984. dispose(): void;
  54985. private _gatherRenderTargets;
  54986. }
  54987. }
  54988. declare module BABYLON {
  54989. /** @hidden */
  54990. export var motionBlurPixelShader: {
  54991. name: string;
  54992. shader: string;
  54993. };
  54994. }
  54995. declare module BABYLON {
  54996. /**
  54997. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  54998. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  54999. * As an example, all you have to do is to create the post-process:
  55000. * var mb = new BABYLON.MotionBlurPostProcess(
  55001. * 'mb', // The name of the effect.
  55002. * scene, // The scene containing the objects to blur according to their velocity.
  55003. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55004. * camera // The camera to apply the render pass to.
  55005. * );
  55006. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55007. */
  55008. export class MotionBlurPostProcess extends PostProcess {
  55009. /**
  55010. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55011. */
  55012. motionStrength: number;
  55013. /**
  55014. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55015. */
  55016. /**
  55017. * Sets the number of iterations to be used for motion blur quality
  55018. */
  55019. motionBlurSamples: number;
  55020. private _motionBlurSamples;
  55021. private _geometryBufferRenderer;
  55022. /**
  55023. * Creates a new instance MotionBlurPostProcess
  55024. * @param name The name of the effect.
  55025. * @param scene The scene containing the objects to blur according to their velocity.
  55026. * @param options The required width/height ratio to downsize to before computing the render pass.
  55027. * @param camera The camera to apply the render pass to.
  55028. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55029. * @param engine The engine which the post process will be applied. (default: current engine)
  55030. * @param reusable If the post process can be reused on the same frame. (default: false)
  55031. * @param textureType Type of textures used when performing the post process. (default: 0)
  55032. * @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)
  55033. */
  55034. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55035. /**
  55036. * Excludes the given skinned mesh from computing bones velocities.
  55037. * 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.
  55038. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  55039. */
  55040. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55041. /**
  55042. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  55043. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  55044. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  55045. */
  55046. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55047. /**
  55048. * Disposes the post process.
  55049. * @param camera The camera to dispose the post process on.
  55050. */
  55051. dispose(camera?: Camera): void;
  55052. }
  55053. }
  55054. declare module BABYLON {
  55055. /** @hidden */
  55056. export var refractionPixelShader: {
  55057. name: string;
  55058. shader: string;
  55059. };
  55060. }
  55061. declare module BABYLON {
  55062. /**
  55063. * Post process which applies a refractin texture
  55064. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55065. */
  55066. export class RefractionPostProcess extends PostProcess {
  55067. /** the base color of the refraction (used to taint the rendering) */
  55068. color: Color3;
  55069. /** simulated refraction depth */
  55070. depth: number;
  55071. /** the coefficient of the base color (0 to remove base color tainting) */
  55072. colorLevel: number;
  55073. private _refTexture;
  55074. private _ownRefractionTexture;
  55075. /**
  55076. * Gets or sets the refraction texture
  55077. * Please note that you are responsible for disposing the texture if you set it manually
  55078. */
  55079. refractionTexture: Texture;
  55080. /**
  55081. * Initializes the RefractionPostProcess
  55082. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55083. * @param name The name of the effect.
  55084. * @param refractionTextureUrl Url of the refraction texture to use
  55085. * @param color the base color of the refraction (used to taint the rendering)
  55086. * @param depth simulated refraction depth
  55087. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55088. * @param camera The camera to apply the render pass to.
  55089. * @param options The required width/height ratio to downsize to before computing the render pass.
  55090. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55091. * @param engine The engine which the post process will be applied. (default: current engine)
  55092. * @param reusable If the post process can be reused on the same frame. (default: false)
  55093. */
  55094. constructor(name: string, refractionTextureUrl: string,
  55095. /** the base color of the refraction (used to taint the rendering) */
  55096. color: Color3,
  55097. /** simulated refraction depth */
  55098. depth: number,
  55099. /** the coefficient of the base color (0 to remove base color tainting) */
  55100. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55101. /**
  55102. * Disposes of the post process
  55103. * @param camera Camera to dispose post process on
  55104. */
  55105. dispose(camera: Camera): void;
  55106. }
  55107. }
  55108. declare module BABYLON {
  55109. /** @hidden */
  55110. export var sharpenPixelShader: {
  55111. name: string;
  55112. shader: string;
  55113. };
  55114. }
  55115. declare module BABYLON {
  55116. /**
  55117. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55118. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55119. */
  55120. export class SharpenPostProcess extends PostProcess {
  55121. /**
  55122. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55123. */
  55124. colorAmount: number;
  55125. /**
  55126. * How much sharpness should be applied (default: 0.3)
  55127. */
  55128. edgeAmount: number;
  55129. /**
  55130. * Creates a new instance ConvolutionPostProcess
  55131. * @param name The name of the effect.
  55132. * @param options The required width/height ratio to downsize to before computing the render pass.
  55133. * @param camera The camera to apply the render pass to.
  55134. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55135. * @param engine The engine which the post process will be applied. (default: current engine)
  55136. * @param reusable If the post process can be reused on the same frame. (default: false)
  55137. * @param textureType Type of textures used when performing the post process. (default: 0)
  55138. * @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)
  55139. */
  55140. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55141. }
  55142. }
  55143. declare module BABYLON {
  55144. /**
  55145. * PostProcessRenderPipeline
  55146. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55147. */
  55148. export class PostProcessRenderPipeline {
  55149. private engine;
  55150. private _renderEffects;
  55151. private _renderEffectsForIsolatedPass;
  55152. /**
  55153. * List of inspectable custom properties (used by the Inspector)
  55154. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55155. */
  55156. inspectableCustomProperties: IInspectable[];
  55157. /**
  55158. * @hidden
  55159. */
  55160. protected _cameras: Camera[];
  55161. /** @hidden */
  55162. _name: string;
  55163. /**
  55164. * Gets pipeline name
  55165. */
  55166. readonly name: string;
  55167. /**
  55168. * Initializes a PostProcessRenderPipeline
  55169. * @param engine engine to add the pipeline to
  55170. * @param name name of the pipeline
  55171. */
  55172. constructor(engine: Engine, name: string);
  55173. /**
  55174. * Gets the class name
  55175. * @returns "PostProcessRenderPipeline"
  55176. */
  55177. getClassName(): string;
  55178. /**
  55179. * If all the render effects in the pipeline are supported
  55180. */
  55181. readonly isSupported: boolean;
  55182. /**
  55183. * Adds an effect to the pipeline
  55184. * @param renderEffect the effect to add
  55185. */
  55186. addEffect(renderEffect: PostProcessRenderEffect): void;
  55187. /** @hidden */
  55188. _rebuild(): void;
  55189. /** @hidden */
  55190. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55191. /** @hidden */
  55192. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55193. /** @hidden */
  55194. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55195. /** @hidden */
  55196. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55197. /** @hidden */
  55198. _attachCameras(cameras: Camera, unique: boolean): void;
  55199. /** @hidden */
  55200. _attachCameras(cameras: Camera[], unique: boolean): void;
  55201. /** @hidden */
  55202. _detachCameras(cameras: Camera): void;
  55203. /** @hidden */
  55204. _detachCameras(cameras: Nullable<Camera[]>): void;
  55205. /** @hidden */
  55206. _update(): void;
  55207. /** @hidden */
  55208. _reset(): void;
  55209. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55210. /**
  55211. * Disposes of the pipeline
  55212. */
  55213. dispose(): void;
  55214. }
  55215. }
  55216. declare module BABYLON {
  55217. /**
  55218. * PostProcessRenderPipelineManager class
  55219. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55220. */
  55221. export class PostProcessRenderPipelineManager {
  55222. private _renderPipelines;
  55223. /**
  55224. * Initializes a PostProcessRenderPipelineManager
  55225. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55226. */
  55227. constructor();
  55228. /**
  55229. * Gets the list of supported render pipelines
  55230. */
  55231. readonly supportedPipelines: PostProcessRenderPipeline[];
  55232. /**
  55233. * Adds a pipeline to the manager
  55234. * @param renderPipeline The pipeline to add
  55235. */
  55236. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55237. /**
  55238. * Attaches a camera to the pipeline
  55239. * @param renderPipelineName The name of the pipeline to attach to
  55240. * @param cameras the camera to attach
  55241. * @param unique if the camera can be attached multiple times to the pipeline
  55242. */
  55243. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55244. /**
  55245. * Detaches a camera from the pipeline
  55246. * @param renderPipelineName The name of the pipeline to detach from
  55247. * @param cameras the camera to detach
  55248. */
  55249. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55250. /**
  55251. * Enables an effect by name on a pipeline
  55252. * @param renderPipelineName the name of the pipeline to enable the effect in
  55253. * @param renderEffectName the name of the effect to enable
  55254. * @param cameras the cameras that the effect should be enabled on
  55255. */
  55256. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55257. /**
  55258. * Disables an effect by name on a pipeline
  55259. * @param renderPipelineName the name of the pipeline to disable the effect in
  55260. * @param renderEffectName the name of the effect to disable
  55261. * @param cameras the cameras that the effect should be disabled on
  55262. */
  55263. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55264. /**
  55265. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55266. */
  55267. update(): void;
  55268. /** @hidden */
  55269. _rebuild(): void;
  55270. /**
  55271. * Disposes of the manager and pipelines
  55272. */
  55273. dispose(): void;
  55274. }
  55275. }
  55276. declare module BABYLON {
  55277. interface Scene {
  55278. /** @hidden (Backing field) */
  55279. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55280. /**
  55281. * Gets the postprocess render pipeline manager
  55282. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55283. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55284. */
  55285. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55286. }
  55287. /**
  55288. * Defines the Render Pipeline scene component responsible to rendering pipelines
  55289. */
  55290. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  55291. /**
  55292. * The component name helpfull to identify the component in the list of scene components.
  55293. */
  55294. readonly name: string;
  55295. /**
  55296. * The scene the component belongs to.
  55297. */
  55298. scene: Scene;
  55299. /**
  55300. * Creates a new instance of the component for the given scene
  55301. * @param scene Defines the scene to register the component in
  55302. */
  55303. constructor(scene: Scene);
  55304. /**
  55305. * Registers the component in a given scene
  55306. */
  55307. register(): void;
  55308. /**
  55309. * Rebuilds the elements related to this component in case of
  55310. * context lost for instance.
  55311. */
  55312. rebuild(): void;
  55313. /**
  55314. * Disposes the component and the associated ressources
  55315. */
  55316. dispose(): void;
  55317. private _gatherRenderTargets;
  55318. }
  55319. }
  55320. declare module BABYLON {
  55321. /**
  55322. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  55323. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55324. */
  55325. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55326. private _scene;
  55327. private _camerasToBeAttached;
  55328. /**
  55329. * ID of the sharpen post process,
  55330. */
  55331. private readonly SharpenPostProcessId;
  55332. /**
  55333. * @ignore
  55334. * ID of the image processing post process;
  55335. */
  55336. readonly ImageProcessingPostProcessId: string;
  55337. /**
  55338. * @ignore
  55339. * ID of the Fast Approximate Anti-Aliasing post process;
  55340. */
  55341. readonly FxaaPostProcessId: string;
  55342. /**
  55343. * ID of the chromatic aberration post process,
  55344. */
  55345. private readonly ChromaticAberrationPostProcessId;
  55346. /**
  55347. * ID of the grain post process
  55348. */
  55349. private readonly GrainPostProcessId;
  55350. /**
  55351. * Sharpen post process which will apply a sharpen convolution to enhance edges
  55352. */
  55353. sharpen: SharpenPostProcess;
  55354. private _sharpenEffect;
  55355. private bloom;
  55356. /**
  55357. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  55358. */
  55359. depthOfField: DepthOfFieldEffect;
  55360. /**
  55361. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55362. */
  55363. fxaa: FxaaPostProcess;
  55364. /**
  55365. * Image post processing pass used to perform operations such as tone mapping or color grading.
  55366. */
  55367. imageProcessing: ImageProcessingPostProcess;
  55368. /**
  55369. * Chromatic aberration post process which will shift rgb colors in the image
  55370. */
  55371. chromaticAberration: ChromaticAberrationPostProcess;
  55372. private _chromaticAberrationEffect;
  55373. /**
  55374. * Grain post process which add noise to the image
  55375. */
  55376. grain: GrainPostProcess;
  55377. private _grainEffect;
  55378. /**
  55379. * Glow post process which adds a glow to emissive areas of the image
  55380. */
  55381. private _glowLayer;
  55382. /**
  55383. * Animations which can be used to tweak settings over a period of time
  55384. */
  55385. animations: Animation[];
  55386. private _imageProcessingConfigurationObserver;
  55387. private _sharpenEnabled;
  55388. private _bloomEnabled;
  55389. private _depthOfFieldEnabled;
  55390. private _depthOfFieldBlurLevel;
  55391. private _fxaaEnabled;
  55392. private _imageProcessingEnabled;
  55393. private _defaultPipelineTextureType;
  55394. private _bloomScale;
  55395. private _chromaticAberrationEnabled;
  55396. private _grainEnabled;
  55397. private _buildAllowed;
  55398. /**
  55399. * Gets active scene
  55400. */
  55401. readonly scene: Scene;
  55402. /**
  55403. * Enable or disable the sharpen process from the pipeline
  55404. */
  55405. sharpenEnabled: boolean;
  55406. private _resizeObserver;
  55407. private _hardwareScaleLevel;
  55408. private _bloomKernel;
  55409. /**
  55410. * Specifies the size of the bloom blur kernel, relative to the final output size
  55411. */
  55412. bloomKernel: number;
  55413. /**
  55414. * Specifies the weight of the bloom in the final rendering
  55415. */
  55416. private _bloomWeight;
  55417. /**
  55418. * Specifies the luma threshold for the area that will be blurred by the bloom
  55419. */
  55420. private _bloomThreshold;
  55421. private _hdr;
  55422. /**
  55423. * The strength of the bloom.
  55424. */
  55425. bloomWeight: number;
  55426. /**
  55427. * The strength of the bloom.
  55428. */
  55429. bloomThreshold: number;
  55430. /**
  55431. * The scale of the bloom, lower value will provide better performance.
  55432. */
  55433. bloomScale: number;
  55434. /**
  55435. * Enable or disable the bloom from the pipeline
  55436. */
  55437. bloomEnabled: boolean;
  55438. private _rebuildBloom;
  55439. /**
  55440. * If the depth of field is enabled.
  55441. */
  55442. depthOfFieldEnabled: boolean;
  55443. /**
  55444. * Blur level of the depth of field effect. (Higher blur will effect performance)
  55445. */
  55446. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  55447. /**
  55448. * If the anti aliasing is enabled.
  55449. */
  55450. fxaaEnabled: boolean;
  55451. private _samples;
  55452. /**
  55453. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55454. */
  55455. samples: number;
  55456. /**
  55457. * If image processing is enabled.
  55458. */
  55459. imageProcessingEnabled: boolean;
  55460. /**
  55461. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  55462. */
  55463. glowLayerEnabled: boolean;
  55464. /**
  55465. * Gets the glow layer (or null if not defined)
  55466. */
  55467. readonly glowLayer: Nullable<GlowLayer>;
  55468. /**
  55469. * Enable or disable the chromaticAberration process from the pipeline
  55470. */
  55471. chromaticAberrationEnabled: boolean;
  55472. /**
  55473. * Enable or disable the grain process from the pipeline
  55474. */
  55475. grainEnabled: boolean;
  55476. /**
  55477. * @constructor
  55478. * @param name - The rendering pipeline name (default: "")
  55479. * @param hdr - If high dynamic range textures should be used (default: true)
  55480. * @param scene - The scene linked to this pipeline (default: the last created scene)
  55481. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  55482. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  55483. */
  55484. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  55485. /**
  55486. * Get the class name
  55487. * @returns "DefaultRenderingPipeline"
  55488. */
  55489. getClassName(): string;
  55490. /**
  55491. * Force the compilation of the entire pipeline.
  55492. */
  55493. prepare(): void;
  55494. private _hasCleared;
  55495. private _prevPostProcess;
  55496. private _prevPrevPostProcess;
  55497. private _setAutoClearAndTextureSharing;
  55498. private _depthOfFieldSceneObserver;
  55499. private _buildPipeline;
  55500. private _disposePostProcesses;
  55501. /**
  55502. * Adds a camera to the pipeline
  55503. * @param camera the camera to be added
  55504. */
  55505. addCamera(camera: Camera): void;
  55506. /**
  55507. * Removes a camera from the pipeline
  55508. * @param camera the camera to remove
  55509. */
  55510. removeCamera(camera: Camera): void;
  55511. /**
  55512. * Dispose of the pipeline and stop all post processes
  55513. */
  55514. dispose(): void;
  55515. /**
  55516. * Serialize the rendering pipeline (Used when exporting)
  55517. * @returns the serialized object
  55518. */
  55519. serialize(): any;
  55520. /**
  55521. * Parse the serialized pipeline
  55522. * @param source Source pipeline.
  55523. * @param scene The scene to load the pipeline to.
  55524. * @param rootUrl The URL of the serialized pipeline.
  55525. * @returns An instantiated pipeline from the serialized object.
  55526. */
  55527. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  55528. }
  55529. }
  55530. declare module BABYLON {
  55531. /** @hidden */
  55532. export var lensHighlightsPixelShader: {
  55533. name: string;
  55534. shader: string;
  55535. };
  55536. }
  55537. declare module BABYLON {
  55538. /** @hidden */
  55539. export var depthOfFieldPixelShader: {
  55540. name: string;
  55541. shader: string;
  55542. };
  55543. }
  55544. declare module BABYLON {
  55545. /**
  55546. * BABYLON.JS Chromatic Aberration GLSL Shader
  55547. * Author: Olivier Guyot
  55548. * Separates very slightly R, G and B colors on the edges of the screen
  55549. * Inspired by Francois Tarlier & Martins Upitis
  55550. */
  55551. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  55552. /**
  55553. * @ignore
  55554. * The chromatic aberration PostProcess id in the pipeline
  55555. */
  55556. LensChromaticAberrationEffect: string;
  55557. /**
  55558. * @ignore
  55559. * The highlights enhancing PostProcess id in the pipeline
  55560. */
  55561. HighlightsEnhancingEffect: string;
  55562. /**
  55563. * @ignore
  55564. * The depth-of-field PostProcess id in the pipeline
  55565. */
  55566. LensDepthOfFieldEffect: string;
  55567. private _scene;
  55568. private _depthTexture;
  55569. private _grainTexture;
  55570. private _chromaticAberrationPostProcess;
  55571. private _highlightsPostProcess;
  55572. private _depthOfFieldPostProcess;
  55573. private _edgeBlur;
  55574. private _grainAmount;
  55575. private _chromaticAberration;
  55576. private _distortion;
  55577. private _highlightsGain;
  55578. private _highlightsThreshold;
  55579. private _dofDistance;
  55580. private _dofAperture;
  55581. private _dofDarken;
  55582. private _dofPentagon;
  55583. private _blurNoise;
  55584. /**
  55585. * @constructor
  55586. *
  55587. * Effect parameters are as follow:
  55588. * {
  55589. * chromatic_aberration: number; // from 0 to x (1 for realism)
  55590. * edge_blur: number; // from 0 to x (1 for realism)
  55591. * distortion: number; // from 0 to x (1 for realism)
  55592. * grain_amount: number; // from 0 to 1
  55593. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  55594. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  55595. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  55596. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  55597. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  55598. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  55599. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  55600. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  55601. * }
  55602. * Note: if an effect parameter is unset, effect is disabled
  55603. *
  55604. * @param name The rendering pipeline name
  55605. * @param parameters - An object containing all parameters (see above)
  55606. * @param scene The scene linked to this pipeline
  55607. * @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)
  55608. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55609. */
  55610. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  55611. /**
  55612. * Get the class name
  55613. * @returns "LensRenderingPipeline"
  55614. */
  55615. getClassName(): string;
  55616. /**
  55617. * Gets associated scene
  55618. */
  55619. readonly scene: Scene;
  55620. /**
  55621. * Gets or sets the edge blur
  55622. */
  55623. edgeBlur: number;
  55624. /**
  55625. * Gets or sets the grain amount
  55626. */
  55627. grainAmount: number;
  55628. /**
  55629. * Gets or sets the chromatic aberration amount
  55630. */
  55631. chromaticAberration: number;
  55632. /**
  55633. * Gets or sets the depth of field aperture
  55634. */
  55635. dofAperture: number;
  55636. /**
  55637. * Gets or sets the edge distortion
  55638. */
  55639. edgeDistortion: number;
  55640. /**
  55641. * Gets or sets the depth of field distortion
  55642. */
  55643. dofDistortion: number;
  55644. /**
  55645. * Gets or sets the darken out of focus amount
  55646. */
  55647. darkenOutOfFocus: number;
  55648. /**
  55649. * Gets or sets a boolean indicating if blur noise is enabled
  55650. */
  55651. blurNoise: boolean;
  55652. /**
  55653. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  55654. */
  55655. pentagonBokeh: boolean;
  55656. /**
  55657. * Gets or sets the highlight grain amount
  55658. */
  55659. highlightsGain: number;
  55660. /**
  55661. * Gets or sets the highlight threshold
  55662. */
  55663. highlightsThreshold: number;
  55664. /**
  55665. * Sets the amount of blur at the edges
  55666. * @param amount blur amount
  55667. */
  55668. setEdgeBlur(amount: number): void;
  55669. /**
  55670. * Sets edge blur to 0
  55671. */
  55672. disableEdgeBlur(): void;
  55673. /**
  55674. * Sets the amout of grain
  55675. * @param amount Amount of grain
  55676. */
  55677. setGrainAmount(amount: number): void;
  55678. /**
  55679. * Set grain amount to 0
  55680. */
  55681. disableGrain(): void;
  55682. /**
  55683. * Sets the chromatic aberration amount
  55684. * @param amount amount of chromatic aberration
  55685. */
  55686. setChromaticAberration(amount: number): void;
  55687. /**
  55688. * Sets chromatic aberration amount to 0
  55689. */
  55690. disableChromaticAberration(): void;
  55691. /**
  55692. * Sets the EdgeDistortion amount
  55693. * @param amount amount of EdgeDistortion
  55694. */
  55695. setEdgeDistortion(amount: number): void;
  55696. /**
  55697. * Sets edge distortion to 0
  55698. */
  55699. disableEdgeDistortion(): void;
  55700. /**
  55701. * Sets the FocusDistance amount
  55702. * @param amount amount of FocusDistance
  55703. */
  55704. setFocusDistance(amount: number): void;
  55705. /**
  55706. * Disables depth of field
  55707. */
  55708. disableDepthOfField(): void;
  55709. /**
  55710. * Sets the Aperture amount
  55711. * @param amount amount of Aperture
  55712. */
  55713. setAperture(amount: number): void;
  55714. /**
  55715. * Sets the DarkenOutOfFocus amount
  55716. * @param amount amount of DarkenOutOfFocus
  55717. */
  55718. setDarkenOutOfFocus(amount: number): void;
  55719. private _pentagonBokehIsEnabled;
  55720. /**
  55721. * Creates a pentagon bokeh effect
  55722. */
  55723. enablePentagonBokeh(): void;
  55724. /**
  55725. * Disables the pentagon bokeh effect
  55726. */
  55727. disablePentagonBokeh(): void;
  55728. /**
  55729. * Enables noise blur
  55730. */
  55731. enableNoiseBlur(): void;
  55732. /**
  55733. * Disables noise blur
  55734. */
  55735. disableNoiseBlur(): void;
  55736. /**
  55737. * Sets the HighlightsGain amount
  55738. * @param amount amount of HighlightsGain
  55739. */
  55740. setHighlightsGain(amount: number): void;
  55741. /**
  55742. * Sets the HighlightsThreshold amount
  55743. * @param amount amount of HighlightsThreshold
  55744. */
  55745. setHighlightsThreshold(amount: number): void;
  55746. /**
  55747. * Disables highlights
  55748. */
  55749. disableHighlights(): void;
  55750. /**
  55751. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  55752. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  55753. */
  55754. dispose(disableDepthRender?: boolean): void;
  55755. private _createChromaticAberrationPostProcess;
  55756. private _createHighlightsPostProcess;
  55757. private _createDepthOfFieldPostProcess;
  55758. private _createGrainTexture;
  55759. }
  55760. }
  55761. declare module BABYLON {
  55762. /** @hidden */
  55763. export var ssao2PixelShader: {
  55764. name: string;
  55765. shader: string;
  55766. };
  55767. }
  55768. declare module BABYLON {
  55769. /** @hidden */
  55770. export var ssaoCombinePixelShader: {
  55771. name: string;
  55772. shader: string;
  55773. };
  55774. }
  55775. declare module BABYLON {
  55776. /**
  55777. * Render pipeline to produce ssao effect
  55778. */
  55779. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  55780. /**
  55781. * @ignore
  55782. * The PassPostProcess id in the pipeline that contains the original scene color
  55783. */
  55784. SSAOOriginalSceneColorEffect: string;
  55785. /**
  55786. * @ignore
  55787. * The SSAO PostProcess id in the pipeline
  55788. */
  55789. SSAORenderEffect: string;
  55790. /**
  55791. * @ignore
  55792. * The horizontal blur PostProcess id in the pipeline
  55793. */
  55794. SSAOBlurHRenderEffect: string;
  55795. /**
  55796. * @ignore
  55797. * The vertical blur PostProcess id in the pipeline
  55798. */
  55799. SSAOBlurVRenderEffect: string;
  55800. /**
  55801. * @ignore
  55802. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55803. */
  55804. SSAOCombineRenderEffect: string;
  55805. /**
  55806. * The output strength of the SSAO post-process. Default value is 1.0.
  55807. */
  55808. totalStrength: number;
  55809. /**
  55810. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  55811. */
  55812. maxZ: number;
  55813. /**
  55814. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  55815. */
  55816. minZAspect: number;
  55817. private _samples;
  55818. /**
  55819. * Number of samples used for the SSAO calculations. Default value is 8
  55820. */
  55821. samples: number;
  55822. private _textureSamples;
  55823. /**
  55824. * Number of samples to use for antialiasing
  55825. */
  55826. textureSamples: number;
  55827. /**
  55828. * Ratio object used for SSAO ratio and blur ratio
  55829. */
  55830. private _ratio;
  55831. /**
  55832. * Dynamically generated sphere sampler.
  55833. */
  55834. private _sampleSphere;
  55835. /**
  55836. * Blur filter offsets
  55837. */
  55838. private _samplerOffsets;
  55839. private _expensiveBlur;
  55840. /**
  55841. * If bilateral blur should be used
  55842. */
  55843. expensiveBlur: boolean;
  55844. /**
  55845. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  55846. */
  55847. radius: number;
  55848. /**
  55849. * The base color of the SSAO post-process
  55850. * The final result is "base + ssao" between [0, 1]
  55851. */
  55852. base: number;
  55853. /**
  55854. * Support test.
  55855. */
  55856. static readonly IsSupported: boolean;
  55857. private _scene;
  55858. private _depthTexture;
  55859. private _normalTexture;
  55860. private _randomTexture;
  55861. private _originalColorPostProcess;
  55862. private _ssaoPostProcess;
  55863. private _blurHPostProcess;
  55864. private _blurVPostProcess;
  55865. private _ssaoCombinePostProcess;
  55866. private _firstUpdate;
  55867. /**
  55868. * Gets active scene
  55869. */
  55870. readonly scene: Scene;
  55871. /**
  55872. * @constructor
  55873. * @param name The rendering pipeline name
  55874. * @param scene The scene linked to this pipeline
  55875. * @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 }
  55876. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55877. */
  55878. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55879. /**
  55880. * Get the class name
  55881. * @returns "SSAO2RenderingPipeline"
  55882. */
  55883. getClassName(): string;
  55884. /**
  55885. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55886. */
  55887. dispose(disableGeometryBufferRenderer?: boolean): void;
  55888. private _createBlurPostProcess;
  55889. /** @hidden */
  55890. _rebuild(): void;
  55891. private _bits;
  55892. private _radicalInverse_VdC;
  55893. private _hammersley;
  55894. private _hemisphereSample_uniform;
  55895. private _generateHemisphere;
  55896. private _createSSAOPostProcess;
  55897. private _createSSAOCombinePostProcess;
  55898. private _createRandomTexture;
  55899. /**
  55900. * Serialize the rendering pipeline (Used when exporting)
  55901. * @returns the serialized object
  55902. */
  55903. serialize(): any;
  55904. /**
  55905. * Parse the serialized pipeline
  55906. * @param source Source pipeline.
  55907. * @param scene The scene to load the pipeline to.
  55908. * @param rootUrl The URL of the serialized pipeline.
  55909. * @returns An instantiated pipeline from the serialized object.
  55910. */
  55911. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  55912. }
  55913. }
  55914. declare module BABYLON {
  55915. /** @hidden */
  55916. export var ssaoPixelShader: {
  55917. name: string;
  55918. shader: string;
  55919. };
  55920. }
  55921. declare module BABYLON {
  55922. /**
  55923. * Render pipeline to produce ssao effect
  55924. */
  55925. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  55926. /**
  55927. * @ignore
  55928. * The PassPostProcess id in the pipeline that contains the original scene color
  55929. */
  55930. SSAOOriginalSceneColorEffect: string;
  55931. /**
  55932. * @ignore
  55933. * The SSAO PostProcess id in the pipeline
  55934. */
  55935. SSAORenderEffect: string;
  55936. /**
  55937. * @ignore
  55938. * The horizontal blur PostProcess id in the pipeline
  55939. */
  55940. SSAOBlurHRenderEffect: string;
  55941. /**
  55942. * @ignore
  55943. * The vertical blur PostProcess id in the pipeline
  55944. */
  55945. SSAOBlurVRenderEffect: string;
  55946. /**
  55947. * @ignore
  55948. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55949. */
  55950. SSAOCombineRenderEffect: string;
  55951. /**
  55952. * The output strength of the SSAO post-process. Default value is 1.0.
  55953. */
  55954. totalStrength: number;
  55955. /**
  55956. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  55957. */
  55958. radius: number;
  55959. /**
  55960. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  55961. * Must not be equal to fallOff and superior to fallOff.
  55962. * Default value is 0.0075
  55963. */
  55964. area: number;
  55965. /**
  55966. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  55967. * Must not be equal to area and inferior to area.
  55968. * Default value is 0.000001
  55969. */
  55970. fallOff: number;
  55971. /**
  55972. * The base color of the SSAO post-process
  55973. * The final result is "base + ssao" between [0, 1]
  55974. */
  55975. base: number;
  55976. private _scene;
  55977. private _depthTexture;
  55978. private _randomTexture;
  55979. private _originalColorPostProcess;
  55980. private _ssaoPostProcess;
  55981. private _blurHPostProcess;
  55982. private _blurVPostProcess;
  55983. private _ssaoCombinePostProcess;
  55984. private _firstUpdate;
  55985. /**
  55986. * Gets active scene
  55987. */
  55988. readonly scene: Scene;
  55989. /**
  55990. * @constructor
  55991. * @param name - The rendering pipeline name
  55992. * @param scene - The scene linked to this pipeline
  55993. * @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 }
  55994. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  55995. */
  55996. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55997. /**
  55998. * Get the class name
  55999. * @returns "SSAORenderingPipeline"
  56000. */
  56001. getClassName(): string;
  56002. /**
  56003. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56004. */
  56005. dispose(disableDepthRender?: boolean): void;
  56006. private _createBlurPostProcess;
  56007. /** @hidden */
  56008. _rebuild(): void;
  56009. private _createSSAOPostProcess;
  56010. private _createSSAOCombinePostProcess;
  56011. private _createRandomTexture;
  56012. }
  56013. }
  56014. declare module BABYLON {
  56015. /** @hidden */
  56016. export var standardPixelShader: {
  56017. name: string;
  56018. shader: string;
  56019. };
  56020. }
  56021. declare module BABYLON {
  56022. /**
  56023. * Standard rendering pipeline
  56024. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56025. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56026. */
  56027. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56028. /**
  56029. * Public members
  56030. */
  56031. /**
  56032. * Post-process which contains the original scene color before the pipeline applies all the effects
  56033. */
  56034. originalPostProcess: Nullable<PostProcess>;
  56035. /**
  56036. * Post-process used to down scale an image x4
  56037. */
  56038. downSampleX4PostProcess: Nullable<PostProcess>;
  56039. /**
  56040. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56041. */
  56042. brightPassPostProcess: Nullable<PostProcess>;
  56043. /**
  56044. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56045. */
  56046. blurHPostProcesses: PostProcess[];
  56047. /**
  56048. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56049. */
  56050. blurVPostProcesses: PostProcess[];
  56051. /**
  56052. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56053. */
  56054. textureAdderPostProcess: Nullable<PostProcess>;
  56055. /**
  56056. * Post-process used to create volumetric lighting effect
  56057. */
  56058. volumetricLightPostProcess: Nullable<PostProcess>;
  56059. /**
  56060. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56061. */
  56062. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56063. /**
  56064. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56065. */
  56066. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56067. /**
  56068. * Post-process used to merge the volumetric light effect and the real scene color
  56069. */
  56070. volumetricLightMergePostProces: Nullable<PostProcess>;
  56071. /**
  56072. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56073. */
  56074. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56075. /**
  56076. * Base post-process used to calculate the average luminance of the final image for HDR
  56077. */
  56078. luminancePostProcess: Nullable<PostProcess>;
  56079. /**
  56080. * Post-processes used to create down sample post-processes in order to get
  56081. * the average luminance of the final image for HDR
  56082. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56083. */
  56084. luminanceDownSamplePostProcesses: PostProcess[];
  56085. /**
  56086. * Post-process used to create a HDR effect (light adaptation)
  56087. */
  56088. hdrPostProcess: Nullable<PostProcess>;
  56089. /**
  56090. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56091. */
  56092. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56093. /**
  56094. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56095. */
  56096. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56097. /**
  56098. * Post-process used to merge the final HDR post-process and the real scene color
  56099. */
  56100. hdrFinalPostProcess: Nullable<PostProcess>;
  56101. /**
  56102. * Post-process used to create a lens flare effect
  56103. */
  56104. lensFlarePostProcess: Nullable<PostProcess>;
  56105. /**
  56106. * Post-process that merges the result of the lens flare post-process and the real scene color
  56107. */
  56108. lensFlareComposePostProcess: Nullable<PostProcess>;
  56109. /**
  56110. * Post-process used to create a motion blur effect
  56111. */
  56112. motionBlurPostProcess: Nullable<PostProcess>;
  56113. /**
  56114. * Post-process used to create a depth of field effect
  56115. */
  56116. depthOfFieldPostProcess: Nullable<PostProcess>;
  56117. /**
  56118. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56119. */
  56120. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56121. /**
  56122. * Represents the brightness threshold in order to configure the illuminated surfaces
  56123. */
  56124. brightThreshold: number;
  56125. /**
  56126. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56127. */
  56128. blurWidth: number;
  56129. /**
  56130. * Sets if the blur for highlighted surfaces must be only horizontal
  56131. */
  56132. horizontalBlur: boolean;
  56133. /**
  56134. * Gets the overall exposure used by the pipeline
  56135. */
  56136. /**
  56137. * Sets the overall exposure used by the pipeline
  56138. */
  56139. exposure: number;
  56140. /**
  56141. * Texture used typically to simulate "dirty" on camera lens
  56142. */
  56143. lensTexture: Nullable<Texture>;
  56144. /**
  56145. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56146. */
  56147. volumetricLightCoefficient: number;
  56148. /**
  56149. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56150. */
  56151. volumetricLightPower: number;
  56152. /**
  56153. * Used the set the blur intensity to smooth the volumetric lights
  56154. */
  56155. volumetricLightBlurScale: number;
  56156. /**
  56157. * Light (spot or directional) used to generate the volumetric lights rays
  56158. * The source light must have a shadow generate so the pipeline can get its
  56159. * depth map
  56160. */
  56161. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56162. /**
  56163. * For eye adaptation, represents the minimum luminance the eye can see
  56164. */
  56165. hdrMinimumLuminance: number;
  56166. /**
  56167. * For eye adaptation, represents the decrease luminance speed
  56168. */
  56169. hdrDecreaseRate: number;
  56170. /**
  56171. * For eye adaptation, represents the increase luminance speed
  56172. */
  56173. hdrIncreaseRate: number;
  56174. /**
  56175. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56176. */
  56177. /**
  56178. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56179. */
  56180. hdrAutoExposure: boolean;
  56181. /**
  56182. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56183. */
  56184. lensColorTexture: Nullable<Texture>;
  56185. /**
  56186. * The overall strengh for the lens flare effect
  56187. */
  56188. lensFlareStrength: number;
  56189. /**
  56190. * Dispersion coefficient for lens flare ghosts
  56191. */
  56192. lensFlareGhostDispersal: number;
  56193. /**
  56194. * Main lens flare halo width
  56195. */
  56196. lensFlareHaloWidth: number;
  56197. /**
  56198. * Based on the lens distortion effect, defines how much the lens flare result
  56199. * is distorted
  56200. */
  56201. lensFlareDistortionStrength: number;
  56202. /**
  56203. * Lens star texture must be used to simulate rays on the flares and is available
  56204. * in the documentation
  56205. */
  56206. lensStarTexture: Nullable<Texture>;
  56207. /**
  56208. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56209. * flare effect by taking account of the dirt texture
  56210. */
  56211. lensFlareDirtTexture: Nullable<Texture>;
  56212. /**
  56213. * Represents the focal length for the depth of field effect
  56214. */
  56215. depthOfFieldDistance: number;
  56216. /**
  56217. * Represents the blur intensity for the blurred part of the depth of field effect
  56218. */
  56219. depthOfFieldBlurWidth: number;
  56220. /**
  56221. * Gets how much the image is blurred by the movement while using the motion blur post-process
  56222. */
  56223. /**
  56224. * Sets how much the image is blurred by the movement while using the motion blur post-process
  56225. */
  56226. motionStrength: number;
  56227. /**
  56228. * Gets wether or not the motion blur post-process is object based or screen based.
  56229. */
  56230. /**
  56231. * Sets wether or not the motion blur post-process should be object based or screen based
  56232. */
  56233. objectBasedMotionBlur: boolean;
  56234. /**
  56235. * List of animations for the pipeline (IAnimatable implementation)
  56236. */
  56237. animations: Animation[];
  56238. /**
  56239. * Private members
  56240. */
  56241. private _scene;
  56242. private _currentDepthOfFieldSource;
  56243. private _basePostProcess;
  56244. private _fixedExposure;
  56245. private _currentExposure;
  56246. private _hdrAutoExposure;
  56247. private _hdrCurrentLuminance;
  56248. private _motionStrength;
  56249. private _isObjectBasedMotionBlur;
  56250. private _floatTextureType;
  56251. private _ratio;
  56252. private _bloomEnabled;
  56253. private _depthOfFieldEnabled;
  56254. private _vlsEnabled;
  56255. private _lensFlareEnabled;
  56256. private _hdrEnabled;
  56257. private _motionBlurEnabled;
  56258. private _fxaaEnabled;
  56259. private _motionBlurSamples;
  56260. private _volumetricLightStepsCount;
  56261. private _samples;
  56262. /**
  56263. * @ignore
  56264. * Specifies if the bloom pipeline is enabled
  56265. */
  56266. BloomEnabled: boolean;
  56267. /**
  56268. * @ignore
  56269. * Specifies if the depth of field pipeline is enabed
  56270. */
  56271. DepthOfFieldEnabled: boolean;
  56272. /**
  56273. * @ignore
  56274. * Specifies if the lens flare pipeline is enabed
  56275. */
  56276. LensFlareEnabled: boolean;
  56277. /**
  56278. * @ignore
  56279. * Specifies if the HDR pipeline is enabled
  56280. */
  56281. HDREnabled: boolean;
  56282. /**
  56283. * @ignore
  56284. * Specifies if the volumetric lights scattering effect is enabled
  56285. */
  56286. VLSEnabled: boolean;
  56287. /**
  56288. * @ignore
  56289. * Specifies if the motion blur effect is enabled
  56290. */
  56291. MotionBlurEnabled: boolean;
  56292. /**
  56293. * Specifies if anti-aliasing is enabled
  56294. */
  56295. fxaaEnabled: boolean;
  56296. /**
  56297. * Specifies the number of steps used to calculate the volumetric lights
  56298. * Typically in interval [50, 200]
  56299. */
  56300. volumetricLightStepsCount: number;
  56301. /**
  56302. * Specifies the number of samples used for the motion blur effect
  56303. * Typically in interval [16, 64]
  56304. */
  56305. motionBlurSamples: number;
  56306. /**
  56307. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56308. */
  56309. samples: number;
  56310. /**
  56311. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56312. * @constructor
  56313. * @param name The rendering pipeline name
  56314. * @param scene The scene linked to this pipeline
  56315. * @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)
  56316. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  56317. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56318. */
  56319. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  56320. private _buildPipeline;
  56321. private _createDownSampleX4PostProcess;
  56322. private _createBrightPassPostProcess;
  56323. private _createBlurPostProcesses;
  56324. private _createTextureAdderPostProcess;
  56325. private _createVolumetricLightPostProcess;
  56326. private _createLuminancePostProcesses;
  56327. private _createHdrPostProcess;
  56328. private _createLensFlarePostProcess;
  56329. private _createDepthOfFieldPostProcess;
  56330. private _createMotionBlurPostProcess;
  56331. private _getDepthTexture;
  56332. private _disposePostProcesses;
  56333. /**
  56334. * Dispose of the pipeline and stop all post processes
  56335. */
  56336. dispose(): void;
  56337. /**
  56338. * Serialize the rendering pipeline (Used when exporting)
  56339. * @returns the serialized object
  56340. */
  56341. serialize(): any;
  56342. /**
  56343. * Parse the serialized pipeline
  56344. * @param source Source pipeline.
  56345. * @param scene The scene to load the pipeline to.
  56346. * @param rootUrl The URL of the serialized pipeline.
  56347. * @returns An instantiated pipeline from the serialized object.
  56348. */
  56349. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  56350. /**
  56351. * Luminance steps
  56352. */
  56353. static LuminanceSteps: number;
  56354. }
  56355. }
  56356. declare module BABYLON {
  56357. /** @hidden */
  56358. export var tonemapPixelShader: {
  56359. name: string;
  56360. shader: string;
  56361. };
  56362. }
  56363. declare module BABYLON {
  56364. /** Defines operator used for tonemapping */
  56365. export enum TonemappingOperator {
  56366. /** Hable */
  56367. Hable = 0,
  56368. /** Reinhard */
  56369. Reinhard = 1,
  56370. /** HejiDawson */
  56371. HejiDawson = 2,
  56372. /** Photographic */
  56373. Photographic = 3
  56374. }
  56375. /**
  56376. * Defines a post process to apply tone mapping
  56377. */
  56378. export class TonemapPostProcess extends PostProcess {
  56379. private _operator;
  56380. /** Defines the required exposure adjustement */
  56381. exposureAdjustment: number;
  56382. /**
  56383. * Creates a new TonemapPostProcess
  56384. * @param name defines the name of the postprocess
  56385. * @param _operator defines the operator to use
  56386. * @param exposureAdjustment defines the required exposure adjustement
  56387. * @param camera defines the camera to use (can be null)
  56388. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  56389. * @param engine defines the hosting engine (can be ignore if camera is set)
  56390. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56391. */
  56392. constructor(name: string, _operator: TonemappingOperator,
  56393. /** Defines the required exposure adjustement */
  56394. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  56395. }
  56396. }
  56397. declare module BABYLON {
  56398. /** @hidden */
  56399. export var depthVertexShader: {
  56400. name: string;
  56401. shader: string;
  56402. };
  56403. }
  56404. declare module BABYLON {
  56405. /** @hidden */
  56406. export var volumetricLightScatteringPixelShader: {
  56407. name: string;
  56408. shader: string;
  56409. };
  56410. }
  56411. declare module BABYLON {
  56412. /** @hidden */
  56413. export var volumetricLightScatteringPassPixelShader: {
  56414. name: string;
  56415. shader: string;
  56416. };
  56417. }
  56418. declare module BABYLON {
  56419. /**
  56420. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  56421. */
  56422. export class VolumetricLightScatteringPostProcess extends PostProcess {
  56423. private _volumetricLightScatteringPass;
  56424. private _volumetricLightScatteringRTT;
  56425. private _viewPort;
  56426. private _screenCoordinates;
  56427. private _cachedDefines;
  56428. /**
  56429. * If not undefined, the mesh position is computed from the attached node position
  56430. */
  56431. attachedNode: {
  56432. position: Vector3;
  56433. };
  56434. /**
  56435. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  56436. */
  56437. customMeshPosition: Vector3;
  56438. /**
  56439. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  56440. */
  56441. useCustomMeshPosition: boolean;
  56442. /**
  56443. * If the post-process should inverse the light scattering direction
  56444. */
  56445. invert: boolean;
  56446. /**
  56447. * The internal mesh used by the post-process
  56448. */
  56449. mesh: Mesh;
  56450. /**
  56451. * @hidden
  56452. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  56453. */
  56454. useDiffuseColor: boolean;
  56455. /**
  56456. * Array containing the excluded meshes not rendered in the internal pass
  56457. */
  56458. excludedMeshes: AbstractMesh[];
  56459. /**
  56460. * Controls the overall intensity of the post-process
  56461. */
  56462. exposure: number;
  56463. /**
  56464. * Dissipates each sample's contribution in range [0, 1]
  56465. */
  56466. decay: number;
  56467. /**
  56468. * Controls the overall intensity of each sample
  56469. */
  56470. weight: number;
  56471. /**
  56472. * Controls the density of each sample
  56473. */
  56474. density: number;
  56475. /**
  56476. * @constructor
  56477. * @param name The post-process name
  56478. * @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)
  56479. * @param camera The camera that the post-process will be attached to
  56480. * @param mesh The mesh used to create the light scattering
  56481. * @param samples The post-process quality, default 100
  56482. * @param samplingModeThe post-process filtering mode
  56483. * @param engine The babylon engine
  56484. * @param reusable If the post-process is reusable
  56485. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  56486. */
  56487. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  56488. /**
  56489. * Returns the string "VolumetricLightScatteringPostProcess"
  56490. * @returns "VolumetricLightScatteringPostProcess"
  56491. */
  56492. getClassName(): string;
  56493. private _isReady;
  56494. /**
  56495. * Sets the new light position for light scattering effect
  56496. * @param position The new custom light position
  56497. */
  56498. setCustomMeshPosition(position: Vector3): void;
  56499. /**
  56500. * Returns the light position for light scattering effect
  56501. * @return Vector3 The custom light position
  56502. */
  56503. getCustomMeshPosition(): Vector3;
  56504. /**
  56505. * Disposes the internal assets and detaches the post-process from the camera
  56506. */
  56507. dispose(camera: Camera): void;
  56508. /**
  56509. * Returns the render target texture used by the post-process
  56510. * @return the render target texture used by the post-process
  56511. */
  56512. getPass(): RenderTargetTexture;
  56513. private _meshExcluded;
  56514. private _createPass;
  56515. private _updateMeshScreenCoordinates;
  56516. /**
  56517. * Creates a default mesh for the Volumeric Light Scattering post-process
  56518. * @param name The mesh name
  56519. * @param scene The scene where to create the mesh
  56520. * @return the default mesh
  56521. */
  56522. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  56523. }
  56524. }
  56525. declare module BABYLON {
  56526. interface Scene {
  56527. /** @hidden (Backing field) */
  56528. _boundingBoxRenderer: BoundingBoxRenderer;
  56529. /** @hidden (Backing field) */
  56530. _forceShowBoundingBoxes: boolean;
  56531. /**
  56532. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  56533. */
  56534. forceShowBoundingBoxes: boolean;
  56535. /**
  56536. * Gets the bounding box renderer associated with the scene
  56537. * @returns a BoundingBoxRenderer
  56538. */
  56539. getBoundingBoxRenderer(): BoundingBoxRenderer;
  56540. }
  56541. interface AbstractMesh {
  56542. /** @hidden (Backing field) */
  56543. _showBoundingBox: boolean;
  56544. /**
  56545. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  56546. */
  56547. showBoundingBox: boolean;
  56548. }
  56549. /**
  56550. * Component responsible of rendering the bounding box of the meshes in a scene.
  56551. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  56552. */
  56553. export class BoundingBoxRenderer implements ISceneComponent {
  56554. /**
  56555. * The component name helpfull to identify the component in the list of scene components.
  56556. */
  56557. readonly name: string;
  56558. /**
  56559. * The scene the component belongs to.
  56560. */
  56561. scene: Scene;
  56562. /**
  56563. * Color of the bounding box lines placed in front of an object
  56564. */
  56565. frontColor: Color3;
  56566. /**
  56567. * Color of the bounding box lines placed behind an object
  56568. */
  56569. backColor: Color3;
  56570. /**
  56571. * Defines if the renderer should show the back lines or not
  56572. */
  56573. showBackLines: boolean;
  56574. /**
  56575. * @hidden
  56576. */
  56577. renderList: SmartArray<BoundingBox>;
  56578. private _colorShader;
  56579. private _vertexBuffers;
  56580. private _indexBuffer;
  56581. /**
  56582. * Instantiates a new bounding box renderer in a scene.
  56583. * @param scene the scene the renderer renders in
  56584. */
  56585. constructor(scene: Scene);
  56586. /**
  56587. * Registers the component in a given scene
  56588. */
  56589. register(): void;
  56590. private _evaluateSubMesh;
  56591. private _activeMesh;
  56592. private _prepareRessources;
  56593. private _createIndexBuffer;
  56594. /**
  56595. * Rebuilds the elements related to this component in case of
  56596. * context lost for instance.
  56597. */
  56598. rebuild(): void;
  56599. /**
  56600. * @hidden
  56601. */
  56602. reset(): void;
  56603. /**
  56604. * Render the bounding boxes of a specific rendering group
  56605. * @param renderingGroupId defines the rendering group to render
  56606. */
  56607. render(renderingGroupId: number): void;
  56608. /**
  56609. * In case of occlusion queries, we can render the occlusion bounding box through this method
  56610. * @param mesh Define the mesh to render the occlusion bounding box for
  56611. */
  56612. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  56613. /**
  56614. * Dispose and release the resources attached to this renderer.
  56615. */
  56616. dispose(): void;
  56617. }
  56618. }
  56619. declare module BABYLON {
  56620. /** @hidden */
  56621. export var depthPixelShader: {
  56622. name: string;
  56623. shader: string;
  56624. };
  56625. }
  56626. declare module BABYLON {
  56627. /**
  56628. * This represents a depth renderer in Babylon.
  56629. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56630. */
  56631. export class DepthRenderer {
  56632. private _scene;
  56633. private _depthMap;
  56634. private _effect;
  56635. private _cachedDefines;
  56636. private _camera;
  56637. /**
  56638. * Specifiess that the depth renderer will only be used within
  56639. * the camera it is created for.
  56640. * This can help forcing its rendering during the camera processing.
  56641. */
  56642. useOnlyInActiveCamera: boolean;
  56643. /** @hidden */
  56644. static _SceneComponentInitialization: (scene: Scene) => void;
  56645. /**
  56646. * Instantiates a depth renderer
  56647. * @param scene The scene the renderer belongs to
  56648. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56649. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56650. */
  56651. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  56652. /**
  56653. * Creates the depth rendering effect and checks if the effect is ready.
  56654. * @param subMesh The submesh to be used to render the depth map of
  56655. * @param useInstances If multiple world instances should be used
  56656. * @returns if the depth renderer is ready to render the depth map
  56657. */
  56658. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56659. /**
  56660. * Gets the texture which the depth map will be written to.
  56661. * @returns The depth map texture
  56662. */
  56663. getDepthMap(): RenderTargetTexture;
  56664. /**
  56665. * Disposes of the depth renderer.
  56666. */
  56667. dispose(): void;
  56668. }
  56669. }
  56670. declare module BABYLON {
  56671. interface Scene {
  56672. /** @hidden (Backing field) */
  56673. _depthRenderer: {
  56674. [id: string]: DepthRenderer;
  56675. };
  56676. /**
  56677. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  56678. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  56679. * @returns the created depth renderer
  56680. */
  56681. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  56682. /**
  56683. * Disables a depth renderer for a given camera
  56684. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  56685. */
  56686. disableDepthRenderer(camera?: Nullable<Camera>): void;
  56687. }
  56688. /**
  56689. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  56690. * in several rendering techniques.
  56691. */
  56692. export class DepthRendererSceneComponent implements ISceneComponent {
  56693. /**
  56694. * The component name helpfull to identify the component in the list of scene components.
  56695. */
  56696. readonly name: string;
  56697. /**
  56698. * The scene the component belongs to.
  56699. */
  56700. scene: Scene;
  56701. /**
  56702. * Creates a new instance of the component for the given scene
  56703. * @param scene Defines the scene to register the component in
  56704. */
  56705. constructor(scene: Scene);
  56706. /**
  56707. * Registers the component in a given scene
  56708. */
  56709. register(): void;
  56710. /**
  56711. * Rebuilds the elements related to this component in case of
  56712. * context lost for instance.
  56713. */
  56714. rebuild(): void;
  56715. /**
  56716. * Disposes the component and the associated ressources
  56717. */
  56718. dispose(): void;
  56719. private _gatherRenderTargets;
  56720. private _gatherActiveCameraRenderTargets;
  56721. }
  56722. }
  56723. declare module BABYLON {
  56724. /** @hidden */
  56725. export var outlinePixelShader: {
  56726. name: string;
  56727. shader: string;
  56728. };
  56729. }
  56730. declare module BABYLON {
  56731. /** @hidden */
  56732. export var outlineVertexShader: {
  56733. name: string;
  56734. shader: string;
  56735. };
  56736. }
  56737. declare module BABYLON {
  56738. interface Scene {
  56739. /** @hidden */
  56740. _outlineRenderer: OutlineRenderer;
  56741. /**
  56742. * Gets the outline renderer associated with the scene
  56743. * @returns a OutlineRenderer
  56744. */
  56745. getOutlineRenderer(): OutlineRenderer;
  56746. }
  56747. interface AbstractMesh {
  56748. /** @hidden (Backing field) */
  56749. _renderOutline: boolean;
  56750. /**
  56751. * Gets or sets a boolean indicating if the outline must be rendered as well
  56752. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  56753. */
  56754. renderOutline: boolean;
  56755. /** @hidden (Backing field) */
  56756. _renderOverlay: boolean;
  56757. /**
  56758. * Gets or sets a boolean indicating if the overlay must be rendered as well
  56759. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  56760. */
  56761. renderOverlay: boolean;
  56762. }
  56763. /**
  56764. * This class is responsible to draw bothe outline/overlay of meshes.
  56765. * It should not be used directly but through the available method on mesh.
  56766. */
  56767. export class OutlineRenderer implements ISceneComponent {
  56768. /**
  56769. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  56770. */
  56771. private static _StencilReference;
  56772. /**
  56773. * The name of the component. Each component must have a unique name.
  56774. */
  56775. name: string;
  56776. /**
  56777. * The scene the component belongs to.
  56778. */
  56779. scene: Scene;
  56780. /**
  56781. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  56782. */
  56783. zOffset: number;
  56784. private _engine;
  56785. private _effect;
  56786. private _cachedDefines;
  56787. private _savedDepthWrite;
  56788. /**
  56789. * Instantiates a new outline renderer. (There could be only one per scene).
  56790. * @param scene Defines the scene it belongs to
  56791. */
  56792. constructor(scene: Scene);
  56793. /**
  56794. * Register the component to one instance of a scene.
  56795. */
  56796. register(): void;
  56797. /**
  56798. * Rebuilds the elements related to this component in case of
  56799. * context lost for instance.
  56800. */
  56801. rebuild(): void;
  56802. /**
  56803. * Disposes the component and the associated ressources.
  56804. */
  56805. dispose(): void;
  56806. /**
  56807. * Renders the outline in the canvas.
  56808. * @param subMesh Defines the sumesh to render
  56809. * @param batch Defines the batch of meshes in case of instances
  56810. * @param useOverlay Defines if the rendering is for the overlay or the outline
  56811. */
  56812. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  56813. /**
  56814. * Returns whether or not the outline renderer is ready for a given submesh.
  56815. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  56816. * @param subMesh Defines the submesh to check readyness for
  56817. * @param useInstances Defines wheter wee are trying to render instances or not
  56818. * @returns true if ready otherwise false
  56819. */
  56820. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56821. private _beforeRenderingMesh;
  56822. private _afterRenderingMesh;
  56823. }
  56824. }
  56825. declare module BABYLON {
  56826. /**
  56827. * Defines the list of states available for a task inside a AssetsManager
  56828. */
  56829. export enum AssetTaskState {
  56830. /**
  56831. * Initialization
  56832. */
  56833. INIT = 0,
  56834. /**
  56835. * Running
  56836. */
  56837. RUNNING = 1,
  56838. /**
  56839. * Done
  56840. */
  56841. DONE = 2,
  56842. /**
  56843. * Error
  56844. */
  56845. ERROR = 3
  56846. }
  56847. /**
  56848. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  56849. */
  56850. export abstract class AbstractAssetTask {
  56851. /**
  56852. * Task name
  56853. */ name: string;
  56854. /**
  56855. * Callback called when the task is successful
  56856. */
  56857. onSuccess: (task: any) => void;
  56858. /**
  56859. * Callback called when the task is not successful
  56860. */
  56861. onError: (task: any, message?: string, exception?: any) => void;
  56862. /**
  56863. * Creates a new AssetsManager
  56864. * @param name defines the name of the task
  56865. */
  56866. constructor(
  56867. /**
  56868. * Task name
  56869. */ name: string);
  56870. private _isCompleted;
  56871. private _taskState;
  56872. private _errorObject;
  56873. /**
  56874. * Get if the task is completed
  56875. */
  56876. readonly isCompleted: boolean;
  56877. /**
  56878. * Gets the current state of the task
  56879. */
  56880. readonly taskState: AssetTaskState;
  56881. /**
  56882. * Gets the current error object (if task is in error)
  56883. */
  56884. readonly errorObject: {
  56885. message?: string;
  56886. exception?: any;
  56887. };
  56888. /**
  56889. * Internal only
  56890. * @hidden
  56891. */
  56892. _setErrorObject(message?: string, exception?: any): void;
  56893. /**
  56894. * Execute the current task
  56895. * @param scene defines the scene where you want your assets to be loaded
  56896. * @param onSuccess is a callback called when the task is successfully executed
  56897. * @param onError is a callback called if an error occurs
  56898. */
  56899. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56900. /**
  56901. * Execute the current task
  56902. * @param scene defines the scene where you want your assets to be loaded
  56903. * @param onSuccess is a callback called when the task is successfully executed
  56904. * @param onError is a callback called if an error occurs
  56905. */
  56906. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56907. /**
  56908. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  56909. * This can be used with failed tasks that have the reason for failure fixed.
  56910. */
  56911. reset(): void;
  56912. private onErrorCallback;
  56913. private onDoneCallback;
  56914. }
  56915. /**
  56916. * Define the interface used by progress events raised during assets loading
  56917. */
  56918. export interface IAssetsProgressEvent {
  56919. /**
  56920. * Defines the number of remaining tasks to process
  56921. */
  56922. remainingCount: number;
  56923. /**
  56924. * Defines the total number of tasks
  56925. */
  56926. totalCount: number;
  56927. /**
  56928. * Defines the task that was just processed
  56929. */
  56930. task: AbstractAssetTask;
  56931. }
  56932. /**
  56933. * Class used to share progress information about assets loading
  56934. */
  56935. export class AssetsProgressEvent implements IAssetsProgressEvent {
  56936. /**
  56937. * Defines the number of remaining tasks to process
  56938. */
  56939. remainingCount: number;
  56940. /**
  56941. * Defines the total number of tasks
  56942. */
  56943. totalCount: number;
  56944. /**
  56945. * Defines the task that was just processed
  56946. */
  56947. task: AbstractAssetTask;
  56948. /**
  56949. * Creates a AssetsProgressEvent
  56950. * @param remainingCount defines the number of remaining tasks to process
  56951. * @param totalCount defines the total number of tasks
  56952. * @param task defines the task that was just processed
  56953. */
  56954. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  56955. }
  56956. /**
  56957. * Define a task used by AssetsManager to load meshes
  56958. */
  56959. export class MeshAssetTask extends AbstractAssetTask {
  56960. /**
  56961. * Defines the name of the task
  56962. */
  56963. name: string;
  56964. /**
  56965. * Defines the list of mesh's names you want to load
  56966. */
  56967. meshesNames: any;
  56968. /**
  56969. * Defines the root url to use as a base to load your meshes and associated resources
  56970. */
  56971. rootUrl: string;
  56972. /**
  56973. * Defines the filename of the scene to load from
  56974. */
  56975. sceneFilename: string;
  56976. /**
  56977. * Gets the list of loaded meshes
  56978. */
  56979. loadedMeshes: Array<AbstractMesh>;
  56980. /**
  56981. * Gets the list of loaded particle systems
  56982. */
  56983. loadedParticleSystems: Array<IParticleSystem>;
  56984. /**
  56985. * Gets the list of loaded skeletons
  56986. */
  56987. loadedSkeletons: Array<Skeleton>;
  56988. /**
  56989. * Gets the list of loaded animation groups
  56990. */
  56991. loadedAnimationGroups: Array<AnimationGroup>;
  56992. /**
  56993. * Callback called when the task is successful
  56994. */
  56995. onSuccess: (task: MeshAssetTask) => void;
  56996. /**
  56997. * Callback called when the task is successful
  56998. */
  56999. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57000. /**
  57001. * Creates a new MeshAssetTask
  57002. * @param name defines the name of the task
  57003. * @param meshesNames defines the list of mesh's names you want to load
  57004. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57005. * @param sceneFilename defines the filename of the scene to load from
  57006. */
  57007. constructor(
  57008. /**
  57009. * Defines the name of the task
  57010. */
  57011. name: string,
  57012. /**
  57013. * Defines the list of mesh's names you want to load
  57014. */
  57015. meshesNames: any,
  57016. /**
  57017. * Defines the root url to use as a base to load your meshes and associated resources
  57018. */
  57019. rootUrl: string,
  57020. /**
  57021. * Defines the filename of the scene to load from
  57022. */
  57023. sceneFilename: string);
  57024. /**
  57025. * Execute the current task
  57026. * @param scene defines the scene where you want your assets to be loaded
  57027. * @param onSuccess is a callback called when the task is successfully executed
  57028. * @param onError is a callback called if an error occurs
  57029. */
  57030. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57031. }
  57032. /**
  57033. * Define a task used by AssetsManager to load text content
  57034. */
  57035. export class TextFileAssetTask extends AbstractAssetTask {
  57036. /**
  57037. * Defines the name of the task
  57038. */
  57039. name: string;
  57040. /**
  57041. * Defines the location of the file to load
  57042. */
  57043. url: string;
  57044. /**
  57045. * Gets the loaded text string
  57046. */
  57047. text: string;
  57048. /**
  57049. * Callback called when the task is successful
  57050. */
  57051. onSuccess: (task: TextFileAssetTask) => void;
  57052. /**
  57053. * Callback called when the task is successful
  57054. */
  57055. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57056. /**
  57057. * Creates a new TextFileAssetTask object
  57058. * @param name defines the name of the task
  57059. * @param url defines the location of the file to load
  57060. */
  57061. constructor(
  57062. /**
  57063. * Defines the name of the task
  57064. */
  57065. name: string,
  57066. /**
  57067. * Defines the location of the file to load
  57068. */
  57069. url: string);
  57070. /**
  57071. * Execute the current task
  57072. * @param scene defines the scene where you want your assets to be loaded
  57073. * @param onSuccess is a callback called when the task is successfully executed
  57074. * @param onError is a callback called if an error occurs
  57075. */
  57076. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57077. }
  57078. /**
  57079. * Define a task used by AssetsManager to load binary data
  57080. */
  57081. export class BinaryFileAssetTask extends AbstractAssetTask {
  57082. /**
  57083. * Defines the name of the task
  57084. */
  57085. name: string;
  57086. /**
  57087. * Defines the location of the file to load
  57088. */
  57089. url: string;
  57090. /**
  57091. * Gets the lodaded data (as an array buffer)
  57092. */
  57093. data: ArrayBuffer;
  57094. /**
  57095. * Callback called when the task is successful
  57096. */
  57097. onSuccess: (task: BinaryFileAssetTask) => void;
  57098. /**
  57099. * Callback called when the task is successful
  57100. */
  57101. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  57102. /**
  57103. * Creates a new BinaryFileAssetTask object
  57104. * @param name defines the name of the new task
  57105. * @param url defines the location of the file to load
  57106. */
  57107. constructor(
  57108. /**
  57109. * Defines the name of the task
  57110. */
  57111. name: string,
  57112. /**
  57113. * Defines the location of the file to load
  57114. */
  57115. url: string);
  57116. /**
  57117. * Execute the current task
  57118. * @param scene defines the scene where you want your assets to be loaded
  57119. * @param onSuccess is a callback called when the task is successfully executed
  57120. * @param onError is a callback called if an error occurs
  57121. */
  57122. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57123. }
  57124. /**
  57125. * Define a task used by AssetsManager to load images
  57126. */
  57127. export class ImageAssetTask extends AbstractAssetTask {
  57128. /**
  57129. * Defines the name of the task
  57130. */
  57131. name: string;
  57132. /**
  57133. * Defines the location of the image to load
  57134. */
  57135. url: string;
  57136. /**
  57137. * Gets the loaded images
  57138. */
  57139. image: HTMLImageElement;
  57140. /**
  57141. * Callback called when the task is successful
  57142. */
  57143. onSuccess: (task: ImageAssetTask) => void;
  57144. /**
  57145. * Callback called when the task is successful
  57146. */
  57147. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  57148. /**
  57149. * Creates a new ImageAssetTask
  57150. * @param name defines the name of the task
  57151. * @param url defines the location of the image to load
  57152. */
  57153. constructor(
  57154. /**
  57155. * Defines the name of the task
  57156. */
  57157. name: string,
  57158. /**
  57159. * Defines the location of the image to load
  57160. */
  57161. url: string);
  57162. /**
  57163. * Execute the current task
  57164. * @param scene defines the scene where you want your assets to be loaded
  57165. * @param onSuccess is a callback called when the task is successfully executed
  57166. * @param onError is a callback called if an error occurs
  57167. */
  57168. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57169. }
  57170. /**
  57171. * Defines the interface used by texture loading tasks
  57172. */
  57173. export interface ITextureAssetTask<TEX extends BaseTexture> {
  57174. /**
  57175. * Gets the loaded texture
  57176. */
  57177. texture: TEX;
  57178. }
  57179. /**
  57180. * Define a task used by AssetsManager to load 2D textures
  57181. */
  57182. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  57183. /**
  57184. * Defines the name of the task
  57185. */
  57186. name: string;
  57187. /**
  57188. * Defines the location of the file to load
  57189. */
  57190. url: string;
  57191. /**
  57192. * Defines if mipmap should not be generated (default is false)
  57193. */
  57194. noMipmap?: boolean | undefined;
  57195. /**
  57196. * Defines if texture must be inverted on Y axis (default is false)
  57197. */
  57198. invertY?: boolean | undefined;
  57199. /**
  57200. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57201. */
  57202. samplingMode: number;
  57203. /**
  57204. * Gets the loaded texture
  57205. */
  57206. texture: Texture;
  57207. /**
  57208. * Callback called when the task is successful
  57209. */
  57210. onSuccess: (task: TextureAssetTask) => void;
  57211. /**
  57212. * Callback called when the task is successful
  57213. */
  57214. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  57215. /**
  57216. * Creates a new TextureAssetTask object
  57217. * @param name defines the name of the task
  57218. * @param url defines the location of the file to load
  57219. * @param noMipmap defines if mipmap should not be generated (default is false)
  57220. * @param invertY defines if texture must be inverted on Y axis (default is false)
  57221. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57222. */
  57223. constructor(
  57224. /**
  57225. * Defines the name of the task
  57226. */
  57227. name: string,
  57228. /**
  57229. * Defines the location of the file to load
  57230. */
  57231. url: string,
  57232. /**
  57233. * Defines if mipmap should not be generated (default is false)
  57234. */
  57235. noMipmap?: boolean | undefined,
  57236. /**
  57237. * Defines if texture must be inverted on Y axis (default is false)
  57238. */
  57239. invertY?: boolean | undefined,
  57240. /**
  57241. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57242. */
  57243. samplingMode?: number);
  57244. /**
  57245. * Execute the current task
  57246. * @param scene defines the scene where you want your assets to be loaded
  57247. * @param onSuccess is a callback called when the task is successfully executed
  57248. * @param onError is a callback called if an error occurs
  57249. */
  57250. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57251. }
  57252. /**
  57253. * Define a task used by AssetsManager to load cube textures
  57254. */
  57255. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  57256. /**
  57257. * Defines the name of the task
  57258. */
  57259. name: string;
  57260. /**
  57261. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57262. */
  57263. url: string;
  57264. /**
  57265. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57266. */
  57267. extensions?: string[] | undefined;
  57268. /**
  57269. * Defines if mipmaps should not be generated (default is false)
  57270. */
  57271. noMipmap?: boolean | undefined;
  57272. /**
  57273. * Defines the explicit list of files (undefined by default)
  57274. */
  57275. files?: string[] | undefined;
  57276. /**
  57277. * Gets the loaded texture
  57278. */
  57279. texture: CubeTexture;
  57280. /**
  57281. * Callback called when the task is successful
  57282. */
  57283. onSuccess: (task: CubeTextureAssetTask) => void;
  57284. /**
  57285. * Callback called when the task is successful
  57286. */
  57287. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  57288. /**
  57289. * Creates a new CubeTextureAssetTask
  57290. * @param name defines the name of the task
  57291. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57292. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57293. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57294. * @param files defines the explicit list of files (undefined by default)
  57295. */
  57296. constructor(
  57297. /**
  57298. * Defines the name of the task
  57299. */
  57300. name: string,
  57301. /**
  57302. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57303. */
  57304. url: string,
  57305. /**
  57306. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57307. */
  57308. extensions?: string[] | undefined,
  57309. /**
  57310. * Defines if mipmaps should not be generated (default is false)
  57311. */
  57312. noMipmap?: boolean | undefined,
  57313. /**
  57314. * Defines the explicit list of files (undefined by default)
  57315. */
  57316. files?: string[] | undefined);
  57317. /**
  57318. * Execute the current task
  57319. * @param scene defines the scene where you want your assets to be loaded
  57320. * @param onSuccess is a callback called when the task is successfully executed
  57321. * @param onError is a callback called if an error occurs
  57322. */
  57323. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57324. }
  57325. /**
  57326. * Define a task used by AssetsManager to load HDR cube textures
  57327. */
  57328. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  57329. /**
  57330. * Defines the name of the task
  57331. */
  57332. name: string;
  57333. /**
  57334. * Defines the location of the file to load
  57335. */
  57336. url: string;
  57337. /**
  57338. * Defines the desired size (the more it increases the longer the generation will be)
  57339. */
  57340. size: number;
  57341. /**
  57342. * Defines if mipmaps should not be generated (default is false)
  57343. */
  57344. noMipmap: boolean;
  57345. /**
  57346. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57347. */
  57348. generateHarmonics: boolean;
  57349. /**
  57350. * 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)
  57351. */
  57352. gammaSpace: boolean;
  57353. /**
  57354. * Internal Use Only
  57355. */
  57356. reserved: boolean;
  57357. /**
  57358. * Gets the loaded texture
  57359. */
  57360. texture: HDRCubeTexture;
  57361. /**
  57362. * Callback called when the task is successful
  57363. */
  57364. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  57365. /**
  57366. * Callback called when the task is successful
  57367. */
  57368. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  57369. /**
  57370. * Creates a new HDRCubeTextureAssetTask object
  57371. * @param name defines the name of the task
  57372. * @param url defines the location of the file to load
  57373. * @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.
  57374. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57375. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57376. * @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)
  57377. * @param reserved Internal use only
  57378. */
  57379. constructor(
  57380. /**
  57381. * Defines the name of the task
  57382. */
  57383. name: string,
  57384. /**
  57385. * Defines the location of the file to load
  57386. */
  57387. url: string,
  57388. /**
  57389. * Defines the desired size (the more it increases the longer the generation will be)
  57390. */
  57391. size: number,
  57392. /**
  57393. * Defines if mipmaps should not be generated (default is false)
  57394. */
  57395. noMipmap?: boolean,
  57396. /**
  57397. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57398. */
  57399. generateHarmonics?: boolean,
  57400. /**
  57401. * 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)
  57402. */
  57403. gammaSpace?: boolean,
  57404. /**
  57405. * Internal Use Only
  57406. */
  57407. reserved?: boolean);
  57408. /**
  57409. * Execute the current task
  57410. * @param scene defines the scene where you want your assets to be loaded
  57411. * @param onSuccess is a callback called when the task is successfully executed
  57412. * @param onError is a callback called if an error occurs
  57413. */
  57414. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57415. }
  57416. /**
  57417. * Define a task used by AssetsManager to load Equirectangular cube textures
  57418. */
  57419. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  57420. /**
  57421. * Defines the name of the task
  57422. */
  57423. name: string;
  57424. /**
  57425. * Defines the location of the file to load
  57426. */
  57427. url: string;
  57428. /**
  57429. * Defines the desired size (the more it increases the longer the generation will be)
  57430. */
  57431. size: number;
  57432. /**
  57433. * Defines if mipmaps should not be generated (default is false)
  57434. */
  57435. noMipmap: boolean;
  57436. /**
  57437. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57438. * but the standard material would require them in Gamma space) (default is true)
  57439. */
  57440. gammaSpace: boolean;
  57441. /**
  57442. * Gets the loaded texture
  57443. */
  57444. texture: EquiRectangularCubeTexture;
  57445. /**
  57446. * Callback called when the task is successful
  57447. */
  57448. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  57449. /**
  57450. * Callback called when the task is successful
  57451. */
  57452. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  57453. /**
  57454. * Creates a new EquiRectangularCubeTextureAssetTask object
  57455. * @param name defines the name of the task
  57456. * @param url defines the location of the file to load
  57457. * @param size defines the desired size (the more it increases the longer the generation will be)
  57458. * If the size is omitted this implies you are using a preprocessed cubemap.
  57459. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57460. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  57461. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  57462. * (default is true)
  57463. */
  57464. constructor(
  57465. /**
  57466. * Defines the name of the task
  57467. */
  57468. name: string,
  57469. /**
  57470. * Defines the location of the file to load
  57471. */
  57472. url: string,
  57473. /**
  57474. * Defines the desired size (the more it increases the longer the generation will be)
  57475. */
  57476. size: number,
  57477. /**
  57478. * Defines if mipmaps should not be generated (default is false)
  57479. */
  57480. noMipmap?: boolean,
  57481. /**
  57482. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57483. * but the standard material would require them in Gamma space) (default is true)
  57484. */
  57485. gammaSpace?: boolean);
  57486. /**
  57487. * Execute the current task
  57488. * @param scene defines the scene where you want your assets to be loaded
  57489. * @param onSuccess is a callback called when the task is successfully executed
  57490. * @param onError is a callback called if an error occurs
  57491. */
  57492. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57493. }
  57494. /**
  57495. * This class can be used to easily import assets into a scene
  57496. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  57497. */
  57498. export class AssetsManager {
  57499. private _scene;
  57500. private _isLoading;
  57501. protected _tasks: AbstractAssetTask[];
  57502. protected _waitingTasksCount: number;
  57503. protected _totalTasksCount: number;
  57504. /**
  57505. * Callback called when all tasks are processed
  57506. */
  57507. onFinish: (tasks: AbstractAssetTask[]) => void;
  57508. /**
  57509. * Callback called when a task is successful
  57510. */
  57511. onTaskSuccess: (task: AbstractAssetTask) => void;
  57512. /**
  57513. * Callback called when a task had an error
  57514. */
  57515. onTaskError: (task: AbstractAssetTask) => void;
  57516. /**
  57517. * Callback called when a task is done (whatever the result is)
  57518. */
  57519. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  57520. /**
  57521. * Observable called when all tasks are processed
  57522. */
  57523. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  57524. /**
  57525. * Observable called when a task had an error
  57526. */
  57527. onTaskErrorObservable: Observable<AbstractAssetTask>;
  57528. /**
  57529. * Observable called when all tasks were executed
  57530. */
  57531. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  57532. /**
  57533. * Observable called when a task is done (whatever the result is)
  57534. */
  57535. onProgressObservable: Observable<IAssetsProgressEvent>;
  57536. /**
  57537. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  57538. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  57539. */
  57540. useDefaultLoadingScreen: boolean;
  57541. /**
  57542. * Creates a new AssetsManager
  57543. * @param scene defines the scene to work on
  57544. */
  57545. constructor(scene: Scene);
  57546. /**
  57547. * Add a MeshAssetTask to the list of active tasks
  57548. * @param taskName defines the name of the new task
  57549. * @param meshesNames defines the name of meshes to load
  57550. * @param rootUrl defines the root url to use to locate files
  57551. * @param sceneFilename defines the filename of the scene file
  57552. * @returns a new MeshAssetTask object
  57553. */
  57554. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  57555. /**
  57556. * Add a TextFileAssetTask to the list of active tasks
  57557. * @param taskName defines the name of the new task
  57558. * @param url defines the url of the file to load
  57559. * @returns a new TextFileAssetTask object
  57560. */
  57561. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  57562. /**
  57563. * Add a BinaryFileAssetTask to the list of active tasks
  57564. * @param taskName defines the name of the new task
  57565. * @param url defines the url of the file to load
  57566. * @returns a new BinaryFileAssetTask object
  57567. */
  57568. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  57569. /**
  57570. * Add a ImageAssetTask to the list of active tasks
  57571. * @param taskName defines the name of the new task
  57572. * @param url defines the url of the file to load
  57573. * @returns a new ImageAssetTask object
  57574. */
  57575. addImageTask(taskName: string, url: string): ImageAssetTask;
  57576. /**
  57577. * Add a TextureAssetTask to the list of active tasks
  57578. * @param taskName defines the name of the new task
  57579. * @param url defines the url of the file to load
  57580. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57581. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  57582. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57583. * @returns a new TextureAssetTask object
  57584. */
  57585. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  57586. /**
  57587. * Add a CubeTextureAssetTask to the list of active tasks
  57588. * @param taskName defines the name of the new task
  57589. * @param url defines the url of the file to load
  57590. * @param extensions defines the extension to use to load the cube map (can be null)
  57591. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57592. * @param files defines the list of files to load (can be null)
  57593. * @returns a new CubeTextureAssetTask object
  57594. */
  57595. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  57596. /**
  57597. *
  57598. * Add a HDRCubeTextureAssetTask to the list of active tasks
  57599. * @param taskName defines the name of the new task
  57600. * @param url defines the url of the file to load
  57601. * @param size defines the size you want for the cubemap (can be null)
  57602. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57603. * @param generateHarmonics defines if you want to automatically generate (true by default)
  57604. * @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)
  57605. * @param reserved Internal use only
  57606. * @returns a new HDRCubeTextureAssetTask object
  57607. */
  57608. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  57609. /**
  57610. *
  57611. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  57612. * @param taskName defines the name of the new task
  57613. * @param url defines the url of the file to load
  57614. * @param size defines the size you want for the cubemap (can be null)
  57615. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57616. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  57617. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  57618. * @returns a new EquiRectangularCubeTextureAssetTask object
  57619. */
  57620. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  57621. /**
  57622. * Remove a task from the assets manager.
  57623. * @param task the task to remove
  57624. */
  57625. removeTask(task: AbstractAssetTask): void;
  57626. private _decreaseWaitingTasksCount;
  57627. private _runTask;
  57628. /**
  57629. * Reset the AssetsManager and remove all tasks
  57630. * @return the current instance of the AssetsManager
  57631. */
  57632. reset(): AssetsManager;
  57633. /**
  57634. * Start the loading process
  57635. * @return the current instance of the AssetsManager
  57636. */
  57637. load(): AssetsManager;
  57638. /**
  57639. * Start the loading process as an async operation
  57640. * @return a promise returning the list of failed tasks
  57641. */
  57642. loadAsync(): Promise<void>;
  57643. }
  57644. }
  57645. declare module BABYLON {
  57646. /**
  57647. * Wrapper class for promise with external resolve and reject.
  57648. */
  57649. export class Deferred<T> {
  57650. /**
  57651. * The promise associated with this deferred object.
  57652. */
  57653. readonly promise: Promise<T>;
  57654. private _resolve;
  57655. private _reject;
  57656. /**
  57657. * The resolve method of the promise associated with this deferred object.
  57658. */
  57659. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  57660. /**
  57661. * The reject method of the promise associated with this deferred object.
  57662. */
  57663. readonly reject: (reason?: any) => void;
  57664. /**
  57665. * Constructor for this deferred object.
  57666. */
  57667. constructor();
  57668. }
  57669. }
  57670. declare module BABYLON {
  57671. /**
  57672. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  57673. */
  57674. export class MeshExploder {
  57675. private _centerMesh;
  57676. private _meshes;
  57677. private _meshesOrigins;
  57678. private _toCenterVectors;
  57679. private _scaledDirection;
  57680. private _newPosition;
  57681. private _centerPosition;
  57682. /**
  57683. * Explodes meshes from a center mesh.
  57684. * @param meshes The meshes to explode.
  57685. * @param centerMesh The mesh to be center of explosion.
  57686. */
  57687. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  57688. private _setCenterMesh;
  57689. /**
  57690. * Get class name
  57691. * @returns "MeshExploder"
  57692. */
  57693. getClassName(): string;
  57694. /**
  57695. * "Exploded meshes"
  57696. * @returns Array of meshes with the centerMesh at index 0.
  57697. */
  57698. getMeshes(): Array<Mesh>;
  57699. /**
  57700. * Explodes meshes giving a specific direction
  57701. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  57702. */
  57703. explode(direction?: number): void;
  57704. }
  57705. }
  57706. declare module BABYLON {
  57707. /**
  57708. * Class used to help managing file picking and drag'n'drop
  57709. */
  57710. export class FilesInput {
  57711. /**
  57712. * List of files ready to be loaded
  57713. */
  57714. static readonly FilesToLoad: {
  57715. [key: string]: File;
  57716. };
  57717. /**
  57718. * Callback called when a file is processed
  57719. */
  57720. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  57721. private _engine;
  57722. private _currentScene;
  57723. private _sceneLoadedCallback;
  57724. private _progressCallback;
  57725. private _additionalRenderLoopLogicCallback;
  57726. private _textureLoadingCallback;
  57727. private _startingProcessingFilesCallback;
  57728. private _onReloadCallback;
  57729. private _errorCallback;
  57730. private _elementToMonitor;
  57731. private _sceneFileToLoad;
  57732. private _filesToLoad;
  57733. /**
  57734. * Creates a new FilesInput
  57735. * @param engine defines the rendering engine
  57736. * @param scene defines the hosting scene
  57737. * @param sceneLoadedCallback callback called when scene is loaded
  57738. * @param progressCallback callback called to track progress
  57739. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  57740. * @param textureLoadingCallback callback called when a texture is loading
  57741. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  57742. * @param onReloadCallback callback called when a reload is requested
  57743. * @param errorCallback callback call if an error occurs
  57744. */
  57745. 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);
  57746. private _dragEnterHandler;
  57747. private _dragOverHandler;
  57748. private _dropHandler;
  57749. /**
  57750. * Calls this function to listen to drag'n'drop events on a specific DOM element
  57751. * @param elementToMonitor defines the DOM element to track
  57752. */
  57753. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  57754. /**
  57755. * Release all associated resources
  57756. */
  57757. dispose(): void;
  57758. private renderFunction;
  57759. private drag;
  57760. private drop;
  57761. private _traverseFolder;
  57762. private _processFiles;
  57763. /**
  57764. * Load files from a drop event
  57765. * @param event defines the drop event to use as source
  57766. */
  57767. loadFiles(event: any): void;
  57768. private _processReload;
  57769. /**
  57770. * Reload the current scene from the loaded files
  57771. */
  57772. reload(): void;
  57773. }
  57774. }
  57775. declare module BABYLON {
  57776. /**
  57777. * Defines the root class used to create scene optimization to use with SceneOptimizer
  57778. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57779. */
  57780. export class SceneOptimization {
  57781. /**
  57782. * Defines the priority of this optimization (0 by default which means first in the list)
  57783. */
  57784. priority: number;
  57785. /**
  57786. * Gets a string describing the action executed by the current optimization
  57787. * @returns description string
  57788. */
  57789. getDescription(): string;
  57790. /**
  57791. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57792. * @param scene defines the current scene where to apply this optimization
  57793. * @param optimizer defines the current optimizer
  57794. * @returns true if everything that can be done was applied
  57795. */
  57796. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57797. /**
  57798. * Creates the SceneOptimization object
  57799. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57800. * @param desc defines the description associated with the optimization
  57801. */
  57802. constructor(
  57803. /**
  57804. * Defines the priority of this optimization (0 by default which means first in the list)
  57805. */
  57806. priority?: number);
  57807. }
  57808. /**
  57809. * Defines an optimization used to reduce the size of render target textures
  57810. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57811. */
  57812. export class TextureOptimization extends SceneOptimization {
  57813. /**
  57814. * Defines the priority of this optimization (0 by default which means first in the list)
  57815. */
  57816. priority: number;
  57817. /**
  57818. * 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
  57819. */
  57820. maximumSize: number;
  57821. /**
  57822. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57823. */
  57824. step: number;
  57825. /**
  57826. * Gets a string describing the action executed by the current optimization
  57827. * @returns description string
  57828. */
  57829. getDescription(): string;
  57830. /**
  57831. * Creates the TextureOptimization object
  57832. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57833. * @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
  57834. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57835. */
  57836. constructor(
  57837. /**
  57838. * Defines the priority of this optimization (0 by default which means first in the list)
  57839. */
  57840. priority?: number,
  57841. /**
  57842. * 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
  57843. */
  57844. maximumSize?: number,
  57845. /**
  57846. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57847. */
  57848. step?: number);
  57849. /**
  57850. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57851. * @param scene defines the current scene where to apply this optimization
  57852. * @param optimizer defines the current optimizer
  57853. * @returns true if everything that can be done was applied
  57854. */
  57855. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57856. }
  57857. /**
  57858. * Defines an optimization used to increase or decrease the rendering resolution
  57859. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57860. */
  57861. export class HardwareScalingOptimization extends SceneOptimization {
  57862. /**
  57863. * Defines the priority of this optimization (0 by default which means first in the list)
  57864. */
  57865. priority: number;
  57866. /**
  57867. * Defines the maximum scale to use (2 by default)
  57868. */
  57869. maximumScale: number;
  57870. /**
  57871. * Defines the step to use between two passes (0.5 by default)
  57872. */
  57873. step: number;
  57874. private _currentScale;
  57875. private _directionOffset;
  57876. /**
  57877. * Gets a string describing the action executed by the current optimization
  57878. * @return description string
  57879. */
  57880. getDescription(): string;
  57881. /**
  57882. * Creates the HardwareScalingOptimization object
  57883. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57884. * @param maximumScale defines the maximum scale to use (2 by default)
  57885. * @param step defines the step to use between two passes (0.5 by default)
  57886. */
  57887. constructor(
  57888. /**
  57889. * Defines the priority of this optimization (0 by default which means first in the list)
  57890. */
  57891. priority?: number,
  57892. /**
  57893. * Defines the maximum scale to use (2 by default)
  57894. */
  57895. maximumScale?: number,
  57896. /**
  57897. * Defines the step to use between two passes (0.5 by default)
  57898. */
  57899. step?: number);
  57900. /**
  57901. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57902. * @param scene defines the current scene where to apply this optimization
  57903. * @param optimizer defines the current optimizer
  57904. * @returns true if everything that can be done was applied
  57905. */
  57906. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57907. }
  57908. /**
  57909. * Defines an optimization used to remove shadows
  57910. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57911. */
  57912. export class ShadowsOptimization extends SceneOptimization {
  57913. /**
  57914. * Gets a string describing the action executed by the current optimization
  57915. * @return description string
  57916. */
  57917. getDescription(): string;
  57918. /**
  57919. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57920. * @param scene defines the current scene where to apply this optimization
  57921. * @param optimizer defines the current optimizer
  57922. * @returns true if everything that can be done was applied
  57923. */
  57924. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57925. }
  57926. /**
  57927. * Defines an optimization used to turn post-processes off
  57928. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57929. */
  57930. export class PostProcessesOptimization extends SceneOptimization {
  57931. /**
  57932. * Gets a string describing the action executed by the current optimization
  57933. * @return description string
  57934. */
  57935. getDescription(): string;
  57936. /**
  57937. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57938. * @param scene defines the current scene where to apply this optimization
  57939. * @param optimizer defines the current optimizer
  57940. * @returns true if everything that can be done was applied
  57941. */
  57942. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57943. }
  57944. /**
  57945. * Defines an optimization used to turn lens flares off
  57946. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57947. */
  57948. export class LensFlaresOptimization extends SceneOptimization {
  57949. /**
  57950. * Gets a string describing the action executed by the current optimization
  57951. * @return description string
  57952. */
  57953. getDescription(): string;
  57954. /**
  57955. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57956. * @param scene defines the current scene where to apply this optimization
  57957. * @param optimizer defines the current optimizer
  57958. * @returns true if everything that can be done was applied
  57959. */
  57960. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57961. }
  57962. /**
  57963. * Defines an optimization based on user defined callback.
  57964. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57965. */
  57966. export class CustomOptimization extends SceneOptimization {
  57967. /**
  57968. * Callback called to apply the custom optimization.
  57969. */
  57970. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  57971. /**
  57972. * Callback called to get custom description
  57973. */
  57974. onGetDescription: () => string;
  57975. /**
  57976. * Gets a string describing the action executed by the current optimization
  57977. * @returns description string
  57978. */
  57979. getDescription(): string;
  57980. /**
  57981. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57982. * @param scene defines the current scene where to apply this optimization
  57983. * @param optimizer defines the current optimizer
  57984. * @returns true if everything that can be done was applied
  57985. */
  57986. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57987. }
  57988. /**
  57989. * Defines an optimization used to turn particles off
  57990. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57991. */
  57992. export class ParticlesOptimization extends SceneOptimization {
  57993. /**
  57994. * Gets a string describing the action executed by the current optimization
  57995. * @return description string
  57996. */
  57997. getDescription(): string;
  57998. /**
  57999. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58000. * @param scene defines the current scene where to apply this optimization
  58001. * @param optimizer defines the current optimizer
  58002. * @returns true if everything that can be done was applied
  58003. */
  58004. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58005. }
  58006. /**
  58007. * Defines an optimization used to turn render targets off
  58008. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58009. */
  58010. export class RenderTargetsOptimization extends SceneOptimization {
  58011. /**
  58012. * Gets a string describing the action executed by the current optimization
  58013. * @return description string
  58014. */
  58015. getDescription(): string;
  58016. /**
  58017. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58018. * @param scene defines the current scene where to apply this optimization
  58019. * @param optimizer defines the current optimizer
  58020. * @returns true if everything that can be done was applied
  58021. */
  58022. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58023. }
  58024. /**
  58025. * Defines an optimization used to merge meshes with compatible materials
  58026. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58027. */
  58028. export class MergeMeshesOptimization extends SceneOptimization {
  58029. private static _UpdateSelectionTree;
  58030. /**
  58031. * Gets or sets a boolean which defines if optimization octree has to be updated
  58032. */
  58033. /**
  58034. * Gets or sets a boolean which defines if optimization octree has to be updated
  58035. */
  58036. static UpdateSelectionTree: boolean;
  58037. /**
  58038. * Gets a string describing the action executed by the current optimization
  58039. * @return description string
  58040. */
  58041. getDescription(): string;
  58042. private _canBeMerged;
  58043. /**
  58044. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58045. * @param scene defines the current scene where to apply this optimization
  58046. * @param optimizer defines the current optimizer
  58047. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58048. * @returns true if everything that can be done was applied
  58049. */
  58050. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58051. }
  58052. /**
  58053. * Defines a list of options used by SceneOptimizer
  58054. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58055. */
  58056. export class SceneOptimizerOptions {
  58057. /**
  58058. * Defines the target frame rate to reach (60 by default)
  58059. */
  58060. targetFrameRate: number;
  58061. /**
  58062. * Defines the interval between two checkes (2000ms by default)
  58063. */
  58064. trackerDuration: number;
  58065. /**
  58066. * Gets the list of optimizations to apply
  58067. */
  58068. optimizations: SceneOptimization[];
  58069. /**
  58070. * Creates a new list of options used by SceneOptimizer
  58071. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58072. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58073. */
  58074. constructor(
  58075. /**
  58076. * Defines the target frame rate to reach (60 by default)
  58077. */
  58078. targetFrameRate?: number,
  58079. /**
  58080. * Defines the interval between two checkes (2000ms by default)
  58081. */
  58082. trackerDuration?: number);
  58083. /**
  58084. * Add a new optimization
  58085. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  58086. * @returns the current SceneOptimizerOptions
  58087. */
  58088. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  58089. /**
  58090. * Add a new custom optimization
  58091. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  58092. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  58093. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58094. * @returns the current SceneOptimizerOptions
  58095. */
  58096. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  58097. /**
  58098. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  58099. * @param targetFrameRate defines the target frame rate (60 by default)
  58100. * @returns a SceneOptimizerOptions object
  58101. */
  58102. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58103. /**
  58104. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  58105. * @param targetFrameRate defines the target frame rate (60 by default)
  58106. * @returns a SceneOptimizerOptions object
  58107. */
  58108. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58109. /**
  58110. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  58111. * @param targetFrameRate defines the target frame rate (60 by default)
  58112. * @returns a SceneOptimizerOptions object
  58113. */
  58114. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58115. }
  58116. /**
  58117. * Class used to run optimizations in order to reach a target frame rate
  58118. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58119. */
  58120. export class SceneOptimizer implements IDisposable {
  58121. private _isRunning;
  58122. private _options;
  58123. private _scene;
  58124. private _currentPriorityLevel;
  58125. private _targetFrameRate;
  58126. private _trackerDuration;
  58127. private _currentFrameRate;
  58128. private _sceneDisposeObserver;
  58129. private _improvementMode;
  58130. /**
  58131. * Defines an observable called when the optimizer reaches the target frame rate
  58132. */
  58133. onSuccessObservable: Observable<SceneOptimizer>;
  58134. /**
  58135. * Defines an observable called when the optimizer enables an optimization
  58136. */
  58137. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  58138. /**
  58139. * Defines an observable called when the optimizer is not able to reach the target frame rate
  58140. */
  58141. onFailureObservable: Observable<SceneOptimizer>;
  58142. /**
  58143. * Gets a boolean indicating if the optimizer is in improvement mode
  58144. */
  58145. readonly isInImprovementMode: boolean;
  58146. /**
  58147. * Gets the current priority level (0 at start)
  58148. */
  58149. readonly currentPriorityLevel: number;
  58150. /**
  58151. * Gets the current frame rate checked by the SceneOptimizer
  58152. */
  58153. readonly currentFrameRate: number;
  58154. /**
  58155. * Gets or sets the current target frame rate (60 by default)
  58156. */
  58157. /**
  58158. * Gets or sets the current target frame rate (60 by default)
  58159. */
  58160. targetFrameRate: number;
  58161. /**
  58162. * Gets or sets the current interval between two checks (every 2000ms by default)
  58163. */
  58164. /**
  58165. * Gets or sets the current interval between two checks (every 2000ms by default)
  58166. */
  58167. trackerDuration: number;
  58168. /**
  58169. * Gets the list of active optimizations
  58170. */
  58171. readonly optimizations: SceneOptimization[];
  58172. /**
  58173. * Creates a new SceneOptimizer
  58174. * @param scene defines the scene to work on
  58175. * @param options defines the options to use with the SceneOptimizer
  58176. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  58177. * @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)
  58178. */
  58179. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  58180. /**
  58181. * Stops the current optimizer
  58182. */
  58183. stop(): void;
  58184. /**
  58185. * Reset the optimizer to initial step (current priority level = 0)
  58186. */
  58187. reset(): void;
  58188. /**
  58189. * Start the optimizer. By default it will try to reach a specific framerate
  58190. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  58191. */
  58192. start(): void;
  58193. private _checkCurrentState;
  58194. /**
  58195. * Release all resources
  58196. */
  58197. dispose(): void;
  58198. /**
  58199. * Helper function to create a SceneOptimizer with one single line of code
  58200. * @param scene defines the scene to work on
  58201. * @param options defines the options to use with the SceneOptimizer
  58202. * @param onSuccess defines a callback to call on success
  58203. * @param onFailure defines a callback to call on failure
  58204. * @returns the new SceneOptimizer object
  58205. */
  58206. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  58207. }
  58208. }
  58209. declare module BABYLON {
  58210. /**
  58211. * Class used to serialize a scene into a string
  58212. */
  58213. export class SceneSerializer {
  58214. /**
  58215. * Clear cache used by a previous serialization
  58216. */
  58217. static ClearCache(): void;
  58218. /**
  58219. * Serialize a scene into a JSON compatible object
  58220. * @param scene defines the scene to serialize
  58221. * @returns a JSON compatible object
  58222. */
  58223. static Serialize(scene: Scene): any;
  58224. /**
  58225. * Serialize a mesh into a JSON compatible object
  58226. * @param toSerialize defines the mesh to serialize
  58227. * @param withParents defines if parents must be serialized as well
  58228. * @param withChildren defines if children must be serialized as well
  58229. * @returns a JSON compatible object
  58230. */
  58231. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  58232. }
  58233. }
  58234. declare module BABYLON {
  58235. /**
  58236. * Class used to host texture specific utilities
  58237. */
  58238. export class TextureTools {
  58239. /**
  58240. * Uses the GPU to create a copy texture rescaled at a given size
  58241. * @param texture Texture to copy from
  58242. * @param width defines the desired width
  58243. * @param height defines the desired height
  58244. * @param useBilinearMode defines if bilinear mode has to be used
  58245. * @return the generated texture
  58246. */
  58247. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  58248. }
  58249. }
  58250. declare module BABYLON {
  58251. /**
  58252. * This represents the different options avilable for the video capture.
  58253. */
  58254. export interface VideoRecorderOptions {
  58255. /** Defines the mime type of the video */
  58256. mimeType: string;
  58257. /** Defines the video the video should be recorded at */
  58258. fps: number;
  58259. /** Defines the chunk size for the recording data */
  58260. recordChunckSize: number;
  58261. /** The audio tracks to attach to the record */
  58262. audioTracks?: MediaStreamTrack[];
  58263. }
  58264. /**
  58265. * This can helps recording videos from BabylonJS.
  58266. * This is based on the available WebRTC functionalities of the browser.
  58267. *
  58268. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  58269. */
  58270. export class VideoRecorder {
  58271. private static readonly _defaultOptions;
  58272. /**
  58273. * Returns wehther or not the VideoRecorder is available in your browser.
  58274. * @param engine Defines the Babylon Engine to check the support for
  58275. * @returns true if supported otherwise false
  58276. */
  58277. static IsSupported(engine: Engine): boolean;
  58278. private readonly _options;
  58279. private _canvas;
  58280. private _mediaRecorder;
  58281. private _recordedChunks;
  58282. private _fileName;
  58283. private _resolve;
  58284. private _reject;
  58285. /**
  58286. * True wether a recording is already in progress.
  58287. */
  58288. readonly isRecording: boolean;
  58289. /**
  58290. * Create a new VideoCapture object which can help converting what you see in Babylon to
  58291. * a video file.
  58292. * @param engine Defines the BabylonJS Engine you wish to record
  58293. * @param options Defines options that can be used to customized the capture
  58294. */
  58295. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  58296. /**
  58297. * Stops the current recording before the default capture timeout passed in the startRecording
  58298. * functions.
  58299. */
  58300. stopRecording(): void;
  58301. /**
  58302. * Starts recording the canvas for a max duration specified in parameters.
  58303. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  58304. * @param maxDuration Defines the maximum recording time in seconds.
  58305. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  58306. * @return a promise callback at the end of the recording with the video data in Blob.
  58307. */
  58308. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  58309. /**
  58310. * Releases internal resources used during the recording.
  58311. */
  58312. dispose(): void;
  58313. private _handleDataAvailable;
  58314. private _handleError;
  58315. private _handleStop;
  58316. }
  58317. }
  58318. declare module BABYLON {
  58319. /**
  58320. * Class containing a set of static utilities functions for screenshots
  58321. */
  58322. export class ScreenshotTools {
  58323. /**
  58324. * Captures a screenshot of the current rendering
  58325. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58326. * @param engine defines the rendering engine
  58327. * @param camera defines the source camera
  58328. * @param size This parameter can be set to a single number or to an object with the
  58329. * following (optional) properties: precision, width, height. If a single number is passed,
  58330. * it will be used for both width and height. If an object is passed, the screenshot size
  58331. * will be derived from the parameters. The precision property is a multiplier allowing
  58332. * rendering at a higher or lower resolution
  58333. * @param successCallback defines the callback receives a single parameter which contains the
  58334. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58335. * src parameter of an <img> to display it
  58336. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  58337. * Check your browser for supported MIME types
  58338. */
  58339. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  58340. /**
  58341. * Generates an image screenshot from the specified camera.
  58342. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58343. * @param engine The engine to use for rendering
  58344. * @param camera The camera to use for rendering
  58345. * @param size This parameter can be set to a single number or to an object with the
  58346. * following (optional) properties: precision, width, height. If a single number is passed,
  58347. * it will be used for both width and height. If an object is passed, the screenshot size
  58348. * will be derived from the parameters. The precision property is a multiplier allowing
  58349. * rendering at a higher or lower resolution
  58350. * @param successCallback The callback receives a single parameter which contains the
  58351. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58352. * src parameter of an <img> to display it
  58353. * @param mimeType The MIME type of the screenshot image (default: image/png).
  58354. * Check your browser for supported MIME types
  58355. * @param samples Texture samples (default: 1)
  58356. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  58357. * @param fileName A name for for the downloaded file.
  58358. */
  58359. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  58360. }
  58361. }
  58362. declare module BABYLON {
  58363. /**
  58364. * A cursor which tracks a point on a path
  58365. */
  58366. export class PathCursor {
  58367. private path;
  58368. /**
  58369. * Stores path cursor callbacks for when an onchange event is triggered
  58370. */
  58371. private _onchange;
  58372. /**
  58373. * The value of the path cursor
  58374. */
  58375. value: number;
  58376. /**
  58377. * The animation array of the path cursor
  58378. */
  58379. animations: Animation[];
  58380. /**
  58381. * Initializes the path cursor
  58382. * @param path The path to track
  58383. */
  58384. constructor(path: Path2);
  58385. /**
  58386. * Gets the cursor point on the path
  58387. * @returns A point on the path cursor at the cursor location
  58388. */
  58389. getPoint(): Vector3;
  58390. /**
  58391. * Moves the cursor ahead by the step amount
  58392. * @param step The amount to move the cursor forward
  58393. * @returns This path cursor
  58394. */
  58395. moveAhead(step?: number): PathCursor;
  58396. /**
  58397. * Moves the cursor behind by the step amount
  58398. * @param step The amount to move the cursor back
  58399. * @returns This path cursor
  58400. */
  58401. moveBack(step?: number): PathCursor;
  58402. /**
  58403. * Moves the cursor by the step amount
  58404. * If the step amount is greater than one, an exception is thrown
  58405. * @param step The amount to move the cursor
  58406. * @returns This path cursor
  58407. */
  58408. move(step: number): PathCursor;
  58409. /**
  58410. * Ensures that the value is limited between zero and one
  58411. * @returns This path cursor
  58412. */
  58413. private ensureLimits;
  58414. /**
  58415. * Runs onchange callbacks on change (used by the animation engine)
  58416. * @returns This path cursor
  58417. */
  58418. private raiseOnChange;
  58419. /**
  58420. * Executes a function on change
  58421. * @param f A path cursor onchange callback
  58422. * @returns This path cursor
  58423. */
  58424. onchange(f: (cursor: PathCursor) => void): PathCursor;
  58425. }
  58426. }
  58427. declare module BABYLON {
  58428. /** @hidden */
  58429. export var blurPixelShader: {
  58430. name: string;
  58431. shader: string;
  58432. };
  58433. }
  58434. declare module BABYLON {
  58435. /** @hidden */
  58436. export var bones300Declaration: {
  58437. name: string;
  58438. shader: string;
  58439. };
  58440. }
  58441. declare module BABYLON {
  58442. /** @hidden */
  58443. export var instances300Declaration: {
  58444. name: string;
  58445. shader: string;
  58446. };
  58447. }
  58448. declare module BABYLON {
  58449. /** @hidden */
  58450. export var pointCloudVertexDeclaration: {
  58451. name: string;
  58452. shader: string;
  58453. };
  58454. }
  58455. // Mixins
  58456. interface Window {
  58457. mozIndexedDB: IDBFactory;
  58458. webkitIndexedDB: IDBFactory;
  58459. msIndexedDB: IDBFactory;
  58460. webkitURL: typeof URL;
  58461. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  58462. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  58463. WebGLRenderingContext: WebGLRenderingContext;
  58464. MSGesture: MSGesture;
  58465. CANNON: any;
  58466. AudioContext: AudioContext;
  58467. webkitAudioContext: AudioContext;
  58468. PointerEvent: any;
  58469. Math: Math;
  58470. Uint8Array: Uint8ArrayConstructor;
  58471. Float32Array: Float32ArrayConstructor;
  58472. mozURL: typeof URL;
  58473. msURL: typeof URL;
  58474. VRFrameData: any; // WebVR, from specs 1.1
  58475. DracoDecoderModule: any;
  58476. setImmediate(handler: (...args: any[]) => void): number;
  58477. }
  58478. interface HTMLCanvasElement {
  58479. requestPointerLock(): void;
  58480. msRequestPointerLock?(): void;
  58481. mozRequestPointerLock?(): void;
  58482. webkitRequestPointerLock?(): void;
  58483. /** Track wether a record is in progress */
  58484. isRecording: boolean;
  58485. /** Capture Stream method defined by some browsers */
  58486. captureStream(fps?: number): MediaStream;
  58487. }
  58488. interface CanvasRenderingContext2D {
  58489. msImageSmoothingEnabled: boolean;
  58490. }
  58491. interface MouseEvent {
  58492. mozMovementX: number;
  58493. mozMovementY: number;
  58494. webkitMovementX: number;
  58495. webkitMovementY: number;
  58496. msMovementX: number;
  58497. msMovementY: number;
  58498. }
  58499. interface Navigator {
  58500. mozGetVRDevices: (any: any) => any;
  58501. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58502. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58503. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58504. webkitGetGamepads(): Gamepad[];
  58505. msGetGamepads(): Gamepad[];
  58506. webkitGamepads(): Gamepad[];
  58507. }
  58508. interface HTMLVideoElement {
  58509. mozSrcObject: any;
  58510. }
  58511. interface Math {
  58512. fround(x: number): number;
  58513. imul(a: number, b: number): number;
  58514. }
  58515. interface WebGLRenderingContext {
  58516. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  58517. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  58518. vertexAttribDivisor(index: number, divisor: number): void;
  58519. createVertexArray(): any;
  58520. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  58521. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  58522. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  58523. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  58524. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  58525. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  58526. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  58527. // Queries
  58528. createQuery(): WebGLQuery;
  58529. deleteQuery(query: WebGLQuery): void;
  58530. beginQuery(target: number, query: WebGLQuery): void;
  58531. endQuery(target: number): void;
  58532. getQueryParameter(query: WebGLQuery, pname: number): any;
  58533. getQuery(target: number, pname: number): any;
  58534. MAX_SAMPLES: number;
  58535. RGBA8: number;
  58536. READ_FRAMEBUFFER: number;
  58537. DRAW_FRAMEBUFFER: number;
  58538. UNIFORM_BUFFER: number;
  58539. HALF_FLOAT_OES: number;
  58540. RGBA16F: number;
  58541. RGBA32F: number;
  58542. R32F: number;
  58543. RG32F: number;
  58544. RGB32F: number;
  58545. R16F: number;
  58546. RG16F: number;
  58547. RGB16F: number;
  58548. RED: number;
  58549. RG: number;
  58550. R8: number;
  58551. RG8: number;
  58552. UNSIGNED_INT_24_8: number;
  58553. DEPTH24_STENCIL8: number;
  58554. /* Multiple Render Targets */
  58555. drawBuffers(buffers: number[]): void;
  58556. readBuffer(src: number): void;
  58557. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  58558. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  58559. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  58560. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  58561. // Occlusion Query
  58562. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  58563. ANY_SAMPLES_PASSED: number;
  58564. QUERY_RESULT_AVAILABLE: number;
  58565. QUERY_RESULT: number;
  58566. }
  58567. interface WebGLProgram {
  58568. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  58569. }
  58570. interface EXT_disjoint_timer_query {
  58571. QUERY_COUNTER_BITS_EXT: number;
  58572. TIME_ELAPSED_EXT: number;
  58573. TIMESTAMP_EXT: number;
  58574. GPU_DISJOINT_EXT: number;
  58575. QUERY_RESULT_EXT: number;
  58576. QUERY_RESULT_AVAILABLE_EXT: number;
  58577. queryCounterEXT(query: WebGLQuery, target: number): void;
  58578. createQueryEXT(): WebGLQuery;
  58579. beginQueryEXT(target: number, query: WebGLQuery): void;
  58580. endQueryEXT(target: number): void;
  58581. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  58582. deleteQueryEXT(query: WebGLQuery): void;
  58583. }
  58584. interface WebGLUniformLocation {
  58585. _currentState: any;
  58586. }
  58587. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  58588. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  58589. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  58590. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58591. interface WebGLRenderingContext {
  58592. readonly RASTERIZER_DISCARD: number;
  58593. readonly DEPTH_COMPONENT24: number;
  58594. readonly TEXTURE_3D: number;
  58595. readonly TEXTURE_2D_ARRAY: number;
  58596. readonly TEXTURE_COMPARE_FUNC: number;
  58597. readonly TEXTURE_COMPARE_MODE: number;
  58598. readonly COMPARE_REF_TO_TEXTURE: number;
  58599. readonly TEXTURE_WRAP_R: number;
  58600. readonly HALF_FLOAT: number;
  58601. readonly RGB8: number;
  58602. readonly RED_INTEGER: number;
  58603. readonly RG_INTEGER: number;
  58604. readonly RGB_INTEGER: number;
  58605. readonly RGBA_INTEGER: number;
  58606. readonly R8_SNORM: number;
  58607. readonly RG8_SNORM: number;
  58608. readonly RGB8_SNORM: number;
  58609. readonly RGBA8_SNORM: number;
  58610. readonly R8I: number;
  58611. readonly RG8I: number;
  58612. readonly RGB8I: number;
  58613. readonly RGBA8I: number;
  58614. readonly R8UI: number;
  58615. readonly RG8UI: number;
  58616. readonly RGB8UI: number;
  58617. readonly RGBA8UI: number;
  58618. readonly R16I: number;
  58619. readonly RG16I: number;
  58620. readonly RGB16I: number;
  58621. readonly RGBA16I: number;
  58622. readonly R16UI: number;
  58623. readonly RG16UI: number;
  58624. readonly RGB16UI: number;
  58625. readonly RGBA16UI: number;
  58626. readonly R32I: number;
  58627. readonly RG32I: number;
  58628. readonly RGB32I: number;
  58629. readonly RGBA32I: number;
  58630. readonly R32UI: number;
  58631. readonly RG32UI: number;
  58632. readonly RGB32UI: number;
  58633. readonly RGBA32UI: number;
  58634. readonly RGB10_A2UI: number;
  58635. readonly R11F_G11F_B10F: number;
  58636. readonly RGB9_E5: number;
  58637. readonly RGB10_A2: number;
  58638. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  58639. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  58640. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  58641. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  58642. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  58643. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  58644. 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;
  58645. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  58646. readonly TRANSFORM_FEEDBACK: number;
  58647. readonly INTERLEAVED_ATTRIBS: number;
  58648. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  58649. createTransformFeedback(): WebGLTransformFeedback;
  58650. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  58651. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  58652. beginTransformFeedback(primitiveMode: number): void;
  58653. endTransformFeedback(): void;
  58654. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  58655. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58656. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58657. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58658. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  58659. }
  58660. interface ImageBitmap {
  58661. readonly width: number;
  58662. readonly height: number;
  58663. close(): void;
  58664. }
  58665. interface WebGLQuery extends WebGLObject {
  58666. }
  58667. declare var WebGLQuery: {
  58668. prototype: WebGLQuery;
  58669. new(): WebGLQuery;
  58670. };
  58671. interface WebGLSampler extends WebGLObject {
  58672. }
  58673. declare var WebGLSampler: {
  58674. prototype: WebGLSampler;
  58675. new(): WebGLSampler;
  58676. };
  58677. interface WebGLSync extends WebGLObject {
  58678. }
  58679. declare var WebGLSync: {
  58680. prototype: WebGLSync;
  58681. new(): WebGLSync;
  58682. };
  58683. interface WebGLTransformFeedback extends WebGLObject {
  58684. }
  58685. declare var WebGLTransformFeedback: {
  58686. prototype: WebGLTransformFeedback;
  58687. new(): WebGLTransformFeedback;
  58688. };
  58689. interface WebGLVertexArrayObject extends WebGLObject {
  58690. }
  58691. declare var WebGLVertexArrayObject: {
  58692. prototype: WebGLVertexArrayObject;
  58693. new(): WebGLVertexArrayObject;
  58694. };
  58695. // Type definitions for WebVR API
  58696. // Project: https://w3c.github.io/webvr/
  58697. // Definitions by: six a <https://github.com/lostfictions>
  58698. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58699. interface VRDisplay extends EventTarget {
  58700. /**
  58701. * Dictionary of capabilities describing the VRDisplay.
  58702. */
  58703. readonly capabilities: VRDisplayCapabilities;
  58704. /**
  58705. * z-depth defining the far plane of the eye view frustum
  58706. * enables mapping of values in the render target depth
  58707. * attachment to scene coordinates. Initially set to 10000.0.
  58708. */
  58709. depthFar: number;
  58710. /**
  58711. * z-depth defining the near plane of the eye view frustum
  58712. * enables mapping of values in the render target depth
  58713. * attachment to scene coordinates. Initially set to 0.01.
  58714. */
  58715. depthNear: number;
  58716. /**
  58717. * An identifier for this distinct VRDisplay. Used as an
  58718. * association point in the Gamepad API.
  58719. */
  58720. readonly displayId: number;
  58721. /**
  58722. * A display name, a user-readable name identifying it.
  58723. */
  58724. readonly displayName: string;
  58725. readonly isConnected: boolean;
  58726. readonly isPresenting: boolean;
  58727. /**
  58728. * If this VRDisplay supports room-scale experiences, the optional
  58729. * stage attribute contains details on the room-scale parameters.
  58730. */
  58731. readonly stageParameters: VRStageParameters | null;
  58732. /**
  58733. * Passing the value returned by `requestAnimationFrame` to
  58734. * `cancelAnimationFrame` will unregister the callback.
  58735. * @param handle Define the hanle of the request to cancel
  58736. */
  58737. cancelAnimationFrame(handle: number): void;
  58738. /**
  58739. * Stops presenting to the VRDisplay.
  58740. * @returns a promise to know when it stopped
  58741. */
  58742. exitPresent(): Promise<void>;
  58743. /**
  58744. * Return the current VREyeParameters for the given eye.
  58745. * @param whichEye Define the eye we want the parameter for
  58746. * @returns the eye parameters
  58747. */
  58748. getEyeParameters(whichEye: string): VREyeParameters;
  58749. /**
  58750. * Populates the passed VRFrameData with the information required to render
  58751. * the current frame.
  58752. * @param frameData Define the data structure to populate
  58753. * @returns true if ok otherwise false
  58754. */
  58755. getFrameData(frameData: VRFrameData): boolean;
  58756. /**
  58757. * Get the layers currently being presented.
  58758. * @returns the list of VR layers
  58759. */
  58760. getLayers(): VRLayer[];
  58761. /**
  58762. * Return a VRPose containing the future predicted pose of the VRDisplay
  58763. * when the current frame will be presented. The value returned will not
  58764. * change until JavaScript has returned control to the browser.
  58765. *
  58766. * The VRPose will contain the position, orientation, velocity,
  58767. * and acceleration of each of these properties.
  58768. * @returns the pose object
  58769. */
  58770. getPose(): VRPose;
  58771. /**
  58772. * Return the current instantaneous pose of the VRDisplay, with no
  58773. * prediction applied.
  58774. * @returns the current instantaneous pose
  58775. */
  58776. getImmediatePose(): VRPose;
  58777. /**
  58778. * The callback passed to `requestAnimationFrame` will be called
  58779. * any time a new frame should be rendered. When the VRDisplay is
  58780. * presenting the callback will be called at the native refresh
  58781. * rate of the HMD. When not presenting this function acts
  58782. * identically to how window.requestAnimationFrame acts. Content should
  58783. * make no assumptions of frame rate or vsync behavior as the HMD runs
  58784. * asynchronously from other displays and at differing refresh rates.
  58785. * @param callback Define the eaction to run next frame
  58786. * @returns the request handle it
  58787. */
  58788. requestAnimationFrame(callback: FrameRequestCallback): number;
  58789. /**
  58790. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  58791. * Repeat calls while already presenting will update the VRLayers being displayed.
  58792. * @param layers Define the list of layer to present
  58793. * @returns a promise to know when the request has been fulfilled
  58794. */
  58795. requestPresent(layers: VRLayer[]): Promise<void>;
  58796. /**
  58797. * Reset the pose for this display, treating its current position and
  58798. * orientation as the "origin/zero" values. VRPose.position,
  58799. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  58800. * updated when calling resetPose(). This should be called in only
  58801. * sitting-space experiences.
  58802. */
  58803. resetPose(): void;
  58804. /**
  58805. * The VRLayer provided to the VRDisplay will be captured and presented
  58806. * in the HMD. Calling this function has the same effect on the source
  58807. * canvas as any other operation that uses its source image, and canvases
  58808. * created without preserveDrawingBuffer set to true will be cleared.
  58809. * @param pose Define the pose to submit
  58810. */
  58811. submitFrame(pose?: VRPose): void;
  58812. }
  58813. declare var VRDisplay: {
  58814. prototype: VRDisplay;
  58815. new(): VRDisplay;
  58816. };
  58817. interface VRLayer {
  58818. leftBounds?: number[] | Float32Array | null;
  58819. rightBounds?: number[] | Float32Array | null;
  58820. source?: HTMLCanvasElement | null;
  58821. }
  58822. interface VRDisplayCapabilities {
  58823. readonly canPresent: boolean;
  58824. readonly hasExternalDisplay: boolean;
  58825. readonly hasOrientation: boolean;
  58826. readonly hasPosition: boolean;
  58827. readonly maxLayers: number;
  58828. }
  58829. interface VREyeParameters {
  58830. /** @deprecated */
  58831. readonly fieldOfView: VRFieldOfView;
  58832. readonly offset: Float32Array;
  58833. readonly renderHeight: number;
  58834. readonly renderWidth: number;
  58835. }
  58836. interface VRFieldOfView {
  58837. readonly downDegrees: number;
  58838. readonly leftDegrees: number;
  58839. readonly rightDegrees: number;
  58840. readonly upDegrees: number;
  58841. }
  58842. interface VRFrameData {
  58843. readonly leftProjectionMatrix: Float32Array;
  58844. readonly leftViewMatrix: Float32Array;
  58845. readonly pose: VRPose;
  58846. readonly rightProjectionMatrix: Float32Array;
  58847. readonly rightViewMatrix: Float32Array;
  58848. readonly timestamp: number;
  58849. }
  58850. interface VRPose {
  58851. readonly angularAcceleration: Float32Array | null;
  58852. readonly angularVelocity: Float32Array | null;
  58853. readonly linearAcceleration: Float32Array | null;
  58854. readonly linearVelocity: Float32Array | null;
  58855. readonly orientation: Float32Array | null;
  58856. readonly position: Float32Array | null;
  58857. readonly timestamp: number;
  58858. }
  58859. interface VRStageParameters {
  58860. sittingToStandingTransform?: Float32Array;
  58861. sizeX?: number;
  58862. sizeY?: number;
  58863. }
  58864. interface Navigator {
  58865. getVRDisplays(): Promise<VRDisplay[]>;
  58866. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  58867. }
  58868. interface Window {
  58869. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  58870. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  58871. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  58872. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58873. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58874. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  58875. }
  58876. interface Gamepad {
  58877. readonly displayId: number;
  58878. }
  58879. interface XRDevice {
  58880. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  58881. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  58882. }
  58883. interface XRSession {
  58884. getInputSources(): Array<any>;
  58885. baseLayer: XRWebGLLayer;
  58886. requestFrameOfReference(type: string): Promise<void>;
  58887. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  58888. end(): Promise<void>;
  58889. requestAnimationFrame: Function;
  58890. addEventListener: Function;
  58891. }
  58892. interface XRSessionCreationOptions {
  58893. outputContext?: WebGLRenderingContext | null;
  58894. immersive?: boolean;
  58895. environmentIntegration?: boolean;
  58896. }
  58897. interface XRLayer {
  58898. getViewport: Function;
  58899. framebufferWidth: number;
  58900. framebufferHeight: number;
  58901. }
  58902. interface XRView {
  58903. projectionMatrix: Float32Array;
  58904. }
  58905. interface XRFrame {
  58906. getDevicePose: Function;
  58907. getInputPose: Function;
  58908. views: Array<XRView>;
  58909. baseLayer: XRLayer;
  58910. }
  58911. interface XRFrameOfReference {
  58912. }
  58913. interface XRWebGLLayer extends XRLayer {
  58914. framebuffer: WebGLFramebuffer;
  58915. }
  58916. declare var XRWebGLLayer: {
  58917. prototype: XRWebGLLayer;
  58918. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  58919. };
  58920. declare module BABYLON.GUI {
  58921. /**
  58922. * Class used to specific a value and its associated unit
  58923. */
  58924. export class ValueAndUnit {
  58925. /** defines the unit to store */
  58926. unit: number;
  58927. /** defines a boolean indicating if the value can be negative */
  58928. negativeValueAllowed: boolean;
  58929. private _value;
  58930. private _originalUnit;
  58931. /**
  58932. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  58933. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  58934. */
  58935. ignoreAdaptiveScaling: boolean;
  58936. /**
  58937. * Creates a new ValueAndUnit
  58938. * @param value defines the value to store
  58939. * @param unit defines the unit to store
  58940. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  58941. */
  58942. constructor(value: number,
  58943. /** defines the unit to store */
  58944. unit?: number,
  58945. /** defines a boolean indicating if the value can be negative */
  58946. negativeValueAllowed?: boolean);
  58947. /** Gets a boolean indicating if the value is a percentage */
  58948. readonly isPercentage: boolean;
  58949. /** Gets a boolean indicating if the value is store as pixel */
  58950. readonly isPixel: boolean;
  58951. /** Gets direct internal value */
  58952. readonly internalValue: number;
  58953. /**
  58954. * Gets value as pixel
  58955. * @param host defines the root host
  58956. * @param refValue defines the reference value for percentages
  58957. * @returns the value as pixel
  58958. */
  58959. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  58960. /**
  58961. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  58962. * @param value defines the value to store
  58963. * @param unit defines the unit to store
  58964. * @returns the current ValueAndUnit
  58965. */
  58966. updateInPlace(value: number, unit?: number): ValueAndUnit;
  58967. /**
  58968. * Gets the value accordingly to its unit
  58969. * @param host defines the root host
  58970. * @returns the value
  58971. */
  58972. getValue(host: AdvancedDynamicTexture): number;
  58973. /**
  58974. * Gets a string representation of the value
  58975. * @param host defines the root host
  58976. * @param decimals defines an optional number of decimals to display
  58977. * @returns a string
  58978. */
  58979. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  58980. /**
  58981. * Store a value parsed from a string
  58982. * @param source defines the source string
  58983. * @returns true if the value was successfully parsed
  58984. */
  58985. fromString(source: string | number): boolean;
  58986. private static _Regex;
  58987. private static _UNITMODE_PERCENTAGE;
  58988. private static _UNITMODE_PIXEL;
  58989. /** UNITMODE_PERCENTAGE */
  58990. static readonly UNITMODE_PERCENTAGE: number;
  58991. /** UNITMODE_PIXEL */
  58992. static readonly UNITMODE_PIXEL: number;
  58993. }
  58994. }
  58995. declare module BABYLON.GUI {
  58996. /**
  58997. * Define a style used by control to automatically setup properties based on a template.
  58998. * Only support font related properties so far
  58999. */
  59000. export class Style implements BABYLON.IDisposable {
  59001. private _fontFamily;
  59002. private _fontStyle;
  59003. private _fontWeight;
  59004. /** @hidden */
  59005. _host: AdvancedDynamicTexture;
  59006. /** @hidden */
  59007. _fontSize: ValueAndUnit;
  59008. /**
  59009. * BABYLON.Observable raised when the style values are changed
  59010. */
  59011. onChangedObservable: BABYLON.Observable<Style>;
  59012. /**
  59013. * Creates a new style object
  59014. * @param host defines the AdvancedDynamicTexture which hosts this style
  59015. */
  59016. constructor(host: AdvancedDynamicTexture);
  59017. /**
  59018. * Gets or sets the font size
  59019. */
  59020. fontSize: string | number;
  59021. /**
  59022. * Gets or sets the font family
  59023. */
  59024. fontFamily: string;
  59025. /**
  59026. * Gets or sets the font style
  59027. */
  59028. fontStyle: string;
  59029. /** Gets or sets font weight */
  59030. fontWeight: string;
  59031. /** Dispose all associated resources */
  59032. dispose(): void;
  59033. }
  59034. }
  59035. declare module BABYLON.GUI {
  59036. /**
  59037. * Class used to transport BABYLON.Vector2 information for pointer events
  59038. */
  59039. export class Vector2WithInfo extends BABYLON.Vector2 {
  59040. /** defines the current mouse button index */
  59041. buttonIndex: number;
  59042. /**
  59043. * Creates a new Vector2WithInfo
  59044. * @param source defines the vector2 data to transport
  59045. * @param buttonIndex defines the current mouse button index
  59046. */
  59047. constructor(source: BABYLON.Vector2,
  59048. /** defines the current mouse button index */
  59049. buttonIndex?: number);
  59050. }
  59051. /** Class used to provide 2D matrix features */
  59052. export class Matrix2D {
  59053. /** Gets the internal array of 6 floats used to store matrix data */
  59054. m: Float32Array;
  59055. /**
  59056. * Creates a new matrix
  59057. * @param m00 defines value for (0, 0)
  59058. * @param m01 defines value for (0, 1)
  59059. * @param m10 defines value for (1, 0)
  59060. * @param m11 defines value for (1, 1)
  59061. * @param m20 defines value for (2, 0)
  59062. * @param m21 defines value for (2, 1)
  59063. */
  59064. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  59065. /**
  59066. * Fills the matrix from direct values
  59067. * @param m00 defines value for (0, 0)
  59068. * @param m01 defines value for (0, 1)
  59069. * @param m10 defines value for (1, 0)
  59070. * @param m11 defines value for (1, 1)
  59071. * @param m20 defines value for (2, 0)
  59072. * @param m21 defines value for (2, 1)
  59073. * @returns the current modified matrix
  59074. */
  59075. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  59076. /**
  59077. * Gets matrix determinant
  59078. * @returns the determinant
  59079. */
  59080. determinant(): number;
  59081. /**
  59082. * Inverses the matrix and stores it in a target matrix
  59083. * @param result defines the target matrix
  59084. * @returns the current matrix
  59085. */
  59086. invertToRef(result: Matrix2D): Matrix2D;
  59087. /**
  59088. * Multiplies the current matrix with another one
  59089. * @param other defines the second operand
  59090. * @param result defines the target matrix
  59091. * @returns the current matrix
  59092. */
  59093. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  59094. /**
  59095. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  59096. * @param x defines the x coordinate to transform
  59097. * @param y defines the x coordinate to transform
  59098. * @param result defines the target vector2
  59099. * @returns the current matrix
  59100. */
  59101. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  59102. /**
  59103. * Creates an identity matrix
  59104. * @returns a new matrix
  59105. */
  59106. static Identity(): Matrix2D;
  59107. /**
  59108. * Creates a translation matrix and stores it in a target matrix
  59109. * @param x defines the x coordinate of the translation
  59110. * @param y defines the y coordinate of the translation
  59111. * @param result defines the target matrix
  59112. */
  59113. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  59114. /**
  59115. * Creates a scaling matrix and stores it in a target matrix
  59116. * @param x defines the x coordinate of the scaling
  59117. * @param y defines the y coordinate of the scaling
  59118. * @param result defines the target matrix
  59119. */
  59120. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  59121. /**
  59122. * Creates a rotation matrix and stores it in a target matrix
  59123. * @param angle defines the rotation angle
  59124. * @param result defines the target matrix
  59125. */
  59126. static RotationToRef(angle: number, result: Matrix2D): void;
  59127. private static _TempPreTranslationMatrix;
  59128. private static _TempPostTranslationMatrix;
  59129. private static _TempRotationMatrix;
  59130. private static _TempScalingMatrix;
  59131. private static _TempCompose0;
  59132. private static _TempCompose1;
  59133. private static _TempCompose2;
  59134. /**
  59135. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  59136. * @param tx defines the x coordinate of the translation
  59137. * @param ty defines the y coordinate of the translation
  59138. * @param angle defines the rotation angle
  59139. * @param scaleX defines the x coordinate of the scaling
  59140. * @param scaleY defines the y coordinate of the scaling
  59141. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  59142. * @param result defines the target matrix
  59143. */
  59144. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  59145. }
  59146. }
  59147. declare module BABYLON.GUI {
  59148. /**
  59149. * Class used to store 2D control sizes
  59150. */
  59151. export class Measure {
  59152. /** defines left coordinate */
  59153. left: number;
  59154. /** defines top coordinate */
  59155. top: number;
  59156. /** defines width dimension */
  59157. width: number;
  59158. /** defines height dimension */
  59159. height: number;
  59160. /**
  59161. * Creates a new measure
  59162. * @param left defines left coordinate
  59163. * @param top defines top coordinate
  59164. * @param width defines width dimension
  59165. * @param height defines height dimension
  59166. */
  59167. constructor(
  59168. /** defines left coordinate */
  59169. left: number,
  59170. /** defines top coordinate */
  59171. top: number,
  59172. /** defines width dimension */
  59173. width: number,
  59174. /** defines height dimension */
  59175. height: number);
  59176. /**
  59177. * Copy from another measure
  59178. * @param other defines the other measure to copy from
  59179. */
  59180. copyFrom(other: Measure): void;
  59181. /**
  59182. * Copy from a group of 4 floats
  59183. * @param left defines left coordinate
  59184. * @param top defines top coordinate
  59185. * @param width defines width dimension
  59186. * @param height defines height dimension
  59187. */
  59188. copyFromFloats(left: number, top: number, width: number, height: number): void;
  59189. /**
  59190. * Computes the axis aligned bounding box measure for two given measures
  59191. * @param a Input measure
  59192. * @param b Input measure
  59193. * @param result the resulting bounding measure
  59194. */
  59195. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  59196. /**
  59197. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  59198. * @param transform the matrix to transform the measure before computing the AABB
  59199. * @param result the resulting AABB
  59200. */
  59201. transformToRef(transform: Matrix2D, result: Measure): void;
  59202. /**
  59203. * Check equality between this measure and another one
  59204. * @param other defines the other measures
  59205. * @returns true if both measures are equals
  59206. */
  59207. isEqualsTo(other: Measure): boolean;
  59208. /**
  59209. * Creates an empty measure
  59210. * @returns a new measure
  59211. */
  59212. static Empty(): Measure;
  59213. }
  59214. }
  59215. declare module BABYLON.GUI {
  59216. /**
  59217. * Interface used to define a control that can receive focus
  59218. */
  59219. export interface IFocusableControl {
  59220. /**
  59221. * Function called when the control receives the focus
  59222. */
  59223. onFocus(): void;
  59224. /**
  59225. * Function called when the control loses the focus
  59226. */
  59227. onBlur(): void;
  59228. /**
  59229. * Function called to let the control handle keyboard events
  59230. * @param evt defines the current keyboard event
  59231. */
  59232. processKeyboard(evt: KeyboardEvent): void;
  59233. /**
  59234. * Function called to get the list of controls that should not steal the focus from this control
  59235. * @returns an array of controls
  59236. */
  59237. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  59238. }
  59239. /**
  59240. * Class used to create texture to support 2D GUI elements
  59241. * @see http://doc.babylonjs.com/how_to/gui
  59242. */
  59243. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  59244. private _isDirty;
  59245. private _renderObserver;
  59246. private _resizeObserver;
  59247. private _preKeyboardObserver;
  59248. private _pointerMoveObserver;
  59249. private _pointerObserver;
  59250. private _canvasPointerOutObserver;
  59251. private _background;
  59252. /** @hidden */
  59253. _rootContainer: Container;
  59254. /** @hidden */
  59255. _lastPickedControl: Control;
  59256. /** @hidden */
  59257. _lastControlOver: {
  59258. [pointerId: number]: Control;
  59259. };
  59260. /** @hidden */
  59261. _lastControlDown: {
  59262. [pointerId: number]: Control;
  59263. };
  59264. /** @hidden */
  59265. _capturingControl: {
  59266. [pointerId: number]: Control;
  59267. };
  59268. /** @hidden */
  59269. _shouldBlockPointer: boolean;
  59270. /** @hidden */
  59271. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  59272. /** @hidden */
  59273. _linkedControls: Control[];
  59274. private _isFullscreen;
  59275. private _fullscreenViewport;
  59276. private _idealWidth;
  59277. private _idealHeight;
  59278. private _useSmallestIdeal;
  59279. private _renderAtIdealSize;
  59280. private _focusedControl;
  59281. private _blockNextFocusCheck;
  59282. private _renderScale;
  59283. private _rootCanvas;
  59284. private _cursorChanged;
  59285. /**
  59286. * Define type to string to ensure compatibility across browsers
  59287. * Safari doesn't support DataTransfer constructor
  59288. */
  59289. private _clipboardData;
  59290. /**
  59291. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  59292. */
  59293. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  59294. /**
  59295. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  59296. */
  59297. onControlPickedObservable: BABYLON.Observable<Control>;
  59298. /**
  59299. * BABYLON.Observable event triggered before layout is evaluated
  59300. */
  59301. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59302. /**
  59303. * BABYLON.Observable event triggered after the layout was evaluated
  59304. */
  59305. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59306. /**
  59307. * BABYLON.Observable event triggered before the texture is rendered
  59308. */
  59309. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59310. /**
  59311. * BABYLON.Observable event triggered after the texture was rendered
  59312. */
  59313. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59314. /**
  59315. * Gets or sets a boolean defining if alpha is stored as premultiplied
  59316. */
  59317. premulAlpha: boolean;
  59318. /**
  59319. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  59320. * Useful when you want more antialiasing
  59321. */
  59322. renderScale: number;
  59323. /** Gets or sets the background color */
  59324. background: string;
  59325. /**
  59326. * Gets or sets the ideal width used to design controls.
  59327. * The GUI will then rescale everything accordingly
  59328. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59329. */
  59330. idealWidth: number;
  59331. /**
  59332. * Gets or sets the ideal height used to design controls.
  59333. * The GUI will then rescale everything accordingly
  59334. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59335. */
  59336. idealHeight: number;
  59337. /**
  59338. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  59339. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59340. */
  59341. useSmallestIdeal: boolean;
  59342. /**
  59343. * Gets or sets a boolean indicating if adaptive scaling must be used
  59344. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59345. */
  59346. renderAtIdealSize: boolean;
  59347. /**
  59348. * Gets the underlying layer used to render the texture when in fullscreen mode
  59349. */
  59350. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  59351. /**
  59352. * Gets the root container control
  59353. */
  59354. readonly rootContainer: Container;
  59355. /**
  59356. * Returns an array containing the root container.
  59357. * This is mostly used to let the Inspector introspects the ADT
  59358. * @returns an array containing the rootContainer
  59359. */
  59360. getChildren(): Array<Container>;
  59361. /**
  59362. * Will return all controls that are inside this texture
  59363. * @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
  59364. * @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
  59365. * @return all child controls
  59366. */
  59367. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  59368. /**
  59369. * Gets or sets the current focused control
  59370. */
  59371. focusedControl: BABYLON.Nullable<IFocusableControl>;
  59372. /**
  59373. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  59374. */
  59375. isForeground: boolean;
  59376. /**
  59377. * Gets or set information about clipboardData
  59378. */
  59379. clipboardData: string;
  59380. /**
  59381. * Creates a new AdvancedDynamicTexture
  59382. * @param name defines the name of the texture
  59383. * @param width defines the width of the texture
  59384. * @param height defines the height of the texture
  59385. * @param scene defines the hosting scene
  59386. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  59387. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  59388. */
  59389. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  59390. /**
  59391. * Get the current class name of the texture useful for serialization or dynamic coding.
  59392. * @returns "AdvancedDynamicTexture"
  59393. */
  59394. getClassName(): string;
  59395. /**
  59396. * Function used to execute a function on all controls
  59397. * @param func defines the function to execute
  59398. * @param container defines the container where controls belong. If null the root container will be used
  59399. */
  59400. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  59401. private _useInvalidateRectOptimization;
  59402. /**
  59403. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  59404. */
  59405. useInvalidateRectOptimization: boolean;
  59406. private _invalidatedRectangle;
  59407. /**
  59408. * Invalidates a rectangle area on the gui texture
  59409. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  59410. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  59411. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  59412. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  59413. */
  59414. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  59415. /**
  59416. * Marks the texture as dirty forcing a complete update
  59417. */
  59418. markAsDirty(): void;
  59419. /**
  59420. * Helper function used to create a new style
  59421. * @returns a new style
  59422. * @see http://doc.babylonjs.com/how_to/gui#styles
  59423. */
  59424. createStyle(): Style;
  59425. /**
  59426. * Adds a new control to the root container
  59427. * @param control defines the control to add
  59428. * @returns the current texture
  59429. */
  59430. addControl(control: Control): AdvancedDynamicTexture;
  59431. /**
  59432. * Removes a control from the root container
  59433. * @param control defines the control to remove
  59434. * @returns the current texture
  59435. */
  59436. removeControl(control: Control): AdvancedDynamicTexture;
  59437. /**
  59438. * Release all resources
  59439. */
  59440. dispose(): void;
  59441. private _onResize;
  59442. /** @hidden */
  59443. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  59444. /**
  59445. * Get screen coordinates for a vector3
  59446. * @param position defines the position to project
  59447. * @param worldMatrix defines the world matrix to use
  59448. * @returns the projected position
  59449. */
  59450. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  59451. private _checkUpdate;
  59452. private _clearMeasure;
  59453. private _render;
  59454. /** @hidden */
  59455. _changeCursor(cursor: string): void;
  59456. /** @hidden */
  59457. _registerLastControlDown(control: Control, pointerId: number): void;
  59458. private _doPicking;
  59459. /** @hidden */
  59460. _cleanControlAfterRemovalFromList(list: {
  59461. [pointerId: number]: Control;
  59462. }, control: Control): void;
  59463. /** @hidden */
  59464. _cleanControlAfterRemoval(control: Control): void;
  59465. /** Attach to all scene events required to support pointer events */
  59466. attach(): void;
  59467. /** @hidden */
  59468. private onClipboardCopy;
  59469. /** @hidden */
  59470. private onClipboardCut;
  59471. /** @hidden */
  59472. private onClipboardPaste;
  59473. /**
  59474. * Register the clipboard Events onto the canvas
  59475. */
  59476. registerClipboardEvents(): void;
  59477. /**
  59478. * Unregister the clipboard Events from the canvas
  59479. */
  59480. unRegisterClipboardEvents(): void;
  59481. /**
  59482. * Connect the texture to a hosting mesh to enable interactions
  59483. * @param mesh defines the mesh to attach to
  59484. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  59485. */
  59486. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  59487. /**
  59488. * Move the focus to a specific control
  59489. * @param control defines the control which will receive the focus
  59490. */
  59491. moveFocusToControl(control: IFocusableControl): void;
  59492. private _manageFocus;
  59493. private _attachToOnPointerOut;
  59494. /**
  59495. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  59496. * @param mesh defines the mesh which will receive the texture
  59497. * @param width defines the texture width (1024 by default)
  59498. * @param height defines the texture height (1024 by default)
  59499. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  59500. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  59501. * @returns a new AdvancedDynamicTexture
  59502. */
  59503. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  59504. /**
  59505. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  59506. * In this mode the texture will rely on a layer for its rendering.
  59507. * This allows it to be treated like any other layer.
  59508. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  59509. * LayerMask is set through advancedTexture.layer.layerMask
  59510. * @param name defines name for the texture
  59511. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  59512. * @param scene defines the hsoting scene
  59513. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  59514. * @returns a new AdvancedDynamicTexture
  59515. */
  59516. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  59517. }
  59518. }
  59519. declare module BABYLON.GUI {
  59520. /**
  59521. * Root class used for all 2D controls
  59522. * @see http://doc.babylonjs.com/how_to/gui#controls
  59523. */
  59524. export class Control {
  59525. /** defines the name of the control */
  59526. name?: string | undefined;
  59527. /**
  59528. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  59529. */
  59530. static AllowAlphaInheritance: boolean;
  59531. private _alpha;
  59532. private _alphaSet;
  59533. private _zIndex;
  59534. /** @hidden */
  59535. _host: AdvancedDynamicTexture;
  59536. /** Gets or sets the control parent */
  59537. parent: BABYLON.Nullable<Container>;
  59538. /** @hidden */
  59539. _currentMeasure: Measure;
  59540. private _fontFamily;
  59541. private _fontStyle;
  59542. private _fontWeight;
  59543. private _fontSize;
  59544. private _font;
  59545. /** @hidden */
  59546. _width: ValueAndUnit;
  59547. /** @hidden */
  59548. _height: ValueAndUnit;
  59549. /** @hidden */
  59550. protected _fontOffset: {
  59551. ascent: number;
  59552. height: number;
  59553. descent: number;
  59554. };
  59555. private _color;
  59556. private _style;
  59557. private _styleObserver;
  59558. /** @hidden */
  59559. protected _horizontalAlignment: number;
  59560. /** @hidden */
  59561. protected _verticalAlignment: number;
  59562. /** @hidden */
  59563. protected _isDirty: boolean;
  59564. /** @hidden */
  59565. protected _wasDirty: boolean;
  59566. /** @hidden */
  59567. _tempParentMeasure: Measure;
  59568. /** @hidden */
  59569. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  59570. /** @hidden */
  59571. protected _cachedParentMeasure: Measure;
  59572. private _paddingLeft;
  59573. private _paddingRight;
  59574. private _paddingTop;
  59575. private _paddingBottom;
  59576. /** @hidden */
  59577. _left: ValueAndUnit;
  59578. /** @hidden */
  59579. _top: ValueAndUnit;
  59580. private _scaleX;
  59581. private _scaleY;
  59582. private _rotation;
  59583. private _transformCenterX;
  59584. private _transformCenterY;
  59585. /** @hidden */
  59586. _transformMatrix: Matrix2D;
  59587. /** @hidden */
  59588. protected _invertTransformMatrix: Matrix2D;
  59589. /** @hidden */
  59590. protected _transformedPosition: BABYLON.Vector2;
  59591. private _isMatrixDirty;
  59592. private _cachedOffsetX;
  59593. private _cachedOffsetY;
  59594. private _isVisible;
  59595. private _isHighlighted;
  59596. /** @hidden */
  59597. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  59598. private _fontSet;
  59599. private _dummyVector2;
  59600. private _downCount;
  59601. private _enterCount;
  59602. private _doNotRender;
  59603. private _downPointerIds;
  59604. protected _isEnabled: boolean;
  59605. protected _disabledColor: string;
  59606. /** @hidden */
  59607. protected _rebuildLayout: boolean;
  59608. /** @hidden */
  59609. _isClipped: boolean;
  59610. /** @hidden */
  59611. _tag: any;
  59612. /**
  59613. * 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
  59614. */
  59615. uniqueId: number;
  59616. /**
  59617. * Gets or sets an object used to store user defined information for the node
  59618. */
  59619. metadata: any;
  59620. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  59621. isHitTestVisible: boolean;
  59622. /** Gets or sets a boolean indicating if the control can block pointer events */
  59623. isPointerBlocker: boolean;
  59624. /** Gets or sets a boolean indicating if the control can be focusable */
  59625. isFocusInvisible: boolean;
  59626. /**
  59627. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  59628. * 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
  59629. */
  59630. clipChildren: boolean;
  59631. /**
  59632. * Gets or sets a boolean indicating that control content must be clipped
  59633. * 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
  59634. */
  59635. clipContent: boolean;
  59636. /**
  59637. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  59638. */
  59639. useBitmapCache: boolean;
  59640. private _cacheData;
  59641. private _shadowOffsetX;
  59642. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  59643. shadowOffsetX: number;
  59644. private _shadowOffsetY;
  59645. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  59646. shadowOffsetY: number;
  59647. private _shadowBlur;
  59648. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  59649. shadowBlur: number;
  59650. private _shadowColor;
  59651. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  59652. shadowColor: string;
  59653. /** Gets or sets the cursor to use when the control is hovered */
  59654. hoverCursor: string;
  59655. /** @hidden */
  59656. protected _linkOffsetX: ValueAndUnit;
  59657. /** @hidden */
  59658. protected _linkOffsetY: ValueAndUnit;
  59659. /** Gets the control type name */
  59660. readonly typeName: string;
  59661. /**
  59662. * Get the current class name of the control.
  59663. * @returns current class name
  59664. */
  59665. getClassName(): string;
  59666. /**
  59667. * An event triggered when the pointer move over the control.
  59668. */
  59669. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  59670. /**
  59671. * An event triggered when the pointer move out of the control.
  59672. */
  59673. onPointerOutObservable: BABYLON.Observable<Control>;
  59674. /**
  59675. * An event triggered when the pointer taps the control
  59676. */
  59677. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  59678. /**
  59679. * An event triggered when pointer up
  59680. */
  59681. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  59682. /**
  59683. * An event triggered when a control is clicked on
  59684. */
  59685. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  59686. /**
  59687. * An event triggered when pointer enters the control
  59688. */
  59689. onPointerEnterObservable: BABYLON.Observable<Control>;
  59690. /**
  59691. * An event triggered when the control is marked as dirty
  59692. */
  59693. onDirtyObservable: BABYLON.Observable<Control>;
  59694. /**
  59695. * An event triggered before drawing the control
  59696. */
  59697. onBeforeDrawObservable: BABYLON.Observable<Control>;
  59698. /**
  59699. * An event triggered after the control was drawn
  59700. */
  59701. onAfterDrawObservable: BABYLON.Observable<Control>;
  59702. /**
  59703. * Get the hosting AdvancedDynamicTexture
  59704. */
  59705. readonly host: AdvancedDynamicTexture;
  59706. /** Gets or set information about font offsets (used to render and align text) */
  59707. fontOffset: {
  59708. ascent: number;
  59709. height: number;
  59710. descent: number;
  59711. };
  59712. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  59713. alpha: number;
  59714. /**
  59715. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  59716. */
  59717. isHighlighted: boolean;
  59718. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  59719. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  59720. */
  59721. scaleX: number;
  59722. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  59723. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  59724. */
  59725. scaleY: number;
  59726. /** Gets or sets the rotation angle (0 by default)
  59727. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  59728. */
  59729. rotation: number;
  59730. /** Gets or sets the transformation center on Y axis (0 by default)
  59731. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  59732. */
  59733. transformCenterY: number;
  59734. /** Gets or sets the transformation center on X axis (0 by default)
  59735. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  59736. */
  59737. transformCenterX: number;
  59738. /**
  59739. * Gets or sets the horizontal alignment
  59740. * @see http://doc.babylonjs.com/how_to/gui#alignments
  59741. */
  59742. horizontalAlignment: number;
  59743. /**
  59744. * Gets or sets the vertical alignment
  59745. * @see http://doc.babylonjs.com/how_to/gui#alignments
  59746. */
  59747. verticalAlignment: number;
  59748. /**
  59749. * Gets or sets control width
  59750. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59751. */
  59752. width: string | number;
  59753. /**
  59754. * Gets or sets the control width in pixel
  59755. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59756. */
  59757. widthInPixels: number;
  59758. /**
  59759. * Gets or sets control height
  59760. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59761. */
  59762. height: string | number;
  59763. /**
  59764. * Gets or sets control height in pixel
  59765. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59766. */
  59767. heightInPixels: number;
  59768. /** Gets or set font family */
  59769. fontFamily: string;
  59770. /** Gets or sets font style */
  59771. fontStyle: string;
  59772. /** Gets or sets font weight */
  59773. fontWeight: string;
  59774. /**
  59775. * Gets or sets style
  59776. * @see http://doc.babylonjs.com/how_to/gui#styles
  59777. */
  59778. style: BABYLON.Nullable<Style>;
  59779. /** @hidden */
  59780. readonly _isFontSizeInPercentage: boolean;
  59781. /** Gets or sets font size in pixels */
  59782. fontSizeInPixels: number;
  59783. /** Gets or sets font size */
  59784. fontSize: string | number;
  59785. /** Gets or sets foreground color */
  59786. color: string;
  59787. /** Gets or sets z index which is used to reorder controls on the z axis */
  59788. zIndex: number;
  59789. /** Gets or sets a boolean indicating if the control can be rendered */
  59790. notRenderable: boolean;
  59791. /** Gets or sets a boolean indicating if the control is visible */
  59792. isVisible: boolean;
  59793. /** Gets a boolean indicating that the control needs to update its rendering */
  59794. readonly isDirty: boolean;
  59795. /**
  59796. * Gets the current linked mesh (or null if none)
  59797. */
  59798. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  59799. /**
  59800. * Gets or sets a value indicating the padding to use on the left of the control
  59801. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59802. */
  59803. paddingLeft: string | number;
  59804. /**
  59805. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  59806. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59807. */
  59808. paddingLeftInPixels: number;
  59809. /**
  59810. * Gets or sets a value indicating the padding to use on the right of the control
  59811. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59812. */
  59813. paddingRight: string | number;
  59814. /**
  59815. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  59816. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59817. */
  59818. paddingRightInPixels: number;
  59819. /**
  59820. * Gets or sets a value indicating the padding to use on the top of the control
  59821. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59822. */
  59823. paddingTop: string | number;
  59824. /**
  59825. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  59826. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59827. */
  59828. paddingTopInPixels: number;
  59829. /**
  59830. * Gets or sets a value indicating the padding to use on the bottom of the control
  59831. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59832. */
  59833. paddingBottom: string | number;
  59834. /**
  59835. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  59836. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59837. */
  59838. paddingBottomInPixels: number;
  59839. /**
  59840. * Gets or sets a value indicating the left coordinate of the control
  59841. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59842. */
  59843. left: string | number;
  59844. /**
  59845. * Gets or sets a value indicating the left coordinate in pixels of the control
  59846. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59847. */
  59848. leftInPixels: number;
  59849. /**
  59850. * Gets or sets a value indicating the top coordinate of the control
  59851. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59852. */
  59853. top: string | number;
  59854. /**
  59855. * Gets or sets a value indicating the top coordinate in pixels of the control
  59856. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59857. */
  59858. topInPixels: number;
  59859. /**
  59860. * Gets or sets a value indicating the offset on X axis to the linked mesh
  59861. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  59862. */
  59863. linkOffsetX: string | number;
  59864. /**
  59865. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  59866. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  59867. */
  59868. linkOffsetXInPixels: number;
  59869. /**
  59870. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  59871. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  59872. */
  59873. linkOffsetY: string | number;
  59874. /**
  59875. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  59876. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  59877. */
  59878. linkOffsetYInPixels: number;
  59879. /** Gets the center coordinate on X axis */
  59880. readonly centerX: number;
  59881. /** Gets the center coordinate on Y axis */
  59882. readonly centerY: number;
  59883. /** Gets or sets if control is Enabled*/
  59884. isEnabled: boolean;
  59885. /** Gets or sets background color of control if it's disabled*/
  59886. disabledColor: string;
  59887. /**
  59888. * Creates a new control
  59889. * @param name defines the name of the control
  59890. */
  59891. constructor(
  59892. /** defines the name of the control */
  59893. name?: string | undefined);
  59894. /** @hidden */
  59895. protected _getTypeName(): string;
  59896. /**
  59897. * Gets the first ascendant in the hierarchy of the given type
  59898. * @param className defines the required type
  59899. * @returns the ascendant or null if not found
  59900. */
  59901. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  59902. /** @hidden */
  59903. _resetFontCache(): void;
  59904. /**
  59905. * Determines if a container is an ascendant of the current control
  59906. * @param container defines the container to look for
  59907. * @returns true if the container is one of the ascendant of the control
  59908. */
  59909. isAscendant(container: Control): boolean;
  59910. /**
  59911. * Gets coordinates in local control space
  59912. * @param globalCoordinates defines the coordinates to transform
  59913. * @returns the new coordinates in local space
  59914. */
  59915. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  59916. /**
  59917. * Gets coordinates in local control space
  59918. * @param globalCoordinates defines the coordinates to transform
  59919. * @param result defines the target vector2 where to store the result
  59920. * @returns the current control
  59921. */
  59922. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  59923. /**
  59924. * Gets coordinates in parent local control space
  59925. * @param globalCoordinates defines the coordinates to transform
  59926. * @returns the new coordinates in parent local space
  59927. */
  59928. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  59929. /**
  59930. * Move the current control to a vector3 position projected onto the screen.
  59931. * @param position defines the target position
  59932. * @param scene defines the hosting scene
  59933. */
  59934. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  59935. /** @hidden */
  59936. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  59937. /**
  59938. * Will return all controls that have this control as ascendant
  59939. * @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
  59940. * @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
  59941. * @return all child controls
  59942. */
  59943. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  59944. /**
  59945. * Link current control with a target mesh
  59946. * @param mesh defines the mesh to link with
  59947. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  59948. */
  59949. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  59950. /** @hidden */
  59951. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  59952. /** @hidden */
  59953. _offsetLeft(offset: number): void;
  59954. /** @hidden */
  59955. _offsetTop(offset: number): void;
  59956. /** @hidden */
  59957. _markMatrixAsDirty(): void;
  59958. /** @hidden */
  59959. _flagDescendantsAsMatrixDirty(): void;
  59960. /** @hidden */
  59961. _intersectsRect(rect: Measure): boolean;
  59962. /** @hidden */
  59963. protected invalidateRect(): void;
  59964. /** @hidden */
  59965. _markAsDirty(force?: boolean): void;
  59966. /** @hidden */
  59967. _markAllAsDirty(): void;
  59968. /** @hidden */
  59969. _link(host: AdvancedDynamicTexture): void;
  59970. /** @hidden */
  59971. protected _transform(context?: CanvasRenderingContext2D): void;
  59972. /** @hidden */
  59973. _renderHighlight(context: CanvasRenderingContext2D): void;
  59974. /** @hidden */
  59975. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  59976. /** @hidden */
  59977. protected _applyStates(context: CanvasRenderingContext2D): void;
  59978. /** @hidden */
  59979. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  59980. /** @hidden */
  59981. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59982. protected _evaluateClippingState(parentMeasure: Measure): void;
  59983. /** @hidden */
  59984. _measure(): void;
  59985. /** @hidden */
  59986. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59987. /** @hidden */
  59988. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59989. /** @hidden */
  59990. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59991. /** @hidden */
  59992. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  59993. private static _ClipMeasure;
  59994. private _tmpMeasureA;
  59995. private _clip;
  59996. /** @hidden */
  59997. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  59998. /** @hidden */
  59999. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  60000. /**
  60001. * Tests if a given coordinates belong to the current control
  60002. * @param x defines x coordinate to test
  60003. * @param y defines y coordinate to test
  60004. * @returns true if the coordinates are inside the control
  60005. */
  60006. contains(x: number, y: number): boolean;
  60007. /** @hidden */
  60008. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60009. /** @hidden */
  60010. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  60011. /** @hidden */
  60012. _onPointerEnter(target: Control): boolean;
  60013. /** @hidden */
  60014. _onPointerOut(target: Control, force?: boolean): void;
  60015. /** @hidden */
  60016. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60017. /** @hidden */
  60018. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  60019. /** @hidden */
  60020. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  60021. /** @hidden */
  60022. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  60023. private _prepareFont;
  60024. /** Releases associated resources */
  60025. dispose(): void;
  60026. private static _HORIZONTAL_ALIGNMENT_LEFT;
  60027. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  60028. private static _HORIZONTAL_ALIGNMENT_CENTER;
  60029. private static _VERTICAL_ALIGNMENT_TOP;
  60030. private static _VERTICAL_ALIGNMENT_BOTTOM;
  60031. private static _VERTICAL_ALIGNMENT_CENTER;
  60032. /** HORIZONTAL_ALIGNMENT_LEFT */
  60033. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  60034. /** HORIZONTAL_ALIGNMENT_RIGHT */
  60035. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  60036. /** HORIZONTAL_ALIGNMENT_CENTER */
  60037. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  60038. /** VERTICAL_ALIGNMENT_TOP */
  60039. static readonly VERTICAL_ALIGNMENT_TOP: number;
  60040. /** VERTICAL_ALIGNMENT_BOTTOM */
  60041. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  60042. /** VERTICAL_ALIGNMENT_CENTER */
  60043. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  60044. private static _FontHeightSizes;
  60045. /** @hidden */
  60046. static _GetFontOffset(font: string): {
  60047. ascent: number;
  60048. height: number;
  60049. descent: number;
  60050. };
  60051. /**
  60052. * Creates a stack panel that can be used to render headers
  60053. * @param control defines the control to associate with the header
  60054. * @param text defines the text of the header
  60055. * @param size defines the size of the header
  60056. * @param options defines options used to configure the header
  60057. * @returns a new StackPanel
  60058. * @ignore
  60059. * @hidden
  60060. */
  60061. static AddHeader: (control: Control, text: string, size: string | number, options: {
  60062. isHorizontal: boolean;
  60063. controlFirst: boolean;
  60064. }) => any;
  60065. /** @hidden */
  60066. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  60067. }
  60068. }
  60069. declare module BABYLON.GUI {
  60070. /**
  60071. * Root class for 2D containers
  60072. * @see http://doc.babylonjs.com/how_to/gui#containers
  60073. */
  60074. export class Container extends Control {
  60075. name?: string | undefined;
  60076. /** @hidden */
  60077. protected _children: Control[];
  60078. /** @hidden */
  60079. protected _measureForChildren: Measure;
  60080. /** @hidden */
  60081. protected _background: string;
  60082. /** @hidden */
  60083. protected _adaptWidthToChildren: boolean;
  60084. /** @hidden */
  60085. protected _adaptHeightToChildren: boolean;
  60086. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  60087. adaptHeightToChildren: boolean;
  60088. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  60089. adaptWidthToChildren: boolean;
  60090. /** Gets or sets background color */
  60091. background: string;
  60092. /** Gets the list of children */
  60093. readonly children: Control[];
  60094. /**
  60095. * Creates a new Container
  60096. * @param name defines the name of the container
  60097. */
  60098. constructor(name?: string | undefined);
  60099. protected _getTypeName(): string;
  60100. _flagDescendantsAsMatrixDirty(): void;
  60101. /**
  60102. * Gets a child using its name
  60103. * @param name defines the child name to look for
  60104. * @returns the child control if found
  60105. */
  60106. getChildByName(name: string): BABYLON.Nullable<Control>;
  60107. /**
  60108. * Gets a child using its type and its name
  60109. * @param name defines the child name to look for
  60110. * @param type defines the child type to look for
  60111. * @returns the child control if found
  60112. */
  60113. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  60114. /**
  60115. * Search for a specific control in children
  60116. * @param control defines the control to look for
  60117. * @returns true if the control is in child list
  60118. */
  60119. containsControl(control: Control): boolean;
  60120. /**
  60121. * Adds a new control to the current container
  60122. * @param control defines the control to add
  60123. * @returns the current container
  60124. */
  60125. addControl(control: BABYLON.Nullable<Control>): Container;
  60126. /**
  60127. * Removes all controls from the current container
  60128. * @returns the current container
  60129. */
  60130. clearControls(): Container;
  60131. /**
  60132. * Removes a control from the current container
  60133. * @param control defines the control to remove
  60134. * @returns the current container
  60135. */
  60136. removeControl(control: Control): Container;
  60137. /** @hidden */
  60138. _reOrderControl(control: Control): void;
  60139. /** @hidden */
  60140. _offsetLeft(offset: number): void;
  60141. /** @hidden */
  60142. _offsetTop(offset: number): void;
  60143. /** @hidden */
  60144. _markAllAsDirty(): void;
  60145. /** @hidden */
  60146. protected _localDraw(context: CanvasRenderingContext2D): void;
  60147. /** @hidden */
  60148. _link(host: AdvancedDynamicTexture): void;
  60149. /** @hidden */
  60150. protected _beforeLayout(): void;
  60151. /** @hidden */
  60152. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60153. /** @hidden */
  60154. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  60155. protected _postMeasure(): void;
  60156. /** @hidden */
  60157. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  60158. /** @hidden */
  60159. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  60160. /** @hidden */
  60161. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60162. /** @hidden */
  60163. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60164. /** Releases associated resources */
  60165. dispose(): void;
  60166. }
  60167. }
  60168. declare module BABYLON.GUI {
  60169. /** Class used to create rectangle container */
  60170. export class Rectangle extends Container {
  60171. name?: string | undefined;
  60172. private _thickness;
  60173. private _cornerRadius;
  60174. /** Gets or sets border thickness */
  60175. thickness: number;
  60176. /** Gets or sets the corner radius angle */
  60177. cornerRadius: number;
  60178. /**
  60179. * Creates a new Rectangle
  60180. * @param name defines the control name
  60181. */
  60182. constructor(name?: string | undefined);
  60183. protected _getTypeName(): string;
  60184. protected _localDraw(context: CanvasRenderingContext2D): void;
  60185. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60186. private _drawRoundedRect;
  60187. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  60188. }
  60189. }
  60190. declare module BABYLON.GUI {
  60191. /**
  60192. * Enum that determines the text-wrapping mode to use.
  60193. */
  60194. export enum TextWrapping {
  60195. /**
  60196. * Clip the text when it's larger than Control.width; this is the default mode.
  60197. */
  60198. Clip = 0,
  60199. /**
  60200. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  60201. */
  60202. WordWrap = 1,
  60203. /**
  60204. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  60205. */
  60206. Ellipsis = 2
  60207. }
  60208. /**
  60209. * Class used to create text block control
  60210. */
  60211. export class TextBlock extends Control {
  60212. /**
  60213. * Defines the name of the control
  60214. */
  60215. name?: string | undefined;
  60216. private _text;
  60217. private _textWrapping;
  60218. private _textHorizontalAlignment;
  60219. private _textVerticalAlignment;
  60220. private _lines;
  60221. private _resizeToFit;
  60222. private _lineSpacing;
  60223. private _outlineWidth;
  60224. private _outlineColor;
  60225. /**
  60226. * An event triggered after the text is changed
  60227. */
  60228. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  60229. /**
  60230. * An event triggered after the text was broken up into lines
  60231. */
  60232. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  60233. /**
  60234. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  60235. */
  60236. readonly lines: any[];
  60237. /**
  60238. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  60239. */
  60240. /**
  60241. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  60242. */
  60243. resizeToFit: boolean;
  60244. /**
  60245. * Gets or sets a boolean indicating if text must be wrapped
  60246. */
  60247. /**
  60248. * Gets or sets a boolean indicating if text must be wrapped
  60249. */
  60250. textWrapping: TextWrapping | boolean;
  60251. /**
  60252. * Gets or sets text to display
  60253. */
  60254. /**
  60255. * Gets or sets text to display
  60256. */
  60257. text: string;
  60258. /**
  60259. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  60260. */
  60261. /**
  60262. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  60263. */
  60264. textHorizontalAlignment: number;
  60265. /**
  60266. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  60267. */
  60268. /**
  60269. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  60270. */
  60271. textVerticalAlignment: number;
  60272. /**
  60273. * Gets or sets line spacing value
  60274. */
  60275. /**
  60276. * Gets or sets line spacing value
  60277. */
  60278. lineSpacing: string | number;
  60279. /**
  60280. * Gets or sets outlineWidth of the text to display
  60281. */
  60282. /**
  60283. * Gets or sets outlineWidth of the text to display
  60284. */
  60285. outlineWidth: number;
  60286. /**
  60287. * Gets or sets outlineColor of the text to display
  60288. */
  60289. /**
  60290. * Gets or sets outlineColor of the text to display
  60291. */
  60292. outlineColor: string;
  60293. /**
  60294. * Creates a new TextBlock object
  60295. * @param name defines the name of the control
  60296. * @param text defines the text to display (emptry string by default)
  60297. */
  60298. constructor(
  60299. /**
  60300. * Defines the name of the control
  60301. */
  60302. name?: string | undefined, text?: string);
  60303. protected _getTypeName(): string;
  60304. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60305. private _drawText;
  60306. /** @hidden */
  60307. _draw(context: CanvasRenderingContext2D): void;
  60308. protected _applyStates(context: CanvasRenderingContext2D): void;
  60309. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  60310. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  60311. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  60312. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  60313. protected _renderLines(context: CanvasRenderingContext2D): void;
  60314. /**
  60315. * Given a width constraint applied on the text block, find the expected height
  60316. * @returns expected height
  60317. */
  60318. computeExpectedHeight(): number;
  60319. dispose(): void;
  60320. }
  60321. }
  60322. declare module BABYLON.GUI {
  60323. /**
  60324. * Class used to create 2D images
  60325. */
  60326. export class Image extends Control {
  60327. name?: string | undefined;
  60328. private static _WorkingCanvas;
  60329. private _domImage;
  60330. private _imageWidth;
  60331. private _imageHeight;
  60332. private _loaded;
  60333. private _stretch;
  60334. private _source;
  60335. private _autoScale;
  60336. private _sourceLeft;
  60337. private _sourceTop;
  60338. private _sourceWidth;
  60339. private _sourceHeight;
  60340. private _cellWidth;
  60341. private _cellHeight;
  60342. private _cellId;
  60343. private _populateNinePatchSlicesFromImage;
  60344. private _sliceLeft;
  60345. private _sliceRight;
  60346. private _sliceTop;
  60347. private _sliceBottom;
  60348. private _detectPointerOnOpaqueOnly;
  60349. /**
  60350. * BABYLON.Observable notified when the content is loaded
  60351. */
  60352. onImageLoadedObservable: BABYLON.Observable<Image>;
  60353. /**
  60354. * Gets a boolean indicating that the content is loaded
  60355. */
  60356. readonly isLoaded: boolean;
  60357. /**
  60358. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  60359. */
  60360. populateNinePatchSlicesFromImage: boolean;
  60361. /**
  60362. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  60363. * Beware using this as this will comsume more memory as the image has to be stored twice
  60364. */
  60365. detectPointerOnOpaqueOnly: boolean;
  60366. /**
  60367. * Gets or sets the left value for slicing (9-patch)
  60368. */
  60369. sliceLeft: number;
  60370. /**
  60371. * Gets or sets the right value for slicing (9-patch)
  60372. */
  60373. sliceRight: number;
  60374. /**
  60375. * Gets or sets the top value for slicing (9-patch)
  60376. */
  60377. sliceTop: number;
  60378. /**
  60379. * Gets or sets the bottom value for slicing (9-patch)
  60380. */
  60381. sliceBottom: number;
  60382. /**
  60383. * Gets or sets the left coordinate in the source image
  60384. */
  60385. sourceLeft: number;
  60386. /**
  60387. * Gets or sets the top coordinate in the source image
  60388. */
  60389. sourceTop: number;
  60390. /**
  60391. * Gets or sets the width to capture in the source image
  60392. */
  60393. sourceWidth: number;
  60394. /**
  60395. * Gets or sets the height to capture in the source image
  60396. */
  60397. sourceHeight: number;
  60398. /**
  60399. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  60400. * @see http://doc.babylonjs.com/how_to/gui#image
  60401. */
  60402. autoScale: boolean;
  60403. /** Gets or sets the streching mode used by the image */
  60404. stretch: number;
  60405. /**
  60406. * Gets or sets the internal DOM image used to render the control
  60407. */
  60408. domImage: HTMLImageElement;
  60409. private _onImageLoaded;
  60410. private _extractNinePatchSliceDataFromImage;
  60411. /**
  60412. * Gets or sets image source url
  60413. */
  60414. source: BABYLON.Nullable<string>;
  60415. /**
  60416. * Gets or sets the cell width to use when animation sheet is enabled
  60417. * @see http://doc.babylonjs.com/how_to/gui#image
  60418. */
  60419. cellWidth: number;
  60420. /**
  60421. * Gets or sets the cell height to use when animation sheet is enabled
  60422. * @see http://doc.babylonjs.com/how_to/gui#image
  60423. */
  60424. cellHeight: number;
  60425. /**
  60426. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  60427. * @see http://doc.babylonjs.com/how_to/gui#image
  60428. */
  60429. cellId: number;
  60430. /**
  60431. * Creates a new Image
  60432. * @param name defines the control name
  60433. * @param url defines the image url
  60434. */
  60435. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  60436. /**
  60437. * Tests if a given coordinates belong to the current control
  60438. * @param x defines x coordinate to test
  60439. * @param y defines y coordinate to test
  60440. * @returns true if the coordinates are inside the control
  60441. */
  60442. contains(x: number, y: number): boolean;
  60443. protected _getTypeName(): string;
  60444. /** Force the control to synchronize with its content */
  60445. synchronizeSizeWithContent(): void;
  60446. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60447. private _prepareWorkingCanvasForOpaqueDetection;
  60448. private _drawImage;
  60449. _draw(context: CanvasRenderingContext2D): void;
  60450. private _renderCornerPatch;
  60451. private _renderNinePatch;
  60452. dispose(): void;
  60453. /** STRETCH_NONE */
  60454. static readonly STRETCH_NONE: number;
  60455. /** STRETCH_FILL */
  60456. static readonly STRETCH_FILL: number;
  60457. /** STRETCH_UNIFORM */
  60458. static readonly STRETCH_UNIFORM: number;
  60459. /** STRETCH_EXTEND */
  60460. static readonly STRETCH_EXTEND: number;
  60461. /** NINE_PATCH */
  60462. static readonly STRETCH_NINE_PATCH: number;
  60463. }
  60464. }
  60465. declare module BABYLON.GUI {
  60466. /**
  60467. * Class used to create 2D buttons
  60468. */
  60469. export class Button extends Rectangle {
  60470. name?: string | undefined;
  60471. /**
  60472. * Function called to generate a pointer enter animation
  60473. */
  60474. pointerEnterAnimation: () => void;
  60475. /**
  60476. * Function called to generate a pointer out animation
  60477. */
  60478. pointerOutAnimation: () => void;
  60479. /**
  60480. * Function called to generate a pointer down animation
  60481. */
  60482. pointerDownAnimation: () => void;
  60483. /**
  60484. * Function called to generate a pointer up animation
  60485. */
  60486. pointerUpAnimation: () => void;
  60487. private _image;
  60488. /**
  60489. * Returns the image part of the button (if any)
  60490. */
  60491. readonly image: BABYLON.Nullable<Image>;
  60492. private _textBlock;
  60493. /**
  60494. * Returns the image part of the button (if any)
  60495. */
  60496. readonly textBlock: BABYLON.Nullable<TextBlock>;
  60497. /**
  60498. * Creates a new Button
  60499. * @param name defines the name of the button
  60500. */
  60501. constructor(name?: string | undefined);
  60502. protected _getTypeName(): string;
  60503. /** @hidden */
  60504. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60505. /** @hidden */
  60506. _onPointerEnter(target: Control): boolean;
  60507. /** @hidden */
  60508. _onPointerOut(target: Control, force?: boolean): void;
  60509. /** @hidden */
  60510. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60511. /** @hidden */
  60512. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  60513. /**
  60514. * Creates a new button made with an image and a text
  60515. * @param name defines the name of the button
  60516. * @param text defines the text of the button
  60517. * @param imageUrl defines the url of the image
  60518. * @returns a new Button
  60519. */
  60520. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  60521. /**
  60522. * Creates a new button made with an image
  60523. * @param name defines the name of the button
  60524. * @param imageUrl defines the url of the image
  60525. * @returns a new Button
  60526. */
  60527. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  60528. /**
  60529. * Creates a new button made with a text
  60530. * @param name defines the name of the button
  60531. * @param text defines the text of the button
  60532. * @returns a new Button
  60533. */
  60534. static CreateSimpleButton(name: string, text: string): Button;
  60535. /**
  60536. * Creates a new button made with an image and a centered text
  60537. * @param name defines the name of the button
  60538. * @param text defines the text of the button
  60539. * @param imageUrl defines the url of the image
  60540. * @returns a new Button
  60541. */
  60542. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  60543. }
  60544. }
  60545. declare module BABYLON.GUI {
  60546. /**
  60547. * Class used to create a 2D stack panel container
  60548. */
  60549. export class StackPanel extends Container {
  60550. name?: string | undefined;
  60551. private _isVertical;
  60552. private _manualWidth;
  60553. private _manualHeight;
  60554. private _doNotTrackManualChanges;
  60555. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  60556. isVertical: boolean;
  60557. /**
  60558. * Gets or sets panel width.
  60559. * This value should not be set when in horizontal mode as it will be computed automatically
  60560. */
  60561. width: string | number;
  60562. /**
  60563. * Gets or sets panel height.
  60564. * This value should not be set when in vertical mode as it will be computed automatically
  60565. */
  60566. height: string | number;
  60567. /**
  60568. * Creates a new StackPanel
  60569. * @param name defines control name
  60570. */
  60571. constructor(name?: string | undefined);
  60572. protected _getTypeName(): string;
  60573. /** @hidden */
  60574. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60575. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60576. protected _postMeasure(): void;
  60577. }
  60578. }
  60579. declare module BABYLON.GUI {
  60580. /**
  60581. * Class used to represent a 2D checkbox
  60582. */
  60583. export class Checkbox extends Control {
  60584. name?: string | undefined;
  60585. private _isChecked;
  60586. private _background;
  60587. private _checkSizeRatio;
  60588. private _thickness;
  60589. /** Gets or sets border thickness */
  60590. thickness: number;
  60591. /**
  60592. * BABYLON.Observable raised when isChecked property changes
  60593. */
  60594. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  60595. /** Gets or sets a value indicating the ratio between overall size and check size */
  60596. checkSizeRatio: number;
  60597. /** Gets or sets background color */
  60598. background: string;
  60599. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  60600. isChecked: boolean;
  60601. /**
  60602. * Creates a new CheckBox
  60603. * @param name defines the control name
  60604. */
  60605. constructor(name?: string | undefined);
  60606. protected _getTypeName(): string;
  60607. /** @hidden */
  60608. _draw(context: CanvasRenderingContext2D): void;
  60609. /** @hidden */
  60610. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60611. /**
  60612. * Utility function to easily create a checkbox with a header
  60613. * @param title defines the label to use for the header
  60614. * @param onValueChanged defines the callback to call when value changes
  60615. * @returns a StackPanel containing the checkbox and a textBlock
  60616. */
  60617. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  60618. }
  60619. }
  60620. declare module BABYLON.GUI {
  60621. /**
  60622. * Class used to store key control properties
  60623. */
  60624. export class KeyPropertySet {
  60625. /** Width */
  60626. width?: string;
  60627. /** Height */
  60628. height?: string;
  60629. /** Left padding */
  60630. paddingLeft?: string;
  60631. /** Right padding */
  60632. paddingRight?: string;
  60633. /** Top padding */
  60634. paddingTop?: string;
  60635. /** Bottom padding */
  60636. paddingBottom?: string;
  60637. /** Foreground color */
  60638. color?: string;
  60639. /** Background color */
  60640. background?: string;
  60641. }
  60642. /**
  60643. * Class used to create virtual keyboard
  60644. */
  60645. export class VirtualKeyboard extends StackPanel {
  60646. /** BABYLON.Observable raised when a key is pressed */
  60647. onKeyPressObservable: BABYLON.Observable<string>;
  60648. /** Gets or sets default key button width */
  60649. defaultButtonWidth: string;
  60650. /** Gets or sets default key button height */
  60651. defaultButtonHeight: string;
  60652. /** Gets or sets default key button left padding */
  60653. defaultButtonPaddingLeft: string;
  60654. /** Gets or sets default key button right padding */
  60655. defaultButtonPaddingRight: string;
  60656. /** Gets or sets default key button top padding */
  60657. defaultButtonPaddingTop: string;
  60658. /** Gets or sets default key button bottom padding */
  60659. defaultButtonPaddingBottom: string;
  60660. /** Gets or sets default key button foreground color */
  60661. defaultButtonColor: string;
  60662. /** Gets or sets default key button background color */
  60663. defaultButtonBackground: string;
  60664. /** Gets or sets shift button foreground color */
  60665. shiftButtonColor: string;
  60666. /** Gets or sets shift button thickness*/
  60667. selectedShiftThickness: number;
  60668. /** Gets shift key state */
  60669. shiftState: number;
  60670. protected _getTypeName(): string;
  60671. private _createKey;
  60672. /**
  60673. * Adds a new row of keys
  60674. * @param keys defines the list of keys to add
  60675. * @param propertySets defines the associated property sets
  60676. */
  60677. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  60678. /**
  60679. * Set the shift key to a specific state
  60680. * @param shiftState defines the new shift state
  60681. */
  60682. applyShiftState(shiftState: number): void;
  60683. private _currentlyConnectedInputText;
  60684. private _connectedInputTexts;
  60685. private _onKeyPressObserver;
  60686. /** Gets the input text control currently attached to the keyboard */
  60687. readonly connectedInputText: BABYLON.Nullable<InputText>;
  60688. /**
  60689. * Connects the keyboard with an input text control
  60690. *
  60691. * @param input defines the target control
  60692. */
  60693. connect(input: InputText): void;
  60694. /**
  60695. * Disconnects the keyboard from connected InputText controls
  60696. *
  60697. * @param input optionally defines a target control, otherwise all are disconnected
  60698. */
  60699. disconnect(input?: InputText): void;
  60700. private _removeConnectedInputObservables;
  60701. /**
  60702. * Release all resources
  60703. */
  60704. dispose(): void;
  60705. /**
  60706. * Creates a new keyboard using a default layout
  60707. *
  60708. * @param name defines control name
  60709. * @returns a new VirtualKeyboard
  60710. */
  60711. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  60712. }
  60713. }
  60714. declare module BABYLON.GUI {
  60715. /**
  60716. * Class used to create input text control
  60717. */
  60718. export class InputText extends Control implements IFocusableControl {
  60719. name?: string | undefined;
  60720. private _text;
  60721. private _placeholderText;
  60722. private _background;
  60723. private _focusedBackground;
  60724. private _focusedColor;
  60725. private _placeholderColor;
  60726. private _thickness;
  60727. private _margin;
  60728. private _autoStretchWidth;
  60729. private _maxWidth;
  60730. private _isFocused;
  60731. private _blinkTimeout;
  60732. private _blinkIsEven;
  60733. private _cursorOffset;
  60734. private _scrollLeft;
  60735. private _textWidth;
  60736. private _clickedCoordinate;
  60737. private _deadKey;
  60738. private _addKey;
  60739. private _currentKey;
  60740. private _isTextHighlightOn;
  60741. private _textHighlightColor;
  60742. private _highligherOpacity;
  60743. private _highlightedText;
  60744. private _startHighlightIndex;
  60745. private _endHighlightIndex;
  60746. private _cursorIndex;
  60747. private _onFocusSelectAll;
  60748. private _isPointerDown;
  60749. private _onClipboardObserver;
  60750. private _onPointerDblTapObserver;
  60751. /** @hidden */
  60752. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  60753. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  60754. promptMessage: string;
  60755. /** BABYLON.Observable raised when the text changes */
  60756. onTextChangedObservable: BABYLON.Observable<InputText>;
  60757. /** BABYLON.Observable raised just before an entered character is to be added */
  60758. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  60759. /** BABYLON.Observable raised when the control gets the focus */
  60760. onFocusObservable: BABYLON.Observable<InputText>;
  60761. /** BABYLON.Observable raised when the control loses the focus */
  60762. onBlurObservable: BABYLON.Observable<InputText>;
  60763. /**Observable raised when the text is highlighted */
  60764. onTextHighlightObservable: BABYLON.Observable<InputText>;
  60765. /**Observable raised when copy event is triggered */
  60766. onTextCopyObservable: BABYLON.Observable<InputText>;
  60767. /** BABYLON.Observable raised when cut event is triggered */
  60768. onTextCutObservable: BABYLON.Observable<InputText>;
  60769. /** BABYLON.Observable raised when paste event is triggered */
  60770. onTextPasteObservable: BABYLON.Observable<InputText>;
  60771. /** BABYLON.Observable raised when a key event was processed */
  60772. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  60773. /** Gets or sets the maximum width allowed by the control */
  60774. maxWidth: string | number;
  60775. /** Gets the maximum width allowed by the control in pixels */
  60776. readonly maxWidthInPixels: number;
  60777. /** Gets or sets the text highlighter transparency; default: 0.4 */
  60778. highligherOpacity: number;
  60779. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  60780. onFocusSelectAll: boolean;
  60781. /** Gets or sets the text hightlight color */
  60782. textHighlightColor: string;
  60783. /** Gets or sets control margin */
  60784. margin: string;
  60785. /** Gets control margin in pixels */
  60786. readonly marginInPixels: number;
  60787. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  60788. autoStretchWidth: boolean;
  60789. /** Gets or sets border thickness */
  60790. thickness: number;
  60791. /** Gets or sets the background color when focused */
  60792. focusedBackground: string;
  60793. /** Gets or sets the background color when focused */
  60794. focusedColor: string;
  60795. /** Gets or sets the background color */
  60796. background: string;
  60797. /** Gets or sets the placeholder color */
  60798. placeholderColor: string;
  60799. /** Gets or sets the text displayed when the control is empty */
  60800. placeholderText: string;
  60801. /** Gets or sets the dead key flag */
  60802. deadKey: boolean;
  60803. /** Gets or sets the highlight text */
  60804. highlightedText: string;
  60805. /** Gets or sets if the current key should be added */
  60806. addKey: boolean;
  60807. /** Gets or sets the value of the current key being entered */
  60808. currentKey: string;
  60809. /** Gets or sets the text displayed in the control */
  60810. text: string;
  60811. /** Gets or sets control width */
  60812. width: string | number;
  60813. /**
  60814. * Creates a new InputText
  60815. * @param name defines the control name
  60816. * @param text defines the text of the control
  60817. */
  60818. constructor(name?: string | undefined, text?: string);
  60819. /** @hidden */
  60820. onBlur(): void;
  60821. /** @hidden */
  60822. onFocus(): void;
  60823. protected _getTypeName(): string;
  60824. /**
  60825. * Function called to get the list of controls that should not steal the focus from this control
  60826. * @returns an array of controls
  60827. */
  60828. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  60829. /** @hidden */
  60830. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  60831. /** @hidden */
  60832. private _updateValueFromCursorIndex;
  60833. /** @hidden */
  60834. private _processDblClick;
  60835. /** @hidden */
  60836. private _selectAllText;
  60837. /**
  60838. * Handles the keyboard event
  60839. * @param evt Defines the KeyboardEvent
  60840. */
  60841. processKeyboard(evt: KeyboardEvent): void;
  60842. /** @hidden */
  60843. private _onCopyText;
  60844. /** @hidden */
  60845. private _onCutText;
  60846. /** @hidden */
  60847. private _onPasteText;
  60848. _draw(context: CanvasRenderingContext2D): void;
  60849. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60850. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  60851. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  60852. protected _beforeRenderText(text: string): string;
  60853. dispose(): void;
  60854. }
  60855. }
  60856. declare module BABYLON.GUI {
  60857. /**
  60858. * Class used to create a 2D grid container
  60859. */
  60860. export class Grid extends Container {
  60861. name?: string | undefined;
  60862. private _rowDefinitions;
  60863. private _columnDefinitions;
  60864. private _cells;
  60865. private _childControls;
  60866. /**
  60867. * Gets the number of columns
  60868. */
  60869. readonly columnCount: number;
  60870. /**
  60871. * Gets the number of rows
  60872. */
  60873. readonly rowCount: number;
  60874. /** Gets the list of children */
  60875. readonly children: Control[];
  60876. /** Gets the list of cells (e.g. the containers) */
  60877. readonly cells: {
  60878. [key: string]: Container;
  60879. };
  60880. /**
  60881. * Gets the definition of a specific row
  60882. * @param index defines the index of the row
  60883. * @returns the row definition
  60884. */
  60885. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  60886. /**
  60887. * Gets the definition of a specific column
  60888. * @param index defines the index of the column
  60889. * @returns the column definition
  60890. */
  60891. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  60892. /**
  60893. * Adds a new row to the grid
  60894. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  60895. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  60896. * @returns the current grid
  60897. */
  60898. addRowDefinition(height: number, isPixel?: boolean): Grid;
  60899. /**
  60900. * Adds a new column to the grid
  60901. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  60902. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  60903. * @returns the current grid
  60904. */
  60905. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  60906. /**
  60907. * Update a row definition
  60908. * @param index defines the index of the row to update
  60909. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  60910. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  60911. * @returns the current grid
  60912. */
  60913. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  60914. /**
  60915. * Update a column definition
  60916. * @param index defines the index of the column to update
  60917. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  60918. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  60919. * @returns the current grid
  60920. */
  60921. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  60922. /**
  60923. * Gets the list of children stored in a specific cell
  60924. * @param row defines the row to check
  60925. * @param column defines the column to check
  60926. * @returns the list of controls
  60927. */
  60928. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  60929. /**
  60930. * Gets a string representing the child cell info (row x column)
  60931. * @param child defines the control to get info from
  60932. * @returns a string containing the child cell info (row x column)
  60933. */
  60934. getChildCellInfo(child: Control): string;
  60935. private _removeCell;
  60936. private _offsetCell;
  60937. /**
  60938. * Remove a column definition at specified index
  60939. * @param index defines the index of the column to remove
  60940. * @returns the current grid
  60941. */
  60942. removeColumnDefinition(index: number): Grid;
  60943. /**
  60944. * Remove a row definition at specified index
  60945. * @param index defines the index of the row to remove
  60946. * @returns the current grid
  60947. */
  60948. removeRowDefinition(index: number): Grid;
  60949. /**
  60950. * Adds a new control to the current grid
  60951. * @param control defines the control to add
  60952. * @param row defines the row where to add the control (0 by default)
  60953. * @param column defines the column where to add the control (0 by default)
  60954. * @returns the current grid
  60955. */
  60956. addControl(control: Control, row?: number, column?: number): Grid;
  60957. /**
  60958. * Removes a control from the current container
  60959. * @param control defines the control to remove
  60960. * @returns the current container
  60961. */
  60962. removeControl(control: Control): Container;
  60963. /**
  60964. * Creates a new Grid
  60965. * @param name defines control name
  60966. */
  60967. constructor(name?: string | undefined);
  60968. protected _getTypeName(): string;
  60969. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  60970. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60971. _flagDescendantsAsMatrixDirty(): void;
  60972. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  60973. /** Releases associated resources */
  60974. dispose(): void;
  60975. }
  60976. }
  60977. declare module BABYLON.GUI {
  60978. /** Class used to create color pickers */
  60979. export class ColorPicker extends Control {
  60980. name?: string | undefined;
  60981. private static _Epsilon;
  60982. private _colorWheelCanvas;
  60983. private _value;
  60984. private _tmpColor;
  60985. private _pointerStartedOnSquare;
  60986. private _pointerStartedOnWheel;
  60987. private _squareLeft;
  60988. private _squareTop;
  60989. private _squareSize;
  60990. private _h;
  60991. private _s;
  60992. private _v;
  60993. private _lastPointerDownID;
  60994. /**
  60995. * BABYLON.Observable raised when the value changes
  60996. */
  60997. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  60998. /** Gets or sets the color of the color picker */
  60999. value: BABYLON.Color3;
  61000. /**
  61001. * Gets or sets control width
  61002. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61003. */
  61004. width: string | number;
  61005. /**
  61006. * Gets or sets control height
  61007. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61008. */
  61009. /** Gets or sets control height */
  61010. height: string | number;
  61011. /** Gets or sets control size */
  61012. size: string | number;
  61013. /**
  61014. * Creates a new ColorPicker
  61015. * @param name defines the control name
  61016. */
  61017. constructor(name?: string | undefined);
  61018. protected _getTypeName(): string;
  61019. /** @hidden */
  61020. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61021. private _updateSquareProps;
  61022. private _drawGradientSquare;
  61023. private _drawCircle;
  61024. private _createColorWheelCanvas;
  61025. /** @hidden */
  61026. _draw(context: CanvasRenderingContext2D): void;
  61027. private _pointerIsDown;
  61028. private _updateValueFromPointer;
  61029. private _isPointOnSquare;
  61030. private _isPointOnWheel;
  61031. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61032. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61033. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61034. /**
  61035. * This function expands the color picker by creating a color picker dialog with manual
  61036. * color value input and the ability to save colors into an array to be used later in
  61037. * subsequent launches of the dialogue.
  61038. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  61039. * @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.
  61040. * @returns picked color as a hex string and the saved colors array as hex strings.
  61041. */
  61042. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  61043. pickerWidth?: string;
  61044. pickerHeight?: string;
  61045. headerHeight?: string;
  61046. lastColor?: string;
  61047. swatchLimit?: number;
  61048. numSwatchesPerLine?: number;
  61049. savedColors?: Array<string>;
  61050. }): Promise<{
  61051. savedColors?: string[];
  61052. pickedColor: string;
  61053. }>;
  61054. }
  61055. }
  61056. declare module BABYLON.GUI {
  61057. /** Class used to create 2D ellipse containers */
  61058. export class Ellipse extends Container {
  61059. name?: string | undefined;
  61060. private _thickness;
  61061. /** Gets or sets border thickness */
  61062. thickness: number;
  61063. /**
  61064. * Creates a new Ellipse
  61065. * @param name defines the control name
  61066. */
  61067. constructor(name?: string | undefined);
  61068. protected _getTypeName(): string;
  61069. protected _localDraw(context: CanvasRenderingContext2D): void;
  61070. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61071. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  61072. }
  61073. }
  61074. declare module BABYLON.GUI {
  61075. /**
  61076. * Class used to create a password control
  61077. */
  61078. export class InputPassword extends InputText {
  61079. protected _beforeRenderText(text: string): string;
  61080. }
  61081. }
  61082. declare module BABYLON.GUI {
  61083. /** Class used to render 2D lines */
  61084. export class Line extends Control {
  61085. name?: string | undefined;
  61086. private _lineWidth;
  61087. private _x1;
  61088. private _y1;
  61089. private _x2;
  61090. private _y2;
  61091. private _dash;
  61092. private _connectedControl;
  61093. private _connectedControlDirtyObserver;
  61094. /** Gets or sets the dash pattern */
  61095. dash: Array<number>;
  61096. /** Gets or sets the control connected with the line end */
  61097. connectedControl: Control;
  61098. /** Gets or sets start coordinates on X axis */
  61099. x1: string | number;
  61100. /** Gets or sets start coordinates on Y axis */
  61101. y1: string | number;
  61102. /** Gets or sets end coordinates on X axis */
  61103. x2: string | number;
  61104. /** Gets or sets end coordinates on Y axis */
  61105. y2: string | number;
  61106. /** Gets or sets line width */
  61107. lineWidth: number;
  61108. /** Gets or sets horizontal alignment */
  61109. horizontalAlignment: number;
  61110. /** Gets or sets vertical alignment */
  61111. verticalAlignment: number;
  61112. private readonly _effectiveX2;
  61113. private readonly _effectiveY2;
  61114. /**
  61115. * Creates a new Line
  61116. * @param name defines the control name
  61117. */
  61118. constructor(name?: string | undefined);
  61119. protected _getTypeName(): string;
  61120. _draw(context: CanvasRenderingContext2D): void;
  61121. _measure(): void;
  61122. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61123. /**
  61124. * Move one end of the line given 3D cartesian coordinates.
  61125. * @param position Targeted world position
  61126. * @param scene BABYLON.Scene
  61127. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  61128. */
  61129. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  61130. /**
  61131. * Move one end of the line to a position in screen absolute space.
  61132. * @param projectedPosition Position in screen absolute space (X, Y)
  61133. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  61134. */
  61135. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  61136. }
  61137. }
  61138. declare module BABYLON.GUI {
  61139. /**
  61140. * Class used to store a point for a MultiLine object.
  61141. * The point can be pure 2D coordinates, a mesh or a control
  61142. */
  61143. export class MultiLinePoint {
  61144. private _multiLine;
  61145. private _x;
  61146. private _y;
  61147. private _control;
  61148. private _mesh;
  61149. private _controlObserver;
  61150. private _meshObserver;
  61151. /** @hidden */
  61152. _point: BABYLON.Vector2;
  61153. /**
  61154. * Creates a new MultiLinePoint
  61155. * @param multiLine defines the source MultiLine object
  61156. */
  61157. constructor(multiLine: MultiLine);
  61158. /** Gets or sets x coordinate */
  61159. x: string | number;
  61160. /** Gets or sets y coordinate */
  61161. y: string | number;
  61162. /** Gets or sets the control associated with this point */
  61163. control: BABYLON.Nullable<Control>;
  61164. /** Gets or sets the mesh associated with this point */
  61165. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  61166. /** Resets links */
  61167. resetLinks(): void;
  61168. /**
  61169. * Gets a translation vector
  61170. * @returns the translation vector
  61171. */
  61172. translate(): BABYLON.Vector2;
  61173. private _translatePoint;
  61174. /** Release associated resources */
  61175. dispose(): void;
  61176. }
  61177. }
  61178. declare module BABYLON.GUI {
  61179. /**
  61180. * Class used to create multi line control
  61181. */
  61182. export class MultiLine extends Control {
  61183. name?: string | undefined;
  61184. private _lineWidth;
  61185. private _dash;
  61186. private _points;
  61187. private _minX;
  61188. private _minY;
  61189. private _maxX;
  61190. private _maxY;
  61191. /**
  61192. * Creates a new MultiLine
  61193. * @param name defines the control name
  61194. */
  61195. constructor(name?: string | undefined);
  61196. /** Gets or sets dash pattern */
  61197. dash: Array<number>;
  61198. /**
  61199. * Gets point stored at specified index
  61200. * @param index defines the index to look for
  61201. * @returns the requested point if found
  61202. */
  61203. getAt(index: number): MultiLinePoint;
  61204. /** Function called when a point is updated */
  61205. onPointUpdate: () => void;
  61206. /**
  61207. * Adds new points to the point collection
  61208. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  61209. * @returns the list of created MultiLinePoint
  61210. */
  61211. add(...items: (AbstractMesh | Control | {
  61212. x: string | number;
  61213. y: string | number;
  61214. })[]): MultiLinePoint[];
  61215. /**
  61216. * Adds a new point to the point collection
  61217. * @param item defines the item (mesh, control or 2d coordiantes) to add
  61218. * @returns the created MultiLinePoint
  61219. */
  61220. push(item?: (AbstractMesh | Control | {
  61221. x: string | number;
  61222. y: string | number;
  61223. })): MultiLinePoint;
  61224. /**
  61225. * Remove a specific value or point from the active point collection
  61226. * @param value defines the value or point to remove
  61227. */
  61228. remove(value: number | MultiLinePoint): void;
  61229. /**
  61230. * Resets this object to initial state (no point)
  61231. */
  61232. reset(): void;
  61233. /**
  61234. * Resets all links
  61235. */
  61236. resetLinks(): void;
  61237. /** Gets or sets line width */
  61238. lineWidth: number;
  61239. horizontalAlignment: number;
  61240. verticalAlignment: number;
  61241. protected _getTypeName(): string;
  61242. _draw(context: CanvasRenderingContext2D): void;
  61243. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61244. _measure(): void;
  61245. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61246. dispose(): void;
  61247. }
  61248. }
  61249. declare module BABYLON.GUI {
  61250. /**
  61251. * Class used to create radio button controls
  61252. */
  61253. export class RadioButton extends Control {
  61254. name?: string | undefined;
  61255. private _isChecked;
  61256. private _background;
  61257. private _checkSizeRatio;
  61258. private _thickness;
  61259. /** Gets or sets border thickness */
  61260. thickness: number;
  61261. /** Gets or sets group name */
  61262. group: string;
  61263. /** BABYLON.Observable raised when isChecked is changed */
  61264. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  61265. /** Gets or sets a value indicating the ratio between overall size and check size */
  61266. checkSizeRatio: number;
  61267. /** Gets or sets background color */
  61268. background: string;
  61269. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  61270. isChecked: boolean;
  61271. /**
  61272. * Creates a new RadioButton
  61273. * @param name defines the control name
  61274. */
  61275. constructor(name?: string | undefined);
  61276. protected _getTypeName(): string;
  61277. _draw(context: CanvasRenderingContext2D): void;
  61278. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61279. /**
  61280. * Utility function to easily create a radio button with a header
  61281. * @param title defines the label to use for the header
  61282. * @param group defines the group to use for the radio button
  61283. * @param isChecked defines the initial state of the radio button
  61284. * @param onValueChanged defines the callback to call when value changes
  61285. * @returns a StackPanel containing the radio button and a textBlock
  61286. */
  61287. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  61288. }
  61289. }
  61290. declare module BABYLON.GUI {
  61291. /**
  61292. * Class used to create slider controls
  61293. */
  61294. export class BaseSlider extends Control {
  61295. name?: string | undefined;
  61296. protected _thumbWidth: ValueAndUnit;
  61297. private _minimum;
  61298. private _maximum;
  61299. private _value;
  61300. private _isVertical;
  61301. protected _barOffset: ValueAndUnit;
  61302. private _isThumbClamped;
  61303. protected _displayThumb: boolean;
  61304. private _step;
  61305. private _lastPointerDownID;
  61306. protected _effectiveBarOffset: number;
  61307. protected _renderLeft: number;
  61308. protected _renderTop: number;
  61309. protected _renderWidth: number;
  61310. protected _renderHeight: number;
  61311. protected _backgroundBoxLength: number;
  61312. protected _backgroundBoxThickness: number;
  61313. protected _effectiveThumbThickness: number;
  61314. /** BABYLON.Observable raised when the sldier value changes */
  61315. onValueChangedObservable: BABYLON.Observable<number>;
  61316. /** Gets or sets a boolean indicating if the thumb must be rendered */
  61317. displayThumb: boolean;
  61318. /** Gets or sets a step to apply to values (0 by default) */
  61319. step: number;
  61320. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  61321. barOffset: string | number;
  61322. /** Gets main bar offset in pixels*/
  61323. readonly barOffsetInPixels: number;
  61324. /** Gets or sets thumb width */
  61325. thumbWidth: string | number;
  61326. /** Gets thumb width in pixels */
  61327. readonly thumbWidthInPixels: number;
  61328. /** Gets or sets minimum value */
  61329. minimum: number;
  61330. /** Gets or sets maximum value */
  61331. maximum: number;
  61332. /** Gets or sets current value */
  61333. value: number;
  61334. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  61335. isVertical: boolean;
  61336. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  61337. isThumbClamped: boolean;
  61338. /**
  61339. * Creates a new BaseSlider
  61340. * @param name defines the control name
  61341. */
  61342. constructor(name?: string | undefined);
  61343. protected _getTypeName(): string;
  61344. protected _getThumbPosition(): number;
  61345. protected _getThumbThickness(type: string): number;
  61346. protected _prepareRenderingData(type: string): void;
  61347. private _pointerIsDown;
  61348. /** @hidden */
  61349. protected _updateValueFromPointer(x: number, y: number): void;
  61350. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61351. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61352. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61353. }
  61354. }
  61355. declare module BABYLON.GUI {
  61356. /**
  61357. * Class used to create slider controls
  61358. */
  61359. export class Slider extends BaseSlider {
  61360. name?: string | undefined;
  61361. private _background;
  61362. private _borderColor;
  61363. private _isThumbCircle;
  61364. protected _displayValueBar: boolean;
  61365. /** Gets or sets a boolean indicating if the value bar must be rendered */
  61366. displayValueBar: boolean;
  61367. /** Gets or sets border color */
  61368. borderColor: string;
  61369. /** Gets or sets background color */
  61370. background: string;
  61371. /** Gets or sets a boolean indicating if the thumb should be round or square */
  61372. isThumbCircle: boolean;
  61373. /**
  61374. * Creates a new Slider
  61375. * @param name defines the control name
  61376. */
  61377. constructor(name?: string | undefined);
  61378. protected _getTypeName(): string;
  61379. _draw(context: CanvasRenderingContext2D): void;
  61380. }
  61381. }
  61382. declare module BABYLON.GUI {
  61383. /** Class used to create a RadioGroup
  61384. * which contains groups of radio buttons
  61385. */
  61386. export class SelectorGroup {
  61387. /** name of SelectorGroup */
  61388. name: string;
  61389. private _groupPanel;
  61390. private _selectors;
  61391. private _groupHeader;
  61392. /**
  61393. * Creates a new SelectorGroup
  61394. * @param name of group, used as a group heading
  61395. */
  61396. constructor(
  61397. /** name of SelectorGroup */
  61398. name: string);
  61399. /** Gets the groupPanel of the SelectorGroup */
  61400. readonly groupPanel: StackPanel;
  61401. /** Gets the selectors array */
  61402. readonly selectors: StackPanel[];
  61403. /** Gets and sets the group header */
  61404. header: string;
  61405. /** @hidden */
  61406. private _addGroupHeader;
  61407. /** @hidden*/
  61408. _getSelector(selectorNb: number): StackPanel | undefined;
  61409. /** Removes the selector at the given position
  61410. * @param selectorNb the position of the selector within the group
  61411. */
  61412. removeSelector(selectorNb: number): void;
  61413. }
  61414. /** Class used to create a CheckboxGroup
  61415. * which contains groups of checkbox buttons
  61416. */
  61417. export class CheckboxGroup extends SelectorGroup {
  61418. /** Adds a checkbox as a control
  61419. * @param text is the label for the selector
  61420. * @param func is the function called when the Selector is checked
  61421. * @param checked is true when Selector is checked
  61422. */
  61423. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  61424. /** @hidden */
  61425. _setSelectorLabel(selectorNb: number, label: string): void;
  61426. /** @hidden */
  61427. _setSelectorLabelColor(selectorNb: number, color: string): void;
  61428. /** @hidden */
  61429. _setSelectorButtonColor(selectorNb: number, color: string): void;
  61430. /** @hidden */
  61431. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  61432. }
  61433. /** Class used to create a RadioGroup
  61434. * which contains groups of radio buttons
  61435. */
  61436. export class RadioGroup extends SelectorGroup {
  61437. private _selectNb;
  61438. /** Adds a radio button as a control
  61439. * @param label is the label for the selector
  61440. * @param func is the function called when the Selector is checked
  61441. * @param checked is true when Selector is checked
  61442. */
  61443. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  61444. /** @hidden */
  61445. _setSelectorLabel(selectorNb: number, label: string): void;
  61446. /** @hidden */
  61447. _setSelectorLabelColor(selectorNb: number, color: string): void;
  61448. /** @hidden */
  61449. _setSelectorButtonColor(selectorNb: number, color: string): void;
  61450. /** @hidden */
  61451. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  61452. }
  61453. /** Class used to create a SliderGroup
  61454. * which contains groups of slider buttons
  61455. */
  61456. export class SliderGroup extends SelectorGroup {
  61457. /**
  61458. * Adds a slider to the SelectorGroup
  61459. * @param label is the label for the SliderBar
  61460. * @param func is the function called when the Slider moves
  61461. * @param unit is a string describing the units used, eg degrees or metres
  61462. * @param min is the minimum value for the Slider
  61463. * @param max is the maximum value for the Slider
  61464. * @param value is the start value for the Slider between min and max
  61465. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  61466. */
  61467. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  61468. /** @hidden */
  61469. _setSelectorLabel(selectorNb: number, label: string): void;
  61470. /** @hidden */
  61471. _setSelectorLabelColor(selectorNb: number, color: string): void;
  61472. /** @hidden */
  61473. _setSelectorButtonColor(selectorNb: number, color: string): void;
  61474. /** @hidden */
  61475. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  61476. }
  61477. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  61478. * @see http://doc.babylonjs.com/how_to/selector
  61479. */
  61480. export class SelectionPanel extends Rectangle {
  61481. /** name of SelectionPanel */
  61482. name: string;
  61483. /** an array of SelectionGroups */
  61484. groups: SelectorGroup[];
  61485. private _panel;
  61486. private _buttonColor;
  61487. private _buttonBackground;
  61488. private _headerColor;
  61489. private _barColor;
  61490. private _barHeight;
  61491. private _spacerHeight;
  61492. private _labelColor;
  61493. private _groups;
  61494. private _bars;
  61495. /**
  61496. * Creates a new SelectionPanel
  61497. * @param name of SelectionPanel
  61498. * @param groups is an array of SelectionGroups
  61499. */
  61500. constructor(
  61501. /** name of SelectionPanel */
  61502. name: string,
  61503. /** an array of SelectionGroups */
  61504. groups?: SelectorGroup[]);
  61505. protected _getTypeName(): string;
  61506. /** Gets or sets the headerColor */
  61507. headerColor: string;
  61508. private _setHeaderColor;
  61509. /** Gets or sets the button color */
  61510. buttonColor: string;
  61511. private _setbuttonColor;
  61512. /** Gets or sets the label color */
  61513. labelColor: string;
  61514. private _setLabelColor;
  61515. /** Gets or sets the button background */
  61516. buttonBackground: string;
  61517. private _setButtonBackground;
  61518. /** Gets or sets the color of separator bar */
  61519. barColor: string;
  61520. private _setBarColor;
  61521. /** Gets or sets the height of separator bar */
  61522. barHeight: string;
  61523. private _setBarHeight;
  61524. /** Gets or sets the height of spacers*/
  61525. spacerHeight: string;
  61526. private _setSpacerHeight;
  61527. /** Adds a bar between groups */
  61528. private _addSpacer;
  61529. /** Add a group to the selection panel
  61530. * @param group is the selector group to add
  61531. */
  61532. addGroup(group: SelectorGroup): void;
  61533. /** Remove the group from the given position
  61534. * @param groupNb is the position of the group in the list
  61535. */
  61536. removeGroup(groupNb: number): void;
  61537. /** Change a group header label
  61538. * @param label is the new group header label
  61539. * @param groupNb is the number of the group to relabel
  61540. * */
  61541. setHeaderName(label: string, groupNb: number): void;
  61542. /** Change selector label to the one given
  61543. * @param label is the new selector label
  61544. * @param groupNb is the number of the groupcontaining the selector
  61545. * @param selectorNb is the number of the selector within a group to relabel
  61546. * */
  61547. relabel(label: string, groupNb: number, selectorNb: number): void;
  61548. /** For a given group position remove the selector at the given position
  61549. * @param groupNb is the number of the group to remove the selector from
  61550. * @param selectorNb is the number of the selector within the group
  61551. */
  61552. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  61553. /** For a given group position of correct type add a checkbox button
  61554. * @param groupNb is the number of the group to remove the selector from
  61555. * @param label is the label for the selector
  61556. * @param func is the function called when the Selector is checked
  61557. * @param checked is true when Selector is checked
  61558. */
  61559. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  61560. /** For a given group position of correct type add a radio button
  61561. * @param groupNb is the number of the group to remove the selector from
  61562. * @param label is the label for the selector
  61563. * @param func is the function called when the Selector is checked
  61564. * @param checked is true when Selector is checked
  61565. */
  61566. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  61567. /**
  61568. * For a given slider group add a slider
  61569. * @param groupNb is the number of the group to add the slider to
  61570. * @param label is the label for the Slider
  61571. * @param func is the function called when the Slider moves
  61572. * @param unit is a string describing the units used, eg degrees or metres
  61573. * @param min is the minimum value for the Slider
  61574. * @param max is the maximum value for the Slider
  61575. * @param value is the start value for the Slider between min and max
  61576. * @param onVal is the function used to format the value displayed, eg radians to degrees
  61577. */
  61578. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  61579. }
  61580. }
  61581. declare module BABYLON.GUI {
  61582. /**
  61583. * Class used to hold a the container for ScrollViewer
  61584. * @hidden
  61585. */
  61586. export class _ScrollViewerWindow extends Container {
  61587. parentClientWidth: number;
  61588. parentClientHeight: number;
  61589. /**
  61590. * Creates a new ScrollViewerWindow
  61591. * @param name of ScrollViewerWindow
  61592. */
  61593. constructor(name?: string);
  61594. protected _getTypeName(): string;
  61595. /** @hidden */
  61596. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61597. protected _postMeasure(): void;
  61598. }
  61599. }
  61600. declare module BABYLON.GUI {
  61601. /**
  61602. * Class used to create slider controls
  61603. */
  61604. export class ScrollBar extends BaseSlider {
  61605. name?: string | undefined;
  61606. private _background;
  61607. private _borderColor;
  61608. private _thumbMeasure;
  61609. /** Gets or sets border color */
  61610. borderColor: string;
  61611. /** Gets or sets background color */
  61612. background: string;
  61613. /**
  61614. * Creates a new Slider
  61615. * @param name defines the control name
  61616. */
  61617. constructor(name?: string | undefined);
  61618. protected _getTypeName(): string;
  61619. protected _getThumbThickness(): number;
  61620. _draw(context: CanvasRenderingContext2D): void;
  61621. private _first;
  61622. private _originX;
  61623. private _originY;
  61624. /** @hidden */
  61625. protected _updateValueFromPointer(x: number, y: number): void;
  61626. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61627. }
  61628. }
  61629. declare module BABYLON.GUI {
  61630. /**
  61631. * Class used to hold a viewer window and sliders in a grid
  61632. */
  61633. export class ScrollViewer extends Rectangle {
  61634. private _grid;
  61635. private _horizontalBarSpace;
  61636. private _verticalBarSpace;
  61637. private _dragSpace;
  61638. private _horizontalBar;
  61639. private _verticalBar;
  61640. private _barColor;
  61641. private _barBackground;
  61642. private _barSize;
  61643. private _endLeft;
  61644. private _endTop;
  61645. private _window;
  61646. private _pointerIsOver;
  61647. private _wheelPrecision;
  61648. private _onPointerObserver;
  61649. private _clientWidth;
  61650. private _clientHeight;
  61651. /**
  61652. * Gets the horizontal scrollbar
  61653. */
  61654. readonly horizontalBar: ScrollBar;
  61655. /**
  61656. * Gets the vertical scrollbar
  61657. */
  61658. readonly verticalBar: ScrollBar;
  61659. /**
  61660. * Adds a new control to the current container
  61661. * @param control defines the control to add
  61662. * @returns the current container
  61663. */
  61664. addControl(control: BABYLON.Nullable<Control>): Container;
  61665. /**
  61666. * Removes a control from the current container
  61667. * @param control defines the control to remove
  61668. * @returns the current container
  61669. */
  61670. removeControl(control: Control): Container;
  61671. /** Gets the list of children */
  61672. readonly children: Control[];
  61673. _flagDescendantsAsMatrixDirty(): void;
  61674. /**
  61675. * Creates a new ScrollViewer
  61676. * @param name of ScrollViewer
  61677. */
  61678. constructor(name?: string);
  61679. /** Reset the scroll viewer window to initial size */
  61680. resetWindow(): void;
  61681. protected _getTypeName(): string;
  61682. private _buildClientSizes;
  61683. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61684. protected _postMeasure(): void;
  61685. /**
  61686. * Gets or sets the mouse wheel precision
  61687. * from 0 to 1 with a default value of 0.05
  61688. * */
  61689. wheelPrecision: number;
  61690. /** Gets or sets the bar color */
  61691. barColor: string;
  61692. /** Gets or sets the size of the bar */
  61693. barSize: number;
  61694. /** Gets or sets the bar background */
  61695. barBackground: string;
  61696. /** @hidden */
  61697. private _updateScroller;
  61698. _link(host: AdvancedDynamicTexture): void;
  61699. /** @hidden */
  61700. private _attachWheel;
  61701. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  61702. /** Releases associated resources */
  61703. dispose(): void;
  61704. }
  61705. }
  61706. declare module BABYLON.GUI {
  61707. /** Class used to render a grid */
  61708. export class DisplayGrid extends Control {
  61709. name?: string | undefined;
  61710. private _cellWidth;
  61711. private _cellHeight;
  61712. private _minorLineTickness;
  61713. private _minorLineColor;
  61714. private _majorLineTickness;
  61715. private _majorLineColor;
  61716. private _majorLineFrequency;
  61717. private _background;
  61718. private _displayMajorLines;
  61719. private _displayMinorLines;
  61720. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  61721. displayMinorLines: boolean;
  61722. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  61723. displayMajorLines: boolean;
  61724. /** Gets or sets background color (Black by default) */
  61725. background: string;
  61726. /** Gets or sets the width of each cell (20 by default) */
  61727. cellWidth: number;
  61728. /** Gets or sets the height of each cell (20 by default) */
  61729. cellHeight: number;
  61730. /** Gets or sets the tickness of minor lines (1 by default) */
  61731. minorLineTickness: number;
  61732. /** Gets or sets the color of minor lines (DarkGray by default) */
  61733. minorLineColor: string;
  61734. /** Gets or sets the tickness of major lines (2 by default) */
  61735. majorLineTickness: number;
  61736. /** Gets or sets the color of major lines (White by default) */
  61737. majorLineColor: string;
  61738. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  61739. majorLineFrequency: number;
  61740. /**
  61741. * Creates a new GridDisplayRectangle
  61742. * @param name defines the control name
  61743. */
  61744. constructor(name?: string | undefined);
  61745. _draw(context: CanvasRenderingContext2D): void;
  61746. protected _getTypeName(): string;
  61747. }
  61748. }
  61749. declare module BABYLON.GUI {
  61750. /**
  61751. * Class used to create slider controls based on images
  61752. */
  61753. export class ImageBasedSlider extends BaseSlider {
  61754. name?: string | undefined;
  61755. private _backgroundImage;
  61756. private _thumbImage;
  61757. private _valueBarImage;
  61758. private _tempMeasure;
  61759. displayThumb: boolean;
  61760. /**
  61761. * Gets or sets the image used to render the background
  61762. */
  61763. backgroundImage: Image;
  61764. /**
  61765. * Gets or sets the image used to render the value bar
  61766. */
  61767. valueBarImage: Image;
  61768. /**
  61769. * Gets or sets the image used to render the thumb
  61770. */
  61771. thumbImage: Image;
  61772. /**
  61773. * Creates a new ImageBasedSlider
  61774. * @param name defines the control name
  61775. */
  61776. constructor(name?: string | undefined);
  61777. protected _getTypeName(): string;
  61778. _draw(context: CanvasRenderingContext2D): void;
  61779. }
  61780. }
  61781. declare module BABYLON.GUI {
  61782. /**
  61783. * Forcing an export so that this code will execute
  61784. * @hidden
  61785. */
  61786. const name = "Statics";
  61787. }
  61788. declare module BABYLON.GUI {
  61789. /**
  61790. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  61791. */
  61792. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  61793. /**
  61794. * Define the instrumented AdvancedDynamicTexture.
  61795. */
  61796. texture: AdvancedDynamicTexture;
  61797. private _captureRenderTime;
  61798. private _renderTime;
  61799. private _captureLayoutTime;
  61800. private _layoutTime;
  61801. private _onBeginRenderObserver;
  61802. private _onEndRenderObserver;
  61803. private _onBeginLayoutObserver;
  61804. private _onEndLayoutObserver;
  61805. /**
  61806. * Gets the perf counter used to capture render time
  61807. */
  61808. readonly renderTimeCounter: BABYLON.PerfCounter;
  61809. /**
  61810. * Gets the perf counter used to capture layout time
  61811. */
  61812. readonly layoutTimeCounter: BABYLON.PerfCounter;
  61813. /**
  61814. * Enable or disable the render time capture
  61815. */
  61816. captureRenderTime: boolean;
  61817. /**
  61818. * Enable or disable the layout time capture
  61819. */
  61820. captureLayoutTime: boolean;
  61821. /**
  61822. * Instantiates a new advanced dynamic texture instrumentation.
  61823. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  61824. * @param texture Defines the AdvancedDynamicTexture to instrument
  61825. */
  61826. constructor(
  61827. /**
  61828. * Define the instrumented AdvancedDynamicTexture.
  61829. */
  61830. texture: AdvancedDynamicTexture);
  61831. /**
  61832. * Dispose and release associated resources.
  61833. */
  61834. dispose(): void;
  61835. }
  61836. }
  61837. declare module BABYLON.GUI {
  61838. /**
  61839. * Class used to create containers for controls
  61840. */
  61841. export class Container3D extends Control3D {
  61842. private _blockLayout;
  61843. /**
  61844. * Gets the list of child controls
  61845. */
  61846. protected _children: Control3D[];
  61847. /**
  61848. * Gets the list of child controls
  61849. */
  61850. readonly children: Array<Control3D>;
  61851. /**
  61852. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  61853. * This is helpful to optimize layout operation when adding multiple children in a row
  61854. */
  61855. blockLayout: boolean;
  61856. /**
  61857. * Creates a new container
  61858. * @param name defines the container name
  61859. */
  61860. constructor(name?: string);
  61861. /**
  61862. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  61863. * @returns the current container
  61864. */
  61865. updateLayout(): Container3D;
  61866. /**
  61867. * Gets a boolean indicating if the given control is in the children of this control
  61868. * @param control defines the control to check
  61869. * @returns true if the control is in the child list
  61870. */
  61871. containsControl(control: Control3D): boolean;
  61872. /**
  61873. * Adds a control to the children of this control
  61874. * @param control defines the control to add
  61875. * @returns the current container
  61876. */
  61877. addControl(control: Control3D): Container3D;
  61878. /**
  61879. * This function will be called everytime a new control is added
  61880. */
  61881. protected _arrangeChildren(): void;
  61882. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  61883. /**
  61884. * Removes a control from the children of this control
  61885. * @param control defines the control to remove
  61886. * @returns the current container
  61887. */
  61888. removeControl(control: Control3D): Container3D;
  61889. protected _getTypeName(): string;
  61890. /**
  61891. * Releases all associated resources
  61892. */
  61893. dispose(): void;
  61894. /** Control rotation will remain unchanged */
  61895. static readonly UNSET_ORIENTATION: number;
  61896. /** Control will rotate to make it look at sphere central axis */
  61897. static readonly FACEORIGIN_ORIENTATION: number;
  61898. /** Control will rotate to make it look back at sphere central axis */
  61899. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  61900. /** Control will rotate to look at z axis (0, 0, 1) */
  61901. static readonly FACEFORWARD_ORIENTATION: number;
  61902. /** Control will rotate to look at negative z axis (0, 0, -1) */
  61903. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  61904. }
  61905. }
  61906. declare module BABYLON.GUI {
  61907. /**
  61908. * Class used to manage 3D user interface
  61909. * @see http://doc.babylonjs.com/how_to/gui3d
  61910. */
  61911. export class GUI3DManager implements BABYLON.IDisposable {
  61912. private _scene;
  61913. private _sceneDisposeObserver;
  61914. private _utilityLayer;
  61915. private _rootContainer;
  61916. private _pointerObserver;
  61917. private _pointerOutObserver;
  61918. /** @hidden */
  61919. _lastPickedControl: Control3D;
  61920. /** @hidden */
  61921. _lastControlOver: {
  61922. [pointerId: number]: Control3D;
  61923. };
  61924. /** @hidden */
  61925. _lastControlDown: {
  61926. [pointerId: number]: Control3D;
  61927. };
  61928. /**
  61929. * BABYLON.Observable raised when the point picked by the pointer events changed
  61930. */
  61931. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  61932. /** @hidden */
  61933. _sharedMaterials: {
  61934. [key: string]: BABYLON.Material;
  61935. };
  61936. /** Gets the hosting scene */
  61937. readonly scene: BABYLON.Scene;
  61938. /** Gets associated utility layer */
  61939. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  61940. /**
  61941. * Creates a new GUI3DManager
  61942. * @param scene
  61943. */
  61944. constructor(scene?: BABYLON.Scene);
  61945. private _handlePointerOut;
  61946. private _doPicking;
  61947. /**
  61948. * Gets the root container
  61949. */
  61950. readonly rootContainer: Container3D;
  61951. /**
  61952. * Gets a boolean indicating if the given control is in the root child list
  61953. * @param control defines the control to check
  61954. * @returns true if the control is in the root child list
  61955. */
  61956. containsControl(control: Control3D): boolean;
  61957. /**
  61958. * Adds a control to the root child list
  61959. * @param control defines the control to add
  61960. * @returns the current manager
  61961. */
  61962. addControl(control: Control3D): GUI3DManager;
  61963. /**
  61964. * Removes a control from the root child list
  61965. * @param control defines the control to remove
  61966. * @returns the current container
  61967. */
  61968. removeControl(control: Control3D): GUI3DManager;
  61969. /**
  61970. * Releases all associated resources
  61971. */
  61972. dispose(): void;
  61973. }
  61974. }
  61975. declare module BABYLON.GUI {
  61976. /**
  61977. * Class used to transport BABYLON.Vector3 information for pointer events
  61978. */
  61979. export class Vector3WithInfo extends BABYLON.Vector3 {
  61980. /** defines the current mouse button index */
  61981. buttonIndex: number;
  61982. /**
  61983. * Creates a new Vector3WithInfo
  61984. * @param source defines the vector3 data to transport
  61985. * @param buttonIndex defines the current mouse button index
  61986. */
  61987. constructor(source: BABYLON.Vector3,
  61988. /** defines the current mouse button index */
  61989. buttonIndex?: number);
  61990. }
  61991. }
  61992. declare module BABYLON.GUI {
  61993. /**
  61994. * Class used as base class for controls
  61995. */
  61996. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  61997. /** Defines the control name */
  61998. name?: string | undefined;
  61999. /** @hidden */
  62000. _host: GUI3DManager;
  62001. private _node;
  62002. private _downCount;
  62003. private _enterCount;
  62004. private _downPointerIds;
  62005. private _isVisible;
  62006. /** Gets or sets the control position in world space */
  62007. position: BABYLON.Vector3;
  62008. /** Gets or sets the control scaling in world space */
  62009. scaling: BABYLON.Vector3;
  62010. /** Callback used to start pointer enter animation */
  62011. pointerEnterAnimation: () => void;
  62012. /** Callback used to start pointer out animation */
  62013. pointerOutAnimation: () => void;
  62014. /** Callback used to start pointer down animation */
  62015. pointerDownAnimation: () => void;
  62016. /** Callback used to start pointer up animation */
  62017. pointerUpAnimation: () => void;
  62018. /**
  62019. * An event triggered when the pointer move over the control
  62020. */
  62021. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  62022. /**
  62023. * An event triggered when the pointer move out of the control
  62024. */
  62025. onPointerOutObservable: BABYLON.Observable<Control3D>;
  62026. /**
  62027. * An event triggered when the pointer taps the control
  62028. */
  62029. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  62030. /**
  62031. * An event triggered when pointer is up
  62032. */
  62033. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  62034. /**
  62035. * An event triggered when a control is clicked on (with a mouse)
  62036. */
  62037. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  62038. /**
  62039. * An event triggered when pointer enters the control
  62040. */
  62041. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  62042. /**
  62043. * Gets or sets the parent container
  62044. */
  62045. parent: BABYLON.Nullable<Container3D>;
  62046. private _behaviors;
  62047. /**
  62048. * Gets the list of attached behaviors
  62049. * @see http://doc.babylonjs.com/features/behaviour
  62050. */
  62051. readonly behaviors: BABYLON.Behavior<Control3D>[];
  62052. /**
  62053. * Attach a behavior to the control
  62054. * @see http://doc.babylonjs.com/features/behaviour
  62055. * @param behavior defines the behavior to attach
  62056. * @returns the current control
  62057. */
  62058. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  62059. /**
  62060. * Remove an attached behavior
  62061. * @see http://doc.babylonjs.com/features/behaviour
  62062. * @param behavior defines the behavior to attach
  62063. * @returns the current control
  62064. */
  62065. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  62066. /**
  62067. * Gets an attached behavior by name
  62068. * @param name defines the name of the behavior to look for
  62069. * @see http://doc.babylonjs.com/features/behaviour
  62070. * @returns null if behavior was not found else the requested behavior
  62071. */
  62072. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  62073. /** Gets or sets a boolean indicating if the control is visible */
  62074. isVisible: boolean;
  62075. /**
  62076. * Creates a new control
  62077. * @param name defines the control name
  62078. */
  62079. constructor(
  62080. /** Defines the control name */
  62081. name?: string | undefined);
  62082. /**
  62083. * Gets a string representing the class name
  62084. */
  62085. readonly typeName: string;
  62086. /**
  62087. * Get the current class name of the control.
  62088. * @returns current class name
  62089. */
  62090. getClassName(): string;
  62091. protected _getTypeName(): string;
  62092. /**
  62093. * Gets the transform node used by this control
  62094. */
  62095. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  62096. /**
  62097. * Gets the mesh used to render this control
  62098. */
  62099. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62100. /**
  62101. * Link the control as child of the given node
  62102. * @param node defines the node to link to. Use null to unlink the control
  62103. * @returns the current control
  62104. */
  62105. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  62106. /** @hidden **/
  62107. _prepareNode(scene: BABYLON.Scene): void;
  62108. /**
  62109. * Node creation.
  62110. * Can be overriden by children
  62111. * @param scene defines the scene where the node must be attached
  62112. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  62113. */
  62114. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  62115. /**
  62116. * Affect a material to the given mesh
  62117. * @param mesh defines the mesh which will represent the control
  62118. */
  62119. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  62120. /** @hidden */
  62121. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  62122. /** @hidden */
  62123. _onPointerEnter(target: Control3D): boolean;
  62124. /** @hidden */
  62125. _onPointerOut(target: Control3D): void;
  62126. /** @hidden */
  62127. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  62128. /** @hidden */
  62129. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62130. /** @hidden */
  62131. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  62132. /** @hidden */
  62133. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  62134. /** @hidden */
  62135. _disposeNode(): void;
  62136. /**
  62137. * Releases all associated resources
  62138. */
  62139. dispose(): void;
  62140. }
  62141. }
  62142. declare module BABYLON.GUI {
  62143. /**
  62144. * Class used as a root to all buttons
  62145. */
  62146. export class AbstractButton3D extends Control3D {
  62147. /**
  62148. * Creates a new button
  62149. * @param name defines the control name
  62150. */
  62151. constructor(name?: string);
  62152. protected _getTypeName(): string;
  62153. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62154. }
  62155. }
  62156. declare module BABYLON.GUI {
  62157. /**
  62158. * Class used to create a button in 3D
  62159. */
  62160. export class Button3D extends AbstractButton3D {
  62161. /** @hidden */
  62162. protected _currentMaterial: BABYLON.Material;
  62163. private _facadeTexture;
  62164. private _content;
  62165. private _contentResolution;
  62166. private _contentScaleRatio;
  62167. /**
  62168. * Gets or sets the texture resolution used to render content (512 by default)
  62169. */
  62170. contentResolution: BABYLON.int;
  62171. /**
  62172. * Gets or sets the texture scale ratio used to render content (2 by default)
  62173. */
  62174. contentScaleRatio: number;
  62175. protected _disposeFacadeTexture(): void;
  62176. protected _resetContent(): void;
  62177. /**
  62178. * Creates a new button
  62179. * @param name defines the control name
  62180. */
  62181. constructor(name?: string);
  62182. /**
  62183. * Gets or sets the GUI 2D content used to display the button's facade
  62184. */
  62185. content: Control;
  62186. /**
  62187. * Apply the facade texture (created from the content property).
  62188. * This function can be overloaded by child classes
  62189. * @param facadeTexture defines the AdvancedDynamicTexture to use
  62190. */
  62191. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  62192. protected _getTypeName(): string;
  62193. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62194. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  62195. /**
  62196. * Releases all associated resources
  62197. */
  62198. dispose(): void;
  62199. }
  62200. }
  62201. declare module BABYLON.GUI {
  62202. /**
  62203. * Abstract class used to create a container panel deployed on the surface of a volume
  62204. */
  62205. export abstract class VolumeBasedPanel extends Container3D {
  62206. private _columns;
  62207. private _rows;
  62208. private _rowThenColum;
  62209. private _orientation;
  62210. protected _cellWidth: number;
  62211. protected _cellHeight: number;
  62212. /**
  62213. * Gets or sets the distance between elements
  62214. */
  62215. margin: number;
  62216. /**
  62217. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  62218. * | Value | Type | Description |
  62219. * | ----- | ----------------------------------- | ----------- |
  62220. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  62221. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  62222. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  62223. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  62224. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  62225. */
  62226. orientation: number;
  62227. /**
  62228. * Gets or sets the number of columns requested (10 by default).
  62229. * The panel will automatically compute the number of rows based on number of child controls.
  62230. */
  62231. columns: BABYLON.int;
  62232. /**
  62233. * Gets or sets a the number of rows requested.
  62234. * The panel will automatically compute the number of columns based on number of child controls.
  62235. */
  62236. rows: BABYLON.int;
  62237. /**
  62238. * Creates new VolumeBasedPanel
  62239. */
  62240. constructor();
  62241. protected _arrangeChildren(): void;
  62242. /** Child classes must implement this function to provide correct control positioning */
  62243. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62244. /** Child classes can implement this function to provide additional processing */
  62245. protected _finalProcessing(): void;
  62246. }
  62247. }
  62248. declare module BABYLON.GUI {
  62249. /**
  62250. * Class used to create a container panel deployed on the surface of a cylinder
  62251. */
  62252. export class CylinderPanel extends VolumeBasedPanel {
  62253. private _radius;
  62254. /**
  62255. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  62256. */
  62257. radius: BABYLON.float;
  62258. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62259. private _cylindricalMapping;
  62260. }
  62261. }
  62262. declare module BABYLON.GUI {
  62263. /** @hidden */
  62264. export var fluentVertexShader: {
  62265. name: string;
  62266. shader: string;
  62267. };
  62268. }
  62269. declare module BABYLON.GUI {
  62270. /** @hidden */
  62271. export var fluentPixelShader: {
  62272. name: string;
  62273. shader: string;
  62274. };
  62275. }
  62276. declare module BABYLON.GUI {
  62277. /** @hidden */
  62278. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  62279. INNERGLOW: boolean;
  62280. BORDER: boolean;
  62281. HOVERLIGHT: boolean;
  62282. TEXTURE: boolean;
  62283. constructor();
  62284. }
  62285. /**
  62286. * Class used to render controls with fluent desgin
  62287. */
  62288. export class FluentMaterial extends BABYLON.PushMaterial {
  62289. /**
  62290. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  62291. */
  62292. innerGlowColorIntensity: number;
  62293. /**
  62294. * Gets or sets the inner glow color (white by default)
  62295. */
  62296. innerGlowColor: BABYLON.Color3;
  62297. /**
  62298. * Gets or sets alpha value (default is 1.0)
  62299. */
  62300. alpha: number;
  62301. /**
  62302. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  62303. */
  62304. albedoColor: BABYLON.Color3;
  62305. /**
  62306. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  62307. */
  62308. renderBorders: boolean;
  62309. /**
  62310. * Gets or sets border width (default is 0.5)
  62311. */
  62312. borderWidth: number;
  62313. /**
  62314. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  62315. */
  62316. edgeSmoothingValue: number;
  62317. /**
  62318. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  62319. */
  62320. borderMinValue: number;
  62321. /**
  62322. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  62323. */
  62324. renderHoverLight: boolean;
  62325. /**
  62326. * Gets or sets the radius used to render the hover light (default is 1.0)
  62327. */
  62328. hoverRadius: number;
  62329. /**
  62330. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  62331. */
  62332. hoverColor: BABYLON.Color4;
  62333. /**
  62334. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  62335. */
  62336. hoverPosition: BABYLON.Vector3;
  62337. private _albedoTexture;
  62338. /** Gets or sets the texture to use for albedo color */
  62339. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  62340. /**
  62341. * Creates a new Fluent material
  62342. * @param name defines the name of the material
  62343. * @param scene defines the hosting scene
  62344. */
  62345. constructor(name: string, scene: BABYLON.Scene);
  62346. needAlphaBlending(): boolean;
  62347. needAlphaTesting(): boolean;
  62348. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  62349. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  62350. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  62351. getActiveTextures(): BABYLON.BaseTexture[];
  62352. hasTexture(texture: BABYLON.BaseTexture): boolean;
  62353. dispose(forceDisposeEffect?: boolean): void;
  62354. clone(name: string): FluentMaterial;
  62355. serialize(): any;
  62356. getClassName(): string;
  62357. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  62358. }
  62359. }
  62360. declare module BABYLON.GUI {
  62361. /**
  62362. * Class used to create a holographic button in 3D
  62363. */
  62364. export class HolographicButton extends Button3D {
  62365. private _backPlate;
  62366. private _textPlate;
  62367. private _frontPlate;
  62368. private _text;
  62369. private _imageUrl;
  62370. private _shareMaterials;
  62371. private _frontMaterial;
  62372. private _backMaterial;
  62373. private _plateMaterial;
  62374. private _pickedPointObserver;
  62375. private _tooltipFade;
  62376. private _tooltipTextBlock;
  62377. private _tooltipTexture;
  62378. private _tooltipMesh;
  62379. private _tooltipHoverObserver;
  62380. private _tooltipOutObserver;
  62381. private _disposeTooltip;
  62382. /**
  62383. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  62384. */
  62385. tooltipText: BABYLON.Nullable<string>;
  62386. /**
  62387. * Gets or sets text for the button
  62388. */
  62389. text: string;
  62390. /**
  62391. * Gets or sets the image url for the button
  62392. */
  62393. imageUrl: string;
  62394. /**
  62395. * Gets the back material used by this button
  62396. */
  62397. readonly backMaterial: FluentMaterial;
  62398. /**
  62399. * Gets the front material used by this button
  62400. */
  62401. readonly frontMaterial: FluentMaterial;
  62402. /**
  62403. * Gets the plate material used by this button
  62404. */
  62405. readonly plateMaterial: BABYLON.StandardMaterial;
  62406. /**
  62407. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  62408. */
  62409. readonly shareMaterials: boolean;
  62410. /**
  62411. * Creates a new button
  62412. * @param name defines the control name
  62413. */
  62414. constructor(name?: string, shareMaterials?: boolean);
  62415. protected _getTypeName(): string;
  62416. private _rebuildContent;
  62417. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62418. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  62419. private _createBackMaterial;
  62420. private _createFrontMaterial;
  62421. private _createPlateMaterial;
  62422. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  62423. /**
  62424. * Releases all associated resources
  62425. */
  62426. dispose(): void;
  62427. }
  62428. }
  62429. declare module BABYLON.GUI {
  62430. /**
  62431. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  62432. */
  62433. export class MeshButton3D extends Button3D {
  62434. /** @hidden */
  62435. protected _currentMesh: BABYLON.Mesh;
  62436. /**
  62437. * Creates a new 3D button based on a mesh
  62438. * @param mesh mesh to become a 3D button
  62439. * @param name defines the control name
  62440. */
  62441. constructor(mesh: BABYLON.Mesh, name?: string);
  62442. protected _getTypeName(): string;
  62443. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62444. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  62445. }
  62446. }
  62447. declare module BABYLON.GUI {
  62448. /**
  62449. * Class used to create a container panel deployed on the surface of a plane
  62450. */
  62451. export class PlanePanel extends VolumeBasedPanel {
  62452. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62453. }
  62454. }
  62455. declare module BABYLON.GUI {
  62456. /**
  62457. * Class used to create a container panel where items get randomized planar mapping
  62458. */
  62459. export class ScatterPanel extends VolumeBasedPanel {
  62460. private _iteration;
  62461. /**
  62462. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  62463. */
  62464. iteration: BABYLON.float;
  62465. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62466. private _scatterMapping;
  62467. protected _finalProcessing(): void;
  62468. }
  62469. }
  62470. declare module BABYLON.GUI {
  62471. /**
  62472. * Class used to create a container panel deployed on the surface of a sphere
  62473. */
  62474. export class SpherePanel extends VolumeBasedPanel {
  62475. private _radius;
  62476. /**
  62477. * Gets or sets the radius of the sphere where to project controls (5 by default)
  62478. */
  62479. radius: BABYLON.float;
  62480. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62481. private _sphericalMapping;
  62482. }
  62483. }
  62484. declare module BABYLON.GUI {
  62485. /**
  62486. * Class used to create a stack panel in 3D on XY plane
  62487. */
  62488. export class StackPanel3D extends Container3D {
  62489. private _isVertical;
  62490. /**
  62491. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  62492. */
  62493. isVertical: boolean;
  62494. /**
  62495. * Gets or sets the distance between elements
  62496. */
  62497. margin: number;
  62498. /**
  62499. * Creates new StackPanel
  62500. * @param isVertical
  62501. */
  62502. constructor(isVertical?: boolean);
  62503. protected _arrangeChildren(): void;
  62504. }
  62505. }
  62506. declare module BABYLON {
  62507. /**
  62508. * Mode that determines the coordinate system to use.
  62509. */
  62510. export enum GLTFLoaderCoordinateSystemMode {
  62511. /**
  62512. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  62513. */
  62514. AUTO = 0,
  62515. /**
  62516. * Sets the useRightHandedSystem flag on the scene.
  62517. */
  62518. FORCE_RIGHT_HANDED = 1
  62519. }
  62520. /**
  62521. * Mode that determines what animations will start.
  62522. */
  62523. export enum GLTFLoaderAnimationStartMode {
  62524. /**
  62525. * No animation will start.
  62526. */
  62527. NONE = 0,
  62528. /**
  62529. * The first animation will start.
  62530. */
  62531. FIRST = 1,
  62532. /**
  62533. * All animations will start.
  62534. */
  62535. ALL = 2
  62536. }
  62537. /**
  62538. * Interface that contains the data for the glTF asset.
  62539. */
  62540. export interface IGLTFLoaderData {
  62541. /**
  62542. * Object that represents the glTF JSON.
  62543. */
  62544. json: Object;
  62545. /**
  62546. * The BIN chunk of a binary glTF.
  62547. */
  62548. bin: Nullable<ArrayBufferView>;
  62549. }
  62550. /**
  62551. * Interface for extending the loader.
  62552. */
  62553. export interface IGLTFLoaderExtension {
  62554. /**
  62555. * The name of this extension.
  62556. */
  62557. readonly name: string;
  62558. /**
  62559. * Defines whether this extension is enabled.
  62560. */
  62561. enabled: boolean;
  62562. }
  62563. /**
  62564. * Loader state.
  62565. */
  62566. export enum GLTFLoaderState {
  62567. /**
  62568. * The asset is loading.
  62569. */
  62570. LOADING = 0,
  62571. /**
  62572. * The asset is ready for rendering.
  62573. */
  62574. READY = 1,
  62575. /**
  62576. * The asset is completely loaded.
  62577. */
  62578. COMPLETE = 2
  62579. }
  62580. /** @hidden */
  62581. export interface IGLTFLoader extends IDisposable {
  62582. readonly state: Nullable<GLTFLoaderState>;
  62583. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  62584. meshes: AbstractMesh[];
  62585. particleSystems: IParticleSystem[];
  62586. skeletons: Skeleton[];
  62587. animationGroups: AnimationGroup[];
  62588. }>;
  62589. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  62590. }
  62591. /**
  62592. * File loader for loading glTF files into a scene.
  62593. */
  62594. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  62595. /** @hidden */
  62596. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  62597. /** @hidden */
  62598. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  62599. /**
  62600. * Raised when the asset has been parsed
  62601. */
  62602. onParsedObservable: Observable<IGLTFLoaderData>;
  62603. private _onParsedObserver;
  62604. /**
  62605. * Raised when the asset has been parsed
  62606. */
  62607. onParsed: (loaderData: IGLTFLoaderData) => void;
  62608. /**
  62609. * 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.
  62610. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  62611. * Defaults to true.
  62612. * @hidden
  62613. */
  62614. static IncrementalLoading: boolean;
  62615. /**
  62616. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  62617. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  62618. * @hidden
  62619. */
  62620. static HomogeneousCoordinates: boolean;
  62621. /**
  62622. * The coordinate system mode. Defaults to AUTO.
  62623. */
  62624. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  62625. /**
  62626. * The animation start mode. Defaults to FIRST.
  62627. */
  62628. animationStartMode: GLTFLoaderAnimationStartMode;
  62629. /**
  62630. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  62631. */
  62632. compileMaterials: boolean;
  62633. /**
  62634. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  62635. */
  62636. useClipPlane: boolean;
  62637. /**
  62638. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  62639. */
  62640. compileShadowGenerators: boolean;
  62641. /**
  62642. * Defines if the Alpha blended materials are only applied as coverage.
  62643. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  62644. * If true, no extra effects are applied to transparent pixels.
  62645. */
  62646. transparencyAsCoverage: boolean;
  62647. /**
  62648. * Function called before loading a url referenced by the asset.
  62649. */
  62650. preprocessUrlAsync: (url: string) => Promise<string>;
  62651. /**
  62652. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  62653. */
  62654. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  62655. private _onMeshLoadedObserver;
  62656. /**
  62657. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  62658. */
  62659. onMeshLoaded: (mesh: AbstractMesh) => void;
  62660. /**
  62661. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  62662. */
  62663. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  62664. private _onTextureLoadedObserver;
  62665. /**
  62666. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  62667. */
  62668. onTextureLoaded: (texture: BaseTexture) => void;
  62669. /**
  62670. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  62671. */
  62672. readonly onMaterialLoadedObservable: Observable<Material>;
  62673. private _onMaterialLoadedObserver;
  62674. /**
  62675. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  62676. */
  62677. onMaterialLoaded: (material: Material) => void;
  62678. /**
  62679. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  62680. */
  62681. readonly onCameraLoadedObservable: Observable<Camera>;
  62682. private _onCameraLoadedObserver;
  62683. /**
  62684. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  62685. */
  62686. onCameraLoaded: (camera: Camera) => void;
  62687. /**
  62688. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  62689. * For assets with LODs, raised when all of the LODs are complete.
  62690. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  62691. */
  62692. readonly onCompleteObservable: Observable<void>;
  62693. private _onCompleteObserver;
  62694. /**
  62695. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  62696. * For assets with LODs, raised when all of the LODs are complete.
  62697. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  62698. */
  62699. onComplete: () => void;
  62700. /**
  62701. * Observable raised when an error occurs.
  62702. */
  62703. readonly onErrorObservable: Observable<any>;
  62704. private _onErrorObserver;
  62705. /**
  62706. * Callback raised when an error occurs.
  62707. */
  62708. onError: (reason: any) => void;
  62709. /**
  62710. * Observable raised after the loader is disposed.
  62711. */
  62712. readonly onDisposeObservable: Observable<void>;
  62713. private _onDisposeObserver;
  62714. /**
  62715. * Callback raised after the loader is disposed.
  62716. */
  62717. onDispose: () => void;
  62718. /**
  62719. * Observable raised after a loader extension is created.
  62720. * Set additional options for a loader extension in this event.
  62721. */
  62722. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  62723. private _onExtensionLoadedObserver;
  62724. /**
  62725. * Callback raised after a loader extension is created.
  62726. */
  62727. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  62728. /**
  62729. * Defines if the loader logging is enabled.
  62730. */
  62731. loggingEnabled: boolean;
  62732. /**
  62733. * Defines if the loader should capture performance counters.
  62734. */
  62735. capturePerformanceCounters: boolean;
  62736. /**
  62737. * Defines if the loader should validate the asset.
  62738. */
  62739. validate: boolean;
  62740. /**
  62741. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  62742. */
  62743. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  62744. private _onValidatedObserver;
  62745. /**
  62746. * Callback raised after a loader extension is created.
  62747. */
  62748. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  62749. private _loader;
  62750. /**
  62751. * Name of the loader ("gltf")
  62752. */
  62753. name: string;
  62754. /**
  62755. * Supported file extensions of the loader (.gltf, .glb)
  62756. */
  62757. extensions: ISceneLoaderPluginExtensions;
  62758. /**
  62759. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  62760. */
  62761. dispose(): void;
  62762. /** @hidden */
  62763. _clear(): void;
  62764. /**
  62765. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  62766. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  62767. * @param scene the scene the meshes should be added to
  62768. * @param data the glTF data to load
  62769. * @param rootUrl root url to load from
  62770. * @param onProgress event that fires when loading progress has occured
  62771. * @param fileName Defines the name of the file to load
  62772. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  62773. */
  62774. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  62775. meshes: AbstractMesh[];
  62776. particleSystems: IParticleSystem[];
  62777. skeletons: Skeleton[];
  62778. animationGroups: AnimationGroup[];
  62779. }>;
  62780. /**
  62781. * Imports all objects from the loaded glTF data and adds them to the scene
  62782. * @param scene the scene the objects should be added to
  62783. * @param data the glTF data to load
  62784. * @param rootUrl root url to load from
  62785. * @param onProgress event that fires when loading progress has occured
  62786. * @param fileName Defines the name of the file to load
  62787. * @returns a promise which completes when objects have been loaded to the scene
  62788. */
  62789. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  62790. /**
  62791. * Load into an asset container.
  62792. * @param scene The scene to load into
  62793. * @param data The data to import
  62794. * @param rootUrl The root url for scene and resources
  62795. * @param onProgress The callback when the load progresses
  62796. * @param fileName Defines the name of the file to load
  62797. * @returns The loaded asset container
  62798. */
  62799. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  62800. /**
  62801. * If the data string can be loaded directly.
  62802. * @param data string contianing the file data
  62803. * @returns if the data can be loaded directly
  62804. */
  62805. canDirectLoad(data: string): boolean;
  62806. /**
  62807. * Rewrites a url by combining a root url and response url.
  62808. */
  62809. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  62810. /**
  62811. * Instantiates a glTF file loader plugin.
  62812. * @returns the created plugin
  62813. */
  62814. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  62815. /**
  62816. * The loader state or null if the loader is not active.
  62817. */
  62818. readonly loaderState: Nullable<GLTFLoaderState>;
  62819. /**
  62820. * Returns a promise that resolves when the asset is completely loaded.
  62821. * @returns a promise that resolves when the asset is completely loaded.
  62822. */
  62823. whenCompleteAsync(): Promise<void>;
  62824. private _parseAsync;
  62825. private _validateAsync;
  62826. private _getLoader;
  62827. private _unpackBinary;
  62828. private _unpackBinaryV1;
  62829. private _unpackBinaryV2;
  62830. private static _parseVersion;
  62831. private static _compareVersion;
  62832. private static _decodeBufferToText;
  62833. private static readonly _logSpaces;
  62834. private _logIndentLevel;
  62835. private _loggingEnabled;
  62836. /** @hidden */
  62837. _log: (message: string) => void;
  62838. /** @hidden */
  62839. _logOpen(message: string): void;
  62840. /** @hidden */
  62841. _logClose(): void;
  62842. private _logEnabled;
  62843. private _logDisabled;
  62844. private _capturePerformanceCounters;
  62845. /** @hidden */
  62846. _startPerformanceCounter: (counterName: string) => void;
  62847. /** @hidden */
  62848. _endPerformanceCounter: (counterName: string) => void;
  62849. private _startPerformanceCounterEnabled;
  62850. private _startPerformanceCounterDisabled;
  62851. private _endPerformanceCounterEnabled;
  62852. private _endPerformanceCounterDisabled;
  62853. }
  62854. }
  62855. declare module BABYLON.GLTF1 {
  62856. /**
  62857. * Enums
  62858. * @hidden
  62859. */
  62860. export enum EComponentType {
  62861. BYTE = 5120,
  62862. UNSIGNED_BYTE = 5121,
  62863. SHORT = 5122,
  62864. UNSIGNED_SHORT = 5123,
  62865. FLOAT = 5126
  62866. }
  62867. /** @hidden */
  62868. export enum EShaderType {
  62869. FRAGMENT = 35632,
  62870. VERTEX = 35633
  62871. }
  62872. /** @hidden */
  62873. export enum EParameterType {
  62874. BYTE = 5120,
  62875. UNSIGNED_BYTE = 5121,
  62876. SHORT = 5122,
  62877. UNSIGNED_SHORT = 5123,
  62878. INT = 5124,
  62879. UNSIGNED_INT = 5125,
  62880. FLOAT = 5126,
  62881. FLOAT_VEC2 = 35664,
  62882. FLOAT_VEC3 = 35665,
  62883. FLOAT_VEC4 = 35666,
  62884. INT_VEC2 = 35667,
  62885. INT_VEC3 = 35668,
  62886. INT_VEC4 = 35669,
  62887. BOOL = 35670,
  62888. BOOL_VEC2 = 35671,
  62889. BOOL_VEC3 = 35672,
  62890. BOOL_VEC4 = 35673,
  62891. FLOAT_MAT2 = 35674,
  62892. FLOAT_MAT3 = 35675,
  62893. FLOAT_MAT4 = 35676,
  62894. SAMPLER_2D = 35678
  62895. }
  62896. /** @hidden */
  62897. export enum ETextureWrapMode {
  62898. CLAMP_TO_EDGE = 33071,
  62899. MIRRORED_REPEAT = 33648,
  62900. REPEAT = 10497
  62901. }
  62902. /** @hidden */
  62903. export enum ETextureFilterType {
  62904. NEAREST = 9728,
  62905. LINEAR = 9728,
  62906. NEAREST_MIPMAP_NEAREST = 9984,
  62907. LINEAR_MIPMAP_NEAREST = 9985,
  62908. NEAREST_MIPMAP_LINEAR = 9986,
  62909. LINEAR_MIPMAP_LINEAR = 9987
  62910. }
  62911. /** @hidden */
  62912. export enum ETextureFormat {
  62913. ALPHA = 6406,
  62914. RGB = 6407,
  62915. RGBA = 6408,
  62916. LUMINANCE = 6409,
  62917. LUMINANCE_ALPHA = 6410
  62918. }
  62919. /** @hidden */
  62920. export enum ECullingType {
  62921. FRONT = 1028,
  62922. BACK = 1029,
  62923. FRONT_AND_BACK = 1032
  62924. }
  62925. /** @hidden */
  62926. export enum EBlendingFunction {
  62927. ZERO = 0,
  62928. ONE = 1,
  62929. SRC_COLOR = 768,
  62930. ONE_MINUS_SRC_COLOR = 769,
  62931. DST_COLOR = 774,
  62932. ONE_MINUS_DST_COLOR = 775,
  62933. SRC_ALPHA = 770,
  62934. ONE_MINUS_SRC_ALPHA = 771,
  62935. DST_ALPHA = 772,
  62936. ONE_MINUS_DST_ALPHA = 773,
  62937. CONSTANT_COLOR = 32769,
  62938. ONE_MINUS_CONSTANT_COLOR = 32770,
  62939. CONSTANT_ALPHA = 32771,
  62940. ONE_MINUS_CONSTANT_ALPHA = 32772,
  62941. SRC_ALPHA_SATURATE = 776
  62942. }
  62943. /** @hidden */
  62944. export interface IGLTFProperty {
  62945. extensions?: {
  62946. [key: string]: any;
  62947. };
  62948. extras?: Object;
  62949. }
  62950. /** @hidden */
  62951. export interface IGLTFChildRootProperty extends IGLTFProperty {
  62952. name?: string;
  62953. }
  62954. /** @hidden */
  62955. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  62956. bufferView: string;
  62957. byteOffset: number;
  62958. byteStride: number;
  62959. count: number;
  62960. type: string;
  62961. componentType: EComponentType;
  62962. max?: number[];
  62963. min?: number[];
  62964. name?: string;
  62965. }
  62966. /** @hidden */
  62967. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  62968. buffer: string;
  62969. byteOffset: number;
  62970. byteLength: number;
  62971. byteStride: number;
  62972. target?: number;
  62973. }
  62974. /** @hidden */
  62975. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  62976. uri: string;
  62977. byteLength?: number;
  62978. type?: string;
  62979. }
  62980. /** @hidden */
  62981. export interface IGLTFShader extends IGLTFChildRootProperty {
  62982. uri: string;
  62983. type: EShaderType;
  62984. }
  62985. /** @hidden */
  62986. export interface IGLTFProgram extends IGLTFChildRootProperty {
  62987. attributes: string[];
  62988. fragmentShader: string;
  62989. vertexShader: string;
  62990. }
  62991. /** @hidden */
  62992. export interface IGLTFTechniqueParameter {
  62993. type: number;
  62994. count?: number;
  62995. semantic?: string;
  62996. node?: string;
  62997. value?: number | boolean | string | Array<any>;
  62998. source?: string;
  62999. babylonValue?: any;
  63000. }
  63001. /** @hidden */
  63002. export interface IGLTFTechniqueCommonProfile {
  63003. lightingModel: string;
  63004. texcoordBindings: Object;
  63005. parameters?: Array<any>;
  63006. }
  63007. /** @hidden */
  63008. export interface IGLTFTechniqueStatesFunctions {
  63009. blendColor?: number[];
  63010. blendEquationSeparate?: number[];
  63011. blendFuncSeparate?: number[];
  63012. colorMask: boolean[];
  63013. cullFace: number[];
  63014. }
  63015. /** @hidden */
  63016. export interface IGLTFTechniqueStates {
  63017. enable: number[];
  63018. functions: IGLTFTechniqueStatesFunctions;
  63019. }
  63020. /** @hidden */
  63021. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  63022. parameters: {
  63023. [key: string]: IGLTFTechniqueParameter;
  63024. };
  63025. program: string;
  63026. attributes: {
  63027. [key: string]: string;
  63028. };
  63029. uniforms: {
  63030. [key: string]: string;
  63031. };
  63032. states: IGLTFTechniqueStates;
  63033. }
  63034. /** @hidden */
  63035. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  63036. technique?: string;
  63037. values: string[];
  63038. }
  63039. /** @hidden */
  63040. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  63041. attributes: {
  63042. [key: string]: string;
  63043. };
  63044. indices: string;
  63045. material: string;
  63046. mode?: number;
  63047. }
  63048. /** @hidden */
  63049. export interface IGLTFMesh extends IGLTFChildRootProperty {
  63050. primitives: IGLTFMeshPrimitive[];
  63051. }
  63052. /** @hidden */
  63053. export interface IGLTFImage extends IGLTFChildRootProperty {
  63054. uri: string;
  63055. }
  63056. /** @hidden */
  63057. export interface IGLTFSampler extends IGLTFChildRootProperty {
  63058. magFilter?: number;
  63059. minFilter?: number;
  63060. wrapS?: number;
  63061. wrapT?: number;
  63062. }
  63063. /** @hidden */
  63064. export interface IGLTFTexture extends IGLTFChildRootProperty {
  63065. sampler: string;
  63066. source: string;
  63067. format?: ETextureFormat;
  63068. internalFormat?: ETextureFormat;
  63069. target?: number;
  63070. type?: number;
  63071. babylonTexture?: Texture;
  63072. }
  63073. /** @hidden */
  63074. export interface IGLTFAmbienLight {
  63075. color?: number[];
  63076. }
  63077. /** @hidden */
  63078. export interface IGLTFDirectionalLight {
  63079. color?: number[];
  63080. }
  63081. /** @hidden */
  63082. export interface IGLTFPointLight {
  63083. color?: number[];
  63084. constantAttenuation?: number;
  63085. linearAttenuation?: number;
  63086. quadraticAttenuation?: number;
  63087. }
  63088. /** @hidden */
  63089. export interface IGLTFSpotLight {
  63090. color?: number[];
  63091. constantAttenuation?: number;
  63092. fallOfAngle?: number;
  63093. fallOffExponent?: number;
  63094. linearAttenuation?: number;
  63095. quadraticAttenuation?: number;
  63096. }
  63097. /** @hidden */
  63098. export interface IGLTFLight extends IGLTFChildRootProperty {
  63099. type: string;
  63100. }
  63101. /** @hidden */
  63102. export interface IGLTFCameraOrthographic {
  63103. xmag: number;
  63104. ymag: number;
  63105. zfar: number;
  63106. znear: number;
  63107. }
  63108. /** @hidden */
  63109. export interface IGLTFCameraPerspective {
  63110. aspectRatio: number;
  63111. yfov: number;
  63112. zfar: number;
  63113. znear: number;
  63114. }
  63115. /** @hidden */
  63116. export interface IGLTFCamera extends IGLTFChildRootProperty {
  63117. type: string;
  63118. }
  63119. /** @hidden */
  63120. export interface IGLTFAnimationChannelTarget {
  63121. id: string;
  63122. path: string;
  63123. }
  63124. /** @hidden */
  63125. export interface IGLTFAnimationChannel {
  63126. sampler: string;
  63127. target: IGLTFAnimationChannelTarget;
  63128. }
  63129. /** @hidden */
  63130. export interface IGLTFAnimationSampler {
  63131. input: string;
  63132. output: string;
  63133. interpolation?: string;
  63134. }
  63135. /** @hidden */
  63136. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  63137. channels?: IGLTFAnimationChannel[];
  63138. parameters?: {
  63139. [key: string]: string;
  63140. };
  63141. samplers?: {
  63142. [key: string]: IGLTFAnimationSampler;
  63143. };
  63144. }
  63145. /** @hidden */
  63146. export interface IGLTFNodeInstanceSkin {
  63147. skeletons: string[];
  63148. skin: string;
  63149. meshes: string[];
  63150. }
  63151. /** @hidden */
  63152. export interface IGLTFSkins extends IGLTFChildRootProperty {
  63153. bindShapeMatrix: number[];
  63154. inverseBindMatrices: string;
  63155. jointNames: string[];
  63156. babylonSkeleton?: Skeleton;
  63157. }
  63158. /** @hidden */
  63159. export interface IGLTFNode extends IGLTFChildRootProperty {
  63160. camera?: string;
  63161. children: string[];
  63162. skin?: string;
  63163. jointName?: string;
  63164. light?: string;
  63165. matrix: number[];
  63166. mesh?: string;
  63167. meshes?: string[];
  63168. rotation?: number[];
  63169. scale?: number[];
  63170. translation?: number[];
  63171. babylonNode?: Node;
  63172. }
  63173. /** @hidden */
  63174. export interface IGLTFScene extends IGLTFChildRootProperty {
  63175. nodes: string[];
  63176. }
  63177. /** @hidden */
  63178. export interface IGLTFRuntime {
  63179. extensions: {
  63180. [key: string]: any;
  63181. };
  63182. accessors: {
  63183. [key: string]: IGLTFAccessor;
  63184. };
  63185. buffers: {
  63186. [key: string]: IGLTFBuffer;
  63187. };
  63188. bufferViews: {
  63189. [key: string]: IGLTFBufferView;
  63190. };
  63191. meshes: {
  63192. [key: string]: IGLTFMesh;
  63193. };
  63194. lights: {
  63195. [key: string]: IGLTFLight;
  63196. };
  63197. cameras: {
  63198. [key: string]: IGLTFCamera;
  63199. };
  63200. nodes: {
  63201. [key: string]: IGLTFNode;
  63202. };
  63203. images: {
  63204. [key: string]: IGLTFImage;
  63205. };
  63206. textures: {
  63207. [key: string]: IGLTFTexture;
  63208. };
  63209. shaders: {
  63210. [key: string]: IGLTFShader;
  63211. };
  63212. programs: {
  63213. [key: string]: IGLTFProgram;
  63214. };
  63215. samplers: {
  63216. [key: string]: IGLTFSampler;
  63217. };
  63218. techniques: {
  63219. [key: string]: IGLTFTechnique;
  63220. };
  63221. materials: {
  63222. [key: string]: IGLTFMaterial;
  63223. };
  63224. animations: {
  63225. [key: string]: IGLTFAnimation;
  63226. };
  63227. skins: {
  63228. [key: string]: IGLTFSkins;
  63229. };
  63230. currentScene?: Object;
  63231. scenes: {
  63232. [key: string]: IGLTFScene;
  63233. };
  63234. extensionsUsed: string[];
  63235. extensionsRequired?: string[];
  63236. buffersCount: number;
  63237. shaderscount: number;
  63238. scene: Scene;
  63239. rootUrl: string;
  63240. loadedBufferCount: number;
  63241. loadedBufferViews: {
  63242. [name: string]: ArrayBufferView;
  63243. };
  63244. loadedShaderCount: number;
  63245. importOnlyMeshes: boolean;
  63246. importMeshesNames?: string[];
  63247. dummyNodes: Node[];
  63248. }
  63249. /** @hidden */
  63250. export interface INodeToRoot {
  63251. bone: Bone;
  63252. node: IGLTFNode;
  63253. id: string;
  63254. }
  63255. /** @hidden */
  63256. export interface IJointNode {
  63257. node: IGLTFNode;
  63258. id: string;
  63259. }
  63260. }
  63261. declare module BABYLON.GLTF1 {
  63262. /**
  63263. * Utils functions for GLTF
  63264. * @hidden
  63265. */
  63266. export class GLTFUtils {
  63267. /**
  63268. * Sets the given "parameter" matrix
  63269. * @param scene: the Scene object
  63270. * @param source: the source node where to pick the matrix
  63271. * @param parameter: the GLTF technique parameter
  63272. * @param uniformName: the name of the shader's uniform
  63273. * @param shaderMaterial: the shader material
  63274. */
  63275. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  63276. /**
  63277. * Sets the given "parameter" matrix
  63278. * @param shaderMaterial: the shader material
  63279. * @param uniform: the name of the shader's uniform
  63280. * @param value: the value of the uniform
  63281. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  63282. */
  63283. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  63284. /**
  63285. * Returns the wrap mode of the texture
  63286. * @param mode: the mode value
  63287. */
  63288. static GetWrapMode(mode: number): number;
  63289. /**
  63290. * Returns the byte stride giving an accessor
  63291. * @param accessor: the GLTF accessor objet
  63292. */
  63293. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  63294. /**
  63295. * Returns the texture filter mode giving a mode value
  63296. * @param mode: the filter mode value
  63297. */
  63298. static GetTextureFilterMode(mode: number): ETextureFilterType;
  63299. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  63300. /**
  63301. * Returns a buffer from its accessor
  63302. * @param gltfRuntime: the GLTF runtime
  63303. * @param accessor: the GLTF accessor
  63304. */
  63305. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  63306. /**
  63307. * Decodes a buffer view into a string
  63308. * @param view: the buffer view
  63309. */
  63310. static DecodeBufferToText(view: ArrayBufferView): string;
  63311. /**
  63312. * Returns the default material of gltf. Related to
  63313. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  63314. * @param scene: the Babylon.js scene
  63315. */
  63316. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  63317. private static _DefaultMaterial;
  63318. }
  63319. }
  63320. declare module BABYLON.GLTF1 {
  63321. /**
  63322. * Implementation of the base glTF spec
  63323. * @hidden
  63324. */
  63325. export class GLTFLoaderBase {
  63326. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  63327. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  63328. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  63329. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  63330. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  63331. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  63332. }
  63333. /**
  63334. * glTF V1 Loader
  63335. * @hidden
  63336. */
  63337. export class GLTFLoader implements IGLTFLoader {
  63338. static Extensions: {
  63339. [name: string]: GLTFLoaderExtension;
  63340. };
  63341. static RegisterExtension(extension: GLTFLoaderExtension): void;
  63342. state: Nullable<GLTFLoaderState>;
  63343. dispose(): void;
  63344. private _importMeshAsync;
  63345. /**
  63346. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  63347. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  63348. * @param scene the scene the meshes should be added to
  63349. * @param data gltf data containing information of the meshes in a loaded file
  63350. * @param rootUrl root url to load from
  63351. * @param onProgress event that fires when loading progress has occured
  63352. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  63353. */
  63354. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  63355. meshes: AbstractMesh[];
  63356. particleSystems: IParticleSystem[];
  63357. skeletons: Skeleton[];
  63358. animationGroups: AnimationGroup[];
  63359. }>;
  63360. private _loadAsync;
  63361. /**
  63362. * Imports all objects from a loaded gltf file and adds them to the scene
  63363. * @param scene the scene the objects should be added to
  63364. * @param data gltf data containing information of the meshes in a loaded file
  63365. * @param rootUrl root url to load from
  63366. * @param onProgress event that fires when loading progress has occured
  63367. * @returns a promise which completes when objects have been loaded to the scene
  63368. */
  63369. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  63370. private _loadShadersAsync;
  63371. private _loadBuffersAsync;
  63372. private _createNodes;
  63373. }
  63374. /** @hidden */
  63375. export abstract class GLTFLoaderExtension {
  63376. private _name;
  63377. constructor(name: string);
  63378. readonly name: string;
  63379. /**
  63380. * Defines an override for loading the runtime
  63381. * Return true to stop further extensions from loading the runtime
  63382. */
  63383. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  63384. /**
  63385. * Defines an onverride for creating gltf runtime
  63386. * Return true to stop further extensions from creating the runtime
  63387. */
  63388. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  63389. /**
  63390. * Defines an override for loading buffers
  63391. * Return true to stop further extensions from loading this buffer
  63392. */
  63393. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  63394. /**
  63395. * Defines an override for loading texture buffers
  63396. * Return true to stop further extensions from loading this texture data
  63397. */
  63398. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  63399. /**
  63400. * Defines an override for creating textures
  63401. * Return true to stop further extensions from loading this texture
  63402. */
  63403. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  63404. /**
  63405. * Defines an override for loading shader strings
  63406. * Return true to stop further extensions from loading this shader data
  63407. */
  63408. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  63409. /**
  63410. * Defines an override for loading materials
  63411. * Return true to stop further extensions from loading this material
  63412. */
  63413. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  63414. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  63415. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  63416. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  63417. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  63418. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  63419. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  63420. private static LoadTextureBufferAsync;
  63421. private static CreateTextureAsync;
  63422. private static ApplyExtensions;
  63423. }
  63424. }
  63425. declare module BABYLON.GLTF1 {
  63426. /** @hidden */
  63427. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  63428. private _bin;
  63429. constructor();
  63430. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  63431. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  63432. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  63433. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  63434. }
  63435. }
  63436. declare module BABYLON.GLTF1 {
  63437. /** @hidden */
  63438. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  63439. constructor();
  63440. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  63441. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  63442. private _loadTexture;
  63443. }
  63444. }
  63445. declare module BABYLON.GLTF2.Loader {
  63446. /**
  63447. * Loader interface with an index field.
  63448. */
  63449. export interface IArrayItem {
  63450. /**
  63451. * The index of this item in the array.
  63452. */
  63453. index: number;
  63454. }
  63455. /**
  63456. * Loader interface with additional members.
  63457. */
  63458. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  63459. /** @hidden */
  63460. _data?: Promise<ArrayBufferView>;
  63461. /** @hidden */
  63462. _babylonVertexBuffer?: Promise<VertexBuffer>;
  63463. }
  63464. /**
  63465. * Loader interface with additional members.
  63466. */
  63467. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  63468. }
  63469. /** @hidden */
  63470. export interface _IAnimationSamplerData {
  63471. input: Float32Array;
  63472. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  63473. output: Float32Array;
  63474. }
  63475. /**
  63476. * Loader interface with additional members.
  63477. */
  63478. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  63479. /** @hidden */
  63480. _data?: Promise<_IAnimationSamplerData>;
  63481. }
  63482. /**
  63483. * Loader interface with additional members.
  63484. */
  63485. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  63486. channels: IAnimationChannel[];
  63487. samplers: IAnimationSampler[];
  63488. /** @hidden */
  63489. _babylonAnimationGroup?: AnimationGroup;
  63490. }
  63491. /**
  63492. * Loader interface with additional members.
  63493. */
  63494. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  63495. /** @hidden */
  63496. _data?: Promise<ArrayBufferView>;
  63497. }
  63498. /**
  63499. * Loader interface with additional members.
  63500. */
  63501. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  63502. /** @hidden */
  63503. _data?: Promise<ArrayBufferView>;
  63504. /** @hidden */
  63505. _babylonBuffer?: Promise<Buffer>;
  63506. }
  63507. /**
  63508. * Loader interface with additional members.
  63509. */
  63510. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  63511. }
  63512. /**
  63513. * Loader interface with additional members.
  63514. */
  63515. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  63516. /** @hidden */
  63517. _data?: Promise<ArrayBufferView>;
  63518. }
  63519. /**
  63520. * Loader interface with additional members.
  63521. */
  63522. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  63523. }
  63524. /**
  63525. * Loader interface with additional members.
  63526. */
  63527. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  63528. }
  63529. /**
  63530. * Loader interface with additional members.
  63531. */
  63532. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  63533. baseColorTexture?: ITextureInfo;
  63534. metallicRoughnessTexture?: ITextureInfo;
  63535. }
  63536. /**
  63537. * Loader interface with additional members.
  63538. */
  63539. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  63540. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  63541. normalTexture?: IMaterialNormalTextureInfo;
  63542. occlusionTexture?: IMaterialOcclusionTextureInfo;
  63543. emissiveTexture?: ITextureInfo;
  63544. /** @hidden */
  63545. _data?: {
  63546. [babylonDrawMode: number]: {
  63547. babylonMaterial: Material;
  63548. babylonMeshes: AbstractMesh[];
  63549. promise: Promise<void>;
  63550. };
  63551. };
  63552. }
  63553. /**
  63554. * Loader interface with additional members.
  63555. */
  63556. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  63557. primitives: IMeshPrimitive[];
  63558. }
  63559. /**
  63560. * Loader interface with additional members.
  63561. */
  63562. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  63563. /** @hidden */
  63564. _instanceData?: {
  63565. babylonSourceMesh: Mesh;
  63566. promise: Promise<any>;
  63567. };
  63568. }
  63569. /**
  63570. * Loader interface with additional members.
  63571. */
  63572. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  63573. /**
  63574. * The parent glTF node.
  63575. */
  63576. parent?: INode;
  63577. /** @hidden */
  63578. _babylonTransformNode?: TransformNode;
  63579. /** @hidden */
  63580. _primitiveBabylonMeshes?: AbstractMesh[];
  63581. /** @hidden */
  63582. _babylonBones?: Bone[];
  63583. /** @hidden */
  63584. _numMorphTargets?: number;
  63585. }
  63586. /** @hidden */
  63587. export interface _ISamplerData {
  63588. noMipMaps: boolean;
  63589. samplingMode: number;
  63590. wrapU: number;
  63591. wrapV: number;
  63592. }
  63593. /**
  63594. * Loader interface with additional members.
  63595. */
  63596. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  63597. /** @hidden */
  63598. _data?: _ISamplerData;
  63599. }
  63600. /**
  63601. * Loader interface with additional members.
  63602. */
  63603. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  63604. }
  63605. /**
  63606. * Loader interface with additional members.
  63607. */
  63608. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  63609. /** @hidden */
  63610. _data?: {
  63611. babylonSkeleton: Skeleton;
  63612. promise: Promise<void>;
  63613. };
  63614. }
  63615. /**
  63616. * Loader interface with additional members.
  63617. */
  63618. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  63619. }
  63620. /**
  63621. * Loader interface with additional members.
  63622. */
  63623. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  63624. }
  63625. /**
  63626. * Loader interface with additional members.
  63627. */
  63628. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  63629. accessors?: IAccessor[];
  63630. animations?: IAnimation[];
  63631. buffers?: IBuffer[];
  63632. bufferViews?: IBufferView[];
  63633. cameras?: ICamera[];
  63634. images?: IImage[];
  63635. materials?: IMaterial[];
  63636. meshes?: IMesh[];
  63637. nodes?: INode[];
  63638. samplers?: ISampler[];
  63639. scenes?: IScene[];
  63640. skins?: ISkin[];
  63641. textures?: ITexture[];
  63642. }
  63643. }
  63644. declare module BABYLON.GLTF2 {
  63645. /**
  63646. * Interface for a glTF loader extension.
  63647. */
  63648. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  63649. /**
  63650. * Called after the loader state changes to LOADING.
  63651. */
  63652. onLoading?(): void;
  63653. /**
  63654. * Called after the loader state changes to READY.
  63655. */
  63656. onReady?(): void;
  63657. /**
  63658. * Define this method to modify the default behavior when loading scenes.
  63659. * @param context The context when loading the asset
  63660. * @param scene The glTF scene property
  63661. * @returns A promise that resolves when the load is complete or null if not handled
  63662. */
  63663. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  63664. /**
  63665. * Define this method to modify the default behavior when loading nodes.
  63666. * @param context The context when loading the asset
  63667. * @param node The glTF node property
  63668. * @param assign A function called synchronously after parsing the glTF properties
  63669. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  63670. */
  63671. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  63672. /**
  63673. * Define this method to modify the default behavior when loading cameras.
  63674. * @param context The context when loading the asset
  63675. * @param camera The glTF camera property
  63676. * @param assign A function called synchronously after parsing the glTF properties
  63677. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  63678. */
  63679. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  63680. /**
  63681. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  63682. * @param context The context when loading the asset
  63683. * @param primitive The glTF mesh primitive property
  63684. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  63685. */
  63686. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  63687. /**
  63688. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  63689. * @param context The context when loading the asset
  63690. * @param name The mesh name when loading the asset
  63691. * @param node The glTF node when loading the asset
  63692. * @param mesh The glTF mesh when loading the asset
  63693. * @param primitive The glTF mesh primitive property
  63694. * @param assign A function called synchronously after parsing the glTF properties
  63695. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  63696. */
  63697. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  63698. /**
  63699. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  63700. * @param context The context when loading the asset
  63701. * @param material The glTF material property
  63702. * @param assign A function called synchronously after parsing the glTF properties
  63703. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  63704. */
  63705. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  63706. /**
  63707. * Define this method to modify the default behavior when creating materials.
  63708. * @param context The context when loading the asset
  63709. * @param material The glTF material property
  63710. * @param babylonDrawMode The draw mode for the Babylon material
  63711. * @returns The Babylon material or null if not handled
  63712. */
  63713. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  63714. /**
  63715. * Define this method to modify the default behavior when loading material properties.
  63716. * @param context The context when loading the asset
  63717. * @param material The glTF material property
  63718. * @param babylonMaterial The Babylon material
  63719. * @returns A promise that resolves when the load is complete or null if not handled
  63720. */
  63721. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  63722. /**
  63723. * Define this method to modify the default behavior when loading texture infos.
  63724. * @param context The context when loading the asset
  63725. * @param textureInfo The glTF texture info property
  63726. * @param assign A function called synchronously after parsing the glTF properties
  63727. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  63728. */
  63729. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  63730. /**
  63731. * Define this method to modify the default behavior when loading animations.
  63732. * @param context The context when loading the asset
  63733. * @param animation The glTF animation property
  63734. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  63735. */
  63736. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  63737. /**
  63738. * @hidden Define this method to modify the default behavior when loading skins.
  63739. * @param context The context when loading the asset
  63740. * @param node The glTF node property
  63741. * @param skin The glTF skin property
  63742. * @returns A promise that resolves when the load is complete or null if not handled
  63743. */
  63744. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  63745. /**
  63746. * @hidden Define this method to modify the default behavior when loading uris.
  63747. * @param context The context when loading the asset
  63748. * @param property The glTF property associated with the uri
  63749. * @param uri The uri to load
  63750. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  63751. */
  63752. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  63753. }
  63754. }
  63755. declare module BABYLON.GLTF2 {
  63756. /**
  63757. * Helper class for working with arrays when loading the glTF asset
  63758. */
  63759. export class ArrayItem {
  63760. /**
  63761. * Gets an item from the given array.
  63762. * @param context The context when loading the asset
  63763. * @param array The array to get the item from
  63764. * @param index The index to the array
  63765. * @returns The array item
  63766. */
  63767. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  63768. /**
  63769. * Assign an `index` field to each item of the given array.
  63770. * @param array The array of items
  63771. */
  63772. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  63773. }
  63774. /**
  63775. * The glTF 2.0 loader
  63776. */
  63777. export class GLTFLoader implements IGLTFLoader {
  63778. /** @hidden */
  63779. _completePromises: Promise<any>[];
  63780. private _disposed;
  63781. private _parent;
  63782. private _state;
  63783. private _extensions;
  63784. private _rootUrl;
  63785. private _fileName;
  63786. private _uniqueRootUrl;
  63787. private _gltf;
  63788. private _babylonScene;
  63789. private _rootBabylonMesh;
  63790. private _defaultBabylonMaterialData;
  63791. private _progressCallback?;
  63792. private _requests;
  63793. private static readonly _DefaultSampler;
  63794. private static _ExtensionNames;
  63795. private static _ExtensionFactories;
  63796. /**
  63797. * Registers a loader extension.
  63798. * @param name The name of the loader extension.
  63799. * @param factory The factory function that creates the loader extension.
  63800. */
  63801. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  63802. /**
  63803. * Unregisters a loader extension.
  63804. * @param name The name of the loader extenion.
  63805. * @returns A boolean indicating whether the extension has been unregistered
  63806. */
  63807. static UnregisterExtension(name: string): boolean;
  63808. /**
  63809. * Gets the loader state.
  63810. */
  63811. readonly state: Nullable<GLTFLoaderState>;
  63812. /**
  63813. * The glTF object parsed from the JSON.
  63814. */
  63815. readonly gltf: IGLTF;
  63816. /**
  63817. * The Babylon scene when loading the asset.
  63818. */
  63819. readonly babylonScene: Scene;
  63820. /**
  63821. * The root Babylon mesh when loading the asset.
  63822. */
  63823. readonly rootBabylonMesh: Mesh;
  63824. /** @hidden */
  63825. constructor(parent: GLTFFileLoader);
  63826. /** @hidden */
  63827. dispose(): void;
  63828. /** @hidden */
  63829. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  63830. meshes: AbstractMesh[];
  63831. particleSystems: IParticleSystem[];
  63832. skeletons: Skeleton[];
  63833. animationGroups: AnimationGroup[];
  63834. }>;
  63835. /** @hidden */
  63836. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  63837. private _loadAsync;
  63838. private _loadData;
  63839. private _setupData;
  63840. private _loadExtensions;
  63841. private _checkExtensions;
  63842. private _setState;
  63843. private _createRootNode;
  63844. /**
  63845. * Loads a glTF scene.
  63846. * @param context The context when loading the asset
  63847. * @param scene The glTF scene property
  63848. * @returns A promise that resolves when the load is complete
  63849. */
  63850. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  63851. private _forEachPrimitive;
  63852. private _getMeshes;
  63853. private _getSkeletons;
  63854. private _getAnimationGroups;
  63855. private _startAnimations;
  63856. /**
  63857. * Loads a glTF node.
  63858. * @param context The context when loading the asset
  63859. * @param node The glTF node property
  63860. * @param assign A function called synchronously after parsing the glTF properties
  63861. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  63862. */
  63863. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  63864. private _loadMeshAsync;
  63865. /**
  63866. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  63867. * @param context The context when loading the asset
  63868. * @param name The mesh name when loading the asset
  63869. * @param node The glTF node when loading the asset
  63870. * @param mesh The glTF mesh when loading the asset
  63871. * @param primitive The glTF mesh primitive property
  63872. * @param assign A function called synchronously after parsing the glTF properties
  63873. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  63874. */
  63875. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  63876. private _loadVertexDataAsync;
  63877. private _createMorphTargets;
  63878. private _loadMorphTargetsAsync;
  63879. private _loadMorphTargetVertexDataAsync;
  63880. private static _LoadTransform;
  63881. private _loadSkinAsync;
  63882. private _loadBones;
  63883. private _loadBone;
  63884. private _loadSkinInverseBindMatricesDataAsync;
  63885. private _updateBoneMatrices;
  63886. private _getNodeMatrix;
  63887. /**
  63888. * Loads a glTF camera.
  63889. * @param context The context when loading the asset
  63890. * @param camera The glTF camera property
  63891. * @param assign A function called synchronously after parsing the glTF properties
  63892. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  63893. */
  63894. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  63895. private _loadAnimationsAsync;
  63896. /**
  63897. * Loads a glTF animation.
  63898. * @param context The context when loading the asset
  63899. * @param animation The glTF animation property
  63900. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  63901. */
  63902. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  63903. /**
  63904. * @hidden Loads a glTF animation channel.
  63905. * @param context The context when loading the asset
  63906. * @param animationContext The context of the animation when loading the asset
  63907. * @param animation The glTF animation property
  63908. * @param channel The glTF animation channel property
  63909. * @param babylonAnimationGroup The babylon animation group property
  63910. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  63911. * @returns A void promise when the channel load is complete
  63912. */
  63913. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  63914. private _loadAnimationSamplerAsync;
  63915. private _loadBufferAsync;
  63916. /**
  63917. * Loads a glTF buffer view.
  63918. * @param context The context when loading the asset
  63919. * @param bufferView The glTF buffer view property
  63920. * @returns A promise that resolves with the loaded data when the load is complete
  63921. */
  63922. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  63923. private _loadIndicesAccessorAsync;
  63924. private _loadFloatAccessorAsync;
  63925. private _loadVertexBufferViewAsync;
  63926. private _loadVertexAccessorAsync;
  63927. private _loadMaterialMetallicRoughnessPropertiesAsync;
  63928. /** @hidden */
  63929. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  63930. private _createDefaultMaterial;
  63931. /**
  63932. * Creates a Babylon material from a glTF material.
  63933. * @param context The context when loading the asset
  63934. * @param material The glTF material property
  63935. * @param babylonDrawMode The draw mode for the Babylon material
  63936. * @returns The Babylon material
  63937. */
  63938. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  63939. /**
  63940. * Loads properties from a glTF material into a Babylon material.
  63941. * @param context The context when loading the asset
  63942. * @param material The glTF material property
  63943. * @param babylonMaterial The Babylon material
  63944. * @returns A promise that resolves when the load is complete
  63945. */
  63946. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  63947. /**
  63948. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  63949. * @param context The context when loading the asset
  63950. * @param material The glTF material property
  63951. * @param babylonMaterial The Babylon material
  63952. * @returns A promise that resolves when the load is complete
  63953. */
  63954. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  63955. /**
  63956. * Loads the alpha properties from a glTF material into a Babylon material.
  63957. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  63958. * @param context The context when loading the asset
  63959. * @param material The glTF material property
  63960. * @param babylonMaterial The Babylon material
  63961. */
  63962. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  63963. /**
  63964. * Loads a glTF texture info.
  63965. * @param context The context when loading the asset
  63966. * @param textureInfo The glTF texture info property
  63967. * @param assign A function called synchronously after parsing the glTF properties
  63968. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  63969. */
  63970. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  63971. private _loadTextureAsync;
  63972. private _loadSampler;
  63973. /**
  63974. * Loads a glTF image.
  63975. * @param context The context when loading the asset
  63976. * @param image The glTF image property
  63977. * @returns A promise that resolves with the loaded data when the load is complete
  63978. */
  63979. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  63980. /**
  63981. * Loads a glTF uri.
  63982. * @param context The context when loading the asset
  63983. * @param property The glTF property associated with the uri
  63984. * @param uri The base64 or relative uri
  63985. * @returns A promise that resolves with the loaded data when the load is complete
  63986. */
  63987. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  63988. private _onProgress;
  63989. /**
  63990. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  63991. * @param babylonObject the Babylon object with metadata
  63992. * @param pointer the JSON pointer
  63993. */
  63994. static AddPointerMetadata(babylonObject: {
  63995. metadata: any;
  63996. }, pointer: string): void;
  63997. private static _GetTextureWrapMode;
  63998. private static _GetTextureSamplingMode;
  63999. private static _GetTypedArray;
  64000. private static _GetNumComponents;
  64001. private static _ValidateUri;
  64002. private static _GetDrawMode;
  64003. private _compileMaterialsAsync;
  64004. private _compileShadowGeneratorsAsync;
  64005. private _forEachExtensions;
  64006. private _applyExtensions;
  64007. private _extensionsOnLoading;
  64008. private _extensionsOnReady;
  64009. private _extensionsLoadSceneAsync;
  64010. private _extensionsLoadNodeAsync;
  64011. private _extensionsLoadCameraAsync;
  64012. private _extensionsLoadVertexDataAsync;
  64013. private _extensionsLoadMeshPrimitiveAsync;
  64014. private _extensionsLoadMaterialAsync;
  64015. private _extensionsCreateMaterial;
  64016. private _extensionsLoadMaterialPropertiesAsync;
  64017. private _extensionsLoadTextureInfoAsync;
  64018. private _extensionsLoadAnimationAsync;
  64019. private _extensionsLoadSkinAsync;
  64020. private _extensionsLoadUriAsync;
  64021. /**
  64022. * Helper method called by a loader extension to load an glTF extension.
  64023. * @param context The context when loading the asset
  64024. * @param property The glTF property to load the extension from
  64025. * @param extensionName The name of the extension to load
  64026. * @param actionAsync The action to run
  64027. * @returns The promise returned by actionAsync or null if the extension does not exist
  64028. */
  64029. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  64030. /**
  64031. * Helper method called by a loader extension to load a glTF extra.
  64032. * @param context The context when loading the asset
  64033. * @param property The glTF property to load the extra from
  64034. * @param extensionName The name of the extension to load
  64035. * @param actionAsync The action to run
  64036. * @returns The promise returned by actionAsync or null if the extra does not exist
  64037. */
  64038. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  64039. /**
  64040. * Increments the indentation level and logs a message.
  64041. * @param message The message to log
  64042. */
  64043. logOpen(message: string): void;
  64044. /**
  64045. * Decrements the indentation level.
  64046. */
  64047. logClose(): void;
  64048. /**
  64049. * Logs a message
  64050. * @param message The message to log
  64051. */
  64052. log(message: string): void;
  64053. /**
  64054. * Starts a performance counter.
  64055. * @param counterName The name of the performance counter
  64056. */
  64057. startPerformanceCounter(counterName: string): void;
  64058. /**
  64059. * Ends a performance counter.
  64060. * @param counterName The name of the performance counter
  64061. */
  64062. endPerformanceCounter(counterName: string): void;
  64063. }
  64064. }
  64065. declare module BABYLON.GLTF2.Loader.Extensions {
  64066. /**
  64067. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  64068. */
  64069. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  64070. /** The name of this extension. */
  64071. readonly name: string;
  64072. /** Defines whether this extension is enabled. */
  64073. enabled: boolean;
  64074. private _loader;
  64075. private _lights?;
  64076. /** @hidden */
  64077. constructor(loader: GLTFLoader);
  64078. /** @hidden */
  64079. dispose(): void;
  64080. /** @hidden */
  64081. onLoading(): void;
  64082. /** @hidden */
  64083. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  64084. private _loadLightAsync;
  64085. }
  64086. }
  64087. declare module BABYLON.GLTF2.Loader.Extensions {
  64088. /**
  64089. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  64090. */
  64091. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  64092. /** The name of this extension. */
  64093. readonly name: string;
  64094. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  64095. dracoCompression?: DracoCompression;
  64096. /** Defines whether this extension is enabled. */
  64097. enabled: boolean;
  64098. private _loader;
  64099. /** @hidden */
  64100. constructor(loader: GLTFLoader);
  64101. /** @hidden */
  64102. dispose(): void;
  64103. /** @hidden */
  64104. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  64105. }
  64106. }
  64107. declare module BABYLON.GLTF2.Loader.Extensions {
  64108. /**
  64109. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  64110. */
  64111. export class KHR_lights implements IGLTFLoaderExtension {
  64112. /** The name of this extension. */
  64113. readonly name: string;
  64114. /** Defines whether this extension is enabled. */
  64115. enabled: boolean;
  64116. private _loader;
  64117. private _lights?;
  64118. /** @hidden */
  64119. constructor(loader: GLTFLoader);
  64120. /** @hidden */
  64121. dispose(): void;
  64122. /** @hidden */
  64123. onLoading(): void;
  64124. /** @hidden */
  64125. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64126. }
  64127. }
  64128. declare module BABYLON.GLTF2.Loader.Extensions {
  64129. /**
  64130. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  64131. */
  64132. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  64133. /** The name of this extension. */
  64134. readonly name: string;
  64135. /** Defines whether this extension is enabled. */
  64136. enabled: boolean;
  64137. private _loader;
  64138. /** @hidden */
  64139. constructor(loader: GLTFLoader);
  64140. /** @hidden */
  64141. dispose(): void;
  64142. /** @hidden */
  64143. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64144. private _loadSpecularGlossinessPropertiesAsync;
  64145. }
  64146. }
  64147. declare module BABYLON.GLTF2.Loader.Extensions {
  64148. /**
  64149. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  64150. */
  64151. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  64152. /** The name of this extension. */
  64153. readonly name: string;
  64154. /** Defines whether this extension is enabled. */
  64155. enabled: boolean;
  64156. private _loader;
  64157. /** @hidden */
  64158. constructor(loader: GLTFLoader);
  64159. /** @hidden */
  64160. dispose(): void;
  64161. /** @hidden */
  64162. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64163. private _loadUnlitPropertiesAsync;
  64164. }
  64165. }
  64166. declare module BABYLON.GLTF2.Loader.Extensions {
  64167. /**
  64168. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  64169. */
  64170. export class KHR_texture_transform implements IGLTFLoaderExtension {
  64171. /** The name of this extension. */
  64172. readonly name: string;
  64173. /** Defines whether this extension is enabled. */
  64174. enabled: boolean;
  64175. private _loader;
  64176. /** @hidden */
  64177. constructor(loader: GLTFLoader);
  64178. /** @hidden */
  64179. dispose(): void;
  64180. /** @hidden */
  64181. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  64182. }
  64183. }
  64184. declare module BABYLON.GLTF2.Loader.Extensions {
  64185. /**
  64186. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  64187. */
  64188. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  64189. /** The name of this extension. */
  64190. readonly name: string;
  64191. /** Defines whether this extension is enabled. */
  64192. enabled: boolean;
  64193. private _loader;
  64194. private _clips;
  64195. private _emitters;
  64196. /** @hidden */
  64197. constructor(loader: GLTFLoader);
  64198. /** @hidden */
  64199. dispose(): void;
  64200. /** @hidden */
  64201. onLoading(): void;
  64202. /** @hidden */
  64203. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  64204. /** @hidden */
  64205. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64206. /** @hidden */
  64207. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  64208. private _loadClipAsync;
  64209. private _loadEmitterAsync;
  64210. private _getEventAction;
  64211. private _loadAnimationEventAsync;
  64212. }
  64213. }
  64214. declare module BABYLON.GLTF2.Loader.Extensions {
  64215. /**
  64216. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  64217. */
  64218. export class MSFT_lod implements IGLTFLoaderExtension {
  64219. /** The name of this extension. */
  64220. readonly name: string;
  64221. /** Defines whether this extension is enabled. */
  64222. enabled: boolean;
  64223. /**
  64224. * Maximum number of LODs to load, starting from the lowest LOD.
  64225. */
  64226. maxLODsToLoad: number;
  64227. /**
  64228. * Observable raised when all node LODs of one level are loaded.
  64229. * The event data is the index of the loaded LOD starting from zero.
  64230. * Dispose the loader to cancel the loading of the next level of LODs.
  64231. */
  64232. onNodeLODsLoadedObservable: Observable<number>;
  64233. /**
  64234. * Observable raised when all material LODs of one level are loaded.
  64235. * The event data is the index of the loaded LOD starting from zero.
  64236. * Dispose the loader to cancel the loading of the next level of LODs.
  64237. */
  64238. onMaterialLODsLoadedObservable: Observable<number>;
  64239. private _loader;
  64240. private _nodeIndexLOD;
  64241. private _nodeSignalLODs;
  64242. private _nodePromiseLODs;
  64243. private _materialIndexLOD;
  64244. private _materialSignalLODs;
  64245. private _materialPromiseLODs;
  64246. /** @hidden */
  64247. constructor(loader: GLTFLoader);
  64248. /** @hidden */
  64249. dispose(): void;
  64250. /** @hidden */
  64251. onReady(): void;
  64252. /** @hidden */
  64253. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64254. /** @hidden */
  64255. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  64256. /** @hidden */
  64257. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  64258. /**
  64259. * Gets an array of LOD properties from lowest to highest.
  64260. */
  64261. private _getLODs;
  64262. private _disposeUnusedMaterials;
  64263. }
  64264. }
  64265. declare module BABYLON.GLTF2.Loader.Extensions {
  64266. /** @hidden */
  64267. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  64268. readonly name: string;
  64269. enabled: boolean;
  64270. private _loader;
  64271. constructor(loader: GLTFLoader);
  64272. dispose(): void;
  64273. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64274. }
  64275. }
  64276. declare module BABYLON.GLTF2.Loader.Extensions {
  64277. /** @hidden */
  64278. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  64279. readonly name: string;
  64280. enabled: boolean;
  64281. private _loader;
  64282. constructor(loader: GLTFLoader);
  64283. dispose(): void;
  64284. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64285. }
  64286. }
  64287. declare module BABYLON {
  64288. /**
  64289. * Class reading and parsing the MTL file bundled with the obj file.
  64290. */
  64291. export class MTLFileLoader {
  64292. /**
  64293. * All material loaded from the mtl will be set here
  64294. */
  64295. materials: StandardMaterial[];
  64296. /**
  64297. * This function will read the mtl file and create each material described inside
  64298. * This function could be improve by adding :
  64299. * -some component missing (Ni, Tf...)
  64300. * -including the specific options available
  64301. *
  64302. * @param scene defines the scene the material will be created in
  64303. * @param data defines the mtl data to parse
  64304. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  64305. */
  64306. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  64307. /**
  64308. * Gets the texture for the material.
  64309. *
  64310. * If the material is imported from input file,
  64311. * We sanitize the url to ensure it takes the textre from aside the material.
  64312. *
  64313. * @param rootUrl The root url to load from
  64314. * @param value The value stored in the mtl
  64315. * @return The Texture
  64316. */
  64317. private static _getTexture;
  64318. }
  64319. /**
  64320. * Options for loading OBJ/MTL files
  64321. */
  64322. type MeshLoadOptions = {
  64323. /**
  64324. * Defines if UVs are optimized by default during load.
  64325. */
  64326. OptimizeWithUV: boolean;
  64327. /**
  64328. * Defines custom scaling of UV coordinates of loaded meshes.
  64329. */
  64330. UVScaling: Vector2;
  64331. /**
  64332. * Invert model on y-axis (does a model scaling inversion)
  64333. */
  64334. InvertY: boolean;
  64335. /**
  64336. * Invert Y-Axis of referenced textures on load
  64337. */
  64338. InvertTextureY: boolean;
  64339. /**
  64340. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  64341. */
  64342. ImportVertexColors: boolean;
  64343. /**
  64344. * Compute the normals for the model, even if normals are present in the file.
  64345. */
  64346. ComputeNormals: boolean;
  64347. /**
  64348. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  64349. */
  64350. SkipMaterials: boolean;
  64351. /**
  64352. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  64353. */
  64354. MaterialLoadingFailsSilently: boolean;
  64355. };
  64356. /**
  64357. * OBJ file type loader.
  64358. * This is a babylon scene loader plugin.
  64359. */
  64360. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  64361. /**
  64362. * Defines if UVs are optimized by default during load.
  64363. */
  64364. static OPTIMIZE_WITH_UV: boolean;
  64365. /**
  64366. * Invert model on y-axis (does a model scaling inversion)
  64367. */
  64368. static INVERT_Y: boolean;
  64369. /**
  64370. * Invert Y-Axis of referenced textures on load
  64371. */
  64372. static INVERT_TEXTURE_Y: boolean;
  64373. /**
  64374. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  64375. */
  64376. static IMPORT_VERTEX_COLORS: boolean;
  64377. /**
  64378. * Compute the normals for the model, even if normals are present in the file.
  64379. */
  64380. static COMPUTE_NORMALS: boolean;
  64381. /**
  64382. * Defines custom scaling of UV coordinates of loaded meshes.
  64383. */
  64384. static UV_SCALING: Vector2;
  64385. /**
  64386. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  64387. */
  64388. static SKIP_MATERIALS: boolean;
  64389. /**
  64390. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  64391. *
  64392. * Defaults to true for backwards compatibility.
  64393. */
  64394. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  64395. /**
  64396. * Defines the name of the plugin.
  64397. */
  64398. name: string;
  64399. /**
  64400. * Defines the extension the plugin is able to load.
  64401. */
  64402. extensions: string;
  64403. /** @hidden */
  64404. obj: RegExp;
  64405. /** @hidden */
  64406. group: RegExp;
  64407. /** @hidden */
  64408. mtllib: RegExp;
  64409. /** @hidden */
  64410. usemtl: RegExp;
  64411. /** @hidden */
  64412. smooth: RegExp;
  64413. /** @hidden */
  64414. vertexPattern: RegExp;
  64415. /** @hidden */
  64416. normalPattern: RegExp;
  64417. /** @hidden */
  64418. uvPattern: RegExp;
  64419. /** @hidden */
  64420. facePattern1: RegExp;
  64421. /** @hidden */
  64422. facePattern2: RegExp;
  64423. /** @hidden */
  64424. facePattern3: RegExp;
  64425. /** @hidden */
  64426. facePattern4: RegExp;
  64427. /** @hidden */
  64428. facePattern5: RegExp;
  64429. private _meshLoadOptions;
  64430. /**
  64431. * Creates loader for .OBJ files
  64432. *
  64433. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  64434. */
  64435. constructor(meshLoadOptions?: MeshLoadOptions);
  64436. private static readonly currentMeshLoadOptions;
  64437. /**
  64438. * Calls synchronously the MTL file attached to this obj.
  64439. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  64440. * Without this function materials are not displayed in the first frame (but displayed after).
  64441. * In consequence it is impossible to get material information in your HTML file
  64442. *
  64443. * @param url The URL of the MTL file
  64444. * @param rootUrl
  64445. * @param onSuccess Callback function to be called when the MTL file is loaded
  64446. * @private
  64447. */
  64448. private _loadMTL;
  64449. /**
  64450. * Instantiates a OBJ file loader plugin.
  64451. * @returns the created plugin
  64452. */
  64453. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  64454. /**
  64455. * If the data string can be loaded directly.
  64456. *
  64457. * @param data string containing the file data
  64458. * @returns if the data can be loaded directly
  64459. */
  64460. canDirectLoad(data: string): boolean;
  64461. /**
  64462. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  64463. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  64464. * @param scene the scene the meshes should be added to
  64465. * @param data the OBJ data to load
  64466. * @param rootUrl root url to load from
  64467. * @param onProgress event that fires when loading progress has occured
  64468. * @param fileName Defines the name of the file to load
  64469. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  64470. */
  64471. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  64472. meshes: AbstractMesh[];
  64473. particleSystems: IParticleSystem[];
  64474. skeletons: Skeleton[];
  64475. animationGroups: AnimationGroup[];
  64476. }>;
  64477. /**
  64478. * Imports all objects from the loaded OBJ data and adds them to the scene
  64479. * @param scene the scene the objects should be added to
  64480. * @param data the OBJ data to load
  64481. * @param rootUrl root url to load from
  64482. * @param onProgress event that fires when loading progress has occured
  64483. * @param fileName Defines the name of the file to load
  64484. * @returns a promise which completes when objects have been loaded to the scene
  64485. */
  64486. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  64487. /**
  64488. * Load into an asset container.
  64489. * @param scene The scene to load into
  64490. * @param data The data to import
  64491. * @param rootUrl The root url for scene and resources
  64492. * @param onProgress The callback when the load progresses
  64493. * @param fileName Defines the name of the file to load
  64494. * @returns The loaded asset container
  64495. */
  64496. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  64497. /**
  64498. * Read the OBJ file and create an Array of meshes.
  64499. * Each mesh contains all information given by the OBJ and the MTL file.
  64500. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  64501. *
  64502. * @param meshesNames
  64503. * @param scene Scene The scene where are displayed the data
  64504. * @param data String The content of the obj file
  64505. * @param rootUrl String The path to the folder
  64506. * @returns Array<AbstractMesh>
  64507. * @private
  64508. */
  64509. private _parseSolid;
  64510. }
  64511. }
  64512. declare module BABYLON {
  64513. /**
  64514. * STL file type loader.
  64515. * This is a babylon scene loader plugin.
  64516. */
  64517. export class STLFileLoader implements ISceneLoaderPlugin {
  64518. /** @hidden */
  64519. solidPattern: RegExp;
  64520. /** @hidden */
  64521. facetsPattern: RegExp;
  64522. /** @hidden */
  64523. normalPattern: RegExp;
  64524. /** @hidden */
  64525. vertexPattern: RegExp;
  64526. /**
  64527. * Defines the name of the plugin.
  64528. */
  64529. name: string;
  64530. /**
  64531. * Defines the extensions the stl loader is able to load.
  64532. * force data to come in as an ArrayBuffer
  64533. * we'll convert to string if it looks like it's an ASCII .stl
  64534. */
  64535. extensions: ISceneLoaderPluginExtensions;
  64536. /**
  64537. * Import meshes into a scene.
  64538. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  64539. * @param scene The scene to import into
  64540. * @param data The data to import
  64541. * @param rootUrl The root url for scene and resources
  64542. * @param meshes The meshes array to import into
  64543. * @param particleSystems The particle systems array to import into
  64544. * @param skeletons The skeletons array to import into
  64545. * @param onError The callback when import fails
  64546. * @returns True if successful or false otherwise
  64547. */
  64548. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  64549. /**
  64550. * Load into a scene.
  64551. * @param scene The scene to load into
  64552. * @param data The data to import
  64553. * @param rootUrl The root url for scene and resources
  64554. * @param onError The callback when import fails
  64555. * @returns true if successful or false otherwise
  64556. */
  64557. load(scene: Scene, data: any, rootUrl: string): boolean;
  64558. /**
  64559. * Load into an asset container.
  64560. * @param scene The scene to load into
  64561. * @param data The data to import
  64562. * @param rootUrl The root url for scene and resources
  64563. * @param onError The callback when import fails
  64564. * @returns The loaded asset container
  64565. */
  64566. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  64567. private _isBinary;
  64568. private _parseBinary;
  64569. private _parseASCII;
  64570. }
  64571. }
  64572. declare module BABYLON {
  64573. /**
  64574. * Class for generating OBJ data from a Babylon scene.
  64575. */
  64576. export class OBJExport {
  64577. /**
  64578. * Exports the geometry of a Mesh array in .OBJ file format (text)
  64579. * @param mesh defines the list of meshes to serialize
  64580. * @param materials defines if materials should be exported
  64581. * @param matlibname defines the name of the associated mtl file
  64582. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  64583. * @returns the OBJ content
  64584. */
  64585. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  64586. /**
  64587. * Exports the material(s) of a mesh in .MTL file format (text)
  64588. * @param mesh defines the mesh to extract the material from
  64589. * @returns the mtl content
  64590. */
  64591. static MTL(mesh: Mesh): string;
  64592. }
  64593. }
  64594. declare module BABYLON {
  64595. /** @hidden */
  64596. export var __IGLTFExporterExtension: number;
  64597. /**
  64598. * Interface for extending the exporter
  64599. * @hidden
  64600. */
  64601. export interface IGLTFExporterExtension {
  64602. /**
  64603. * The name of this extension
  64604. */
  64605. readonly name: string;
  64606. /**
  64607. * Defines whether this extension is enabled
  64608. */
  64609. enabled: boolean;
  64610. /**
  64611. * Defines whether this extension is required
  64612. */
  64613. required: boolean;
  64614. }
  64615. }
  64616. declare module BABYLON.GLTF2.Exporter {
  64617. /** @hidden */
  64618. export var __IGLTFExporterExtensionV2: number;
  64619. /**
  64620. * Interface for a glTF exporter extension
  64621. * @hidden
  64622. */
  64623. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  64624. /**
  64625. * Define this method to modify the default behavior before exporting a texture
  64626. * @param context The context when loading the asset
  64627. * @param babylonTexture The glTF texture info property
  64628. * @param mimeType The mime-type of the generated image
  64629. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  64630. */
  64631. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  64632. /**
  64633. * Define this method to modify the default behavior when exporting texture info
  64634. * @param context The context when loading the asset
  64635. * @param meshPrimitive glTF mesh primitive
  64636. * @param babylonSubMesh Babylon submesh
  64637. * @param binaryWriter glTF serializer binary writer instance
  64638. * @returns nullable IMeshPrimitive promise
  64639. */
  64640. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  64641. /**
  64642. * Define this method to modify the default behavior when exporting a node
  64643. * @param context The context when exporting the node
  64644. * @param node glTF node
  64645. * @param babylonNode BabylonJS node
  64646. * @returns nullable INode promise
  64647. */
  64648. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  64649. /**
  64650. * Called after the exporter state changes to EXPORTING
  64651. */
  64652. onExporting?(): void;
  64653. }
  64654. }
  64655. declare module BABYLON.GLTF2.Exporter {
  64656. /**
  64657. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  64658. * @hidden
  64659. */
  64660. export class _GLTFMaterialExporter {
  64661. /**
  64662. * Represents the dielectric specular values for R, G and B
  64663. */
  64664. private static readonly _DielectricSpecular;
  64665. /**
  64666. * Allows the maximum specular power to be defined for material calculations
  64667. */
  64668. private static readonly _MaxSpecularPower;
  64669. /**
  64670. * Mapping to store textures
  64671. */
  64672. private _textureMap;
  64673. /**
  64674. * Numeric tolerance value
  64675. */
  64676. private static readonly _Epsilon;
  64677. /**
  64678. * Reference to the glTF Exporter
  64679. */
  64680. private _exporter;
  64681. constructor(exporter: _Exporter);
  64682. /**
  64683. * Specifies if two colors are approximately equal in value
  64684. * @param color1 first color to compare to
  64685. * @param color2 second color to compare to
  64686. * @param epsilon threshold value
  64687. */
  64688. private static FuzzyEquals;
  64689. /**
  64690. * Gets the materials from a Babylon scene and converts them to glTF materials
  64691. * @param scene babylonjs scene
  64692. * @param mimeType texture mime type
  64693. * @param images array of images
  64694. * @param textures array of textures
  64695. * @param materials array of materials
  64696. * @param imageData mapping of texture names to base64 textures
  64697. * @param hasTextureCoords specifies if texture coordinates are present on the material
  64698. */
  64699. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  64700. /**
  64701. * Makes a copy of the glTF material without the texture parameters
  64702. * @param originalMaterial original glTF material
  64703. * @returns glTF material without texture parameters
  64704. */
  64705. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  64706. /**
  64707. * Specifies if the material has any texture parameters present
  64708. * @param material glTF Material
  64709. * @returns boolean specifying if texture parameters are present
  64710. */
  64711. _hasTexturesPresent(material: IMaterial): boolean;
  64712. /**
  64713. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  64714. * @param babylonStandardMaterial
  64715. * @returns glTF Metallic Roughness Material representation
  64716. */
  64717. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  64718. /**
  64719. * Computes the metallic factor
  64720. * @param diffuse diffused value
  64721. * @param specular specular value
  64722. * @param oneMinusSpecularStrength one minus the specular strength
  64723. * @returns metallic value
  64724. */
  64725. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  64726. /**
  64727. * Gets the glTF alpha mode from the Babylon Material
  64728. * @param babylonMaterial Babylon Material
  64729. * @returns The Babylon alpha mode value
  64730. */
  64731. _getAlphaMode(babylonMaterial: Material): MaterialAlphaMode;
  64732. /**
  64733. * Converts a Babylon Standard Material to a glTF Material
  64734. * @param babylonStandardMaterial BJS Standard Material
  64735. * @param mimeType mime type to use for the textures
  64736. * @param images array of glTF image interfaces
  64737. * @param textures array of glTF texture interfaces
  64738. * @param materials array of glTF material interfaces
  64739. * @param imageData map of image file name to data
  64740. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  64741. */
  64742. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  64743. /**
  64744. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  64745. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  64746. * @param mimeType mime type to use for the textures
  64747. * @param images array of glTF image interfaces
  64748. * @param textures array of glTF texture interfaces
  64749. * @param materials array of glTF material interfaces
  64750. * @param imageData map of image file name to data
  64751. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  64752. */
  64753. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  64754. /**
  64755. * Converts an image typed array buffer to a base64 image
  64756. * @param buffer typed array buffer
  64757. * @param width width of the image
  64758. * @param height height of the image
  64759. * @param mimeType mimetype of the image
  64760. * @returns base64 image string
  64761. */
  64762. private _createBase64FromCanvasAsync;
  64763. /**
  64764. * Generates a white texture based on the specified width and height
  64765. * @param width width of the texture in pixels
  64766. * @param height height of the texture in pixels
  64767. * @param scene babylonjs scene
  64768. * @returns white texture
  64769. */
  64770. private _createWhiteTexture;
  64771. /**
  64772. * 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
  64773. * @param texture1 first texture to resize
  64774. * @param texture2 second texture to resize
  64775. * @param scene babylonjs scene
  64776. * @returns resized textures or null
  64777. */
  64778. private _resizeTexturesToSameDimensions;
  64779. /**
  64780. * Converts an array of pixels to a Float32Array
  64781. * Throws an error if the pixel format is not supported
  64782. * @param pixels - array buffer containing pixel values
  64783. * @returns Float32 of pixels
  64784. */
  64785. private _convertPixelArrayToFloat32;
  64786. /**
  64787. * Convert Specular Glossiness Textures to Metallic Roughness
  64788. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  64789. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  64790. * @param diffuseTexture texture used to store diffuse information
  64791. * @param specularGlossinessTexture texture used to store specular and glossiness information
  64792. * @param factors specular glossiness material factors
  64793. * @param mimeType the mime type to use for the texture
  64794. * @returns pbr metallic roughness interface or null
  64795. */
  64796. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  64797. /**
  64798. * Converts specular glossiness material properties to metallic roughness
  64799. * @param specularGlossiness interface with specular glossiness material properties
  64800. * @returns interface with metallic roughness material properties
  64801. */
  64802. private _convertSpecularGlossinessToMetallicRoughness;
  64803. /**
  64804. * Calculates the surface reflectance, independent of lighting conditions
  64805. * @param color Color source to calculate brightness from
  64806. * @returns number representing the perceived brightness, or zero if color is undefined
  64807. */
  64808. private _getPerceivedBrightness;
  64809. /**
  64810. * Returns the maximum color component value
  64811. * @param color
  64812. * @returns maximum color component value, or zero if color is null or undefined
  64813. */
  64814. private _getMaxComponent;
  64815. /**
  64816. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  64817. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  64818. * @param mimeType mime type to use for the textures
  64819. * @param images array of glTF image interfaces
  64820. * @param textures array of glTF texture interfaces
  64821. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  64822. * @param imageData map of image file name to data
  64823. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  64824. * @returns glTF PBR Metallic Roughness factors
  64825. */
  64826. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  64827. private _getGLTFTextureSampler;
  64828. private _getGLTFTextureWrapMode;
  64829. private _getGLTFTextureWrapModesSampler;
  64830. /**
  64831. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  64832. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  64833. * @param mimeType mime type to use for the textures
  64834. * @param images array of glTF image interfaces
  64835. * @param textures array of glTF texture interfaces
  64836. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  64837. * @param imageData map of image file name to data
  64838. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  64839. * @returns glTF PBR Metallic Roughness factors
  64840. */
  64841. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  64842. /**
  64843. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  64844. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  64845. * @param mimeType mime type to use for the textures
  64846. * @param images array of glTF image interfaces
  64847. * @param textures array of glTF texture interfaces
  64848. * @param materials array of glTF material interfaces
  64849. * @param imageData map of image file name to data
  64850. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  64851. */
  64852. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  64853. private setMetallicRoughnessPbrMaterial;
  64854. private getPixelsFromTexture;
  64855. /**
  64856. * Extracts a texture from a Babylon texture into file data and glTF data
  64857. * @param babylonTexture Babylon texture to extract
  64858. * @param mimeType Mime Type of the babylonTexture
  64859. * @return glTF texture info, or null if the texture format is not supported
  64860. */
  64861. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  64862. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  64863. /**
  64864. * Builds a texture from base64 string
  64865. * @param base64Texture base64 texture string
  64866. * @param baseTextureName Name to use for the texture
  64867. * @param mimeType image mime type for the texture
  64868. * @param images array of images
  64869. * @param textures array of textures
  64870. * @param imageData map of image data
  64871. * @returns glTF texture info, or null if the texture format is not supported
  64872. */
  64873. private _getTextureInfoFromBase64;
  64874. }
  64875. }
  64876. declare module BABYLON {
  64877. /**
  64878. * Class for holding and downloading glTF file data
  64879. */
  64880. export class GLTFData {
  64881. /**
  64882. * Object which contains the file name as the key and its data as the value
  64883. */
  64884. glTFFiles: {
  64885. [fileName: string]: string | Blob;
  64886. };
  64887. /**
  64888. * Initializes the glTF file object
  64889. */
  64890. constructor();
  64891. /**
  64892. * Downloads the glTF data as files based on their names and data
  64893. */
  64894. downloadFiles(): void;
  64895. }
  64896. }
  64897. declare module BABYLON {
  64898. /**
  64899. * Holds a collection of exporter options and parameters
  64900. */
  64901. export interface IExportOptions {
  64902. /**
  64903. * Function which indicates whether a babylon node should be exported or not
  64904. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  64905. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  64906. */
  64907. shouldExportNode?(node: Node): boolean;
  64908. /**
  64909. * The sample rate to bake animation curves
  64910. */
  64911. animationSampleRate?: number;
  64912. /**
  64913. * Begin serialization without waiting for the scene to be ready
  64914. */
  64915. exportWithoutWaitingForScene?: boolean;
  64916. }
  64917. /**
  64918. * Class for generating glTF data from a Babylon scene.
  64919. */
  64920. export class GLTF2Export {
  64921. /**
  64922. * Exports the geometry of the scene to .gltf file format asynchronously
  64923. * @param scene Babylon scene with scene hierarchy information
  64924. * @param filePrefix File prefix to use when generating the glTF file
  64925. * @param options Exporter options
  64926. * @returns Returns an object with a .gltf file and associates texture names
  64927. * as keys and their data and paths as values
  64928. */
  64929. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  64930. private static _PreExportAsync;
  64931. private static _PostExportAsync;
  64932. /**
  64933. * Exports the geometry of the scene to .glb file format asychronously
  64934. * @param scene Babylon scene with scene hierarchy information
  64935. * @param filePrefix File prefix to use when generating glb file
  64936. * @param options Exporter options
  64937. * @returns Returns an object with a .glb filename as key and data as value
  64938. */
  64939. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  64940. }
  64941. }
  64942. declare module BABYLON.GLTF2.Exporter {
  64943. /**
  64944. * @hidden
  64945. */
  64946. export class _GLTFUtilities {
  64947. /**
  64948. * Creates a buffer view based on the supplied arguments
  64949. * @param bufferIndex index value of the specified buffer
  64950. * @param byteOffset byte offset value
  64951. * @param byteLength byte length of the bufferView
  64952. * @param byteStride byte distance between conequential elements
  64953. * @param name name of the buffer view
  64954. * @returns bufferView for glTF
  64955. */
  64956. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  64957. /**
  64958. * Creates an accessor based on the supplied arguments
  64959. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  64960. * @param name The name of the accessor
  64961. * @param type The type of the accessor
  64962. * @param componentType The datatype of components in the attribute
  64963. * @param count The number of attributes referenced by this accessor
  64964. * @param byteOffset The offset relative to the start of the bufferView in bytes
  64965. * @param min Minimum value of each component in this attribute
  64966. * @param max Maximum value of each component in this attribute
  64967. * @returns accessor for glTF
  64968. */
  64969. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  64970. /**
  64971. * Calculates the minimum and maximum values of an array of position floats
  64972. * @param positions Positions array of a mesh
  64973. * @param vertexStart Starting vertex offset to calculate min and max values
  64974. * @param vertexCount Number of vertices to check for min and max values
  64975. * @returns min number array and max number array
  64976. */
  64977. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  64978. min: number[];
  64979. max: number[];
  64980. };
  64981. /**
  64982. * Converts a new right-handed Vector3
  64983. * @param vector vector3 array
  64984. * @returns right-handed Vector3
  64985. */
  64986. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  64987. /**
  64988. * Converts a Vector3 to right-handed
  64989. * @param vector Vector3 to convert to right-handed
  64990. */
  64991. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  64992. /**
  64993. * Converts a three element number array to right-handed
  64994. * @param vector number array to convert to right-handed
  64995. */
  64996. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  64997. /**
  64998. * Converts a new right-handed Vector3
  64999. * @param vector vector3 array
  65000. * @returns right-handed Vector3
  65001. */
  65002. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  65003. /**
  65004. * Converts a Vector3 to right-handed
  65005. * @param vector Vector3 to convert to right-handed
  65006. */
  65007. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  65008. /**
  65009. * Converts a three element number array to right-handed
  65010. * @param vector number array to convert to right-handed
  65011. */
  65012. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  65013. /**
  65014. * Converts a Vector4 to right-handed
  65015. * @param vector Vector4 to convert to right-handed
  65016. */
  65017. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  65018. /**
  65019. * Converts a Vector4 to right-handed
  65020. * @param vector Vector4 to convert to right-handed
  65021. */
  65022. static _GetRightHandedArray4FromRef(vector: number[]): void;
  65023. /**
  65024. * Converts a Quaternion to right-handed
  65025. * @param quaternion Source quaternion to convert to right-handed
  65026. */
  65027. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  65028. /**
  65029. * Converts a Quaternion to right-handed
  65030. * @param quaternion Source quaternion to convert to right-handed
  65031. */
  65032. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  65033. static _NormalizeTangentFromRef(tangent: Vector4): void;
  65034. }
  65035. }
  65036. declare module BABYLON.GLTF2.Exporter {
  65037. /**
  65038. * Converts Babylon Scene into glTF 2.0.
  65039. * @hidden
  65040. */
  65041. export class _Exporter {
  65042. /**
  65043. * Stores the glTF to export
  65044. */
  65045. _glTF: IGLTF;
  65046. /**
  65047. * Stores all generated buffer views, which represents views into the main glTF buffer data
  65048. */
  65049. _bufferViews: IBufferView[];
  65050. /**
  65051. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  65052. */
  65053. _accessors: IAccessor[];
  65054. /**
  65055. * Stores all the generated nodes, which contains transform and/or mesh information per node
  65056. */
  65057. private _nodes;
  65058. /**
  65059. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  65060. */
  65061. private _scenes;
  65062. /**
  65063. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  65064. */
  65065. private _meshes;
  65066. /**
  65067. * Stores all the generated material information, which represents the appearance of each primitive
  65068. */
  65069. _materials: IMaterial[];
  65070. _materialMap: {
  65071. [materialID: number]: number;
  65072. };
  65073. /**
  65074. * Stores all the generated texture information, which is referenced by glTF materials
  65075. */
  65076. _textures: ITexture[];
  65077. /**
  65078. * Stores all the generated image information, which is referenced by glTF textures
  65079. */
  65080. _images: IImage[];
  65081. /**
  65082. * Stores all the texture samplers
  65083. */
  65084. _samplers: ISampler[];
  65085. /**
  65086. * Stores all the generated animation samplers, which is referenced by glTF animations
  65087. */
  65088. /**
  65089. * Stores the animations for glTF models
  65090. */
  65091. private _animations;
  65092. /**
  65093. * Stores the total amount of bytes stored in the glTF buffer
  65094. */
  65095. private _totalByteLength;
  65096. /**
  65097. * Stores a reference to the Babylon scene containing the source geometry and material information
  65098. */
  65099. _babylonScene: Scene;
  65100. /**
  65101. * Stores a map of the image data, where the key is the file name and the value
  65102. * is the image data
  65103. */
  65104. _imageData: {
  65105. [fileName: string]: {
  65106. data: Uint8Array;
  65107. mimeType: ImageMimeType;
  65108. };
  65109. };
  65110. /**
  65111. * Stores a map of the unique id of a node to its index in the node array
  65112. */
  65113. private _nodeMap;
  65114. /**
  65115. * Specifies if the Babylon scene should be converted to right-handed on export
  65116. */
  65117. _convertToRightHandedSystem: boolean;
  65118. /**
  65119. * Baked animation sample rate
  65120. */
  65121. private _animationSampleRate;
  65122. /**
  65123. * Callback which specifies if a node should be exported or not
  65124. */
  65125. private _shouldExportNode;
  65126. private _localEngine;
  65127. _glTFMaterialExporter: _GLTFMaterialExporter;
  65128. private _extensions;
  65129. private static _ExtensionNames;
  65130. private static _ExtensionFactories;
  65131. private _applyExtensions;
  65132. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  65133. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  65134. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  65135. private _forEachExtensions;
  65136. private _extensionsOnExporting;
  65137. /**
  65138. * Load glTF serializer extensions
  65139. */
  65140. private _loadExtensions;
  65141. /**
  65142. * Creates a glTF Exporter instance, which can accept optional exporter options
  65143. * @param babylonScene Babylon scene object
  65144. * @param options Options to modify the behavior of the exporter
  65145. */
  65146. constructor(babylonScene: Scene, options?: IExportOptions);
  65147. /**
  65148. * Registers a glTF exporter extension
  65149. * @param name Name of the extension to export
  65150. * @param factory The factory function that creates the exporter extension
  65151. */
  65152. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  65153. /**
  65154. * Un-registers an exporter extension
  65155. * @param name The name fo the exporter extension
  65156. * @returns A boolean indicating whether the extension has been un-registered
  65157. */
  65158. static UnregisterExtension(name: string): boolean;
  65159. /**
  65160. * Lazy load a local engine with premultiplied alpha set to false
  65161. */
  65162. _getLocalEngine(): Engine;
  65163. private reorderIndicesBasedOnPrimitiveMode;
  65164. /**
  65165. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  65166. * clock-wise during export to glTF
  65167. * @param submesh BabylonJS submesh
  65168. * @param primitiveMode Primitive mode of the mesh
  65169. * @param sideOrientation the winding order of the submesh
  65170. * @param vertexBufferKind The type of vertex attribute
  65171. * @param meshAttributeArray The vertex attribute data
  65172. * @param byteOffset The offset to the binary data
  65173. * @param binaryWriter The binary data for the glTF file
  65174. */
  65175. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  65176. /**
  65177. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  65178. * clock-wise during export to glTF
  65179. * @param submesh BabylonJS submesh
  65180. * @param primitiveMode Primitive mode of the mesh
  65181. * @param sideOrientation the winding order of the submesh
  65182. * @param vertexBufferKind The type of vertex attribute
  65183. * @param meshAttributeArray The vertex attribute data
  65184. * @param byteOffset The offset to the binary data
  65185. * @param binaryWriter The binary data for the glTF file
  65186. */
  65187. private reorderTriangleFillMode;
  65188. /**
  65189. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  65190. * clock-wise during export to glTF
  65191. * @param submesh BabylonJS submesh
  65192. * @param primitiveMode Primitive mode of the mesh
  65193. * @param sideOrientation the winding order of the submesh
  65194. * @param vertexBufferKind The type of vertex attribute
  65195. * @param meshAttributeArray The vertex attribute data
  65196. * @param byteOffset The offset to the binary data
  65197. * @param binaryWriter The binary data for the glTF file
  65198. */
  65199. private reorderTriangleStripDrawMode;
  65200. /**
  65201. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  65202. * clock-wise during export to glTF
  65203. * @param submesh BabylonJS submesh
  65204. * @param primitiveMode Primitive mode of the mesh
  65205. * @param sideOrientation the winding order of the submesh
  65206. * @param vertexBufferKind The type of vertex attribute
  65207. * @param meshAttributeArray The vertex attribute data
  65208. * @param byteOffset The offset to the binary data
  65209. * @param binaryWriter The binary data for the glTF file
  65210. */
  65211. private reorderTriangleFanMode;
  65212. /**
  65213. * Writes the vertex attribute data to binary
  65214. * @param vertices The vertices to write to the binary writer
  65215. * @param byteOffset The offset into the binary writer to overwrite binary data
  65216. * @param vertexAttributeKind The vertex attribute type
  65217. * @param meshAttributeArray The vertex attribute data
  65218. * @param binaryWriter The writer containing the binary data
  65219. */
  65220. private writeVertexAttributeData;
  65221. /**
  65222. * Writes mesh attribute data to a data buffer
  65223. * Returns the bytelength of the data
  65224. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  65225. * @param meshAttributeArray Array containing the attribute data
  65226. * @param binaryWriter The buffer to write the binary data to
  65227. * @param indices Used to specify the order of the vertex data
  65228. */
  65229. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  65230. /**
  65231. * Generates glTF json data
  65232. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  65233. * @param glTFPrefix Text to use when prefixing a glTF file
  65234. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  65235. * @returns json data as string
  65236. */
  65237. private generateJSON;
  65238. /**
  65239. * Generates data for .gltf and .bin files based on the glTF prefix string
  65240. * @param glTFPrefix Text to use when prefixing a glTF file
  65241. * @returns GLTFData with glTF file data
  65242. */
  65243. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  65244. /**
  65245. * Creates a binary buffer for glTF
  65246. * @returns array buffer for binary data
  65247. */
  65248. private _generateBinaryAsync;
  65249. /**
  65250. * Pads the number to a multiple of 4
  65251. * @param num number to pad
  65252. * @returns padded number
  65253. */
  65254. private _getPadding;
  65255. /**
  65256. * Generates a glb file from the json and binary data
  65257. * Returns an object with the glb file name as the key and data as the value
  65258. * @param glTFPrefix
  65259. * @returns object with glb filename as key and data as value
  65260. */
  65261. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  65262. /**
  65263. * Sets the TRS for each node
  65264. * @param node glTF Node for storing the transformation data
  65265. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  65266. */
  65267. private setNodeTransformation;
  65268. private getVertexBufferFromMesh;
  65269. /**
  65270. * Creates a bufferview based on the vertices type for the Babylon mesh
  65271. * @param kind Indicates the type of vertices data
  65272. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  65273. * @param binaryWriter The buffer to write the bufferview data to
  65274. */
  65275. private createBufferViewKind;
  65276. /**
  65277. * The primitive mode of the Babylon mesh
  65278. * @param babylonMesh The BabylonJS mesh
  65279. */
  65280. private getMeshPrimitiveMode;
  65281. /**
  65282. * Sets the primitive mode of the glTF mesh primitive
  65283. * @param meshPrimitive glTF mesh primitive
  65284. * @param primitiveMode The primitive mode
  65285. */
  65286. private setPrimitiveMode;
  65287. /**
  65288. * Sets the vertex attribute accessor based of the glTF mesh primitive
  65289. * @param meshPrimitive glTF mesh primitive
  65290. * @param attributeKind vertex attribute
  65291. * @returns boolean specifying if uv coordinates are present
  65292. */
  65293. private setAttributeKind;
  65294. /**
  65295. * Sets data for the primitive attributes of each submesh
  65296. * @param mesh glTF Mesh object to store the primitive attribute information
  65297. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  65298. * @param binaryWriter Buffer to write the attribute data to
  65299. */
  65300. private setPrimitiveAttributesAsync;
  65301. /**
  65302. * Creates a glTF scene based on the array of meshes
  65303. * Returns the the total byte offset
  65304. * @param babylonScene Babylon scene to get the mesh data from
  65305. * @param binaryWriter Buffer to write binary data to
  65306. */
  65307. private createSceneAsync;
  65308. /**
  65309. * Creates a mapping of Node unique id to node index and handles animations
  65310. * @param babylonScene Babylon Scene
  65311. * @param nodes Babylon transform nodes
  65312. * @param shouldExportNode Callback specifying if a transform node should be exported
  65313. * @param binaryWriter Buffer to write binary data to
  65314. * @returns Node mapping of unique id to index
  65315. */
  65316. private createNodeMapAndAnimationsAsync;
  65317. /**
  65318. * Creates a glTF node from a Babylon mesh
  65319. * @param babylonMesh Source Babylon mesh
  65320. * @param binaryWriter Buffer for storing geometry data
  65321. * @returns glTF node
  65322. */
  65323. private createNodeAsync;
  65324. }
  65325. /**
  65326. * @hidden
  65327. *
  65328. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  65329. */
  65330. export class _BinaryWriter {
  65331. /**
  65332. * Array buffer which stores all binary data
  65333. */
  65334. private _arrayBuffer;
  65335. /**
  65336. * View of the array buffer
  65337. */
  65338. private _dataView;
  65339. /**
  65340. * byte offset of data in array buffer
  65341. */
  65342. private _byteOffset;
  65343. /**
  65344. * Initialize binary writer with an initial byte length
  65345. * @param byteLength Initial byte length of the array buffer
  65346. */
  65347. constructor(byteLength: number);
  65348. /**
  65349. * Resize the array buffer to the specified byte length
  65350. * @param byteLength
  65351. */
  65352. private resizeBuffer;
  65353. /**
  65354. * Get an array buffer with the length of the byte offset
  65355. * @returns ArrayBuffer resized to the byte offset
  65356. */
  65357. getArrayBuffer(): ArrayBuffer;
  65358. /**
  65359. * Get the byte offset of the array buffer
  65360. * @returns byte offset
  65361. */
  65362. getByteOffset(): number;
  65363. /**
  65364. * Stores an UInt8 in the array buffer
  65365. * @param entry
  65366. * @param byteOffset If defined, specifies where to set the value as an offset.
  65367. */
  65368. setUInt8(entry: number, byteOffset?: number): void;
  65369. /**
  65370. * Gets an UInt32 in the array buffer
  65371. * @param entry
  65372. * @param byteOffset If defined, specifies where to set the value as an offset.
  65373. */
  65374. getUInt32(byteOffset: number): number;
  65375. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  65376. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  65377. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  65378. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  65379. /**
  65380. * Stores a Float32 in the array buffer
  65381. * @param entry
  65382. */
  65383. setFloat32(entry: number, byteOffset?: number): void;
  65384. /**
  65385. * Stores an UInt32 in the array buffer
  65386. * @param entry
  65387. * @param byteOffset If defined, specifies where to set the value as an offset.
  65388. */
  65389. setUInt32(entry: number, byteOffset?: number): void;
  65390. }
  65391. }
  65392. declare module BABYLON.GLTF2.Exporter {
  65393. /**
  65394. * @hidden
  65395. * Interface to store animation data.
  65396. */
  65397. export interface _IAnimationData {
  65398. /**
  65399. * Keyframe data.
  65400. */
  65401. inputs: number[];
  65402. /**
  65403. * Value data.
  65404. */
  65405. outputs: number[][];
  65406. /**
  65407. * Animation interpolation data.
  65408. */
  65409. samplerInterpolation: AnimationSamplerInterpolation;
  65410. /**
  65411. * Minimum keyframe value.
  65412. */
  65413. inputsMin: number;
  65414. /**
  65415. * Maximum keyframe value.
  65416. */
  65417. inputsMax: number;
  65418. }
  65419. /**
  65420. * @hidden
  65421. */
  65422. export interface _IAnimationInfo {
  65423. /**
  65424. * The target channel for the animation
  65425. */
  65426. animationChannelTargetPath: AnimationChannelTargetPath;
  65427. /**
  65428. * The glTF accessor type for the data.
  65429. */
  65430. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  65431. /**
  65432. * Specifies if quaternions should be used.
  65433. */
  65434. useQuaternion: boolean;
  65435. }
  65436. /**
  65437. * @hidden
  65438. * Utility class for generating glTF animation data from BabylonJS.
  65439. */
  65440. export class _GLTFAnimation {
  65441. /**
  65442. * @ignore
  65443. *
  65444. * Creates glTF channel animation from BabylonJS animation.
  65445. * @param babylonTransformNode - BabylonJS mesh.
  65446. * @param animation - animation.
  65447. * @param animationChannelTargetPath - The target animation channel.
  65448. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  65449. * @param useQuaternion - Specifies if quaternions are used.
  65450. * @returns nullable IAnimationData
  65451. */
  65452. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  65453. private static _DeduceAnimationInfo;
  65454. /**
  65455. * @ignore
  65456. * Create node animations from the transform node animations
  65457. * @param babylonNode
  65458. * @param runtimeGLTFAnimation
  65459. * @param idleGLTFAnimations
  65460. * @param nodeMap
  65461. * @param nodes
  65462. * @param binaryWriter
  65463. * @param bufferViews
  65464. * @param accessors
  65465. * @param convertToRightHandedSystem
  65466. */
  65467. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  65468. [key: number]: number;
  65469. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  65470. /**
  65471. * @ignore
  65472. * Create node animations from the animation groups
  65473. * @param babylonScene
  65474. * @param glTFAnimations
  65475. * @param nodeMap
  65476. * @param nodes
  65477. * @param binaryWriter
  65478. * @param bufferViews
  65479. * @param accessors
  65480. * @param convertToRightHandedSystem
  65481. */
  65482. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  65483. [key: number]: number;
  65484. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  65485. private static AddAnimation;
  65486. /**
  65487. * Create a baked animation
  65488. * @param babylonTransformNode BabylonJS mesh
  65489. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  65490. * @param animationChannelTargetPath animation target channel
  65491. * @param minFrame minimum animation frame
  65492. * @param maxFrame maximum animation frame
  65493. * @param fps frames per second of the animation
  65494. * @param inputs input key frames of the animation
  65495. * @param outputs output key frame data of the animation
  65496. * @param convertToRightHandedSystem converts the values to right-handed
  65497. * @param useQuaternion specifies if quaternions should be used
  65498. */
  65499. private static _CreateBakedAnimation;
  65500. private static _ConvertFactorToVector3OrQuaternion;
  65501. private static _SetInterpolatedValue;
  65502. /**
  65503. * Creates linear animation from the animation key frames
  65504. * @param babylonTransformNode BabylonJS mesh
  65505. * @param animation BabylonJS animation
  65506. * @param animationChannelTargetPath The target animation channel
  65507. * @param frameDelta The difference between the last and first frame of the animation
  65508. * @param inputs Array to store the key frame times
  65509. * @param outputs Array to store the key frame data
  65510. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  65511. * @param useQuaternion Specifies if quaternions are used in the animation
  65512. */
  65513. private static _CreateLinearOrStepAnimation;
  65514. /**
  65515. * Creates cubic spline animation from the animation key frames
  65516. * @param babylonTransformNode BabylonJS mesh
  65517. * @param animation BabylonJS animation
  65518. * @param animationChannelTargetPath The target animation channel
  65519. * @param frameDelta The difference between the last and first frame of the animation
  65520. * @param inputs Array to store the key frame times
  65521. * @param outputs Array to store the key frame data
  65522. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  65523. * @param useQuaternion Specifies if quaternions are used in the animation
  65524. */
  65525. private static _CreateCubicSplineAnimation;
  65526. private static _GetBasePositionRotationOrScale;
  65527. /**
  65528. * Adds a key frame value
  65529. * @param keyFrame
  65530. * @param animation
  65531. * @param outputs
  65532. * @param animationChannelTargetPath
  65533. * @param basePositionRotationOrScale
  65534. * @param convertToRightHandedSystem
  65535. * @param useQuaternion
  65536. */
  65537. private static _AddKeyframeValue;
  65538. /**
  65539. * Determine the interpolation based on the key frames
  65540. * @param keyFrames
  65541. * @param animationChannelTargetPath
  65542. * @param useQuaternion
  65543. */
  65544. private static _DeduceInterpolation;
  65545. /**
  65546. * Adds an input tangent or output tangent to the output data
  65547. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  65548. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  65549. * @param outputs The animation data by keyframe
  65550. * @param animationChannelTargetPath The target animation channel
  65551. * @param interpolation The interpolation type
  65552. * @param keyFrame The key frame with the animation data
  65553. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  65554. * @param useQuaternion Specifies if quaternions are used
  65555. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  65556. */
  65557. private static AddSplineTangent;
  65558. /**
  65559. * Get the minimum and maximum key frames' frame values
  65560. * @param keyFrames animation key frames
  65561. * @returns the minimum and maximum key frame value
  65562. */
  65563. private static calculateMinMaxKeyFrames;
  65564. }
  65565. }
  65566. declare module BABYLON.GLTF2.Exporter {
  65567. /** @hidden */
  65568. export var textureTransformPixelShader: {
  65569. name: string;
  65570. shader: string;
  65571. };
  65572. }
  65573. declare module BABYLON.GLTF2.Exporter.Extensions {
  65574. /**
  65575. * @hidden
  65576. */
  65577. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  65578. /** Name of this extension */
  65579. readonly name: string;
  65580. /** Defines whether this extension is enabled */
  65581. enabled: boolean;
  65582. /** Defines whether this extension is required */
  65583. required: boolean;
  65584. /** Reference to the glTF exporter */
  65585. private _exporter;
  65586. constructor(exporter: _Exporter);
  65587. dispose(): void;
  65588. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  65589. /**
  65590. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  65591. * @param babylonTexture
  65592. * @param offset
  65593. * @param rotation
  65594. * @param scale
  65595. * @param scene
  65596. */
  65597. textureTransformTextureAsync(babylonTexture: Texture, offset: Vector2, rotation: number, scale: Vector2, scene: Scene): Promise<BaseTexture>;
  65598. }
  65599. }
  65600. declare module BABYLON.GLTF2.Exporter.Extensions {
  65601. /**
  65602. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  65603. */
  65604. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  65605. /** The name of this extension. */
  65606. readonly name: string;
  65607. /** Defines whether this extension is enabled. */
  65608. enabled: boolean;
  65609. /** Defines whether this extension is required */
  65610. required: boolean;
  65611. /** Reference to the glTF exporter */
  65612. private _exporter;
  65613. private _lights;
  65614. /** @hidden */
  65615. constructor(exporter: _Exporter);
  65616. /** @hidden */
  65617. dispose(): void;
  65618. /** @hidden */
  65619. onExporting(): void;
  65620. /**
  65621. * Define this method to modify the default behavior when exporting a node
  65622. * @param context The context when exporting the node
  65623. * @param node glTF node
  65624. * @param babylonNode BabylonJS node
  65625. * @returns nullable INode promise
  65626. */
  65627. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  65628. }
  65629. }
  65630. declare module BABYLON {
  65631. /**
  65632. * Class for generating STL data from a Babylon scene.
  65633. */
  65634. export class STLExport {
  65635. /**
  65636. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  65637. * @param meshes list defines the mesh to serialize
  65638. * @param download triggers the automatic download of the file.
  65639. * @param fileName changes the downloads fileName.
  65640. * @param binary changes the STL to a binary type.
  65641. * @param isLittleEndian toggle for binary type exporter.
  65642. * @returns the STL as UTF8 string
  65643. */
  65644. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  65645. }
  65646. }
  65647. /**
  65648. * @ignoreChildren
  65649. * @ignore
  65650. */
  65651. declare module "babylonjs-gltf2interface" {
  65652. export = BABYLON.GLTF2;
  65653. }
  65654. /**
  65655. * Module for glTF 2.0 Interface
  65656. * @ignoreChildren
  65657. * @ignore
  65658. */
  65659. declare module BABYLON.GLTF2 {
  65660. /**
  65661. * The datatype of the components in the attribute
  65662. */
  65663. const enum AccessorComponentType {
  65664. /**
  65665. * Byte
  65666. */
  65667. BYTE = 5120,
  65668. /**
  65669. * Unsigned Byte
  65670. */
  65671. UNSIGNED_BYTE = 5121,
  65672. /**
  65673. * Short
  65674. */
  65675. SHORT = 5122,
  65676. /**
  65677. * Unsigned Short
  65678. */
  65679. UNSIGNED_SHORT = 5123,
  65680. /**
  65681. * Unsigned Int
  65682. */
  65683. UNSIGNED_INT = 5125,
  65684. /**
  65685. * Float
  65686. */
  65687. FLOAT = 5126,
  65688. }
  65689. /**
  65690. * Specifies if the attirbute is a scalar, vector, or matrix
  65691. */
  65692. const enum AccessorType {
  65693. /**
  65694. * Scalar
  65695. */
  65696. SCALAR = "SCALAR",
  65697. /**
  65698. * Vector2
  65699. */
  65700. VEC2 = "VEC2",
  65701. /**
  65702. * Vector3
  65703. */
  65704. VEC3 = "VEC3",
  65705. /**
  65706. * Vector4
  65707. */
  65708. VEC4 = "VEC4",
  65709. /**
  65710. * Matrix2x2
  65711. */
  65712. MAT2 = "MAT2",
  65713. /**
  65714. * Matrix3x3
  65715. */
  65716. MAT3 = "MAT3",
  65717. /**
  65718. * Matrix4x4
  65719. */
  65720. MAT4 = "MAT4",
  65721. }
  65722. /**
  65723. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  65724. */
  65725. const enum AnimationChannelTargetPath {
  65726. /**
  65727. * Translation
  65728. */
  65729. TRANSLATION = "translation",
  65730. /**
  65731. * Rotation
  65732. */
  65733. ROTATION = "rotation",
  65734. /**
  65735. * Scale
  65736. */
  65737. SCALE = "scale",
  65738. /**
  65739. * Weights
  65740. */
  65741. WEIGHTS = "weights",
  65742. }
  65743. /**
  65744. * Interpolation algorithm
  65745. */
  65746. const enum AnimationSamplerInterpolation {
  65747. /**
  65748. * The animated values are linearly interpolated between keyframes
  65749. */
  65750. LINEAR = "LINEAR",
  65751. /**
  65752. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  65753. */
  65754. STEP = "STEP",
  65755. /**
  65756. * The animation's interpolation is computed using a cubic spline with specified tangents
  65757. */
  65758. CUBICSPLINE = "CUBICSPLINE",
  65759. }
  65760. /**
  65761. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  65762. */
  65763. const enum CameraType {
  65764. /**
  65765. * A perspective camera containing properties to create a perspective projection matrix
  65766. */
  65767. PERSPECTIVE = "perspective",
  65768. /**
  65769. * An orthographic camera containing properties to create an orthographic projection matrix
  65770. */
  65771. ORTHOGRAPHIC = "orthographic",
  65772. }
  65773. /**
  65774. * The mime-type of the image
  65775. */
  65776. const enum ImageMimeType {
  65777. /**
  65778. * JPEG Mime-type
  65779. */
  65780. JPEG = "image/jpeg",
  65781. /**
  65782. * PNG Mime-type
  65783. */
  65784. PNG = "image/png",
  65785. }
  65786. /**
  65787. * The alpha rendering mode of the material
  65788. */
  65789. const enum MaterialAlphaMode {
  65790. /**
  65791. * The alpha value is ignored and the rendered output is fully opaque
  65792. */
  65793. OPAQUE = "OPAQUE",
  65794. /**
  65795. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  65796. */
  65797. MASK = "MASK",
  65798. /**
  65799. * 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)
  65800. */
  65801. BLEND = "BLEND",
  65802. }
  65803. /**
  65804. * The type of the primitives to render
  65805. */
  65806. const enum MeshPrimitiveMode {
  65807. /**
  65808. * Points
  65809. */
  65810. POINTS = 0,
  65811. /**
  65812. * Lines
  65813. */
  65814. LINES = 1,
  65815. /**
  65816. * Line Loop
  65817. */
  65818. LINE_LOOP = 2,
  65819. /**
  65820. * Line Strip
  65821. */
  65822. LINE_STRIP = 3,
  65823. /**
  65824. * Triangles
  65825. */
  65826. TRIANGLES = 4,
  65827. /**
  65828. * Triangle Strip
  65829. */
  65830. TRIANGLE_STRIP = 5,
  65831. /**
  65832. * Triangle Fan
  65833. */
  65834. TRIANGLE_FAN = 6,
  65835. }
  65836. /**
  65837. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  65838. */
  65839. const enum TextureMagFilter {
  65840. /**
  65841. * Nearest
  65842. */
  65843. NEAREST = 9728,
  65844. /**
  65845. * Linear
  65846. */
  65847. LINEAR = 9729,
  65848. }
  65849. /**
  65850. * Minification filter. All valid values correspond to WebGL enums
  65851. */
  65852. const enum TextureMinFilter {
  65853. /**
  65854. * Nearest
  65855. */
  65856. NEAREST = 9728,
  65857. /**
  65858. * Linear
  65859. */
  65860. LINEAR = 9729,
  65861. /**
  65862. * Nearest Mip-Map Nearest
  65863. */
  65864. NEAREST_MIPMAP_NEAREST = 9984,
  65865. /**
  65866. * Linear Mipmap Nearest
  65867. */
  65868. LINEAR_MIPMAP_NEAREST = 9985,
  65869. /**
  65870. * Nearest Mipmap Linear
  65871. */
  65872. NEAREST_MIPMAP_LINEAR = 9986,
  65873. /**
  65874. * Linear Mipmap Linear
  65875. */
  65876. LINEAR_MIPMAP_LINEAR = 9987,
  65877. }
  65878. /**
  65879. * S (U) wrapping mode. All valid values correspond to WebGL enums
  65880. */
  65881. const enum TextureWrapMode {
  65882. /**
  65883. * Clamp to Edge
  65884. */
  65885. CLAMP_TO_EDGE = 33071,
  65886. /**
  65887. * Mirrored Repeat
  65888. */
  65889. MIRRORED_REPEAT = 33648,
  65890. /**
  65891. * Repeat
  65892. */
  65893. REPEAT = 10497,
  65894. }
  65895. /**
  65896. * glTF Property
  65897. */
  65898. interface IProperty {
  65899. /**
  65900. * Dictionary object with extension-specific objects
  65901. */
  65902. extensions?: {
  65903. [key: string]: any;
  65904. };
  65905. /**
  65906. * Application-Specific data
  65907. */
  65908. extras?: any;
  65909. }
  65910. /**
  65911. * glTF Child of Root Property
  65912. */
  65913. interface IChildRootProperty extends IProperty {
  65914. /**
  65915. * The user-defined name of this object
  65916. */
  65917. name?: string;
  65918. }
  65919. /**
  65920. * Indices of those attributes that deviate from their initialization value
  65921. */
  65922. interface IAccessorSparseIndices extends IProperty {
  65923. /**
  65924. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  65925. */
  65926. bufferView: number;
  65927. /**
  65928. * The offset relative to the start of the bufferView in bytes. Must be aligned
  65929. */
  65930. byteOffset?: number;
  65931. /**
  65932. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  65933. */
  65934. componentType: AccessorComponentType;
  65935. }
  65936. /**
  65937. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  65938. */
  65939. interface IAccessorSparseValues extends IProperty {
  65940. /**
  65941. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  65942. */
  65943. bufferView: number;
  65944. /**
  65945. * The offset relative to the start of the bufferView in bytes. Must be aligned
  65946. */
  65947. byteOffset?: number;
  65948. }
  65949. /**
  65950. * Sparse storage of attributes that deviate from their initialization value
  65951. */
  65952. interface IAccessorSparse extends IProperty {
  65953. /**
  65954. * The number of attributes encoded in this sparse accessor
  65955. */
  65956. count: number;
  65957. /**
  65958. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  65959. */
  65960. indices: IAccessorSparseIndices;
  65961. /**
  65962. * 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
  65963. */
  65964. values: IAccessorSparseValues;
  65965. }
  65966. /**
  65967. * 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
  65968. */
  65969. interface IAccessor extends IChildRootProperty {
  65970. /**
  65971. * The index of the bufferview
  65972. */
  65973. bufferView?: number;
  65974. /**
  65975. * The offset relative to the start of the bufferView in bytes
  65976. */
  65977. byteOffset?: number;
  65978. /**
  65979. * The datatype of components in the attribute
  65980. */
  65981. componentType: AccessorComponentType;
  65982. /**
  65983. * Specifies whether integer data values should be normalized
  65984. */
  65985. normalized?: boolean;
  65986. /**
  65987. * The number of attributes referenced by this accessor
  65988. */
  65989. count: number;
  65990. /**
  65991. * Specifies if the attribute is a scalar, vector, or matrix
  65992. */
  65993. type: AccessorType;
  65994. /**
  65995. * Maximum value of each component in this attribute
  65996. */
  65997. max?: number[];
  65998. /**
  65999. * Minimum value of each component in this attribute
  66000. */
  66001. min?: number[];
  66002. /**
  66003. * Sparse storage of attributes that deviate from their initialization value
  66004. */
  66005. sparse?: IAccessorSparse;
  66006. }
  66007. /**
  66008. * Targets an animation's sampler at a node's property
  66009. */
  66010. interface IAnimationChannel extends IProperty {
  66011. /**
  66012. * The index of a sampler in this animation used to compute the value for the target
  66013. */
  66014. sampler: number;
  66015. /**
  66016. * The index of the node and TRS property to target
  66017. */
  66018. target: IAnimationChannelTarget;
  66019. }
  66020. /**
  66021. * The index of the node and TRS property that an animation channel targets
  66022. */
  66023. interface IAnimationChannelTarget extends IProperty {
  66024. /**
  66025. * The index of the node to target
  66026. */
  66027. node: number;
  66028. /**
  66029. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  66030. */
  66031. path: AnimationChannelTargetPath;
  66032. }
  66033. /**
  66034. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  66035. */
  66036. interface IAnimationSampler extends IProperty {
  66037. /**
  66038. * The index of an accessor containing keyframe input values, e.g., time
  66039. */
  66040. input: number;
  66041. /**
  66042. * Interpolation algorithm
  66043. */
  66044. interpolation?: AnimationSamplerInterpolation;
  66045. /**
  66046. * The index of an accessor, containing keyframe output values
  66047. */
  66048. output: number;
  66049. }
  66050. /**
  66051. * A keyframe animation
  66052. */
  66053. interface IAnimation extends IChildRootProperty {
  66054. /**
  66055. * An array of channels, each of which targets an animation's sampler at a node's property
  66056. */
  66057. channels: IAnimationChannel[];
  66058. /**
  66059. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  66060. */
  66061. samplers: IAnimationSampler[];
  66062. }
  66063. /**
  66064. * Metadata about the glTF asset
  66065. */
  66066. interface IAsset extends IChildRootProperty {
  66067. /**
  66068. * A copyright message suitable for display to credit the content creator
  66069. */
  66070. copyright?: string;
  66071. /**
  66072. * Tool that generated this glTF model. Useful for debugging
  66073. */
  66074. generator?: string;
  66075. /**
  66076. * The glTF version that this asset targets
  66077. */
  66078. version: string;
  66079. /**
  66080. * The minimum glTF version that this asset targets
  66081. */
  66082. minVersion?: string;
  66083. }
  66084. /**
  66085. * A buffer points to binary geometry, animation, or skins
  66086. */
  66087. interface IBuffer extends IChildRootProperty {
  66088. /**
  66089. * 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
  66090. */
  66091. uri?: string;
  66092. /**
  66093. * The length of the buffer in bytes
  66094. */
  66095. byteLength: number;
  66096. }
  66097. /**
  66098. * A view into a buffer generally representing a subset of the buffer
  66099. */
  66100. interface IBufferView extends IChildRootProperty {
  66101. /**
  66102. * The index of the buffer
  66103. */
  66104. buffer: number;
  66105. /**
  66106. * The offset into the buffer in bytes
  66107. */
  66108. byteOffset?: number;
  66109. /**
  66110. * The lenth of the bufferView in bytes
  66111. */
  66112. byteLength: number;
  66113. /**
  66114. * The stride, in bytes
  66115. */
  66116. byteStride?: number;
  66117. }
  66118. /**
  66119. * An orthographic camera containing properties to create an orthographic projection matrix
  66120. */
  66121. interface ICameraOrthographic extends IProperty {
  66122. /**
  66123. * The floating-point horizontal magnification of the view. Must not be zero
  66124. */
  66125. xmag: number;
  66126. /**
  66127. * The floating-point vertical magnification of the view. Must not be zero
  66128. */
  66129. ymag: number;
  66130. /**
  66131. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  66132. */
  66133. zfar: number;
  66134. /**
  66135. * The floating-point distance to the near clipping plane
  66136. */
  66137. znear: number;
  66138. }
  66139. /**
  66140. * A perspective camera containing properties to create a perspective projection matrix
  66141. */
  66142. interface ICameraPerspective extends IProperty {
  66143. /**
  66144. * The floating-point aspect ratio of the field of view
  66145. */
  66146. aspectRatio?: number;
  66147. /**
  66148. * The floating-point vertical field of view in radians
  66149. */
  66150. yfov: number;
  66151. /**
  66152. * The floating-point distance to the far clipping plane
  66153. */
  66154. zfar?: number;
  66155. /**
  66156. * The floating-point distance to the near clipping plane
  66157. */
  66158. znear: number;
  66159. }
  66160. /**
  66161. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  66162. */
  66163. interface ICamera extends IChildRootProperty {
  66164. /**
  66165. * An orthographic camera containing properties to create an orthographic projection matrix
  66166. */
  66167. orthographic?: ICameraOrthographic;
  66168. /**
  66169. * A perspective camera containing properties to create a perspective projection matrix
  66170. */
  66171. perspective?: ICameraPerspective;
  66172. /**
  66173. * Specifies if the camera uses a perspective or orthographic projection
  66174. */
  66175. type: CameraType;
  66176. }
  66177. /**
  66178. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  66179. */
  66180. interface IImage extends IChildRootProperty {
  66181. /**
  66182. * 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
  66183. */
  66184. uri?: string;
  66185. /**
  66186. * The image's MIME type
  66187. */
  66188. mimeType?: ImageMimeType;
  66189. /**
  66190. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  66191. */
  66192. bufferView?: number;
  66193. }
  66194. /**
  66195. * Material Normal Texture Info
  66196. */
  66197. interface IMaterialNormalTextureInfo extends ITextureInfo {
  66198. /**
  66199. * The scalar multiplier applied to each normal vector of the normal texture
  66200. */
  66201. scale?: number;
  66202. }
  66203. /**
  66204. * Material Occlusion Texture Info
  66205. */
  66206. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  66207. /**
  66208. * A scalar multiplier controlling the amount of occlusion applied
  66209. */
  66210. strength?: number;
  66211. }
  66212. /**
  66213. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  66214. */
  66215. interface IMaterialPbrMetallicRoughness {
  66216. /**
  66217. * The material's base color factor
  66218. */
  66219. baseColorFactor?: number[];
  66220. /**
  66221. * The base color texture
  66222. */
  66223. baseColorTexture?: ITextureInfo;
  66224. /**
  66225. * The metalness of the material
  66226. */
  66227. metallicFactor?: number;
  66228. /**
  66229. * The roughness of the material
  66230. */
  66231. roughnessFactor?: number;
  66232. /**
  66233. * The metallic-roughness texture
  66234. */
  66235. metallicRoughnessTexture?: ITextureInfo;
  66236. }
  66237. /**
  66238. * The material appearance of a primitive
  66239. */
  66240. interface IMaterial extends IChildRootProperty {
  66241. /**
  66242. * 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
  66243. */
  66244. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  66245. /**
  66246. * The normal map texture
  66247. */
  66248. normalTexture?: IMaterialNormalTextureInfo;
  66249. /**
  66250. * The occlusion map texture
  66251. */
  66252. occlusionTexture?: IMaterialOcclusionTextureInfo;
  66253. /**
  66254. * The emissive map texture
  66255. */
  66256. emissiveTexture?: ITextureInfo;
  66257. /**
  66258. * 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
  66259. */
  66260. emissiveFactor?: number[];
  66261. /**
  66262. * The alpha rendering mode of the material
  66263. */
  66264. alphaMode?: MaterialAlphaMode;
  66265. /**
  66266. * The alpha cutoff value of the material
  66267. */
  66268. alphaCutoff?: number;
  66269. /**
  66270. * Specifies whether the material is double sided
  66271. */
  66272. doubleSided?: boolean;
  66273. }
  66274. /**
  66275. * Geometry to be rendered with the given material
  66276. */
  66277. interface IMeshPrimitive extends IProperty {
  66278. /**
  66279. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  66280. */
  66281. attributes: {
  66282. [name: string]: number;
  66283. };
  66284. /**
  66285. * The index of the accessor that contains the indices
  66286. */
  66287. indices?: number;
  66288. /**
  66289. * The index of the material to apply to this primitive when rendering
  66290. */
  66291. material?: number;
  66292. /**
  66293. * The type of primitives to render. All valid values correspond to WebGL enums
  66294. */
  66295. mode?: MeshPrimitiveMode;
  66296. /**
  66297. * 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
  66298. */
  66299. targets?: {
  66300. [name: string]: number;
  66301. }[];
  66302. }
  66303. /**
  66304. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  66305. */
  66306. interface IMesh extends IChildRootProperty {
  66307. /**
  66308. * An array of primitives, each defining geometry to be rendered with a material
  66309. */
  66310. primitives: IMeshPrimitive[];
  66311. /**
  66312. * Array of weights to be applied to the Morph Targets
  66313. */
  66314. weights?: number[];
  66315. }
  66316. /**
  66317. * A node in the node hierarchy
  66318. */
  66319. interface INode extends IChildRootProperty {
  66320. /**
  66321. * The index of the camera referenced by this node
  66322. */
  66323. camera?: number;
  66324. /**
  66325. * The indices of this node's children
  66326. */
  66327. children?: number[];
  66328. /**
  66329. * The index of the skin referenced by this node
  66330. */
  66331. skin?: number;
  66332. /**
  66333. * A floating-point 4x4 transformation matrix stored in column-major order
  66334. */
  66335. matrix?: number[];
  66336. /**
  66337. * The index of the mesh in this node
  66338. */
  66339. mesh?: number;
  66340. /**
  66341. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  66342. */
  66343. rotation?: number[];
  66344. /**
  66345. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  66346. */
  66347. scale?: number[];
  66348. /**
  66349. * The node's translation along the x, y, and z axes
  66350. */
  66351. translation?: number[];
  66352. /**
  66353. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  66354. */
  66355. weights?: number[];
  66356. }
  66357. /**
  66358. * Texture sampler properties for filtering and wrapping modes
  66359. */
  66360. interface ISampler extends IChildRootProperty {
  66361. /**
  66362. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  66363. */
  66364. magFilter?: TextureMagFilter;
  66365. /**
  66366. * Minification filter. All valid values correspond to WebGL enums
  66367. */
  66368. minFilter?: TextureMinFilter;
  66369. /**
  66370. * S (U) wrapping mode. All valid values correspond to WebGL enums
  66371. */
  66372. wrapS?: TextureWrapMode;
  66373. /**
  66374. * T (V) wrapping mode. All valid values correspond to WebGL enums
  66375. */
  66376. wrapT?: TextureWrapMode;
  66377. }
  66378. /**
  66379. * The root nodes of a scene
  66380. */
  66381. interface IScene extends IChildRootProperty {
  66382. /**
  66383. * The indices of each root node
  66384. */
  66385. nodes: number[];
  66386. }
  66387. /**
  66388. * Joints and matrices defining a skin
  66389. */
  66390. interface ISkin extends IChildRootProperty {
  66391. /**
  66392. * 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
  66393. */
  66394. inverseBindMatrices?: number;
  66395. /**
  66396. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  66397. */
  66398. skeleton?: number;
  66399. /**
  66400. * 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)
  66401. */
  66402. joints: number[];
  66403. }
  66404. /**
  66405. * A texture and its sampler
  66406. */
  66407. interface ITexture extends IChildRootProperty {
  66408. /**
  66409. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  66410. */
  66411. sampler?: number;
  66412. /**
  66413. * The index of the image used by this texture
  66414. */
  66415. source: number;
  66416. }
  66417. /**
  66418. * Reference to a texture
  66419. */
  66420. interface ITextureInfo extends IProperty {
  66421. /**
  66422. * The index of the texture
  66423. */
  66424. index: number;
  66425. /**
  66426. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  66427. */
  66428. texCoord?: number;
  66429. }
  66430. /**
  66431. * The root object for a glTF asset
  66432. */
  66433. interface IGLTF extends IProperty {
  66434. /**
  66435. * An array of accessors. An accessor is a typed view into a bufferView
  66436. */
  66437. accessors?: IAccessor[];
  66438. /**
  66439. * An array of keyframe animations
  66440. */
  66441. animations?: IAnimation[];
  66442. /**
  66443. * Metadata about the glTF asset
  66444. */
  66445. asset: IAsset;
  66446. /**
  66447. * An array of buffers. A buffer points to binary geometry, animation, or skins
  66448. */
  66449. buffers?: IBuffer[];
  66450. /**
  66451. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  66452. */
  66453. bufferViews?: IBufferView[];
  66454. /**
  66455. * An array of cameras
  66456. */
  66457. cameras?: ICamera[];
  66458. /**
  66459. * Names of glTF extensions used somewhere in this asset
  66460. */
  66461. extensionsUsed?: string[];
  66462. /**
  66463. * Names of glTF extensions required to properly load this asset
  66464. */
  66465. extensionsRequired?: string[];
  66466. /**
  66467. * An array of images. An image defines data used to create a texture
  66468. */
  66469. images?: IImage[];
  66470. /**
  66471. * An array of materials. A material defines the appearance of a primitive
  66472. */
  66473. materials?: IMaterial[];
  66474. /**
  66475. * An array of meshes. A mesh is a set of primitives to be rendered
  66476. */
  66477. meshes?: IMesh[];
  66478. /**
  66479. * An array of nodes
  66480. */
  66481. nodes?: INode[];
  66482. /**
  66483. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  66484. */
  66485. samplers?: ISampler[];
  66486. /**
  66487. * The index of the default scene
  66488. */
  66489. scene?: number;
  66490. /**
  66491. * An array of scenes
  66492. */
  66493. scenes?: IScene[];
  66494. /**
  66495. * An array of skins. A skin is defined by joints and matrices
  66496. */
  66497. skins?: ISkin[];
  66498. /**
  66499. * An array of textures
  66500. */
  66501. textures?: ITexture[];
  66502. }
  66503. /**
  66504. * The glTF validation results
  66505. */
  66506. interface IGLTFValidationResults {
  66507. info: {
  66508. generator: string;
  66509. hasAnimations: boolean;
  66510. hasDefaultScene: boolean;
  66511. hasMaterials: boolean;
  66512. hasMorphTargets: boolean;
  66513. hasSkins: boolean;
  66514. hasTextures: boolean;
  66515. maxAttributesUsed: number;
  66516. primitivesCount: number
  66517. };
  66518. issues: {
  66519. messages: Array<string>;
  66520. numErrors: number;
  66521. numHints: number;
  66522. numInfos: number;
  66523. numWarnings: number;
  66524. truncated: boolean
  66525. };
  66526. mimeType: string;
  66527. uri: string;
  66528. validatedAt: string;
  66529. validatorVersion: string;
  66530. }
  66531. /**
  66532. * The glTF validation options
  66533. */
  66534. interface IGLTFValidationOptions {
  66535. uri?: string;
  66536. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  66537. validateAccessorData?: boolean;
  66538. maxIssues?: number;
  66539. ignoredIssues?: Array<string>;
  66540. severityOverrides?: Object;
  66541. }
  66542. /**
  66543. * The glTF validator object
  66544. */
  66545. interface IGLTFValidator {
  66546. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  66547. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  66548. }
  66549. }
  66550. declare module BABYLON {
  66551. /** @hidden */
  66552. export var cellPixelShader: {
  66553. name: string;
  66554. shader: string;
  66555. };
  66556. }
  66557. declare module BABYLON {
  66558. /** @hidden */
  66559. export var cellVertexShader: {
  66560. name: string;
  66561. shader: string;
  66562. };
  66563. }
  66564. declare module BABYLON {
  66565. export class CellMaterial extends BABYLON.PushMaterial {
  66566. private _diffuseTexture;
  66567. diffuseTexture: BABYLON.BaseTexture;
  66568. diffuseColor: BABYLON.Color3;
  66569. _computeHighLevel: boolean;
  66570. computeHighLevel: boolean;
  66571. private _disableLighting;
  66572. disableLighting: boolean;
  66573. private _maxSimultaneousLights;
  66574. maxSimultaneousLights: number;
  66575. private _renderId;
  66576. constructor(name: string, scene: BABYLON.Scene);
  66577. needAlphaBlending(): boolean;
  66578. needAlphaTesting(): boolean;
  66579. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66580. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66581. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66582. getAnimatables(): BABYLON.IAnimatable[];
  66583. getActiveTextures(): BABYLON.BaseTexture[];
  66584. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66585. dispose(forceDisposeEffect?: boolean): void;
  66586. getClassName(): string;
  66587. clone(name: string): CellMaterial;
  66588. serialize(): any;
  66589. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  66590. }
  66591. }
  66592. declare module BABYLON {
  66593. export class CustomShaderStructure {
  66594. FragmentStore: string;
  66595. VertexStore: string;
  66596. constructor();
  66597. }
  66598. export class ShaderSpecialParts {
  66599. constructor();
  66600. Fragment_Begin: string;
  66601. Fragment_Definitions: string;
  66602. Fragment_MainBegin: string;
  66603. Fragment_Custom_Diffuse: string;
  66604. Fragment_Before_Lights: string;
  66605. Fragment_Before_Fog: string;
  66606. Fragment_Custom_Alpha: string;
  66607. Fragment_Before_FragColor: string;
  66608. Vertex_Begin: string;
  66609. Vertex_Definitions: string;
  66610. Vertex_MainBegin: string;
  66611. Vertex_Before_PositionUpdated: string;
  66612. Vertex_Before_NormalUpdated: string;
  66613. Vertex_MainEnd: string;
  66614. }
  66615. export class CustomMaterial extends BABYLON.StandardMaterial {
  66616. static ShaderIndexer: number;
  66617. CustomParts: ShaderSpecialParts;
  66618. _isCreatedShader: boolean;
  66619. _createdShaderName: string;
  66620. _customUniform: string[];
  66621. _newUniforms: string[];
  66622. _newUniformInstances: any[];
  66623. _newSamplerInstances: BABYLON.Texture[];
  66624. FragmentShader: string;
  66625. VertexShader: string;
  66626. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  66627. ReviewUniform(name: string, arr: string[]): string[];
  66628. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  66629. constructor(name: string, scene: BABYLON.Scene);
  66630. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  66631. Fragment_Begin(shaderPart: string): CustomMaterial;
  66632. Fragment_Definitions(shaderPart: string): CustomMaterial;
  66633. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  66634. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  66635. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  66636. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  66637. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  66638. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  66639. Vertex_Begin(shaderPart: string): CustomMaterial;
  66640. Vertex_Definitions(shaderPart: string): CustomMaterial;
  66641. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  66642. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  66643. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  66644. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  66645. }
  66646. }
  66647. declare module BABYLON {
  66648. export class ShaderAlebdoParts {
  66649. constructor();
  66650. Fragment_Begin: string;
  66651. Fragment_Definitions: string;
  66652. Fragment_MainBegin: string;
  66653. Fragment_Custom_Albedo: string;
  66654. Fragment_Before_Lights: string;
  66655. Fragment_Custom_MetallicRoughness: string;
  66656. Fragment_Custom_MicroSurface: string;
  66657. Fragment_Before_Fog: string;
  66658. Fragment_Custom_Alpha: string;
  66659. Fragment_Before_FragColor: string;
  66660. Vertex_Begin: string;
  66661. Vertex_Definitions: string;
  66662. Vertex_MainBegin: string;
  66663. Vertex_Before_PositionUpdated: string;
  66664. Vertex_Before_NormalUpdated: string;
  66665. Vertex_MainEnd: string;
  66666. }
  66667. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  66668. static ShaderIndexer: number;
  66669. CustomParts: ShaderAlebdoParts;
  66670. _isCreatedShader: boolean;
  66671. _createdShaderName: string;
  66672. _customUniform: string[];
  66673. _newUniforms: string[];
  66674. _newUniformInstances: any[];
  66675. _newSamplerInstances: BABYLON.Texture[];
  66676. FragmentShader: string;
  66677. VertexShader: string;
  66678. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  66679. ReviewUniform(name: string, arr: string[]): string[];
  66680. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  66681. constructor(name: string, scene: BABYLON.Scene);
  66682. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  66683. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  66684. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  66685. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  66686. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  66687. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  66688. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  66689. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  66690. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  66691. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  66692. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  66693. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  66694. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  66695. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  66696. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  66697. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  66698. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  66699. }
  66700. }
  66701. declare module BABYLON {
  66702. /** @hidden */
  66703. export var firePixelShader: {
  66704. name: string;
  66705. shader: string;
  66706. };
  66707. }
  66708. declare module BABYLON {
  66709. /** @hidden */
  66710. export var fireVertexShader: {
  66711. name: string;
  66712. shader: string;
  66713. };
  66714. }
  66715. declare module BABYLON {
  66716. export class FireMaterial extends BABYLON.PushMaterial {
  66717. private _diffuseTexture;
  66718. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66719. private _distortionTexture;
  66720. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66721. private _opacityTexture;
  66722. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66723. diffuseColor: BABYLON.Color3;
  66724. speed: number;
  66725. private _scaledDiffuse;
  66726. private _renderId;
  66727. private _lastTime;
  66728. constructor(name: string, scene: BABYLON.Scene);
  66729. needAlphaBlending(): boolean;
  66730. needAlphaTesting(): boolean;
  66731. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66732. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66733. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66734. getAnimatables(): BABYLON.IAnimatable[];
  66735. getActiveTextures(): BABYLON.BaseTexture[];
  66736. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66737. getClassName(): string;
  66738. dispose(forceDisposeEffect?: boolean): void;
  66739. clone(name: string): FireMaterial;
  66740. serialize(): any;
  66741. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  66742. }
  66743. }
  66744. declare module BABYLON {
  66745. /** @hidden */
  66746. export var furPixelShader: {
  66747. name: string;
  66748. shader: string;
  66749. };
  66750. }
  66751. declare module BABYLON {
  66752. /** @hidden */
  66753. export var furVertexShader: {
  66754. name: string;
  66755. shader: string;
  66756. };
  66757. }
  66758. declare module BABYLON {
  66759. export class FurMaterial extends BABYLON.PushMaterial {
  66760. private _diffuseTexture;
  66761. diffuseTexture: BABYLON.BaseTexture;
  66762. private _heightTexture;
  66763. heightTexture: BABYLON.BaseTexture;
  66764. diffuseColor: BABYLON.Color3;
  66765. furLength: number;
  66766. furAngle: number;
  66767. furColor: BABYLON.Color3;
  66768. furOffset: number;
  66769. furSpacing: number;
  66770. furGravity: BABYLON.Vector3;
  66771. furSpeed: number;
  66772. furDensity: number;
  66773. furOcclusion: number;
  66774. furTexture: BABYLON.DynamicTexture;
  66775. private _disableLighting;
  66776. disableLighting: boolean;
  66777. private _maxSimultaneousLights;
  66778. maxSimultaneousLights: number;
  66779. highLevelFur: boolean;
  66780. _meshes: BABYLON.AbstractMesh[];
  66781. private _renderId;
  66782. private _furTime;
  66783. constructor(name: string, scene: BABYLON.Scene);
  66784. furTime: number;
  66785. needAlphaBlending(): boolean;
  66786. needAlphaTesting(): boolean;
  66787. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66788. updateFur(): void;
  66789. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66790. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66791. getAnimatables(): BABYLON.IAnimatable[];
  66792. getActiveTextures(): BABYLON.BaseTexture[];
  66793. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66794. dispose(forceDisposeEffect?: boolean): void;
  66795. clone(name: string): FurMaterial;
  66796. serialize(): any;
  66797. getClassName(): string;
  66798. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  66799. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  66800. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  66801. }
  66802. }
  66803. declare module BABYLON {
  66804. /** @hidden */
  66805. export var gradientPixelShader: {
  66806. name: string;
  66807. shader: string;
  66808. };
  66809. }
  66810. declare module BABYLON {
  66811. /** @hidden */
  66812. export var gradientVertexShader: {
  66813. name: string;
  66814. shader: string;
  66815. };
  66816. }
  66817. declare module BABYLON {
  66818. export class GradientMaterial extends BABYLON.PushMaterial {
  66819. private _maxSimultaneousLights;
  66820. maxSimultaneousLights: number;
  66821. topColor: BABYLON.Color3;
  66822. topColorAlpha: number;
  66823. bottomColor: BABYLON.Color3;
  66824. bottomColorAlpha: number;
  66825. offset: number;
  66826. scale: number;
  66827. smoothness: number;
  66828. private _disableLighting;
  66829. disableLighting: boolean;
  66830. private _renderId;
  66831. constructor(name: string, scene: BABYLON.Scene);
  66832. needAlphaBlending(): boolean;
  66833. needAlphaTesting(): boolean;
  66834. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66835. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66836. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66837. getAnimatables(): BABYLON.IAnimatable[];
  66838. dispose(forceDisposeEffect?: boolean): void;
  66839. clone(name: string): GradientMaterial;
  66840. serialize(): any;
  66841. getClassName(): string;
  66842. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  66843. }
  66844. }
  66845. declare module BABYLON {
  66846. /** @hidden */
  66847. export var gridPixelShader: {
  66848. name: string;
  66849. shader: string;
  66850. };
  66851. }
  66852. declare module BABYLON {
  66853. /** @hidden */
  66854. export var gridVertexShader: {
  66855. name: string;
  66856. shader: string;
  66857. };
  66858. }
  66859. declare module BABYLON {
  66860. /**
  66861. * The grid materials allows you to wrap any shape with a grid.
  66862. * Colors are customizable.
  66863. */
  66864. export class GridMaterial extends BABYLON.PushMaterial {
  66865. /**
  66866. * Main color of the grid (e.g. between lines)
  66867. */
  66868. mainColor: BABYLON.Color3;
  66869. /**
  66870. * Color of the grid lines.
  66871. */
  66872. lineColor: BABYLON.Color3;
  66873. /**
  66874. * The scale of the grid compared to unit.
  66875. */
  66876. gridRatio: number;
  66877. /**
  66878. * Allows setting an offset for the grid lines.
  66879. */
  66880. gridOffset: BABYLON.Vector3;
  66881. /**
  66882. * The frequency of thicker lines.
  66883. */
  66884. majorUnitFrequency: number;
  66885. /**
  66886. * The visibility of minor units in the grid.
  66887. */
  66888. minorUnitVisibility: number;
  66889. /**
  66890. * The grid opacity outside of the lines.
  66891. */
  66892. opacity: number;
  66893. /**
  66894. * Determine RBG output is premultiplied by alpha value.
  66895. */
  66896. preMultiplyAlpha: boolean;
  66897. private _opacityTexture;
  66898. opacityTexture: BABYLON.BaseTexture;
  66899. private _gridControl;
  66900. private _renderId;
  66901. /**
  66902. * constructor
  66903. * @param name The name given to the material in order to identify it afterwards.
  66904. * @param scene The scene the material is used in.
  66905. */
  66906. constructor(name: string, scene: BABYLON.Scene);
  66907. /**
  66908. * Returns wehter or not the grid requires alpha blending.
  66909. */
  66910. needAlphaBlending(): boolean;
  66911. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  66912. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66913. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66914. /**
  66915. * Dispose the material and its associated resources.
  66916. * @param forceDisposeEffect will also dispose the used effect when true
  66917. */
  66918. dispose(forceDisposeEffect?: boolean): void;
  66919. clone(name: string): GridMaterial;
  66920. serialize(): any;
  66921. getClassName(): string;
  66922. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  66923. }
  66924. }
  66925. declare module BABYLON {
  66926. /** @hidden */
  66927. export var lavaPixelShader: {
  66928. name: string;
  66929. shader: string;
  66930. };
  66931. }
  66932. declare module BABYLON {
  66933. /** @hidden */
  66934. export var lavaVertexShader: {
  66935. name: string;
  66936. shader: string;
  66937. };
  66938. }
  66939. declare module BABYLON {
  66940. export class LavaMaterial extends BABYLON.PushMaterial {
  66941. private _diffuseTexture;
  66942. diffuseTexture: BABYLON.BaseTexture;
  66943. noiseTexture: BABYLON.BaseTexture;
  66944. fogColor: BABYLON.Color3;
  66945. speed: number;
  66946. movingSpeed: number;
  66947. lowFrequencySpeed: number;
  66948. fogDensity: number;
  66949. private _lastTime;
  66950. diffuseColor: BABYLON.Color3;
  66951. private _disableLighting;
  66952. disableLighting: boolean;
  66953. private _unlit;
  66954. unlit: boolean;
  66955. private _maxSimultaneousLights;
  66956. maxSimultaneousLights: number;
  66957. private _scaledDiffuse;
  66958. private _renderId;
  66959. constructor(name: string, scene: BABYLON.Scene);
  66960. needAlphaBlending(): boolean;
  66961. needAlphaTesting(): boolean;
  66962. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66963. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66964. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66965. getAnimatables(): BABYLON.IAnimatable[];
  66966. getActiveTextures(): BABYLON.BaseTexture[];
  66967. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66968. dispose(forceDisposeEffect?: boolean): void;
  66969. clone(name: string): LavaMaterial;
  66970. serialize(): any;
  66971. getClassName(): string;
  66972. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  66973. }
  66974. }
  66975. declare module BABYLON {
  66976. /** @hidden */
  66977. export var mixPixelShader: {
  66978. name: string;
  66979. shader: string;
  66980. };
  66981. }
  66982. declare module BABYLON {
  66983. /** @hidden */
  66984. export var mixVertexShader: {
  66985. name: string;
  66986. shader: string;
  66987. };
  66988. }
  66989. declare module BABYLON {
  66990. export class MixMaterial extends BABYLON.PushMaterial {
  66991. /**
  66992. * Mix textures
  66993. */
  66994. private _mixTexture1;
  66995. mixTexture1: BABYLON.BaseTexture;
  66996. private _mixTexture2;
  66997. mixTexture2: BABYLON.BaseTexture;
  66998. /**
  66999. * Diffuse textures
  67000. */
  67001. private _diffuseTexture1;
  67002. diffuseTexture1: BABYLON.Texture;
  67003. private _diffuseTexture2;
  67004. diffuseTexture2: BABYLON.Texture;
  67005. private _diffuseTexture3;
  67006. diffuseTexture3: BABYLON.Texture;
  67007. private _diffuseTexture4;
  67008. diffuseTexture4: BABYLON.Texture;
  67009. private _diffuseTexture5;
  67010. diffuseTexture5: BABYLON.Texture;
  67011. private _diffuseTexture6;
  67012. diffuseTexture6: BABYLON.Texture;
  67013. private _diffuseTexture7;
  67014. diffuseTexture7: BABYLON.Texture;
  67015. private _diffuseTexture8;
  67016. diffuseTexture8: BABYLON.Texture;
  67017. /**
  67018. * Uniforms
  67019. */
  67020. diffuseColor: BABYLON.Color3;
  67021. specularColor: BABYLON.Color3;
  67022. specularPower: number;
  67023. private _disableLighting;
  67024. disableLighting: boolean;
  67025. private _maxSimultaneousLights;
  67026. maxSimultaneousLights: number;
  67027. private _renderId;
  67028. constructor(name: string, scene: BABYLON.Scene);
  67029. needAlphaBlending(): boolean;
  67030. needAlphaTesting(): boolean;
  67031. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67032. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67033. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67034. getAnimatables(): BABYLON.IAnimatable[];
  67035. getActiveTextures(): BABYLON.BaseTexture[];
  67036. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67037. dispose(forceDisposeEffect?: boolean): void;
  67038. clone(name: string): MixMaterial;
  67039. serialize(): any;
  67040. getClassName(): string;
  67041. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  67042. }
  67043. }
  67044. declare module BABYLON {
  67045. /** @hidden */
  67046. export var normalPixelShader: {
  67047. name: string;
  67048. shader: string;
  67049. };
  67050. }
  67051. declare module BABYLON {
  67052. /** @hidden */
  67053. export var normalVertexShader: {
  67054. name: string;
  67055. shader: string;
  67056. };
  67057. }
  67058. declare module BABYLON {
  67059. export class NormalMaterial extends BABYLON.PushMaterial {
  67060. private _diffuseTexture;
  67061. diffuseTexture: BABYLON.BaseTexture;
  67062. diffuseColor: BABYLON.Color3;
  67063. private _disableLighting;
  67064. disableLighting: boolean;
  67065. private _maxSimultaneousLights;
  67066. maxSimultaneousLights: number;
  67067. private _renderId;
  67068. constructor(name: string, scene: BABYLON.Scene);
  67069. needAlphaBlending(): boolean;
  67070. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  67071. needAlphaTesting(): boolean;
  67072. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67073. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67074. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67075. getAnimatables(): BABYLON.IAnimatable[];
  67076. getActiveTextures(): BABYLON.BaseTexture[];
  67077. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67078. dispose(forceDisposeEffect?: boolean): void;
  67079. clone(name: string): NormalMaterial;
  67080. serialize(): any;
  67081. getClassName(): string;
  67082. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  67083. }
  67084. }
  67085. declare module BABYLON {
  67086. /** @hidden */
  67087. export var shadowOnlyPixelShader: {
  67088. name: string;
  67089. shader: string;
  67090. };
  67091. }
  67092. declare module BABYLON {
  67093. /** @hidden */
  67094. export var shadowOnlyVertexShader: {
  67095. name: string;
  67096. shader: string;
  67097. };
  67098. }
  67099. declare module BABYLON {
  67100. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  67101. private _renderId;
  67102. private _activeLight;
  67103. constructor(name: string, scene: BABYLON.Scene);
  67104. shadowColor: BABYLON.Color3;
  67105. needAlphaBlending(): boolean;
  67106. needAlphaTesting(): boolean;
  67107. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67108. activeLight: BABYLON.IShadowLight;
  67109. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67110. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67111. clone(name: string): ShadowOnlyMaterial;
  67112. serialize(): any;
  67113. getClassName(): string;
  67114. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  67115. }
  67116. }
  67117. declare module BABYLON {
  67118. /** @hidden */
  67119. export var simplePixelShader: {
  67120. name: string;
  67121. shader: string;
  67122. };
  67123. }
  67124. declare module BABYLON {
  67125. /** @hidden */
  67126. export var simpleVertexShader: {
  67127. name: string;
  67128. shader: string;
  67129. };
  67130. }
  67131. declare module BABYLON {
  67132. export class SimpleMaterial extends BABYLON.PushMaterial {
  67133. private _diffuseTexture;
  67134. diffuseTexture: BABYLON.BaseTexture;
  67135. diffuseColor: BABYLON.Color3;
  67136. private _disableLighting;
  67137. disableLighting: boolean;
  67138. private _maxSimultaneousLights;
  67139. maxSimultaneousLights: number;
  67140. private _renderId;
  67141. constructor(name: string, scene: BABYLON.Scene);
  67142. needAlphaBlending(): boolean;
  67143. needAlphaTesting(): boolean;
  67144. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67145. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67146. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67147. getAnimatables(): BABYLON.IAnimatable[];
  67148. getActiveTextures(): BABYLON.BaseTexture[];
  67149. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67150. dispose(forceDisposeEffect?: boolean): void;
  67151. clone(name: string): SimpleMaterial;
  67152. serialize(): any;
  67153. getClassName(): string;
  67154. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  67155. }
  67156. }
  67157. declare module BABYLON {
  67158. /** @hidden */
  67159. export var skyPixelShader: {
  67160. name: string;
  67161. shader: string;
  67162. };
  67163. }
  67164. declare module BABYLON {
  67165. /** @hidden */
  67166. export var skyVertexShader: {
  67167. name: string;
  67168. shader: string;
  67169. };
  67170. }
  67171. declare module BABYLON {
  67172. /**
  67173. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  67174. * @see https://doc.babylonjs.com/extensions/sky
  67175. */
  67176. export class SkyMaterial extends BABYLON.PushMaterial {
  67177. /**
  67178. * Defines the overall luminance of sky in interval ]0, 1[.
  67179. */
  67180. luminance: number;
  67181. /**
  67182. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  67183. */
  67184. turbidity: number;
  67185. /**
  67186. * Defines the sky appearance (light intensity).
  67187. */
  67188. rayleigh: number;
  67189. /**
  67190. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  67191. */
  67192. mieCoefficient: number;
  67193. /**
  67194. * Defines the amount of haze particles following the Mie scattering theory.
  67195. */
  67196. mieDirectionalG: number;
  67197. /**
  67198. * Defines the distance of the sun according to the active scene camera.
  67199. */
  67200. distance: number;
  67201. /**
  67202. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  67203. * "inclined".
  67204. */
  67205. inclination: number;
  67206. /**
  67207. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  67208. * an object direction and a reference direction.
  67209. */
  67210. azimuth: number;
  67211. /**
  67212. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  67213. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  67214. */
  67215. sunPosition: BABYLON.Vector3;
  67216. /**
  67217. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  67218. * .sunPosition property.
  67219. */
  67220. useSunPosition: boolean;
  67221. /**
  67222. * Defines an offset vector used to get a horizon offset.
  67223. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  67224. */
  67225. cameraOffset: BABYLON.Vector3;
  67226. private _cameraPosition;
  67227. private _renderId;
  67228. /**
  67229. * Instantiates a new sky material.
  67230. * This material allows to create dynamic and texture free
  67231. * effects for skyboxes by taking care of the atmosphere state.
  67232. * @see https://doc.babylonjs.com/extensions/sky
  67233. * @param name Define the name of the material in the scene
  67234. * @param scene Define the scene the material belong to
  67235. */
  67236. constructor(name: string, scene: BABYLON.Scene);
  67237. /**
  67238. * Specifies if the material will require alpha blending
  67239. * @returns a boolean specifying if alpha blending is needed
  67240. */
  67241. needAlphaBlending(): boolean;
  67242. /**
  67243. * Specifies if this material should be rendered in alpha test mode
  67244. * @returns false as the sky material doesn't need alpha testing.
  67245. */
  67246. needAlphaTesting(): boolean;
  67247. /**
  67248. * Get the texture used for alpha test purpose.
  67249. * @returns null as the sky material has no texture.
  67250. */
  67251. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67252. /**
  67253. * Get if the submesh is ready to be used and all its information available.
  67254. * Child classes can use it to update shaders
  67255. * @param mesh defines the mesh to check
  67256. * @param subMesh defines which submesh to check
  67257. * @param useInstances specifies that instances should be used
  67258. * @returns a boolean indicating that the submesh is ready or not
  67259. */
  67260. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67261. /**
  67262. * Binds the submesh to this material by preparing the effect and shader to draw
  67263. * @param world defines the world transformation matrix
  67264. * @param mesh defines the mesh containing the submesh
  67265. * @param subMesh defines the submesh to bind the material to
  67266. */
  67267. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67268. /**
  67269. * Get the list of animatables in the material.
  67270. * @returns the list of animatables object used in the material
  67271. */
  67272. getAnimatables(): BABYLON.IAnimatable[];
  67273. /**
  67274. * Disposes the material
  67275. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  67276. */
  67277. dispose(forceDisposeEffect?: boolean): void;
  67278. /**
  67279. * Makes a duplicate of the material, and gives it a new name
  67280. * @param name defines the new name for the duplicated material
  67281. * @returns the cloned material
  67282. */
  67283. clone(name: string): SkyMaterial;
  67284. /**
  67285. * Serializes this material in a JSON representation
  67286. * @returns the serialized material object
  67287. */
  67288. serialize(): any;
  67289. /**
  67290. * Gets the current class name of the material e.g. "SkyMaterial"
  67291. * Mainly use in serialization.
  67292. * @returns the class name
  67293. */
  67294. getClassName(): string;
  67295. /**
  67296. * Creates a sky material from parsed material data
  67297. * @param source defines the JSON representation of the material
  67298. * @param scene defines the hosting scene
  67299. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67300. * @returns a new sky material
  67301. */
  67302. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  67303. }
  67304. }
  67305. declare module BABYLON {
  67306. /** @hidden */
  67307. export var terrainPixelShader: {
  67308. name: string;
  67309. shader: string;
  67310. };
  67311. }
  67312. declare module BABYLON {
  67313. /** @hidden */
  67314. export var terrainVertexShader: {
  67315. name: string;
  67316. shader: string;
  67317. };
  67318. }
  67319. declare module BABYLON {
  67320. export class TerrainMaterial extends BABYLON.PushMaterial {
  67321. private _mixTexture;
  67322. mixTexture: BABYLON.BaseTexture;
  67323. private _diffuseTexture1;
  67324. diffuseTexture1: BABYLON.Texture;
  67325. private _diffuseTexture2;
  67326. diffuseTexture2: BABYLON.Texture;
  67327. private _diffuseTexture3;
  67328. diffuseTexture3: BABYLON.Texture;
  67329. private _bumpTexture1;
  67330. bumpTexture1: BABYLON.Texture;
  67331. private _bumpTexture2;
  67332. bumpTexture2: BABYLON.Texture;
  67333. private _bumpTexture3;
  67334. bumpTexture3: BABYLON.Texture;
  67335. diffuseColor: BABYLON.Color3;
  67336. specularColor: BABYLON.Color3;
  67337. specularPower: number;
  67338. private _disableLighting;
  67339. disableLighting: boolean;
  67340. private _maxSimultaneousLights;
  67341. maxSimultaneousLights: number;
  67342. private _renderId;
  67343. constructor(name: string, scene: BABYLON.Scene);
  67344. needAlphaBlending(): boolean;
  67345. needAlphaTesting(): boolean;
  67346. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67347. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67348. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67349. getAnimatables(): BABYLON.IAnimatable[];
  67350. getActiveTextures(): BABYLON.BaseTexture[];
  67351. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67352. dispose(forceDisposeEffect?: boolean): void;
  67353. clone(name: string): TerrainMaterial;
  67354. serialize(): any;
  67355. getClassName(): string;
  67356. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  67357. }
  67358. }
  67359. declare module BABYLON {
  67360. /** @hidden */
  67361. export var triplanarPixelShader: {
  67362. name: string;
  67363. shader: string;
  67364. };
  67365. }
  67366. declare module BABYLON {
  67367. /** @hidden */
  67368. export var triplanarVertexShader: {
  67369. name: string;
  67370. shader: string;
  67371. };
  67372. }
  67373. declare module BABYLON {
  67374. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  67375. mixTexture: BABYLON.BaseTexture;
  67376. private _diffuseTextureX;
  67377. diffuseTextureX: BABYLON.BaseTexture;
  67378. private _diffuseTextureY;
  67379. diffuseTextureY: BABYLON.BaseTexture;
  67380. private _diffuseTextureZ;
  67381. diffuseTextureZ: BABYLON.BaseTexture;
  67382. private _normalTextureX;
  67383. normalTextureX: BABYLON.BaseTexture;
  67384. private _normalTextureY;
  67385. normalTextureY: BABYLON.BaseTexture;
  67386. private _normalTextureZ;
  67387. normalTextureZ: BABYLON.BaseTexture;
  67388. tileSize: number;
  67389. diffuseColor: BABYLON.Color3;
  67390. specularColor: BABYLON.Color3;
  67391. specularPower: number;
  67392. private _disableLighting;
  67393. disableLighting: boolean;
  67394. private _maxSimultaneousLights;
  67395. maxSimultaneousLights: number;
  67396. private _renderId;
  67397. constructor(name: string, scene: BABYLON.Scene);
  67398. needAlphaBlending(): boolean;
  67399. needAlphaTesting(): boolean;
  67400. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67401. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67402. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67403. getAnimatables(): BABYLON.IAnimatable[];
  67404. getActiveTextures(): BABYLON.BaseTexture[];
  67405. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67406. dispose(forceDisposeEffect?: boolean): void;
  67407. clone(name: string): TriPlanarMaterial;
  67408. serialize(): any;
  67409. getClassName(): string;
  67410. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  67411. }
  67412. }
  67413. declare module BABYLON {
  67414. /** @hidden */
  67415. export var waterPixelShader: {
  67416. name: string;
  67417. shader: string;
  67418. };
  67419. }
  67420. declare module BABYLON {
  67421. /** @hidden */
  67422. export var waterVertexShader: {
  67423. name: string;
  67424. shader: string;
  67425. };
  67426. }
  67427. declare module BABYLON {
  67428. export class WaterMaterial extends BABYLON.PushMaterial {
  67429. renderTargetSize: BABYLON.Vector2;
  67430. private _bumpTexture;
  67431. bumpTexture: BABYLON.BaseTexture;
  67432. diffuseColor: BABYLON.Color3;
  67433. specularColor: BABYLON.Color3;
  67434. specularPower: number;
  67435. private _disableLighting;
  67436. disableLighting: boolean;
  67437. private _maxSimultaneousLights;
  67438. maxSimultaneousLights: number;
  67439. /**
  67440. * @param {number}: Represents the wind force
  67441. */
  67442. windForce: number;
  67443. /**
  67444. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  67445. */
  67446. windDirection: BABYLON.Vector2;
  67447. /**
  67448. * @param {number}: Wave height, represents the height of the waves
  67449. */
  67450. waveHeight: number;
  67451. /**
  67452. * @param {number}: Bump height, represents the bump height related to the bump map
  67453. */
  67454. bumpHeight: number;
  67455. /**
  67456. * @param {boolean}: Add a smaller moving bump to less steady waves.
  67457. */
  67458. private _bumpSuperimpose;
  67459. bumpSuperimpose: boolean;
  67460. /**
  67461. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  67462. */
  67463. private _fresnelSeparate;
  67464. fresnelSeparate: boolean;
  67465. /**
  67466. * @param {boolean}: bump Waves modify the reflection.
  67467. */
  67468. private _bumpAffectsReflection;
  67469. bumpAffectsReflection: boolean;
  67470. /**
  67471. * @param {number}: The water color blended with the refraction (near)
  67472. */
  67473. waterColor: BABYLON.Color3;
  67474. /**
  67475. * @param {number}: The blend factor related to the water color
  67476. */
  67477. colorBlendFactor: number;
  67478. /**
  67479. * @param {number}: The water color blended with the reflection (far)
  67480. */
  67481. waterColor2: BABYLON.Color3;
  67482. /**
  67483. * @param {number}: The blend factor related to the water color (reflection, far)
  67484. */
  67485. colorBlendFactor2: number;
  67486. /**
  67487. * @param {number}: Represents the maximum length of a wave
  67488. */
  67489. waveLength: number;
  67490. /**
  67491. * @param {number}: Defines the waves speed
  67492. */
  67493. waveSpeed: number;
  67494. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  67495. private _mesh;
  67496. private _refractionRTT;
  67497. private _reflectionRTT;
  67498. private _reflectionTransform;
  67499. private _lastTime;
  67500. private _lastDeltaTime;
  67501. private _renderId;
  67502. private _useLogarithmicDepth;
  67503. private _waitingRenderList;
  67504. /**
  67505. * Gets a boolean indicating that current material needs to register RTT
  67506. */
  67507. readonly hasRenderTargetTextures: boolean;
  67508. /**
  67509. * Constructor
  67510. */
  67511. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  67512. useLogarithmicDepth: boolean;
  67513. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  67514. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  67515. addToRenderList(node: any): void;
  67516. enableRenderTargets(enable: boolean): void;
  67517. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  67518. readonly renderTargetsEnabled: boolean;
  67519. needAlphaBlending(): boolean;
  67520. needAlphaTesting(): boolean;
  67521. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67522. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67523. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67524. private _createRenderTargets;
  67525. getAnimatables(): BABYLON.IAnimatable[];
  67526. getActiveTextures(): BABYLON.BaseTexture[];
  67527. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67528. dispose(forceDisposeEffect?: boolean): void;
  67529. clone(name: string): WaterMaterial;
  67530. serialize(): any;
  67531. getClassName(): string;
  67532. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  67533. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  67534. }
  67535. }
  67536. declare module BABYLON {
  67537. /** @hidden */
  67538. export var asciiartPixelShader: {
  67539. name: string;
  67540. shader: string;
  67541. };
  67542. }
  67543. declare module BABYLON {
  67544. /**
  67545. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  67546. *
  67547. * It basically takes care rendering the font front the given font size to a texture.
  67548. * This is used later on in the postprocess.
  67549. */
  67550. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  67551. private _font;
  67552. private _text;
  67553. private _charSize;
  67554. /**
  67555. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  67556. */
  67557. readonly charSize: number;
  67558. /**
  67559. * Create a new instance of the Ascii Art FontTexture class
  67560. * @param name the name of the texture
  67561. * @param font the font to use, use the W3C CSS notation
  67562. * @param text the caracter set to use in the rendering.
  67563. * @param scene the scene that owns the texture
  67564. */
  67565. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  67566. /**
  67567. * Gets the max char width of a font.
  67568. * @param font the font to use, use the W3C CSS notation
  67569. * @return the max char width
  67570. */
  67571. private getFontWidth;
  67572. /**
  67573. * Gets the max char height of a font.
  67574. * @param font the font to use, use the W3C CSS notation
  67575. * @return the max char height
  67576. */
  67577. private getFontHeight;
  67578. /**
  67579. * Clones the current AsciiArtTexture.
  67580. * @return the clone of the texture.
  67581. */
  67582. clone(): AsciiArtFontTexture;
  67583. /**
  67584. * Parses a json object representing the texture and returns an instance of it.
  67585. * @param source the source JSON representation
  67586. * @param scene the scene to create the texture for
  67587. * @return the parsed texture
  67588. */
  67589. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  67590. }
  67591. /**
  67592. * Option available in the Ascii Art Post Process.
  67593. */
  67594. export interface IAsciiArtPostProcessOptions {
  67595. /**
  67596. * The font to use following the w3c font definition.
  67597. */
  67598. font?: string;
  67599. /**
  67600. * The character set to use in the postprocess.
  67601. */
  67602. characterSet?: string;
  67603. /**
  67604. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  67605. * This number is defined between 0 and 1;
  67606. */
  67607. mixToTile?: number;
  67608. /**
  67609. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  67610. * This number is defined between 0 and 1;
  67611. */
  67612. mixToNormal?: number;
  67613. }
  67614. /**
  67615. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  67616. *
  67617. * Simmply add it to your scene and let the nerd that lives in you have fun.
  67618. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  67619. */
  67620. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  67621. /**
  67622. * The font texture used to render the char in the post process.
  67623. */
  67624. private _asciiArtFontTexture;
  67625. /**
  67626. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  67627. * This number is defined between 0 and 1;
  67628. */
  67629. mixToTile: number;
  67630. /**
  67631. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  67632. * This number is defined between 0 and 1;
  67633. */
  67634. mixToNormal: number;
  67635. /**
  67636. * Instantiates a new Ascii Art Post Process.
  67637. * @param name the name to give to the postprocess
  67638. * @camera the camera to apply the post process to.
  67639. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  67640. */
  67641. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  67642. }
  67643. }
  67644. declare module BABYLON {
  67645. /** @hidden */
  67646. export var digitalrainPixelShader: {
  67647. name: string;
  67648. shader: string;
  67649. };
  67650. }
  67651. declare module BABYLON {
  67652. /**
  67653. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  67654. *
  67655. * It basically takes care rendering the font front the given font size to a texture.
  67656. * This is used later on in the postprocess.
  67657. */
  67658. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  67659. private _font;
  67660. private _text;
  67661. private _charSize;
  67662. /**
  67663. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  67664. */
  67665. readonly charSize: number;
  67666. /**
  67667. * Create a new instance of the Digital Rain FontTexture class
  67668. * @param name the name of the texture
  67669. * @param font the font to use, use the W3C CSS notation
  67670. * @param text the caracter set to use in the rendering.
  67671. * @param scene the scene that owns the texture
  67672. */
  67673. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  67674. /**
  67675. * Gets the max char width of a font.
  67676. * @param font the font to use, use the W3C CSS notation
  67677. * @return the max char width
  67678. */
  67679. private getFontWidth;
  67680. /**
  67681. * Gets the max char height of a font.
  67682. * @param font the font to use, use the W3C CSS notation
  67683. * @return the max char height
  67684. */
  67685. private getFontHeight;
  67686. /**
  67687. * Clones the current DigitalRainFontTexture.
  67688. * @return the clone of the texture.
  67689. */
  67690. clone(): DigitalRainFontTexture;
  67691. /**
  67692. * Parses a json object representing the texture and returns an instance of it.
  67693. * @param source the source JSON representation
  67694. * @param scene the scene to create the texture for
  67695. * @return the parsed texture
  67696. */
  67697. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  67698. }
  67699. /**
  67700. * Option available in the Digital Rain Post Process.
  67701. */
  67702. export interface IDigitalRainPostProcessOptions {
  67703. /**
  67704. * The font to use following the w3c font definition.
  67705. */
  67706. font?: string;
  67707. /**
  67708. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  67709. * This number is defined between 0 and 1;
  67710. */
  67711. mixToTile?: number;
  67712. /**
  67713. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  67714. * This number is defined between 0 and 1;
  67715. */
  67716. mixToNormal?: number;
  67717. }
  67718. /**
  67719. * DigitalRainPostProcess helps rendering everithing in digital rain.
  67720. *
  67721. * Simmply add it to your scene and let the nerd that lives in you have fun.
  67722. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  67723. */
  67724. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  67725. /**
  67726. * The font texture used to render the char in the post process.
  67727. */
  67728. private _digitalRainFontTexture;
  67729. /**
  67730. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  67731. * This number is defined between 0 and 1;
  67732. */
  67733. mixToTile: number;
  67734. /**
  67735. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  67736. * This number is defined between 0 and 1;
  67737. */
  67738. mixToNormal: number;
  67739. /**
  67740. * Instantiates a new Digital Rain Post Process.
  67741. * @param name the name to give to the postprocess
  67742. * @camera the camera to apply the post process to.
  67743. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  67744. */
  67745. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  67746. }
  67747. }
  67748. declare module BABYLON {
  67749. /** @hidden */
  67750. export var oceanPostProcessPixelShader: {
  67751. name: string;
  67752. shader: string;
  67753. };
  67754. }
  67755. declare module BABYLON {
  67756. /**
  67757. * Option available in the Ocean Post Process.
  67758. */
  67759. export interface IOceanPostProcessOptions {
  67760. /**
  67761. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  67762. */
  67763. reflectionSize?: number | {
  67764. width: number;
  67765. height: number;
  67766. } | {
  67767. ratio: number;
  67768. };
  67769. /**
  67770. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  67771. */
  67772. refractionSize?: number | {
  67773. width: number;
  67774. height: number;
  67775. } | {
  67776. ratio: number;
  67777. };
  67778. }
  67779. /**
  67780. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  67781. *
  67782. * Simmply add it to your scene and let the nerd that lives in you have fun.
  67783. * Example usage:
  67784. * var pp = new OceanPostProcess("myOcean", camera);
  67785. * pp.reflectionEnabled = true;
  67786. * pp.refractionEnabled = true;
  67787. */
  67788. export class OceanPostProcess extends BABYLON.PostProcess {
  67789. /**
  67790. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  67791. */
  67792. /**
  67793. * Sets weither or not the real-time reflection is enabled on the ocean.
  67794. * Is set to true, the reflection mirror texture will be used as reflection texture.
  67795. */
  67796. reflectionEnabled: boolean;
  67797. /**
  67798. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  67799. */
  67800. /**
  67801. * Sets weither or not the real-time refraction is enabled on the ocean.
  67802. * Is set to true, the refraction render target texture will be used as refraction texture.
  67803. */
  67804. refractionEnabled: boolean;
  67805. /**
  67806. * Gets wether or not the post-processes is supported by the running hardware.
  67807. * This requires draw buffer supports.
  67808. */
  67809. readonly isSupported: boolean;
  67810. /**
  67811. * This is the reflection mirror texture used to display reflections on the ocean.
  67812. * By default, render list is empty.
  67813. */
  67814. reflectionTexture: BABYLON.MirrorTexture;
  67815. /**
  67816. * This is the refraction render target texture used to display refraction on the ocean.
  67817. * By default, render list is empty.
  67818. */
  67819. refractionTexture: BABYLON.RenderTargetTexture;
  67820. private _time;
  67821. private _cameraRotation;
  67822. private _cameraViewMatrix;
  67823. private _reflectionEnabled;
  67824. private _refractionEnabled;
  67825. private _geometryRenderer;
  67826. /**
  67827. * Instantiates a new Ocean Post Process.
  67828. * @param name the name to give to the postprocess.
  67829. * @camera the camera to apply the post process to.
  67830. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  67831. */
  67832. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  67833. /**
  67834. * Returns the appropriate defines according to the current configuration.
  67835. */
  67836. private _getDefines;
  67837. /**
  67838. * Computes the current camera rotation as the shader requires a camera rotation.
  67839. */
  67840. private _computeCameraRotation;
  67841. }
  67842. }
  67843. declare module BABYLON {
  67844. /** @hidden */
  67845. export var brickProceduralTexturePixelShader: {
  67846. name: string;
  67847. shader: string;
  67848. };
  67849. }
  67850. declare module BABYLON {
  67851. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  67852. private _numberOfBricksHeight;
  67853. private _numberOfBricksWidth;
  67854. private _jointColor;
  67855. private _brickColor;
  67856. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67857. updateShaderUniforms(): void;
  67858. numberOfBricksHeight: number;
  67859. numberOfBricksWidth: number;
  67860. jointColor: BABYLON.Color3;
  67861. brickColor: BABYLON.Color3;
  67862. /**
  67863. * Serializes this brick procedural texture
  67864. * @returns a serialized brick procedural texture object
  67865. */
  67866. serialize(): any;
  67867. /**
  67868. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  67869. * @param parsedTexture defines parsed texture data
  67870. * @param scene defines the current scene
  67871. * @param rootUrl defines the root URL containing brick procedural texture information
  67872. * @returns a parsed Brick Procedural BABYLON.Texture
  67873. */
  67874. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  67875. }
  67876. }
  67877. declare module BABYLON {
  67878. /** @hidden */
  67879. export var cloudProceduralTexturePixelShader: {
  67880. name: string;
  67881. shader: string;
  67882. };
  67883. }
  67884. declare module BABYLON {
  67885. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  67886. private _skyColor;
  67887. private _cloudColor;
  67888. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67889. updateShaderUniforms(): void;
  67890. skyColor: BABYLON.Color4;
  67891. cloudColor: BABYLON.Color4;
  67892. /**
  67893. * Serializes this cloud procedural texture
  67894. * @returns a serialized cloud procedural texture object
  67895. */
  67896. serialize(): any;
  67897. /**
  67898. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  67899. * @param parsedTexture defines parsed texture data
  67900. * @param scene defines the current scene
  67901. * @param rootUrl defines the root URL containing cloud procedural texture information
  67902. * @returns a parsed Cloud Procedural BABYLON.Texture
  67903. */
  67904. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  67905. }
  67906. }
  67907. declare module BABYLON {
  67908. /** @hidden */
  67909. export var fireProceduralTexturePixelShader: {
  67910. name: string;
  67911. shader: string;
  67912. };
  67913. }
  67914. declare module BABYLON {
  67915. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  67916. private _time;
  67917. private _speed;
  67918. private _autoGenerateTime;
  67919. private _fireColors;
  67920. private _alphaThreshold;
  67921. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67922. updateShaderUniforms(): void;
  67923. render(useCameraPostProcess?: boolean): void;
  67924. static readonly PurpleFireColors: BABYLON.Color3[];
  67925. static readonly GreenFireColors: BABYLON.Color3[];
  67926. static readonly RedFireColors: BABYLON.Color3[];
  67927. static readonly BlueFireColors: BABYLON.Color3[];
  67928. autoGenerateTime: boolean;
  67929. fireColors: BABYLON.Color3[];
  67930. time: number;
  67931. speed: BABYLON.Vector2;
  67932. alphaThreshold: number;
  67933. /**
  67934. * Serializes this fire procedural texture
  67935. * @returns a serialized fire procedural texture object
  67936. */
  67937. serialize(): any;
  67938. /**
  67939. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  67940. * @param parsedTexture defines parsed texture data
  67941. * @param scene defines the current scene
  67942. * @param rootUrl defines the root URL containing fire procedural texture information
  67943. * @returns a parsed Fire Procedural BABYLON.Texture
  67944. */
  67945. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  67946. }
  67947. }
  67948. declare module BABYLON {
  67949. /** @hidden */
  67950. export var grassProceduralTexturePixelShader: {
  67951. name: string;
  67952. shader: string;
  67953. };
  67954. }
  67955. declare module BABYLON {
  67956. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  67957. private _grassColors;
  67958. private _groundColor;
  67959. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67960. updateShaderUniforms(): void;
  67961. grassColors: BABYLON.Color3[];
  67962. groundColor: BABYLON.Color3;
  67963. /**
  67964. * Serializes this grass procedural texture
  67965. * @returns a serialized grass procedural texture object
  67966. */
  67967. serialize(): any;
  67968. /**
  67969. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  67970. * @param parsedTexture defines parsed texture data
  67971. * @param scene defines the current scene
  67972. * @param rootUrl defines the root URL containing grass procedural texture information
  67973. * @returns a parsed Grass Procedural BABYLON.Texture
  67974. */
  67975. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  67976. }
  67977. }
  67978. declare module BABYLON {
  67979. /** @hidden */
  67980. export var marbleProceduralTexturePixelShader: {
  67981. name: string;
  67982. shader: string;
  67983. };
  67984. }
  67985. declare module BABYLON {
  67986. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  67987. private _numberOfTilesHeight;
  67988. private _numberOfTilesWidth;
  67989. private _amplitude;
  67990. private _jointColor;
  67991. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67992. updateShaderUniforms(): void;
  67993. numberOfTilesHeight: number;
  67994. amplitude: number;
  67995. numberOfTilesWidth: number;
  67996. jointColor: BABYLON.Color3;
  67997. /**
  67998. * Serializes this marble procedural texture
  67999. * @returns a serialized marble procedural texture object
  68000. */
  68001. serialize(): any;
  68002. /**
  68003. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  68004. * @param parsedTexture defines parsed texture data
  68005. * @param scene defines the current scene
  68006. * @param rootUrl defines the root URL containing marble procedural texture information
  68007. * @returns a parsed Marble Procedural BABYLON.Texture
  68008. */
  68009. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  68010. }
  68011. }
  68012. declare module BABYLON {
  68013. /** @hidden */
  68014. export var normalMapProceduralTexturePixelShader: {
  68015. name: string;
  68016. shader: string;
  68017. };
  68018. }
  68019. declare module BABYLON {
  68020. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  68021. private _baseTexture;
  68022. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68023. updateShaderUniforms(): void;
  68024. render(useCameraPostProcess?: boolean): void;
  68025. resize(size: any, generateMipMaps: any): void;
  68026. baseTexture: BABYLON.Texture;
  68027. /**
  68028. * Serializes this normal map procedural texture
  68029. * @returns a serialized normal map procedural texture object
  68030. */
  68031. serialize(): any;
  68032. /**
  68033. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  68034. * @param parsedTexture defines parsed texture data
  68035. * @param scene defines the current scene
  68036. * @param rootUrl defines the root URL containing normal map procedural texture information
  68037. * @returns a parsed Normal Map Procedural BABYLON.Texture
  68038. */
  68039. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  68040. }
  68041. }
  68042. declare module BABYLON {
  68043. /** @hidden */
  68044. export var perlinNoiseProceduralTexturePixelShader: {
  68045. name: string;
  68046. shader: string;
  68047. };
  68048. }
  68049. declare module BABYLON {
  68050. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  68051. time: number;
  68052. timeScale: number;
  68053. translationSpeed: number;
  68054. private _currentTranslation;
  68055. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68056. updateShaderUniforms(): void;
  68057. render(useCameraPostProcess?: boolean): void;
  68058. resize(size: any, generateMipMaps: any): void;
  68059. /**
  68060. * Serializes this perlin noise procedural texture
  68061. * @returns a serialized perlin noise procedural texture object
  68062. */
  68063. serialize(): any;
  68064. /**
  68065. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  68066. * @param parsedTexture defines parsed texture data
  68067. * @param scene defines the current scene
  68068. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  68069. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  68070. */
  68071. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  68072. }
  68073. }
  68074. declare module BABYLON {
  68075. /** @hidden */
  68076. export var roadProceduralTexturePixelShader: {
  68077. name: string;
  68078. shader: string;
  68079. };
  68080. }
  68081. declare module BABYLON {
  68082. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  68083. private _roadColor;
  68084. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68085. updateShaderUniforms(): void;
  68086. roadColor: BABYLON.Color3;
  68087. /**
  68088. * Serializes this road procedural texture
  68089. * @returns a serialized road procedural texture object
  68090. */
  68091. serialize(): any;
  68092. /**
  68093. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  68094. * @param parsedTexture defines parsed texture data
  68095. * @param scene defines the current scene
  68096. * @param rootUrl defines the root URL containing road procedural texture information
  68097. * @returns a parsed Road Procedural BABYLON.Texture
  68098. */
  68099. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  68100. }
  68101. }
  68102. declare module BABYLON {
  68103. /** @hidden */
  68104. export var starfieldProceduralTexturePixelShader: {
  68105. name: string;
  68106. shader: string;
  68107. };
  68108. }
  68109. declare module BABYLON {
  68110. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  68111. private _time;
  68112. private _alpha;
  68113. private _beta;
  68114. private _zoom;
  68115. private _formuparam;
  68116. private _stepsize;
  68117. private _tile;
  68118. private _brightness;
  68119. private _darkmatter;
  68120. private _distfading;
  68121. private _saturation;
  68122. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68123. updateShaderUniforms(): void;
  68124. time: number;
  68125. alpha: number;
  68126. beta: number;
  68127. formuparam: number;
  68128. stepsize: number;
  68129. zoom: number;
  68130. tile: number;
  68131. brightness: number;
  68132. darkmatter: number;
  68133. distfading: number;
  68134. saturation: number;
  68135. /**
  68136. * Serializes this starfield procedural texture
  68137. * @returns a serialized starfield procedural texture object
  68138. */
  68139. serialize(): any;
  68140. /**
  68141. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  68142. * @param parsedTexture defines parsed texture data
  68143. * @param scene defines the current scene
  68144. * @param rootUrl defines the root URL containing startfield procedural texture information
  68145. * @returns a parsed Starfield Procedural BABYLON.Texture
  68146. */
  68147. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  68148. }
  68149. }
  68150. declare module BABYLON {
  68151. /** @hidden */
  68152. export var woodProceduralTexturePixelShader: {
  68153. name: string;
  68154. shader: string;
  68155. };
  68156. }
  68157. declare module BABYLON {
  68158. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  68159. private _ampScale;
  68160. private _woodColor;
  68161. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68162. updateShaderUniforms(): void;
  68163. ampScale: number;
  68164. woodColor: BABYLON.Color3;
  68165. /**
  68166. * Serializes this wood procedural texture
  68167. * @returns a serialized wood procedural texture object
  68168. */
  68169. serialize(): any;
  68170. /**
  68171. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  68172. * @param parsedTexture defines parsed texture data
  68173. * @param scene defines the current scene
  68174. * @param rootUrl defines the root URL containing wood procedural texture information
  68175. * @returns a parsed Wood Procedural BABYLON.Texture
  68176. */
  68177. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  68178. }
  68179. }